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 |
---|---|---|---|---|---|---|
set the schedule as inactive (kinda of delete it)
|
def setInactive
self.update_attribute(:end_active_at, DateTime.now - 1.minute)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def disable\n admin_only do\n handle_recurring_schedule_failure 'disable', 'disabled' do\n # get the schedule object to be disabled.\n @test = get_test_with_rescue\n @test.active = nil\n @test.save!\n end\n redirect_to action: \"index\"\n end\n end",
"def unschedule\r\n if (self.time != :forever)\r\n @job.unschedule\r\n @time = :forever\r\n @timed_out = false\r\n end\r\n end",
"def unschedule\n\n @scheduler.unschedule(@job_id)\n end",
"def deactivate!\n self.status = 'Inactive'\n nil\n end",
"def clear; @schedule_lock.synchronize { @schedule.clear } end",
"def active_schedule\n @_schedule = Schedule.active\n end",
"def inactive!\n @active.update { |_| false }\n end",
"def remove_inactive_tasks\n self.tasks = self.tasks.active\n end",
"def inactive!\n self.active = false\n save!\n end",
"def disable_cron\n scheduler.shutdown if scheduler.up?\n PuppetHerald.logger.info 'Scheduler stopped.'\n end",
"def make_inactive\n self.status = \"I\"\n end",
"def suspend!\n self.update_attribute(:activated_at, nil)\n end",
"def make_inactive\n self.active = false\n self.save!\n end",
"def make_inactive\n self.active = false\n self.save!\n end",
"def unresched\n action('unresched')\n end",
"def cancel\n @active = false\n\t\t\[email protected]_sorted self\n end",
"def clear_schedule!\n rufus_scheduler.stop\n @rufus_scheduler = nil\n rufus_scheduler\n end",
"def inactive\n end",
"def deactivate\n @manage_sieve.set_active(nil)\n end",
"def deactivate\n self.activation_code = 'DEACTIVATED'\n self.activated_at = nil\n end",
"def inactive!\n self.update_attribute(:status, INACTIVE)\n end",
"def deactivate\n self.active = false\n save\n end",
"def unscheduled?\n state == :unscheduled\n end",
"def set_auto_renew_off_for_inactive_plans inactive_billables\n change_plan_status(inactive_billables, renew: true)\n end",
"def deactivate\n @active = false\n end",
"def destroy\n @schedule.destroy\n end",
"def set_expired_plans_to_inactive_if_autorenew_is_off billables\n change_plan_status(billables, renew: false)\n end",
"def deactivate\n update(state: 'inactive')\n end",
"def deactivate!\n update(status: false)\n end",
"def deactivate; end",
"def set_schedule\n @schedule = Schedule.find(params[:id]) unless params[:id] == 'destroy_multiple' || params[:id].to_i.zero?\n end",
"def deleteschedule(scid)\r\n scrbslog(\"======Begin to delete a schedule======\")\r\n @schedule = Schedule.find(scid)\r\n @user = User.find(@schedule.user_id)\r\n scrbslog(\"Author:\" + @user.name)\r\n @status = Status.find_by_scheduleid(@schedule.id)\r\n scrbslog(@schedule.title + \" \" + @schedule.schedule_day + \" \" + @schedule.start_time + \" \" + @schedule.end_time + \" \" + @schedule.comment + \" \" + @schedule.room_id.to_s)\r\n @status.delete\r\n @schedule.delete \r\n scrbslog(\"======Begin to delete a schedule======\")\r\n end",
"def cancel_appointment appointment\n time_range = TimeRange.new appointment.started_at, appointment.finished_at\n if appointment.daily_schedule_id == self.id\n self.free time_range\n true\n end\n false\n end",
"def update_status\n\t\tIFeeSchedule.where(feeActive: true).where.not(id: self.id).update_all(feeActive: false)\n\tend",
"def unclaim\n timeslot = Timeslot.find(params[:id])\n if current_user.id == timeslot.user_id || current_user.user_role.can_create\n timeslot.user = nil\n timeslot.save\n end\n redirect_to event_path(timeslot.event)\n end",
"def disable!\n @active = false\n change_status(:disabled)\n end",
"def remove_time_slot\n\n end",
"def desactiver\n DBC.require( actif?, \"Cours deja inactif: #{self}\" )\n\n @actif = false\n end",
"def deactivate\n transaction do\n if update(active: false)\n case_assignments.update_all(active: false)\n supervisor_volunteer&.update(is_active: false)\n end\n end\n self\n end",
"def trigger_off_schedule(time=EoTime.now)\n\n do_trigger(time)\n end",
"def toggle_scheduler\n new_scheduler = WaterManager.first.scheduling_option == CRONTAB_SPRINKLE_ALL ? DAEMON_MINUTE_HAND : CRONTAB_SPRINKLE_ALL\n WaterManager.first.update(scheduling_option: new_scheduler)\n end",
"def deactivate\n \n end",
"def remove_schedule(name)\n Que.execute Que::Scheduler::SQL[:destroy_schedule], [name]\n end",
"def deactivate!\n update_column(:active, false)\n end",
"def deactivate!\n update_column(:active, false)\n end",
"def deactivate\n self.active = false\n self.save(:validate => false)\n end",
"def remove_upcoming_registrations_if_inactive\n remove_upcoming_registrations if !self.active \n end",
"def deactivate\n @active = false\n return\n end",
"def deactivate()\n end",
"def suspend!\n self.update_attribute(:status, SUSPENDED)\n self.registration.update_attribute(:status, SUSPENDED) if self.registration\n end",
"def inactivate_stop\n self.is_active = false\n self.send(:update_without_callbacks)\n end",
"def set_scheduled_flag(value)\n self.scheduled = value\n self.save!\n end",
"def remove_registrations_if_inactive\n remove_upcoming_registrations if !self.active \n end",
"def inactive_tasks\n @tasks.select { | task | ! task.active }\n end",
"def stop_periodic_timers; end",
"def clear_schedule\n bytes = [0] * 15\n schedule(bytes)\n bytes\n end",
"def schedule_enable_disable(schedules, enabled)\n schedules.reject { |schedule| schedule.enabled == enabled }\n .sort_by { |e| e.name.downcase }.each do |schedule|\n schedule.enabled = enabled\n schedule.save!\n end\n end",
"def schedule=(value)\n @schedule = value\n end",
"def schedule=(value)\n @schedule = value\n end",
"def schedule=(value)\n @schedule = value\n end",
"def disable_school_year\n @active.disable!\n @active.save!\n end",
"def invisible\n gateway_check\n update_status(:invisible, @activity, nil)\n end",
"def mark_unavailable\n t = @user_application.interview_availabilities.find_by_time_and_offering_interview_timeblock_id(\n params[:time].to_time, params[:timeblock_id])\n t.destroy\n render :partial => \"timeslot_not_available\", :locals => { :b => params[:timeblock_id], :ti => params[:ti], :time => params[:time] }\n end",
"def resched\n action('resched')\n end",
"def inactive_students\n self.students.each{|s| s.active = false}\n end",
"def activate_stop\n self.is_active = true\n self.send(:update_without_callbacks)\n end",
"def purge_expired_schedules\n _schedules = Schedule.where('student_id = ? AND end_date < ?', @student.id, Date.today)\n _schedules.each {|s| s.destroy}\n\n redirect_to @student, notice: 'Expired schedules have been deleted'\n end",
"def unset(event)\n key[:schedule].zrem event\n end",
"def set_active_inactive\n to_set_inactive = (EvaluationTemplate.where.not(id: self.id)).\n where(active: true).where(quarter_id: self.quarter_id)\n if self.active?\n to_set_inactive.each { |t| t.update_attributes(active: false) }\n end\n end",
"def deactivate\n return false if deactivated?\n self.status = 'deactivated'\n save\n end",
"def disable!\n self.enabled = false\n end",
"def destroy_if_old\n return false unless inactive?\n # Completely remove the recurrence\n @recurrence.destroy\n true\n end",
"def delete\n self.update(active: false)\n end",
"def delete\n self.update(active: false)\n end",
"def unblock!\n self.blocked = nil\n self.save\n end",
"def stop\n update(underway_at: nil)\n end",
"def disable_last_budget\n # Only on the creation it receive active as true\n self.active = true if self.id.nil?\n last_budget = self.campaign.budgets.last\n unless last_budget.nil?\n begin\n last_budget.update(active:false, closed_date:\"#{Time.now()}\")\n rescue => e\n self.errors.messages.add(e.message)\n end\n end\n end",
"def disable\n @enabled = false\n end",
"def evaulate_schedule\n true\n end",
"def disable_polling(reason = nil)\n self.deactivate\n self.deactivation_reason = reason.to_s\n self.deactivated_at = Time.now\n self.save!\n end",
"def remove_schedule(name, reload = true)\n non_persistent_schedules.delete(name)\n redis.hdel(:persistent_schedules, name)\n redis.sadd(:schedules_changed, [name])\n\n reload_schedule! if reload\n end",
"def unban\n self.enabled = true\n save\n end",
"def disable\n exclusively do\n @enabled = false\n @manual_toggle = true\n end\n\n save_state\n sync_control { stop_upkeep }\n end",
"def allow_custom_assignment_schedule=(value)\n @allow_custom_assignment_schedule = value\n end",
"def clean_activity!\n $redis.zremrangebyscore(activity_key, '-inf', Time.now.to_i - 1.minute)\n end",
"def destroy\n run_callbacks :destroy do\n self.update(active: false)\n end\n end",
"def disable(id)\n change_status id, false\n end",
"def destroy\n @timeslot.destroy\n end",
"def disable!\n @enabled = false\n end",
"def set_day_if_discarded; end",
"def disableTimer(type)\n\n Utils_visiona.verifyInput(String, type.class)\n\n return unless hastimer?(type)\n @timer.delete(type)\n writeLog(\"Timer of type #{type} disabled\")\n end",
"def disable!\n @enabled = false\n end",
"def deactivate\n status = auth_post(\"/api/xml/dns/#{@id}\", {:query => {\"zone[status]\" => \"Inactive\", :email => @email, :token => @token}})[\"hash\"][\"status\"]\n raise \"Unable to deactivate zone\" unless status == \"Inactive\"\n return status\n end",
"def reset_schedule\n leader = User.where(:id => self.creator).first\n self.initialize_group_schedule(leader.schedule)\n self.users.each do |user|\n self.update_group_schedule(user.schedule)\n end\n end",
"def off!\n set(:on => false)\n end",
"def deactivate\n copy self.class.deactivate(@id)\n true\n end",
"def deactivate_account!\n time_since_sign_in = Time.now - self.last_sign_in_at\n inactive_days = Time.now - 60.days\n if last_signed_in_at.where(inactive_days > time_since_sign_in)\n update_attribute :is_active, false\n end\n end",
"def stop_maintenance\n return true unless maint_mode?\n\n Instance.running_for_profile(self).map {|i| i.stop}\n maint_mode = false\n self.save!\n end",
"def vacate_room(room)\n room.occupied = 0\n end",
"def stop\n @enabled = false\n end"
] |
[
"0.660496",
"0.6542165",
"0.64737517",
"0.64187944",
"0.64089084",
"0.63907045",
"0.63865834",
"0.63838214",
"0.6215918",
"0.6193541",
"0.6175287",
"0.6153415",
"0.61463314",
"0.61463314",
"0.612563",
"0.61003274",
"0.6097641",
"0.60695654",
"0.60602826",
"0.5994032",
"0.59875214",
"0.59871936",
"0.59700984",
"0.5942253",
"0.5937319",
"0.5930373",
"0.5917037",
"0.5912172",
"0.5869676",
"0.5850799",
"0.5825746",
"0.58055747",
"0.5796586",
"0.5793596",
"0.5772035",
"0.5771664",
"0.57417935",
"0.57083046",
"0.5697252",
"0.5693208",
"0.5690167",
"0.56852585",
"0.568379",
"0.56344664",
"0.56344664",
"0.5630571",
"0.56166255",
"0.5610968",
"0.56102335",
"0.5609855",
"0.5594231",
"0.5590506",
"0.558736",
"0.55812544",
"0.5562927",
"0.55623853",
"0.5527427",
"0.5515719",
"0.5515719",
"0.5515719",
"0.54923695",
"0.5491644",
"0.5491592",
"0.5476535",
"0.5464623",
"0.54464555",
"0.54461336",
"0.5439584",
"0.54261464",
"0.5402758",
"0.53984445",
"0.53955984",
"0.53852904",
"0.53852904",
"0.53845197",
"0.53764087",
"0.5374332",
"0.53677523",
"0.5356453",
"0.5349485",
"0.5345746",
"0.5344196",
"0.53425646",
"0.5338666",
"0.53354686",
"0.53320545",
"0.53282523",
"0.5327117",
"0.531468",
"0.5312665",
"0.5307604",
"0.5302935",
"0.5300296",
"0.5297168",
"0.5288283",
"0.52870846",
"0.5273993",
"0.5269745",
"0.526937",
"0.5269079"
] |
0.65547127
|
1
|
Return the current logged in username.
|
def username
response = get 'v1/market/private/user/username.json'
response[:username]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_username\n @user_name ||= self.user.username\n end",
"def current_user_name\n logged_in? ? (user_name(current_user_id) || current_user_id) : nil\n end",
"def user_username\n if self.user != nil\n self.user.username\n end\n end",
"def string_username\n CaseInsensitiveString.str(current_user.getUsername())\n end",
"def get_username()\n username_gitconfig = %x(git config user.name).strip\n username_passwd = Etc.getpwnam(Etc.getlogin).gecos.gsub(/ - SBP.*/,'')\n\n username = username_gitconfig unless username_gitconfig.nil?\n username = username_passwd if username.empty?\n username\n end",
"def getUsername\n return @username\n end",
"def username\n user.username\n end",
"def hubssolib_get_user_name\n user = self.hubssolib_current_user\n user ? user.user_real_name : nil\n end",
"def username\n username = user.username\n end",
"def current_user\n # We just do a 'basename' on the principal to give back a sane value\n # here.\n user_name = Http::UrlUtil.split_path(current_principal)[1]\n\n user_name\n end",
"def username\r\n return @user.username\r\n end",
"def get_current_user_name\n return @name if @name\n name = get_current_user_meta\n name = name['query']['userinfo']['name'] if name\n\n name\n end",
"def username\n if @user.nil?\n @user = JavaSystem.getProperty(\"user.name\")\n end\n\n @user\n end",
"def username\n \treturn session[:username]\n \tend",
"def username\n user.username\n end",
"def username\n if @username.nil?\n if os_type(:nice, :not_extended) == 'Solaris'\n @username = @platform.exec(\"/usr/ucb/whoami\").strip\n else\n @username = @platform.exec(\"whoami\").strip\n end\n end\n \n @username\n end",
"def simple_username\n return user.firstname + ' ' + user.lastname.first + '.' if !user.nil?\n name\n end",
"def current_user\n session[:username]\n end",
"def username\n profile['Username']\n end",
"def getusername()\r\n return getvalue(SVTags::USER_ID)\r\n end",
"def username\n user.username\n end",
"def username\n user.username\n end",
"def current_user_name_or_id\n require 'etc' if !defined?(Etc)\n begin\n user = Etc.getpwuid(Process.uid)\n rescue ArgumentError\n user = nil\n end\n if user\n return user.name\n else\n return \"##{Process.uid}\"\n end\n end",
"def username\n @username\n end",
"def username\n client.username if client\n end",
"def login_user_name\n user_name.tr('.', '')\n end",
"def username\n @username\n end",
"def getUserName(session)\n\n if(isUserLoggedIn(session))\n return session[\"loginName\"]\n end\n return nil\n end",
"def get_username(user_id)\n return User.find(user_id).username\n end",
"def user_name\n @user_name ||= SlackUtils::SingletonClient.instance.find_user_name(@user_id)\n end",
"def username\n credentials.first\n end",
"def get_user_name_not_null\n user = User.first(:id => self.user_id )\n return user.login if user\n return \"anon\"\n end",
"def current_user_screen_name\n session[:user_info][\"nickname\"]\n end",
"def username\n account = github_accounts.first || slack_accounts.first\n account ? account.username : id\n end",
"def user_name\n self.user.login\n end",
"def user_name\n self.user.login\n end",
"def username\n name\n end",
"def real_username\n defined?(USERS_MAP) ? USERS_MAP[@username] : @username\n end",
"def username\n @username || @token['data']\n end",
"def username\n @config[\"username\"]\n end",
"def username\n return username_nada if !username_nada.nil?\n username_kth\n end",
"def user_name\n read_attribute('user_name') || \"anonymous\"\n end",
"def username # best practice to reference the same name\n @username\n end",
"def current_user\n session[:name]\n end",
"def get_user_logged_in\n\t\tif current_user != nil\n\t\t\treturn 'Currently signed in as: ' + current_user.forename + ' ' + current_user.surname\n\t\telse\n\t\t\treturn 'You are not logged in!'\n\t\tend\n\tend",
"def username\n # this @user will always be an instance of a User\n @user.username\n end",
"def display_name\n username\n end",
"def username\n\t\treturn @un\n\tend",
"def username\n @username ||= match[3]\n end",
"def get_and_store_username\n @user = User.find_by_id(session[:current_user_id])\n if !@user\n redirect_to logins_path()\n end\n end",
"def name\n userName\n end",
"def username\n self['default_rhlogin']\n end",
"def full_username\r\n return @user.username + '#' + @user.discriminator\r\n end",
"def username\n self.user.username \n end",
"def user_name(user)\n current_user == user ? I18n.t('helpers.me') : user.name\n end",
"def current_user\n session[:name]\n end",
"def current_user\n session[:name]\n end",
"def get_username_by_user_id(user_id)\n User.find(user_id).username\n end",
"def get_username_by_user_id(user_id)\n User.find(user_id).username\n end",
"def current_user\n `whoami`.strip\nend",
"def get_username\n return Sessions.get_username(session[:session_id])\nend",
"def get_username\n return Sessions.get_username(session[:session_id])\nend",
"def username\n @username || email\n end",
"def full_name\n name = `finger $USER 2> /dev/null | grep Login | colrm 1 46`.chomp\n name.empty? ? \"John Doe\" : name.squish\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def username\n ENV['USER']\n end",
"def find_username\n @username || $config.fetch(:username) || prompt_username\n end",
"def username\n @username ||= config_value.split('-')[0]\n end",
"def user_name\n @user_name ||= InchCI::ProjectUID.new(uid).user_name\n end",
"def username\n \"rocky\"\n end",
"def full_name\n name = `finger $USER 2> /dev/null | grep Login | colrm 1 46`.chomp\n name.present? ? name.squish : \"John Doe\"\n end",
"def user_name\n return User.find(user_id).name\n end",
"def user_name\n return User.find(user_id).name\n end",
"def login_name\n return @login_name\n end",
"def username\n @obj['username']\n end",
"def user_id\n username\n end",
"def display_name \n username\n end",
"def username\n @attributes[:username]\n end",
"def username\n @attributes[:username]\n end",
"def username\n @attributes[:username]\n end",
"def username\n @attributes[:username]\n end",
"def username\n @digest_parts['username']\n end",
"def user_name\n name = user.nil? ? '' : user.name\n end",
"def username\n @username ||= match[3]\n end",
"def nickname\r\n return @user.nickname\r\n end",
"def to_s\n username\n end",
"def to_s\n username\n end",
"def who\n\t\t\t@username\n\t\tend",
"def user_name(name = nil)\n return user_name_from_name(name) if name\n\n user_name_random\n end",
"def username\n Shellwords.shellescape(SabreDAVExport.username)\n end",
"def username\n config['couch_username_key'] ? \"#{ENV[config['couch_username_key']]}\" : \"\"\n end"
] |
[
"0.8468469",
"0.8302197",
"0.81750333",
"0.8040615",
"0.7953156",
"0.7938333",
"0.79277164",
"0.79260933",
"0.78911954",
"0.7888102",
"0.78618485",
"0.77948165",
"0.7771885",
"0.7769177",
"0.7746243",
"0.76707506",
"0.7654127",
"0.76538897",
"0.7633293",
"0.76301247",
"0.7613777",
"0.7613777",
"0.7601383",
"0.7556594",
"0.75423574",
"0.75298333",
"0.7527685",
"0.7523597",
"0.7520497",
"0.75120795",
"0.751093",
"0.7420308",
"0.73888737",
"0.7371027",
"0.7363796",
"0.7363796",
"0.7355541",
"0.7346262",
"0.73426414",
"0.7322665",
"0.73214525",
"0.7314004",
"0.72904855",
"0.7278718",
"0.726934",
"0.7258823",
"0.7257265",
"0.7237996",
"0.7232237",
"0.7221578",
"0.7217177",
"0.7215995",
"0.7215027",
"0.72041327",
"0.71966285",
"0.7194079",
"0.7194079",
"0.71855",
"0.71855",
"0.7185334",
"0.7184866",
"0.7184866",
"0.7184815",
"0.71704537",
"0.71574366",
"0.71574366",
"0.71574366",
"0.71574366",
"0.71574366",
"0.71574366",
"0.71574366",
"0.71574366",
"0.71574366",
"0.71574366",
"0.715159",
"0.714673",
"0.7141435",
"0.71361476",
"0.7126573",
"0.7122924",
"0.7119421",
"0.7119421",
"0.71108484",
"0.7108632",
"0.7096682",
"0.70868117",
"0.70795906",
"0.70795906",
"0.70795906",
"0.70795906",
"0.70778966",
"0.7074968",
"0.7074033",
"0.70668864",
"0.7056695",
"0.7056695",
"0.70306826",
"0.70285106",
"0.70261246",
"0.7018292"
] |
0.72305536
|
49
|
Return the current logged in email address.
|
def email_address
response = get 'v1/market/private/user/email.json'
response[:email]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def email\n (@session[:current_user_details] || {})[:email]\n end",
"def me_user_email\n email = Email.find_primary(me).take if auth?\n email.email || ''\n end",
"def get_useremail()\n email = nil\n git_user_email = %x(git config user.email).strip\n email = git_user_email if git_user_email\n email\n end",
"def get_email_address\n response = get_current_user_meta('email')\n email = response['query']['userinfo']['email']\n return if email == ''\n\n email\n end",
"def email_address\n authentications.emails.active.first.uid rescue nil\n end",
"def email\n\t\tif self.email_address\n\t\t\tself.email_address.email\n\t\telse\n\t\t\tself.user.email\n\t\tend\n\tend",
"def email\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n end",
"def hubssolib_get_user_address\n user = self.hubssolib_current_user\n user ? user.user_email : nil\n end",
"def user_email\n session[:user_id]\n end",
"def email\n return @email\n end",
"def email\n return @email\n end",
"def email\n return unless @user.loa3?\n\n value_for('emails')&.first\n end",
"def email\n `git config --get user.email`.strip.presence\n rescue\n nil\n end",
"def email\n @email ||= ENV['EMAIL']\n end",
"def email_address\n return @email_address\n end",
"def email_address\n return @email_address\n end",
"def email\n connect\n user = self.class.query('CMD_API_SHOW_USER_CONFIG',\n :user => resource[:username]\n )\n return user[\"email\"]\n end",
"def get_user_email\n useremail[:value]\n end",
"def email\n\t\treturn @email\n\tend",
"def get_user_email\n user = User.find(self.user_id)\n user.email\n end",
"def email\n self.user.try(:email) || self.original_email\n end",
"def email\n self.user.try(:email) || self.original_email\n end",
"def email\n preferred_email\n end",
"def user_email\n @gapi.user_email\n end",
"def email_address\n get_attribute(Yoti::Attribute::EMAIL_ADDRESS)\n end",
"def mail_nickname\n return @mail_nickname\n end",
"def get_user_email\n unless auth_hash\n return nil if recaptcha_enabled? && !verify_recaptcha\n return params['email']\n end\n\n case auth_hash.provider\n when 'twitter'\n auth_hash.info.nickname\n when 'github'\n check_user_github_organizations ? auth_hash.info.email : nil\n else\n auth_hash.info.email\n end\n end",
"def email\n @auth.include?('@') ? @auth : kitsu_user&.email\n end",
"def default_user_email\n return default_email( DEFAULT_USER )\n end",
"def email_domain\n user.email_domain\n end",
"def device_account_email\n return @device_account_email\n end",
"def email\n if read_attribute(:active) == 1\n if Rails.env.development?\n self.first_name + \" \" + self.last_name + \" <[email protected]>\"\n else\n read_attribute(:email)\n end\n else\n \"\"\n end\n end",
"def u_email\n (self.user).email\n end",
"def email_name\n @email_name || if self[:email]\n split_host = URI.parse(\"#{self[:email]}\").path.split('@')\n \"#{split_host.first}\" if 2 == split_host.size\n end\n rescue URI::InvalidURIError\n nil\n end",
"def email\n get_attribute('Email')\n end",
"def email\n mail.first\n end",
"def email\n mail.first\n end",
"def email\n self[:emailAddress]\n end",
"def email\n if self.alternate_email.blank?\n if self.alumni?\n \"#{self.username}@alumni.calvin.edu\"\n else\n \"#{self.username}@students.calvin.edu\"\n end\n else\n self.alternate_email\n end\n end",
"def email; @email; end",
"def email\n attributes['email']\n end",
"def email\n user.present? ? user.email : self[:email]\n end",
"def email\n @net_ldap_entry[:mail].first\n end",
"def email\n return Contact.get_default_email self.id\n end",
"def email\n mentee_user ? mentee_user.email : nil\n end",
"def email\n if self[:email] && !@email_name\n self[:email]\n elsif self.email_name && self.email_domain\n self[:email] = \"#{self.email_name}@#{self.email_domain}\"\n end\n end",
"def email\n ENV['NEARMISS_EMAIL'] || config['email']\n end",
"def email\n @attributes[:email]\n end",
"def email\n @attributes[:email]\n end",
"def email\n @attributes[:email]\n end",
"def email\n @attributes[:email]\n end",
"def authorized_email\n session[:browserid_email]\n end",
"def contact_email\n return @contact_email\n end",
"def email\n pull unless @details\n begin\n return @details.email_address.address\n rescue\n return nil\n end\n end",
"def official_email\n @net_ldap_entry[:berkeleyeduofficialemail].first\n end",
"def contact_email\n\t\treturn get_configuration['sa_contact_email']\n\tend",
"def email\n multi_email.primary_email_record.try(:email)\n end",
"def recipient_email\n return @recipient_email\n end",
"def recipient_email\n return @recipient_email\n end",
"def email\n params['email']\n end",
"def get_user_email(role)\n get_user(role).email\n end",
"def email\n\t\t@email\n\tend",
"def email\n\t\t@email\n\tend",
"def seller_email\r\n user.email rescue nil\r\n end",
"def user_email\n msg['email'] || entry['email'] || reject['email']\n end",
"def email(full = false)\n full ? \"#{self.profile.name} <#{self.login}>\" : self.login\n end",
"def idonethis_email\n personal_account? ? \"[email protected]\" : \"#{team}@team.idonethis.com\"\n end",
"def email\n userid.try(:match, / <(.*@.*)>/).try(:[], 1)\n end",
"def primary_email\n if self[\"gd$email\"]\n _email = self[\"gd$email\"].find { |e| e.primary == \"true\" }\n _email ? _email.address : nil\n else\n nil # no emails at all\n end\n end",
"def default_email( cid )\n return \"#{cid}@#{DEFAULT_DOMAIN}\"\n end",
"def email\n find_by_type('email')\n end",
"def investor_email_address\n return self.user_company_info.blank? ? self.email : self.user_company_info.business_email\n end",
"def email\n if md = RE_EMAIL.match(contact.to_s)\n md[0]\n else\n nil\n end\n end",
"def display_name\n email\n end",
"def to_s\n\t\temail\n\tend",
"def current_user\n User.where(email: \"[email protected]\").first\n end",
"def email\n # logger.debug2 \"email = #{read_attribute(:email)} (#{read_attribute(:email).class.name})\"\n share_account_id = new_encrypt_pk unless share_account_id\n return nil unless (extended_email = read_attribute(:email))\n encrypt_remove_pre_and_postfix(extended_email, 'email', 49)\n end",
"def to_s\n email\n end",
"def to_s\n email\n end",
"def to_s\n email\n end",
"def to_s\n email\n end",
"def to_s\n email\n end",
"def to_s\n email\n end",
"def to_s\n email\n end",
"def to_s\n email\n end",
"def to_s\n email\n end",
"def to_s\n email\n end",
"def to_s\n email\n end",
"def to_s\n email\n end",
"def to_s\n email\n end",
"def to_s\n email\n end",
"def to_s\n email\n end",
"def to_s\n email\n end",
"def to_s\n email\n end",
"def to_s\n email\n end",
"def to_s\n email\n end",
"def to_s\n email\n end",
"def to_s\n email\n end",
"def to_s\n email\n end",
"def to_s\n email\n end"
] |
[
"0.8399334",
"0.83256274",
"0.82597697",
"0.8223617",
"0.7894504",
"0.7885804",
"0.7824782",
"0.7818323",
"0.7717989",
"0.76120365",
"0.76120365",
"0.75991946",
"0.7501167",
"0.74950176",
"0.7448361",
"0.7448361",
"0.7440689",
"0.7401813",
"0.73996234",
"0.73818237",
"0.73727715",
"0.73727715",
"0.73563856",
"0.7352201",
"0.7310457",
"0.7289185",
"0.7289167",
"0.7265018",
"0.7239208",
"0.7221025",
"0.72005767",
"0.71679705",
"0.7138371",
"0.7138216",
"0.7103903",
"0.71028906",
"0.71028906",
"0.70993894",
"0.70905286",
"0.70774996",
"0.7071362",
"0.70709395",
"0.70676035",
"0.7004594",
"0.70040244",
"0.6988362",
"0.6982232",
"0.6968056",
"0.6968056",
"0.6968056",
"0.6968056",
"0.69635385",
"0.6962648",
"0.69537157",
"0.69457465",
"0.69379586",
"0.6899315",
"0.6831423",
"0.6831423",
"0.6831017",
"0.68297553",
"0.6827158",
"0.6827158",
"0.6811141",
"0.6795142",
"0.6791415",
"0.6785332",
"0.6783291",
"0.6783266",
"0.6768987",
"0.67671824",
"0.67659205",
"0.6745217",
"0.6717548",
"0.67041504",
"0.6666775",
"0.66527003",
"0.6647844",
"0.6647844",
"0.6647844",
"0.6647844",
"0.6647844",
"0.6647844",
"0.6647844",
"0.6647844",
"0.6647844",
"0.6647844",
"0.6647844",
"0.6647844",
"0.6647844",
"0.6647844",
"0.6647844",
"0.6647844",
"0.6647844",
"0.6647844",
"0.6647844",
"0.6647844",
"0.6647844",
"0.6647844",
"0.6647844"
] |
0.71884453
|
31
|
Retrieve information about a user.
|
def user_information(username)
response = get "v1/market/user:#{username}.json"
response[:user]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_user_info\n response = send_method(:get_user_info)\n user_from(response)\n end",
"def user_info\n response = from_server \"api/user.json\"\n response.data\n end",
"def get_user_info\n get(\"/api/v1/oauth_user_info.json\")\n end",
"def get_user_info(user)\n if user.respond_to? :id\n username = Digest::MD5.hexdigest(user.id.to_s)\n else\n username = user\n end\n\n begin\n url = \"#{DOMAIN}/#{ORG}/#{APP}/users/#{username}\"\n response = RestClient.get(url, \"Authorization\" => \"Bearer #{access_token}\", content_type: :json, accept: :json)\n res = JSON.parse(response.body)\n p res[\"entities\"]\n rescue => e\n puts e.response\n end\n end",
"def info()\n get(:session, {:method => \"user.getInfo\"})\n end",
"def user_information\n { \"username\": @user.username, \"email\": @user.email, \"id\": @user.id }\n end",
"def info\n\t@user = User.find(params[:id])\n end",
"def user_info\n @user = @github.users.get user: params[:username]\n render json: Hash[@user]\n end",
"def show\n render json: get_full_user_details(user), status: :ok\n rescue => e\n log_and_render_users_controller_error(e, \"get user details failed\")\n end",
"def user(id)\n self.class.get(\"/user/#{id}\", @options).parsed_response\n end",
"def retrieve(user_id:)\n User.new get_request(\"users/#{user_id}\").body.dig(\"user\")\n end",
"def get_user(user_id:)\n parse(JSON.parse(connection.get(\"users/#{user_id}\").body))\n end",
"def show\n\t\t@user = User.find(params[:id]) rescue nil\n\t\tif @user\n\t\t\tapi_response(@user, 'User Details', :ok)\n\t\telse\n\t\t\tapi_response(nil, 'User id not present in the database', :bad_request)\n\t\tend\n\tend",
"def info()\n _params = {}\n return @master.call 'users/info', _params\n end",
"def show(id)\n response = request(:get, \"/users/#{id}.json\")\n response[\"user\"]\n end",
"def user\n {user_id: self.object.user.id,\n user_name: self.object.user.name\n }\n end",
"def get_info(user_name)\n uri = create_api_uri(@@base_uri, user_name, 'getInfo')\n return get(uri)\n end",
"def user_info\n auth_hash['user_info']\n end",
"def show\n @user = UserService.getUserById(params[:id])\n end",
"def user_info(access_token:, user_id:)\n query = {\n user: user_id\n }.compact\n response = HTTParty.get(\"https://slack.com/api/users.info\",\n query: query,\n headers: { 'Authorization': \"Bearer #{access_token}\" })\n JSON.parse(response.body, symbolize_names: true)\n end",
"def user_info\n {\n 'uid' => user_hash['feed']['author'][0]['email']['$t'],\n 'nickname' => user_hash['feed']['author'][0]['name']['$t'],\n }\n end",
"def user_info\n {\n 'uid' => user_hash['feed']['author'][0]['email']['$t'],\n 'nickname' => user_hash['feed']['author'][0]['name']['$t']\n }\n end",
"def user(user_id)\n response = connection.get do |req|\n req.url \"/user/#{user_id}\", simple_params\n end\n response.body[0]\n end",
"def user_info\n @user_info ||= raw_info\n end",
"def user_info\n @user_info ||= raw_info.nil? ? {} : raw_info['query']['results'][\"profile\"]\n end",
"def get_user(id)\n conn = @client.get do |req|\n req.url \"/api/v2/user/#{id}\"\n req.headers[\"Authorization\"] = @token\n end\n conn.body\n end",
"def user_info\n\t\t@user_info ||= fetch_latest_user_info\n\tend",
"def user(username_or_id)\n puts \"Getting Info about User %s\" % username_or_id.to_s\n begin\n u = @MT.user(username_or_id)\n string_data = {\n :name => u.name,\n :screen_name => u.screen_name,\n :location => u.location,\n :description => u.description,\n :url => u.url \n }\n user_data = {\n :id => u.id,\n :followers_count => u.followers_count,\n :friends_count => u.friends_count,\n :protected => u.protected,\n :listed_count => u.listed_count,\n :created_at => u.created_at,\n :favourites_count => u.favourites_count,\n :utc_offset => u.utc_offset,\n :time_zone => u.time_zone,\n :geo_enabled => u.geo_enabled,\n :verified => u.verified,\n :statuses_count => u.statuses_count,\n :lang => u.lang,\n :is_translator => u.is_translator\n }\n string_data.each { |k,v| v.nil? ? (user_data[k] = nil) : (user_data[k] = v) }\n user_data\n rescue Twitter::Error::Unauthorized, Twitter::Error::Forbidden, Twitter::Error::NotFound\n puts \"Suspended?\"\n nil\n end\n end",
"def get_user id, options={}, headers={}\n @connection.get \"users/#{id}.json\", options, headers\n end",
"def get_user_data\n @user = User.find(params[:id])\n end",
"def get_user_data(uid)\n @conn.get(\"/api/v1/users/#{uid}\")\n end",
"def get(user_id)\n get_request(t_url(:user, user_id))\n end",
"def user_info\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n\n respond_to do |format|\n name = @current_user.name\n username = @current_user.username\n format.json {\n render json: {\n :name => name,\n :username => username,\n }.to_json, status: 200\n }\n end\n end",
"def user_info(user_oauth_token)\n api_post(@user_info_url, user_oauth_token)\n end",
"def get_user_details\n\t\tid = params[:id]\n\t\tTheCityAdmin::AdminApi.connect(Rcplugin::CITY_ADMIN_SECRET,Rcplugin::CITY_USER_TOKEN)\n\t\t@user = TheCityAdmin::User.load_by_id(id)\n\tend",
"def user(user_id)\n params = {\n :client_id => Swiftype.platform_client_id,\n :client_secret => Swiftype.platform_client_secret\n }\n get(\"users/#{user_id}.json\", params)\n end",
"def user(user_id, params = {})\n make_get_request(\"/users/#{user_id}\", params)\n end",
"def info\n {\n email: username\n }\n end",
"def show\n {\n id: @current_user.id,\n first_name: @current_user.first_name,\n last_name: @current_user.last_name,\n email: @current_user.email,\n role_name: @current_user.super_admin ? 'Super Admin' : @current_user.role.try(:name),\n permissions: Permissions::Builder.user_permissions(@current_user)\n }\n end",
"def get_user\n @user = User.find(params[:user_id])\n end",
"def user\n UserRepository.find(user_id)\n end",
"def show\n @user = User.find(params[:id]) \n @user_me = retrieve_authenticated_user\n end",
"def get_user(user_id)\n request(Route.new(:GET, '/users/%{user_id}', user_id: user_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 get_user_info\n id = params[\"id\"]\n error_list = []\n status = 1\n json_response = {}\n user = User.find_by(id: id)\n\n if user.nil?\n error_list.append(\"Error: The specified user doesn't exist.\")\n status = -1\n else\n json_response[\"user\"] = user.get_user_json_data\n end\n\n if status == -1\n json_response[\"errors\"] = error_list\n end\n\n json_response[\"status\"] = status\n\n # Format the json_response into proper JSON and respond with it\n json_response = json_response.to_json\n\n respond_to do |format|\n format.json { render json: json_response }\n end\n end",
"def show\n\t\t@user = User.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t format.html # show.html.erb\n\t\t format.json { render json: @user }\n\t\tend\n\tend",
"def get_user_details(opts = {})\n get_user_details_with_http_info(opts)\n nil\n end",
"def user(id = 'self')\n get(\"users/#{id}\").user\n end",
"def userinfo\n if @user.nil?\n nil\n elsif @password.nil?\n @user\n else\n @user + ':' + @password\n end\n end",
"def user_info\n {\n 'nickname' => user_hash['NickName'],\n 'name' => user_hash['NickName']\n }\n end",
"def info(query=nil, options={})\n # options[:number] ||= options.delete(:phone) if options.has_key? :phone\n # options[:endpoint] ||= Mogreet.endpoint(\"user.info\")\n # options[:method] ||= \"user.info\" unless options.has_key? :endpoint\n method = \"user.info\"\n Mogreet::Response::Base.new Mogreet.get_response(method, query, options)\n end",
"def get_user_info\n userTokenInfo = request.env['oauth.token']\n @user = userTokenInfo.user\n end",
"def get_user_details(account)\n # Get the user's profile information.\n response = access_token(account).get('http://gdata.youtube.com/feeds/api/users/default')\n xml = Nokogiri::XML(response.body)\n username = xml.xpath('//yt:username/text()', {'yt' => 'http://gdata.youtube.com/schemas/2007'}).to_s\n first_name = xml.xpath('//yt:firstName/text()', {'yt' => 'http://gdata.youtube.com/schemas/2007'}).to_s\n last_name = xml.xpath('//yt:lastName/text()', {'yt' => 'http://gdata.youtube.com/schemas/2007'}).to_s\n\n # Return the user details.\n return {:username => username, :full_name => \"#{first_name} #{last_name}\", :url => \"http://www.youtube.com/user/#{username}\"}\n end",
"def show\n @client = basic_connect\n @user_info = @client.user_info['user']\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_token }\n end\n end",
"def show\n\t\t@user = User.find(params[:id])\n\t\trespond_to do |format|\n\t\t\tformat.html { render :action => \"show\" }\n\t\t\tformat.json { render :json => @user }\n\t\tend\n\tend",
"def view_user(params)\n user_id = params.delete(:user_id)\n raise ArgumentError.new(\"user_id required\") unless user_id\n res = call_api(:method => :get, :uri => @api_base.merge(\"user/#{user_id}\"), :query_params => params)\n return unless res.successful?\n User::Person.new(res.data)\n end",
"def user_info\n @user_info ||= raw_info.nil? ? {} : raw_info[\"person\"]\n end",
"def show\n\t\t@the_user = User.find(params[:id])\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.xml { render :xml => @the_user }\n\t\tend\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\t\t@user = User.find(params[:id])\n\tend",
"def user(user=nil, options = {})\n get User.path(user), options\n end",
"def show\n # loads one user in the database\n @user = User.find(params[:id])\n end",
"def user\n User.get(contact, client: @client)\n end",
"def fetch_user(id)\n client.user(id)\n end",
"def info(refresh = false)\n return @info if @info and not refresh\n\n begin\n cache_info(nil) # reset existing info\n info = @api.get_account_info['user']\n cache_info(info)\n rescue Api::NotAuthorized, Api::InvalidInput\n nil\n end\n end",
"def show\n @user = get_user\n end",
"def show(id)\n response = request(:get, \"/users/#{id}.json\")\n response.first[1]\n end",
"def get_user_detail(user_id)\n endpoint = \"/api/#{@version}/kyc/get-detail/\"\n params = request_parameters(endpoint, {user_id: user_id})\n get(params)\n end",
"def get_user(id, &block)\n get(\"#{@base_url}/user/#{id}/json\", user_mapping, block)\n end",
"def show\n json_response(@user)\n end",
"def get_user(id)\n @client.raw('get', \"/config/users/#{id}\")\n end",
"def find user_name\n response = @client.action \"DescribeUser\", \"Name\" => user_name\n\n Response::User.new response.body['DescribeUserResponse']\n rescue Hugs::Errors::BadRequest\n end",
"def show\n\t\t@user = User.find(params(:id))\n\tend",
"def user(user_id_or_url = nil, options = {})\n options = make_options(:user_id, user_id_or_url, options)\n get(options)\n end",
"def getUserDetails\n\t\tuser = java.util.HashMap.new()\n\t\t# user name\n\t\tuser.put(KEY_NAME, @pref.getString(KEY_NAME, nil))\n\t\t\n\t\t# user email id\n\t\tuser.put(KEY_EMAIL, @pref.getString(KEY_EMAIL, nil))\n\t\t\n\t\t# return user\n\t\treturn user;\n\tend",
"def user(id)\n target = \"#{self.base_url}/user/#{id.to_s}/\"\n self.class.get(target, {basic_auth: self.auth})\n end",
"def user_info\n @user_info ||= raw_info.nil? ? {} : raw_info\n end",
"def user_info\n @user_info ||= raw_info.nil? ? {} : raw_info\n end",
"def user\n user = JSON.parse(RestClient.get(\"https://api.discord.bio/v1/user/details/#{slug}\"))\n\n DBio::User.new(user['payload'])\n end",
"def get_user_info(*fields)\n str_fields = fields.map(&:to_s).join(',')\n url = GRAPH_URL + @user.id + '?fields=' + str_fields + '&access_token=' +\n ENV['ACCESS_TOKEN']\n begin\n return call_graph_api(url)\n rescue => e\n return false\n end\n end",
"def read\n\t\tuser = User.find_by_username(params[:username])\n\t\tif user\n payload = {\n username: user.username,\n first_name: user.first_name,\n last_name: user.last_name,\n created_at: user.created_at.strftime(\"%-m/%-d/%Y\")\n }\n\t\t\tif @current_user and @current_user.id == user.id\n payload[:email_address] = user.email_address\n end\n render status: 200, json: payload\n\t\telse\n\t\t\trender status: 404, json: {error: true}\n\t\tend\n\tend",
"def getUser(user, info)\n @@users[user][info]\n end",
"def user(user_name)\n OctocatHerder::User.fetch(user_name, connection)\n end",
"def get_all_info_from_user()\n\n db = connect_to_db(\"db/db.db\")\n\n db.execute(\"SELECT * FROM users\")\n end",
"def show\n user = User.find_by(id: params[:id])\n render json: user, status: :ok\n end",
"def check\n api.get_user\n end",
"def user\n parse!\n @user\n end",
"def user user_id, options = {}\n perform_get_with_object(\"/users/#{user_id}\", options, Vimeo::Entities::User)\n end",
"def get_user_info user\n unless user.known_user.nil?\n known_user = user.known_user\n is_me = known_user.is_current_user || false\n return is_me ? \"people/me\" : known_user.person_name\n end\n get_one_of user\nend",
"def get_user(id)\r\n # Prepare query url.\r\n _path_url = '/users/{id}'\r\n _path_url = APIHelper.append_url_with_template_parameters(\r\n _path_url,\r\n 'id' => id\r\n )\r\n _query_builder = Configuration.get_base_uri\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n CustomHeaderAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n UserDetail.from_hash(decoded)\r\n end",
"def show\n @user = User.get(params[:id]) \n end",
"def get_user(request, params)\n # --- Get the USER ---\n user = UserOCCI.new(\n User.build_xml(params[:id]),\n @client)\n\n # --- Prepare XML Response ---\n rc = user.info\n if OpenNebula.is_error?(rc)\n return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]\n end\n\n return to_occi_xml(user, :code=>200)\n end",
"def get_user(handle)\n request(Net::HTTP::Get, \"/api/#{API_VERSION}/user/#{handle}\", nil, nil, false)\n end",
"def get_user\n @user = User.find(params[:user_id])\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 user(options={})\n get('/user', options)\n end"
] |
[
"0.86762273",
"0.8345303",
"0.8176553",
"0.8121085",
"0.79798824",
"0.78839564",
"0.77523303",
"0.7684491",
"0.7645323",
"0.76193017",
"0.7606617",
"0.7593977",
"0.75910556",
"0.7581551",
"0.75036395",
"0.7470414",
"0.7427205",
"0.7424319",
"0.7411673",
"0.7392343",
"0.7332568",
"0.7321866",
"0.7320004",
"0.73123",
"0.7306964",
"0.7306307",
"0.7300735",
"0.7296945",
"0.7285501",
"0.7267632",
"0.7262351",
"0.7261198",
"0.72543377",
"0.72431415",
"0.7209976",
"0.7200303",
"0.7195813",
"0.7173621",
"0.7163058",
"0.716299",
"0.7162093",
"0.7148242",
"0.71322703",
"0.71207106",
"0.71207106",
"0.7119941",
"0.711574",
"0.71141016",
"0.709847",
"0.7091964",
"0.7089165",
"0.7085882",
"0.7085607",
"0.7075555",
"0.70610154",
"0.7056406",
"0.7053177",
"0.70476705",
"0.7041921",
"0.70406085",
"0.70406085",
"0.70406085",
"0.70406085",
"0.70406085",
"0.70256543",
"0.70193434",
"0.70190626",
"0.7018188",
"0.70086986",
"0.7003334",
"0.70019203",
"0.69978535",
"0.6992098",
"0.6981921",
"0.698081",
"0.69735867",
"0.69644254",
"0.69482607",
"0.69459283",
"0.69368285",
"0.6936033",
"0.6936033",
"0.6915053",
"0.69001997",
"0.6900187",
"0.68865967",
"0.68851423",
"0.68820065",
"0.6878635",
"0.6875215",
"0.68741405",
"0.6860132",
"0.68593353",
"0.6858038",
"0.68537366",
"0.6852353",
"0.68501127",
"0.6840866",
"0.6839006",
"0.6838084"
] |
0.7832102
|
6
|
Find badges for a user.
|
def badges_for_user(username)
response = get "v1/market/user-badges:#{username}.json"
response[:'user-badges']
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def badges(user_id: '-')\n return get(\"#{API_URI}/#{PROFILE_API_VERSION}/user/#{user_id}/badges.json\")\n end",
"def badges\n get(\"user/#{user_id}/badges.json\")\n end",
"def badges(options={})\n get('/user_badge', options)\n end",
"def badges(id)\n get(\"users/#{id}/badges\")\n end",
"def badges(options={})\n self.class.parse_badges(request(singular(user_id) + \"/badges\", options))\n end",
"def user_badges user_id=\"self\"\n response = get(\"/users/#{user_id}/badges\")[\"response\"]\n if response[\"sets\"] and response[\"sets\"][\"groups\"]\n response[\"sets\"][\"groups\"].map!{|group| Foursquared::Response::BadgeGroup.new(self, group)}\n end\n\n if response[\"badges\"]\n response[\"badges\"].each_key do |badge_id|\n response[\"badges\"][badge_id] = badge(badge_id)\n end\n end\n response\n end",
"def badge_status(user)\n if user.badges.select {|b| b.is_a?(self)}.empty?\n 0\n else\n current = user.badges.select {|b| b.is_a?(self)}\n current.map {|b| b.level }.max\n end\n end",
"def badges\n end",
"def full_badges\n client.user_badges(id)\n end",
"def badges\n Merit::Badge.find { |b| b.custom_fields[:skill_level] == self.name_key.to_sym }\n end",
"def badges_count\n badges.count\n end",
"def badge_percentage(user, badge) \n case badge \n when \"ownership\"\n score = user.ownership.score \n when \"persistence\"\n score = user.persistence.score \n when \"communication\"\n score = user.communication.score \n when \"gratitude\"\n score = user.gratitude.score \n else\n #Failsafe\n end\n level = user.badge_ding_threshold(badge)\n value = score.to_f / level.to_f\n percentage = value * 100\n return percentage.to_i\n end",
"def badge_for(user, style = :thumb)\n if user\n content_tag :div, :class => 'user-badge' do\n content = link_to(avatar(user, style), user_path(user))\n content += image_tag(user.current_badge.image.url(style), :class => 'badge-label', :alt => user.current_badge.name) if user.current_badge\n concat content\n end\n end\n end",
"def index\n @user_badges = UserBadge.where(active: true).where(user_id: params[:user_id])\n end",
"def badges\n achievements.reduce({}) do |badges, achievement|\n badges.merge(achievement.name => achievement.badges)\n end\n end",
"def find_badgedefs_to_test(user_id, course_id)\n user_badges = Badge.where(user_id: user_id)\n awarded_bd_ids = user_badges.map { |b| b.badge_def_id }\n\n all_course_badgedefs = BadgeDef.where(course_id: course_id, active: true)\n all_bd_ids = all_course_badgedefs.map { |bd| bd.id }\n unawarded_bd_ids = all_bd_ids - awarded_bd_ids\n\n BadgeDef.find(unawarded_bd_ids)\n end",
"def selects_the_user_name_age_and_pledge_amount_for_all_pledges\n\"SELECT users.name, users.age , SUM(pledges.amount) FROM pledges INNER JOIN users ON users.id = pledges.user_id GROUP by users.name;\"\n## go through all pledges, and find the pledge amount matching the user_id. return the\n## pledge amount linked to user_id and their name and ages.\nend",
"def user_badge(user, override: nil, link: true)\n raise \"Invalid badge override\" if ![nil, :standard, :silver, :gold].include?(override)\n return '???' if user.nil?\n\n badge = 'badge-dark'\n title = nil\n\n if override.present?\n badge = 'badge-dark' if override == :standard\n\n if override == :gold\n badge = 'badge-warning'\n title = \"#{user} is a Splits.io patron!\"\n end\n\n if override == :silver\n badge = 'badge-secondary'\n title = \"#{user} is a Splits.io patron!\"\n end\n\n return \"<span class='badge #{badge}' content='#{title}' v-tippy>#{user}</span>\" if !link\n\n return link_to(user, user_path(user), class: ['badge', badge], content: title, 'v-tippy' => true)\n end\n\n if user.patron?\n badge = 'badge-secondary'\n title = \"#{user} is a Splits.io patron!\"\n end\n\n if user.patron?(tier: 2)\n badge = 'badge-warning'\n title = \"#{user} is a Splits.io patron!\"\n end\n\n if user.admin?\n badge = 'badge-danger'\n title = \"#{user} is a Splits.io staff member!\"\n end\n\n link_to(user, user_path(user), class: \"badge #{badge}\", content: title, 'v-tippy' => '') # Must be '', not true\n end",
"def badges(league_id, player_id)\n # get players\n players = player_ids league_id\n badges = Hash.new { |h, k| h[k] = [] }\n all_games = game_ids(league_id)\n\n # tournament hack\n # badges[399] << badge('🏆', 'New Bags Champs') #adam\n # badges[453] << badge('🏆', 'Jan 18th Champs') #james\n # badges[397] << badge('🥈', 'New Bags 2nd Place') #greg\n # badges[319] << badge('🥈', 'Jan 18th - 2nd Place') #mike\n # badges[449] << badge('🥉', 'New Bags 3rd Place') #kirk\n # badges[21] << badge('🥉', 'Jan 18th - 3rd Place') #randall\n\n # plays a lot\n # players.each do |p|\n # badges[p] << badge('⚽', 'Determined') if games_this_week(p, league_id) > 50\n # end\n\n # fire badge\n # best daily change\n best_change = players.group_by { |p| daily_elo_change(p, league_id) }.max\n best_change.last.each { |b| badges[b] << badge('🔥', 'On Fire') } if !best_change.nil? && best_change.first >= 10\n\n # poop badge\n # worst daily change\n worst_change = players.group_by { |p| daily_elo_change(p, league_id) }.min\n worst_change.last.each { |b| badges[b] << badge('💩', 'Rough Day') } if !worst_change.nil? && worst_change.first <= -10\n\n # baby badge\n # 10-15 games played\n babies = players.select do |p|\n games_with_player(p, league_id, 20).length.between?(10, 15)\n end\n babies.each { |b| badges[b] << badge('👶🏼', 'Newly Ranked') } unless all_games.length < 100 || babies.nil?\n\n # monkey badge\n # won last game but elo went down\n # flexing badge\n # won last game and gained 10+ elo\n players.select do |p|\n games = games_with_player(p, league_id, 1)\n next if games.empty?\n last_game = api_game(games.first, league_id)\n winner = last_game[:teams][0][:players].any? { |a| a[:playerID] == p }\n badges[p] << badge('🙈', 'Monkey\\'d') if last_game[:teams][0][:delta] < 0 && winner\n badges[p] << badge('🍌', 'Graceful Loss') if last_game[:teams][0][:delta] < 0 && !winner\n badges[p] << badge('💪🏼', 'Hefty Win') if last_game[:teams][0][:delta] >= 10 && winner\n badges[p] << badge('🤕', 'Hospital Bound') if last_game[:teams][0][:delta] >= 10 && !winner\n end\n\n # toilet badge\n # last skunk (lost w/ 0 points)\n toilet_game = all_games.find do |g|\n (api_game(g, league_id)[:teams][1][:score]).zero?\n end\n toilets = api_game(toilet_game, league_id)[:teams][1][:players] if toilet_game\n toilets.each { |b| badges[b[:playerID]] << badge('🚽', 'Get Rekt') } unless toilets.nil?\n\n # win streak badges\n # 5 and 10 current win streak\n win_streaks = {}\n players.each do |p|\n games = games_with_player(p, league_id, 20)\n last_wins = games.take_while do |g|\n game = api_game(g, league_id)\n game[:teams][0][:players].any? { |a| a[:playerID] == p }\n end\n win_streaks[p] = last_wins.length\n end\n\n win_streaks.each do |p, s|\n badges[p] << badge(\"#{s}⃣\", \"#{s}-Win Streak\") if s.between?(3, 9)\n badges[p] << badge('💰', \"#{s}-Win Streak\") if s.between?(10, 19)\n badges[p] << badge('👑', '20+ Win Streak') if s >= 20\n end\n\n # zzz badge\n # hasn't played a game in 2 weeks\n if league_id == 1\n sleepers = players.select do |p|\n player_snoozin(p, league_id)\n end\n sleepers.each { |b| badges[b] << badge('💤', 'Snoozin\\'') }\n end\n\n # nemesis and ally badges\n if player_id > 0\n nemeses = []\n allies = []\n you = api_player(player_id, true, league_id)\n players.each do |p|\n this_player = api_player(p, false, league_id)\n nemeses << p if this_player[:displayName] == you[:nemesis]\n allies << p if this_player[:displayName] == you[:ally]\n end\n nemeses.each { |b| badges[b] << badge('😈', 'Your Nemesis') }\n allies.each { |b| badges[b] << badge('😇', 'Your Ally') }\n end\n\n # build hash\n badges.collect do |k, v|\n {\n playerID: k,\n badges: v\n }\n end\nend",
"def current_holders\n badge_nominations.select{ |bn| bn.accepted? }.map{ |bn| bn.user }\n end",
"def compare_response_to_user_budget(user_id)\n fares_under_budget = []\n convert_strings_to_floats(user_id).each do |fare|\n if fare <= User.find_by_id(user_id).budget\n fares_under_budget << fare\n end\n end\n fares_under_budget\nend",
"def parse_badges(result)\n parse_type(result, \"badge\")\n end",
"def badge_progress(user, badge)\n case badge\n when \"ownership\"\n score = \"#{user.ownership.score}\"\n when \"persistence\"\n score = \"#{user.persistence.score}\"\n when \"communication\"\n score = \"#{user.communication.score}\"\n when \"gratitude\"\n score = \"#{user.gratitude.score} \"\n else \n # Renders a failsafe\n end\n \"#{score} / #{user.badge_ding_threshold(badge)}\"\n end",
"def badge\n if badge_id\n Merit::Badge.find(badge_id)\n else\n Merit::Badge.find_by_name_and_level(badge_name, level)\n end\n end",
"def set_user\n id = params[:slug] || params[:id]\n @user = User.find(id)\n @badges = @user.badges.group_by(&:level)\n end",
"def backfill_awarded_badges(user)\n MeritRebuilder.new.rebuild_merit_for(user)\n end",
"def set_users_badge\n @users_badge = UsersBadge.find(params[:id])\n end",
"def show\n @user = User.find(params[:id])\n unless @user.uuid == current_user.uuid\n unless current_user.rels(dir: :outgoing, type: :visits, between: @user).blank?\n rel = current_user.rels(dir: :outgoing, type: :visits, between: @user)\n rel[0].count = rel[0].count + 1\n rel[0].save!\n else\n rel = Visit.new\n rel.from_node = current_user\n rel.to_node = @user\n rel.count = 1\n rel.save!\n end\n current_user.save!\n end\n #@b = current_user.badges(:u, :r).where( uuid: @user.uuid ).pluck(:r)\n #@badges = @b.map {|b| b.badgeType}.uniq\n @uniq_badges = @user.rels(dir: :incoming, type: :badges).each.map {|r| r.badgeType}.uniq\n @all_badges = {}\n @uniq_badges.each do |badge|\n @all_badges[badge] = @user.rels(dir: :incoming, type: :badges).each.select{|r| r.badgeType == badge }.count\n end\n @my_badges = []\n @badges_count = @user.rels(dir: :incoming, type: \"badges\").count\n if current_user.uuid != @user.uuid\n current_user.rels(dir: :outgoing, type: :badges, between: @user).each do |r|\n #current_user.badges(:u, :r).where( uuid: @user.uuid ).each_with_rel do |u, r| \n @my_badges << r[:badgeType]\n end\n end\n @pictures = @user.pictures\n @testimonials = @user.testimonials\n\n unless @user.uuid == current_user.uuid\n @like = current_user.rels(dir: :outgoing, type: :likes, between: @user).blank? ? true : false\n end\n @likes_count = @user.rels(dir: :incoming, type: \"likes\").count\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def get_stack_user_info(user_id)\n user_info = HTTParty.get(\"https://api.stackexchange.com/2.2/users/\" + user_id + \"?order=desc&sort=reputation&site=stackoverflow&filter=!406FePY_tk75WKBzx&key=d9Fe13Jxvcb)WMzdPi8t7A((\")\n\n user_info = user_info[\"items\"][0]\n total_badges = user_info[\"badge_counts\"].values.sum\n stack_info = {id: user_id, reputation: user_info[\"reputation\"], age: user_info[\"age\"].to_i, badge_counts: total_badges}\n stack_info\n end",
"def worst_user\n @group_users.min_by(&:get_rate)\n end",
"def neighbours(user, options={})\n get(:standard, {:method => \"user.getNeighbours\", :user => user}.merge(options))\n end",
"def user_outstanding_balance(user, group_custom_biller = nil)\n if group_custom_biller.present?\n # only participations and subscriptions for biller\n invoiceable_reservations = invoiceable_game_passes = []\n else\n invoiceable_reservations = user_reservations(user).invoiceable\n invoiceable_game_passes = game_passes.where(user: user).invoiceable\n end\n\n invoiceable_participations = participations_by_biller(group_custom_biller).\n where(user: user).invoiceable\n invoiceable_group_subscriptions = group_subscriptions_by_biller(group_custom_biller).\n where(user: user).invoiceable\n\n invoiceable_reservations.map { |r| r.outstanding_balance || 0.to_d }.sum.to_d +\n invoiceable_game_passes.map { |r| r.price || 0.to_d }.sum.to_d +\n invoiceable_participations.map { |r| r.price || 0.to_d }.sum.to_d +\n invoiceable_group_subscriptions.map { |r| r.price || 0.to_d }.sum.to_d\n end",
"def get_bills_for_user(user)\n bills = BillPart.where(participant_id:user.id).map(&:id)\n end",
"def badge_level_up\n\t\tbadge_level_up_aux(\"Birdman\",\"bird\",\"following\",\"follower\") #devo passare il parametro follower poichè non si chiama \"user\" come negli altri casi di badges\n\tend",
"def badge_level(name)\n these_badges = self.badges.find_all { |b| b.name == name }\n if these_badges.any?\n these_badges.sort_by { |b| b.level }.last.level\n else\n 0\n end\n end",
"def find_user_event_balance(user_id)\n\t\tself.user_event_balances.find_by_user_id(user_id)\n\tend",
"def users_vote(user)\n votes.includes(:user).find_each { |v| return v if v.user_id == user.id }\n nil\n end",
"def user_outstanding_balance(user)\n invoicable_reservations = reservations.where(user: user).invoicable\n invoicable_game_passes = game_passes.where(user: user).invoicable\n\n invoicable_reservations.map(&:outstanding_balance).sum.to_f +\n invoicable_game_passes.map(&:price).sum.to_f\n end",
"def find_bridges(params={}, headers=default_headers)\n @logger.info(\"Find Bridges.\")\n get(\"#{@api_url}/bridges\", params, headers)\n end",
"def find_badge(name)\n badge_name = name.delete(\" \").downcase #delete whitespace\n return name unless badges.has_key?(badge_name)\n badges[badge_name] \n end",
"def user_votes(user)\n namings.each_with_object([]) do |n, votes|\n v = n.users_vote(user)\n votes << v if v\n end\n end",
"def badge\n if @badge.nil?\n badges = Badge.by_name(badge_name)\n badges = badges.by_level(level) unless level.nil?\n @badge = badges.first\n end\n @badge\n end",
"def add_badge!( badge, update_badge = true )\n unless @badges.include?( badge )\n @badges << badge\n badge.add_user!( self, false) if update_badge\n end\n return @badges\n end",
"def pledges\n # Look through all pledges\n # only keep the ones where pledge.user == self\n Pledge.all.select do |pledge|\n pledge.user == self\n end\n end",
"def availableWins(userId)\n return availableWinsByDivision(userId, nil, nil)\n end",
"def get_user_greetings(user_id, opts = {})\n data, _status_code, _headers = get_user_greetings_with_http_info(user_id, opts)\n return data\n end",
"def pledges\n # Look through all pledges\n # only keep the ones where pledge.user == self\n Pledge.all.select do |pledge|\n pledge.user == self\n end\n end",
"def analyze_most_radlib_fillins_by_user(user)\n analyze_most_generic(user.uid, user.num_radlibs_created.to_i, DOCS[:most_fillins])\n self\n end",
"def find_user(username)\n usrid = username\n user = PuppetForge::User.find(username) # The Puppetforge::User object retrieves all data from the forge API\n count = user.module_count # The module_count method returns the total number of modules for the user\n release = user.release_count # The release_count returns the total number of releases for a user\n\n modules = PuppetForge::Module.where(owner: username) \n\n # Add all the numbers together using reduce\n totals = modules.unpaginated.reduce(0) do | sum, mod | \n sum + mod.downloads\n end\n\n return { cols: [ {value: usrid}, {value: totals}, {value: count}, {value: release} ]} # returns a row of user data collected from the forge. Format: Username, Total Downloads, Module Count, Release Count\n\nend",
"def outstanding_balances\n invoicable_reservations = reservations.invoicable.group_by(&:user_id)\n invoicable_game_passes = game_passes.invoicable.group_by(&:user_id)\n\n user_ids = invoicable_reservations.keys + invoicable_game_passes.keys\n\n user_ids.map do |user_id|\n [user_id,\n invoicable_reservations[user_id].try(:map, &:outstanding_balance).try(:sum).to_f +\n invoicable_game_passes[user_id].try(:map, &:price).try(:sum).to_f\n ]\n end.to_h\n end",
"def print_user_badges(user_data)\n puts \"-\" * 70\n puts \"Badge Name\".ljust(60) + \"Date\".ljust(10)\n puts \"-\" * 70\n\n # loop through all badges and format the date into something readable\n user_data[\"badges\"].each do |badge|\n puts badge[\"name\"].slice(0, 60).ljust(60) + badge[\"earned_date\"].slice(0, 10).split(\"-\").join(\"/\").ljust(10)\n end\n\n puts \"-\" * 70\nend",
"def lifetime_balances(user_ids = nil)\n reservations_relation = reservations.includes(:user)\n game_passes_relation = game_passes\n participations_relation = participations\n group_subscriptions_relation = group_subscriptions\n\n if user_ids.present?\n game_passes_relation.where!(user_id: user_ids)\n participations_relation.where!(user_id: user_ids)\n group_subscriptions_relation.where!(user_id: user_ids)\n # cannot do this on reservations because they may belong to a group, where we have to bill\n # the owner of that group (that's why we group on `fetch_owner_id`)\n # reservations_relation.where!(user_id: user_ids)\n end\n\n reservations_by_user = reservations_relation.group_by(&:fetch_owner_id)\n game_passes_balances = game_passes_relation.group(:user_id).sum(:price)\n participations_balances = participations_relation.group('participations.user_id').sum(:price)\n group_subscriptions_balances = group_subscriptions_relation.group(:user_id).sum(:price)\n\n users.map do |user|\n [user.id,\n (reservations_by_user[user.id].to_a.map(&:price).sum || 0).to_d +\n (game_passes_balances[user.id] || 0).to_d +\n (participations_balances[user.id] || 0).to_d +\n (group_subscriptions_balances[user.id] || 0).to_d\n ]\n end.to_h\n end",
"def find_tagged_with_by_user(tags, user, options = {})\n options.assert_valid_keys([:match])\n find_tagged_with(tags, {:match => options[:match], :user => user})\n end",
"def find_tagged_with_by_user(tags, user, options = {})\n options.assert_valid_keys([:match])\n find_tagged_with(tags, {:match => options[:match], :user => user})\n end",
"def badge_level_up\n\t return if recipe.ratings.where(user_id: user.id).first.score == 0 \n\t\tbadge_level_up_aux(\"Critic\",\"critic\",\"ratings\")\n\tend",
"def get_limit(user)\r\n fail \"missing user\" if user.nil?\r\n\r\n @member_limits.fetch(user.email).limit\r\n end",
"def get_blacklist(user)\n username = Digest::MD5.hexdigest(user.id.to_s)\n begin\n response = RestClient.get(\"#{DOMAIN}/#{ORG}/#{APP}/users/#{username}/blocks/users\",\n \"Authorization\" => \"Bearer #{access_token}\",\n :content_type => :json,\n :accept => :json\n )\n if response.code == 200\n p response\n\n body = JSON.parse(response.body)\n p body\n end\n rescue => e\n puts e.response\n end\n end",
"def user_lifetime_balance(user)\n reservations_balance = reservations.where(user: user).sum(:price)\n game_passes_balance = game_passes.where(user: user).sum(:price)\n\n reservations_balance.to_f + game_passes_balance.to_f\n end",
"def attack(user)\n # Variable to see how many damage instances will be\n damage_instances_count = 0\n\n # Search within weapons for damage bonus\n user.weapons.each do |weapon|\n weapon.bonuses.each do |bonus|\n if bonus.bonus_type == 'damage'\n damage_instances_count = bonus.multiplier\n end\n end\n end\n\n # For each damage bonus we will calculate the attack again\n damage_instances = (1..damage_instances_count).map do\n # Values from weapons\n weapon_attack_points = 0\n weapon_attack_modifiers = 0\n weapon_attack_recoil_modifier = 0\n\n weapon_defense_points = 0\n weapon_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.weapons.each do |weapon|\n weapon_attack_points += weapon.attack_points\n weapon_defense_points += weapon.defense_points\n\n weapon.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n weapon_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'recoil'\n weapon_attack_recoil_modifier += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n weapon_defense_modifiers += bonus.multiplier\n end\n end\n end\n\n # Values from rings\n rings_attack_points = 0\n rings_attack_modifiers = 0\n\n rings_defense_points = 0\n rings_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.rings.each do |ring|\n rings_attack_points += ring.attack_points\n rings_defense_points += ring.defense_points\n\n ring.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n rings_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n rings_defense_modifiers += bonus.multiplier\n end\n end\n end\n\n # Values from helmets\n helmet_attack_points = user.helmet.attack_points\n helmet_attack_modifiers = 0\n\n helmet_defense_points = user.helmet.defense_points\n helmet_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.helmet.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n helmet_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n helmet_defense_modifiers += bonus.multiplier\n end\n end\n\n # Values from body armor\n body_armor_attack_points = user.body_armor.attack_points\n body_armor_attack_modifiers = 0\n\n body_armor_defense_points = user.body_armor.defense_points\n body_armor_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.body_armor.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n body_armor_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n body_armor_defense_modifiers += bonus.multiplier\n end\n end\n\n # Values from boots\n boots_attack_points = user.boots.attack_points\n boots_attack_modifiers = 0\n\n boots_defense_points = user.boots.defense_points\n boots_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.boots.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n boots_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n boots_defense_modifiers += bonus.multiplier\n end\n end\n\n # Values from gloves\n gloves_attack_points = user.gloves.attack_points\n gloves_attack_modifiers = 0\n\n gloves_defense_points = user.gloves.defense_points\n gloves_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.gloves.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n gloves_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n gloves_defense_modifiers += bonus.multiplier\n end\n end\n\n # Values from amulet\n amulet_attack_points = user.amulet.attack_points\n amulet_attack_modifiers = 0\n\n amulet_defense_points = user.amulet.defense_points\n amulet_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.amulet.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n amulet_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n amulet_defense_modifiers += bonus.multiplier\n end\n end\n\n # Making a sum of all the points from the itens\n attack_points_sum = weapon_attack_points + rings_attack_points + helmet_attack_points + body_armor_attack_points + boots_attack_points + gloves_attack_points + amulet_attack_points\n defense_points_sum = weapon_defense_points + rings_defense_points + helmet_defense_points + body_armor_defense_points + boots_defense_points + gloves_defense_points + amulet_defense_points\n\n # Making a sum of all the bonuses from the items\n attack_modifiers_sum = weapon_attack_modifiers + rings_attack_modifiers + helmet_attack_modifiers + body_armor_attack_modifiers + boots_attack_modifiers + gloves_attack_modifiers + amulet_attack_modifiers\n defense_modifiers_sum = weapon_defense_modifiers + rings_defense_modifiers + helmet_defense_modifiers + body_armor_defense_modifiers + boots_defense_modifiers + gloves_defense_modifiers + amulet_defense_modifiers\n\n # Calculating damage, defense and recoil\n attack_total = attack_points_sum * attack_modifiers_sum\n defense_total = defense_points_sum * defense_modifiers_sum\n recoil_total = (attack_total * weapon_attack_recoil_modifier * ((attack_total / (defense_total + (E ** -attack_total))) / 100)).floor\n\n # Creating a new DamageInstance\n DamageInstance.new(attack_total, recoil_total)\n end\n\n # Returning damage instances\n damage_instances\n end",
"def blocked_amount\n ledgers.where(\n betable_type: 'User',\n transaction_type: 'debit',\n status: Ledger::PENDING\n ).sum(:amount)\n end",
"def notification_badge\n if current_user.notifications.any?\n mi.notifications\n else\n mi.notifications_none\n end\n end",
"def top_tagged(user_id)\n\t\tfrom_instagram = retrieve_last_10_photos(user_id)\n\n\t\tnumber_of_photos = from_instagram[\"data\"].size\n\n\t\tall_people_you_tag = []\n\t\tusers_per_photo = []\n\t\ti = 0\n\t\twhile i < number_of_photos\n\t\t\tx = 0\n\t\t\tpeople_per_photo = from_instagram[\"data\"][i][\"users_in_photo\"].size\n\t\t\tpeople_you_tag = from_instagram[\"data\"][i][\"users_in_photo\"]\n\t\t\twhile x < people_per_photo\n\t\t\t\tusername = from_instagram[\"data\"][i][\"users_in_photo\"][x][\"user\"][\"username\"]\n\t\t\t\tarray = users_per_photo.push(username)\n\t\t\t\tx = x + 1\n\t\t\tend\n\t\t\ti = i + 1\n\t\tend\n\n\t\tif array\n\n\t\t\tb = Hash.new(0)\n\t\t\tarray.each do |v|\n\t\t\t\tb[v] += 1\n\t\t\tend\n\n\t\t\tsorted_b = b.sort_by {|k, v| v}\n\t\t\tsorted_b = sorted_b.reverse\n\n\t\t\tsorted_b.map do |k, v|\n\t\t\t\tputs \"#{k}: #{v} tags\"\n\t\t\tend\n\n\t\t\treturn sorted_b\n\n\t\telse \n\t\t\treturn \"No users tagged\"\n\t\tend\n\n\tend",
"def user_gold\n self.tickets.all_gold.unused.count\n end",
"def get_most_radlib_fillins_by_user(num_users = 5)\n get_most_generic_for_users(DOCS[:most_prolific], num_users)\n end",
"def set_user_badge\n @user_badge = UserBadge.find(params[:user_badge_id])\n end",
"def earned(badge_id)\n badges = JSON.parse(self.badges)\n badges[\"#{badge_id}\"][\"earned\"]\n end",
"def get_user_status(user_id)\n\t\treturn nil if not party_list[user_id]\n\t\treturn party_list[user_id][:status]\n\tend",
"def balances\n # Very inefficient at this point for a large network...\n self.network_as_users.map { |user|\n {:balance => self.balance_with(user), :user => user}\n }.select {|balance| balance[:balance].to_f != 0.0}\n end",
"def users_vote(user = User.current)\n user_id = user.is_a?(User) ? user.id : user.to_i\n vote_hash[user_id]\n end",
"def friendlist(user)\n User.find_by_sql(\n \"SELECT\n friend_interests_users.user_id as id,\n count(common_interests.id) as num_common_interests\n FROM\n users as me\n left join interests_users as my_interests_users on my_interests_users.user_id = me.id\n left join interests as common_interests on my_interests_users.interest_id = common_interests.id\n left join interests_users as friend_interests_users on common_interests.id = friend_interests_users.interest_id\n WHERE\n friend_interests_users.user_id <> #{user.id} and\n me.id = #{user.id}\n GROUP BY\n friend_interests_users.user_id\n ORDER BY\n num_common_interests desc;\"\n )\n end",
"def banned_user_ids\n Rails.cache.fetch('banned-user-ids', expires_in: 1.week) do\n User.banned.pluck(:id)\n end\n end",
"def get_grade(user)\n chain_grade = 1\n for link in get_chain_as_links()\n chain_grade *= link.get_grade(user)\n end\n\n chain_grade\n end",
"def get_user_score(user)\n\t\ttotal = 0\n\t\tmy_genres_array = user[:favorite_genres].split(\"|\")\n\n\t\ttotal += self.get_score\n\t\ttotal += self.genre_bonus(my_genres_array)\n\t\ttotal += self.old_movie_bonus(user)\n\t\treturn total\n\tend",
"def initialize(user)\n @user = user\n @badges = user.badges\n @accounts = user.accounts\n end",
"def user_holds opts= {}\n path, opts = build_user_path(\"holds\", opts)\n JSON.parse(get path, opts)\n end",
"def outstanding_balances(group_custom_biller = nil)\n if group_custom_biller.present?\n # only participations and subscriptions for biller\n invoiceable_reservations = invoiceable_game_passes = []\n else\n invoiceable_reservations = reservations.invoiceable.\n users_with_groups(users).\n includes(:user).\n group_by(&:fetch_owner_id)\n invoiceable_game_passes = game_passes.invoiceable.group_by(&:user_id)\n end\n\n invoiceable_participations = participations_by_biller(group_custom_biller).\n invoiceable.group_by(&:user_id)\n invoiceable_group_subscriptions = group_subscriptions_by_biller(group_custom_biller).\n invoiceable.group_by(&:user_id)\n\n users.map do |user|\n [user.id,\n invoiceable_reservations[user.id].to_a.map { |r| r.outstanding_balance || 0.to_d }.sum.to_d +\n invoiceable_game_passes[user.id].to_a.map { |r| r.price || 0.to_d }.sum.to_d +\n invoiceable_participations[user.id].to_a.map { |r| r.price || 0.to_d }.sum.to_d +\n invoiceable_group_subscriptions[user.id].to_a.map { |r| r.price || 0.to_d }.sum.to_d\n ]\n end.to_h\n end",
"def find_rated_by(user)\n find_statement(:user_id, user.id)\n end",
"def get_holds(user, **opt)\n return unless (cid = account_id(user))\n get_data('users', cid, 'holds', opt)\n data = response&.body&.presence\n IlsHolds.new(data, error: @exception)\n end",
"def user_pledge_rewards\n user_pledge_rewards = []\n self.project_pledge_remaining.each do |project_id, pledge_amount_remaining|\n project = Project.find(project_id)\n reward_list = project.rewards\n reward_list.each do |reward|\n if pledge_amount_remaining >= reward.dollar_amount\n user_pledge_rewards << reward\n end\n end\n end\n return user_pledge_rewards\n end",
"def user_lifetime_balance(user)\n reservations_balance = user_reservations(user).sum(:price)\n game_passes_balance = game_passes.where(user: user).sum(:price)\n participations_balance = participations.where(user: user).sum(:price)\n group_subscriptions_balance = group_subscriptions.where(user: user).sum(:price)\n\n reservations_balance.to_d +\n game_passes_balance.to_d +\n participations_balance.to_d +\n group_subscriptions_balance.to_d\n end",
"def top_tagged(user_id)\n from_instagram = retrieve_last_10_photos(user_id)\n\n number_of_photos = from_instagram[\"data\"].size\n\n all_people_you_tag = []\n users_per_photo = []\n i = 0\n while i < number_of_photos\n x = 0\n people_per_photo = from_instagram[\"data\"][i][\"users_in_photo\"].size\n people_you_tag = from_instagram[\"data\"][i][\"users_in_photo\"]\n while x < people_per_photo\n username = from_instagram[\"data\"][i][\"users_in_photo\"][x][\"user\"][\"username\"]\n array = users_per_photo.push(username)\n x = x + 1\n end\n i = i + 1\n end\n\n if array\n\n b = Hash.new(0)\n array.each do |v|\n b[v] += 1\n end\n\n sorted_b = b.sort_by {|k, v| v}\n sorted_b = sorted_b.reverse\n\n sorted_b.map do |k, v|\n puts \"#{k}: #{v} tags\"\n end\n\n return sorted_b\n\n else\n return \"No users tagged\"\n end\n\n end",
"def get_user_balance_color(user)\n if user.balance.positive?\n \"#257942\"\n else\n \"#cc0f35\"\n end\n end",
"def get_loss_count(username)\n get_count(username, 'Losses')\n end",
"def for_user(user)\n find_by(user_email: user.emails)\n end",
"def hejia_bbs_user user_id\n CACHE.fetch(\"/hejia_bbs_user/#{user_id}\", 1.day) do\n HejiaUserBbs.find_by_USERBBSID user_id\n end\n end",
"def show\n @badge = Badge.find(params[:id])\n @users = @badge.users\n respond_with @badge\n end",
"def new_badges\n achievements.map(&:new_badges).flatten\n end",
"def user_reach_level(achievement, user)\n user_tree = TreeService::UserTreeFetcher.new(user, nil)\n user_tree.depth == achievement.settings['level']\n end",
"def top_tagged(user_id)\n from_instagram = retrieve_last_10_photos(user_id)\n\n number_of_photos = from_instagram[\"data\"].size\n\n all_people_you_tag = []\n users_per_photo = []\n i = 0\n while i < number_of_photos\n x = 0\n people_per_photo = from_instagram[\"data\"][i][\"users_in_photo\"].size\n people_you_tag = from_instagram[\"data\"][i][\"users_in_photo\"]\n while x < people_per_photo\n username = from_instagram[\"data\"][i][\"users_in_photo\"][x][\"user\"][\"username\"]\n array = users_per_photo.push(username)\n x = x + 1\n end\n i = i + 1\n end\n\n if array\n\n b = Hash.new(0)\n array.each do |v|\n b[v] += 1\n end\n\n sorted_b = b.sort_by {|k, v| v}\n sorted_b = sorted_b.reverse\n\n sorted_b.map do |k, v|\n puts \"#{k}: #{v} tags\"\n end\n\n return sorted_b\n\n else \n return \"No users tagged\"\n end\n\n end",
"def find_with_user(user)\n rooms.values.select{|r| r.users.include?(user) }\n end",
"def business(level = 3)\n data = @data['families'].find { |type| type['name'] == 'Business' }\n badge = data['earnedAchievements'].find { |le| le['familyOrder'] == (level - 1) }\n HQTrivia::Badge.new(badge)\n end",
"def get_user_tag_count(owner_user_id)\n count = USER_TAGS.where(owner_user_id: owner_user_id).count\n return count.nil? ? 0 : count\n end",
"def add_user!( user, update_user = true )\n puts \"add_user\"\n unless @users.include?( user )\n @users << user\n user.add_badge!( self, false ) if update_user\n end\n return @users\n end",
"def guests_age(guest_name)\n guest_age_found = @all_guests.find do |guest| guest.name == guest_name\n end\n return guest_age_found.age\n\n end",
"def user_voters\n votes = self.votes.order(created_at: :desc)\n user_ids = []\n\n votes.each do |vote|\n user_ids << vote.user_id\n end\n\n users = []\n user_ids.each do |num|\n user = User.find_by(id: num)\n users << user\n end\n\n return users\n end",
"def likes(user_id)\n from_instagram = retrieve_last_10_photos(user_id)\n\n all_likes = from_instagram[\"data\"].map do |datum|\n datum[\"likes\"][\"count\"]\n end\n\n all_likes = all_likes.reduce(:+)\n\n return all_likes\n end",
"def best_user\n @group_users.max_by(&:rate)\n end",
"def verify_weekend_warrior(badge_user,expected_earned_date,expected_total_warrior_badges,reason)\n warrior = badge_user.badges.reload.detect{|b|b.badge_key==Badge::WeekendWarrior && b.earned_date == expected_earned_date} \n if warrior\n if badge_user.badges.select{|b|b.badge_key==Badge::WeekendWarrior}.size == expected_total_warrior_badges\n # bacon pancaaaaaaaaakes\n return true\n else\n puts \"boo! weekend warrior badge doesn't work! (#{reason}) badges below\"\n puts y(badge_user.badges)\n return false\n end\n else\n puts \"boo! weekend warrior badge doesn't work! (#{reason}, badge not earned for #{expected_earned_date}). badges below\"\n puts y(badge_user.badges)\n return false\n end\nend",
"def badges_version_list(owner, repo, package_format, package_name, package_version, package_identifiers, opts = {})\n badges_version_list_with_http_info(owner, repo, package_format, package_name, package_version, package_identifiers, opts)\n return nil\n end",
"def get_project_vulnerabilities_badge(name, version, opts = {})\n data, _status_code, _headers = get_project_vulnerabilities_badge_with_http_info(name, version, opts)\n data\n end"
] |
[
"0.78773445",
"0.7613429",
"0.72986996",
"0.7257249",
"0.7142821",
"0.70736796",
"0.6588264",
"0.6379599",
"0.6214791",
"0.6193804",
"0.61089796",
"0.59106946",
"0.58672756",
"0.5829829",
"0.5637001",
"0.5625826",
"0.5574686",
"0.5549229",
"0.5526664",
"0.5433903",
"0.5387077",
"0.53594834",
"0.5347747",
"0.5317319",
"0.5231483",
"0.5225326",
"0.52168393",
"0.51971066",
"0.51937616",
"0.5191292",
"0.5183478",
"0.517802",
"0.5175389",
"0.5159538",
"0.51545346",
"0.5150074",
"0.51491714",
"0.51453084",
"0.5130494",
"0.51234984",
"0.51049626",
"0.5098299",
"0.50849533",
"0.5081048",
"0.5076174",
"0.5074359",
"0.50732684",
"0.5073008",
"0.50683826",
"0.5058948",
"0.50521904",
"0.5045802",
"0.50350213",
"0.50350213",
"0.49986133",
"0.49874306",
"0.49664074",
"0.49656558",
"0.49634278",
"0.4957723",
"0.4954639",
"0.49489233",
"0.4945192",
"0.49369442",
"0.49203888",
"0.49189094",
"0.48962837",
"0.4891263",
"0.48682877",
"0.4864983",
"0.48577258",
"0.48565373",
"0.48524535",
"0.4847079",
"0.48377094",
"0.48367292",
"0.4835121",
"0.48340225",
"0.48253936",
"0.48163855",
"0.4807293",
"0.4804459",
"0.480322",
"0.4793335",
"0.4791593",
"0.47889322",
"0.478204",
"0.47817498",
"0.47788274",
"0.4772224",
"0.47587234",
"0.47517228",
"0.47342828",
"0.47216934",
"0.47169417",
"0.47086138",
"0.47038606",
"0.47028717",
"0.47020218",
"0.47008604"
] |
0.7952129
|
0
|
Find items by a single user based on marketplace.
|
def user_items_by_site(username)
response = get "v1/market/user-items-by-site:#{username}.json"
response[:'user-items-by-site']
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def search_by_user(user)\n # d = db\n transaction do\n d.select { |_, v| v[:user] == user }\n end\n end",
"def find_by_user(client, user: required(\"user\"), workspace: required(\"workspace\"), options: {})\n params = { workspace: workspace }.reject { |_,v| v.nil? || Array(v).empty? }\n Resource.new(parse(client.get(\"/users/#{user}/user_task_list\", params: params, options: options)).first, client: client)\n end",
"def strategy_items(user_id, company_id, offset=0, limit=MAX_DISPLAYED_TAGS)\n query = \"select b.id from strategy_items b, taggings, tags\"\n query << \" where taggings.taggable_type = 'StrategyItem'\"\n query << \" and tags.company_id = #{company_id}\"\n query << \" and tags.id = #{self.id}\"\n query << \" and (b.private is false or (b.private is true and b.owner_id = #{user_id}))\"\n query << \" and b.id in (select strategy_item_id from permissions where group_id in (select group_id from memberships where user_id=#{user_id}))\"\n query << \" and taggings.tag_id = tags.id\"\n query << \" and taggings.taggable_id = b.id\"\n query << \" order by b.title\"\n query << \" limit #{limit} offset #{offset}\"\n StrategyItem.find_by_sql(query)\n end",
"def user_list(user)\n List.find_by(restaurant: self, user: user)\n end",
"def item_owner(item)\n User.find(item.user_id)\n end",
"def user_need(user_id)\n trade_lines.each do |x|\n if x.inventory_need.user_id == user_id\n return x\n end\n end\n end",
"def get_matching_item(request)\r\n matching_items= self.overlay.active_items_by_name_and_user(request.name, self)\r\n matching_items[0]\r\n end",
"def find_by_user(user_id, options = {})\n options.merge!({user_id: user_id })\n if options[:start]\n options[:start] = options[:start].strftime('%Y-%m-%d %H:%M:%S')\n end\n if options[:end]\n options[:end] = options[:end].strftime('%Y-%m-%d %H:%M:%S')\n end\n result = Paymo::API.get :entries, :find_by_user, options\n if result['status'] == 'ok'\n if result['entries'].any?\n result['entries']['entry'].map! do |entry|\n Paymo::Entry.new(entry)\n end\n end\n end\n end",
"def get_item(user, item)\r\n position = user.get_position(item)\r\n x = user.show_item(position)\r\n self.add_item(x)\r\n user.give_away_item(position)\r\n end",
"def find_item(item)\n md5 = ItemBuilder.md5(item)\n items.find { |e| e[0] == md5 } if items\n end",
"def user_items_list\n @items = Item.find_all_by_user_id(current_user.id)\n @categories = Category.all\n @search = Item.search(params[:search])\n @keyword = params[:search]\n end",
"def find_by_user\n playlists_by_user = Playlist.where(\"user_id = #{session[:user_id]}\")\n if playlists_by_user\n render json: { status: 200, playlists_by_user: playlists_by_user }\n else\n render json: { status: 500 }\n end\n end",
"def user_items(user_id=self.username, context='pack')\n response = connection.get do |req|\n req.url \"/users/#{user_id}/items\", :context => context\n end\n response.body.items\n end",
"def find_by_id(user_id)\n find_by_query do |table|\n table.where(:id => user_id)\n end\n end",
"def stock_item(variant_id, user_id = nil, original_stock_location_id = nil)\n return super(variant_id) unless reserved_items?\n raise(\n UserRequiredArgumentError,\n Spree.t(:user_id_required_for_reserved_stock_location)\n ) unless user_id.present?\n items = stock_items.where(variant_id: variant_id, user_id: user_id)\n items = items.where(\n original_stock_location_id: original_stock_location_id\n ) unless original_stock_location_id.blank?\n items.order(:id).first\n end",
"def show_user_items\n\t\t# gather user items of current user\n \t@user_items = UserItem.paginate :per_page => 8, :page => params[:page], :conditions => { :user_id => current_user.id }, :order => 'created_at DESC'\n\t\t# gather sold items of current user\n @sold = Transaction.find_all_by_seller_id(current_user.id)\n\t\t# gather bought items of current user\n @bought = Transaction.find_all_by_buyer_id(current_user.id)\n\t\t# gather all users the current user follows\n @following_users = current_user.followings\n\t\t# gather items the current user is watching\n @watched = Watch.find_all_by_watcher_id(current_user.id)\n end",
"def get_items(user,ex_items)\r\n\t\trv = []\r\n\t\tdb.each { |x,y|\r\n\t\t\trv << y if(x==user)\r\n\t\t\t}\r\n\t\trv - ex_items\r\n\tend",
"def for_user(user)\n find_by(user_email: user.emails)\n end",
"def find(user_id, query)\n favourites = @favourites_store.where(user_id)\n venues = @foursquare_proxy.search_venues(query)\n parse_results(venues, favourites)\n end",
"def seller_index\n @items = Item.find_all_by_user_id(params[:id])\n end",
"def find_item(purchase_or_id)\n raise NotImplementedError\n end",
"def index\n if params[:user_id].present?\n @items = current_user.items.page params[:page]\n else\n @items = Item.available.page params[:page]\n end\n end",
"def find_by_id(equipo_id, user_id)\n return self.class.get(\n #na rota passo o equipo id\n \"/equipos/#{equipo_id}\",\n headers: {\n #passo o user id para o header para ter a altorização para consultar\n \"user_id\": user_id,\n },\n )\n end",
"def search_by_user(user, additional_filters={})\n additional_filters[:user] = user\n return search(additional_filters)\n end",
"def user_own(user_id)\n trade_lines.each do |x|\n if x.inventory_own.user_id == user_id\n return x\n end\n end\n end",
"def find_with_user(user)\n rooms.values.select{|r| r.users.include?(user) }\n end",
"def index\n\t\t @items = Item.find_my_items(current_user) \n end",
"def search_for_item\n search_service.fetch(params[:id], { fl: ['visibility_ssi'] })\n end",
"def favourite_places_for_user(user_id)\n where(:user_id => user_id).map(&:place_id)\n end",
"def find item\n\tend",
"def find(item_name)\n @inventory.find(item_name)\n end",
"def find_with_only_user(user)\n uid = user.is_a?(::Starbot::Contact) ? user.id : user\n rooms.values.select{|r| r.users.count == 2 && r.users.map{|u| u.id }.include?(uid) }\n end",
"def get_items(rut)\n user = User.find_by_national_id(rut)\n items= {}\n if user.smartphone_id\n sp = Smartphone.find(user.smartphone_id)\n items[:sp] = sp\n end\n if user.bam_id\n bam = Bam.find(user.bam_id)\n items[:bam] = bam\n end\n if user.sim_id\n sim = Sim.find(user.sim_id)\n items[:sim] = sim\n end\n if user.plan_id\n plan = Plan.find(user.plan_id)\n items[:plan] = plan\n end\n return items\n end",
"def equipment\n @items = Item.where(user_id: params[:user_id])\n end",
"def get_user(item)\n\t\t@user = User.find_by_id(item.user.id)\n\tend",
"def created_by_user(user_id, source_id, number_to_return = :all, starting_index = 0)\n # ids = PublicEarth::Db::Place.many.created_by_user(user_id, source_id, number_to_return == :all && 250 || number_to_return, starting_index).map { |result| result['created_by_user'] }\n ids = PublicEarth::Db::Place.many.created_by_user(user_id, source_id).map { |result| result['created_by_user'] }\n PublicEarth::Db::Place.find_from_search(*ids)\n end",
"def get_user_basket\n @user = Users.find(session[:current_user_id])\n @basket = Baskets.find_by(:user_id => @user.id)\nend",
"def get_tradeline_from(user_id)\n other_tradelines = get_tradelines_except(user_id)\n other_tradelines.each do |x|\n if x.inventory_need.user_id == user_id\n return x\n end\n end\n end",
"def find(item, type = nil)\n find_by_id(item) || find_by_generic(item, type)\n end",
"def index \n \t@items = Item.paginate(page: params[:page])\n\n @user_items = current_user.user_items.pluck(:id).uniq\n @all_user_items = UserItem.where(id: @user_items)\n end",
"def find_item(name)\n items.find do |item|\n item.name == name ||\n item.short_name.gsub('…','') == name.gsub('…','')\n end\n end",
"def search_for_user(user, params={})\n folder_ids = params[:folder_id].present? ? [params[:folder_id]] : user.share_folder_ids\n options = params.with_indifferent_access.merge(user_id: user.id, folder_ids: folder_ids)\n search(options)\n end",
"def find_player_with_user_id(user_id)\n go_fish.find_player_with_user_id(user_id)\n end",
"def find_item\n @item = @list.items.find(params[:id])\n authorize @item\n end",
"def find_markers_by_user(user) \n markable = ActiveRecord::Base.send(:class_name_of_active_record_descendant, self).to_s\n \n Marker.find(:all,\n :conditions => [\"user_id = ? and markable_type = ?\", user.id, markable],\n :order => \"created_at DESC\"\n )\n end",
"def user_by_id(user_id)\n Egi::Fedcloud::Vmhound::Log.debug \"[#{self.class}] Picking user ID #{user_id.inspect} from pool\"\n users.select { |user| user[:id] == user_id.to_i }.first\n end",
"def feed_items\n # Following users\n following_user_ids = \"SELECT followed_id FROM relationships\n WHERE follower_id = :user_id\"\n # Following Tags\n following_tag_ids = \"SELECT tag_id FROM tag_follows\n WHERE user_id = :user_id\"\n # Following tag's items\n following_tag_item_ids = \"SELECT taggable_id FROM taggings WHERE taggable_type = 'Item' AND tag_id IN (#{following_tag_ids})\"\n # Stocking items\n stocking_item_ids = \"SELECT item_id FROM item_stocks WHERE user_id = :user_id\"\n\n Item.includes(:update_user).where(\"create_user_id IN (#{following_user_ids}) OR update_user_id IN (#{following_user_ids})\n OR create_user_id = :user_id OR update_user_id = :user_id\n OR id IN (#{stocking_item_ids})\n OR id IN (#{following_tag_item_ids})\", user_id: id)\n .where(active: true).limit(20)\n end",
"def vendors_that_sell(query_item)\n @vendors.find_all do |vendor|\n vendor.inventory.keys.include?(query_item)\n end\n end",
"def find(key)\n items.find do |item|\n item.key == key\n end\n end",
"def find_on_sale(name)\n flyer_items.find do |i|\n i.match?(name) unless i.nil?\n end\n end",
"def indexbyuser\n @user = User.find_by_id params[:id]\n unless @user.nil?\n @treks = Trek.find_by_user params[:id]\n else\n redirect_to root_url, :alert => \"User not found\"\n end\n end",
"def find_item\n @item = Item.new(query_service.find_by(id: params[:id]).symbolize_keys)\n end",
"def get_by_user_id(args)\n JSON.parse(api_request('private.request.search', 'GET', {:sUserId => args[:user_id]}))['request'] rescue nil\n end",
"def modified_by_user(user_id, source_id, number_to_return = :all, starting_index = 0)\n # ids = PublicEarth::Db::Place.many.modified_by_user(user_id, source_id, number_to_return == :all && 250 || number_to_return, starting_index).map { |result| result['modified_by_user'] }\n ids = PublicEarth::Db::Place.many.modified_by_user(user_id, source_id).map { |result| result['modified_by_user'] }\n PublicEarth::Db::Place.find_from_search(*ids)\n end",
"def find(options)\n BorrowDirect::FindItem::Response.new find_item_request(options), self.auth_id\n end",
"def for_id(user_id)\n Iterable.request(conf, \"/users/byUserId/#{user_id}\").get\n end",
"def find_item(selected_item)\n return find(selected_item)\n end",
"def podio_helper_find_item_by_unique_id(unique_id, option)\n attributes = {:sort_by => 'last_edit_on'}\n if option == 'universidade'\n app_id = 14568134\n attributes[:filters] = {117992837 => unique_id}\n elsif option == 'curso'\n app_id = 14568143\n attributes[:filters] = {117992834 => unique_id}\n end\n\n response = Podio.connection.post do |req|\n req.url \"/item/app/#{app_id}/filter/\"\n req.body = attributes\n end\n\n Podio::Item.collection(response.body).first\n end",
"def index\n @items = Item.find_all_by_user_id(current_user.id)\n end",
"def user_by_id(user_id)\n @group_users.find { |item| item.user_id == user_id }\n end",
"def index\n str ='buyer_id=' + current_user.id.to_s\n \n @carts = Cart.where(str)\n end",
"def fetch_cart_item(current_user)\n user_cart = Cart.find_by(user_id: current_user.id)\n\n if user_cart\n cart_item = CartItem.find_by(cart_id: user_cart.id, menu_item_id: id)\n if cart_item\n return cart_item\n end\n end\n\n return false\n end",
"def find_item_by_model(model)\n @models_to_items[model]\n end",
"def by_user\n user = find_obj_or_goto_index(\n model: User, obj_id: params[:by_user].to_s,\n index_path: locations_path\n )\n return unless user\n\n query = create_query(:Location, :by_user, user: user)\n show_selected_locations(query, link_all_sorts: true)\n end",
"def find_items_like_mine\n if self.forsale\n return Item.where('ownership_id == ? AND lower(name) == ?', WANTED, self.name.downcase)\n elsif self.wanted\n return Item.where('ownership_id == ? AND lower(name) == ?', FORSALE, self.name.downcase)\n else\n return nil\n end\n end",
"def find_item_by_id(id)\n\n @items.each do |item|\n return item if item.item_id == id\n end\n return nil\n end",
"def find_item_in_collection(collection:, item:)\n collection.find(item)\n end",
"def find\n\t\tputs \"Enter keyword, EX: Mexican or Mex\"\n\t\tuserKeyword = gets.chomp.downcase.strip\n\t\trestaurants = Restaurant.saved_restaurants\n\t\tfound_restaurant_array = []\n\t\t\trestaurants.each do |rest|\n\t\t\tif rest.cuisine.include?(userKeyword)\n\t\t\t\tfound_restaurant_array << rest\n\t\t\tend\n\t\tend\n\t\tif !found_restaurant_array.empty?\n\t\toutput_restaurant_table(found_restaurant_array)\n\t\telse\n\t\t\toutput_action_footer(\"oops! could not find an entry\")\n\t\tend\n\tend",
"def recommend_by_item_based(user, top = @default_recommendation_count)\n return unless @similarity_matrix\n \n weighted_similar_items = Hash.new(0.0)\n similarity_sum_per_item = Hash.new(0.0)\n \n user.list.items.each_value do |user_item|\n item = @items[user_item.id]\n \n sim_objs = @similarity_matrix[item.id]\n sim_objs.each do |obj|\n next if user.has_item? obj[:id]\n weighted_similar_items[obj[:id]] += user_item.rating * obj[:similarity].abs\n similarity_sum_per_item[obj[:id]] += obj[:similarity].abs\n end\n end\n \n recommendations = weighted_similar_items.collect do |k, v|\n next if v == 0.0 or similarity_sum_per_item[k] == 0.0\n { :id => k, :est => (v / similarity_sum_per_item[k]) }\n end\n recommendations.compact.sort{ |x, y| y[:est] <=> x[:est] }.first(top || recommendations.size)\n end",
"def get_all_for_sale\n Listing.find_all_by_market_status( 1 , :include => :user )\n end",
"def fetch_items_of(account_id)\n fail \"No account with id #{account_id}\" unless DAOAccount.instance.account_exists?(account_id)\n @items.values.select {|item| item.owner.id == account_id}\n end",
"def get_user_items(user_id, course_id)\r\n relative_url = PATH_USERS_COURSES_ITEMS % [user_id, course_id]\r\n get(relative_url)\r\n end",
"def list_item(item, seller_id, price)\n u = User.new(seller_id)\n @conn.multi do |multi|\n multi.srem(u.inventory_id, item)\n multi.zadd(\"market\", price, u.item_id(item))\n end\n end",
"def isIn(user)\n \n isIn = false\n @userList.getcontents.each { |users| \n \n if(user == users)\n isIn = true\n break\n end\n \n }\n return isIn\n end",
"def find_item(item)\n return nil if cart_items.blank?\n\n item = prepare_for_cart_item(item)\n result = cart_items.detect do |ci|\n ci.type == item.type && ci.unit == item.unit\n end\n return result.nil? ? false : result\n end",
"def locations_by_user # :nologin: :norobots:\n if user = params[:id] ? find_or_goto_index(User, params[:id].to_s) : @user\n query = create_query(:Location, :by_user, :user => user)\n show_selected_locations(query, :link_all_sorts => true)\n end\n end",
"def search_get_available_quick_searches(user_id)\n response = xmlrpc('SearchService.getAvailableQuickSearches', user_id)\n end",
"def search_for_item\n Rails.logger.warn(\"starting search for item for #{request.headers['X-Origin-URI']}\")\n child_oid = request.headers['X-Origin-URI'].gsub(/^\\/iiif\\/2\\/(\\d+)\\/.*/, '\\1')\n # search_state[:q] = { child_oids_ssim: child_oid }\n search_state[:rows] = 1\n search_service_class.new(config: blacklight_config, search_state: search_state, user_params: search_state.to_h, **search_service_context)\n r, d = search_service.search_results do |builder|\n builder.where(child_oids_ssim: [child_oid])\n builder.processor_chain.delete(:filter_by_visibility)\n builder\n end\n [r, d.first]\n end",
"def find_items_like_mine\n\t\tif self.forsale\n\t\t\treturn Item.where('ownership_id == ? AND lower(name) == ?', WANTED, self.name.downcase) \n\t\telsif self.wanted \n\t\t\treturn Item.where('ownership_id == ? AND lower(name) == ?', FORSALE, self.name.downcase)\n\t else \n\t \t\treturn nil \t \n\t end \n\tend",
"def look_for_user(name)\n User.find_by name: name\nend",
"def search (query_string)\n\n OpenWFE::Extras::Workitem.search(query_string, store_names).find_all do |wi|\n\n @user.admin? or (\n wi.store_name != 'users' || wi.participant_name == @user.name)\n end\n end",
"def get_autocomplete_items(parameters)\n items = super(parameters)\n if current_user.admin?\n items\n else\n items.includes(:users).where(users:{id: current_user.id})\n end\n end",
"def find_by_name(name)\n # this works because of `def item.=='\n item = @set.find { |c| c == name }\n item\n end",
"def find_best_match_for_user(user)\n LegacySheetUser.find_best_user_match(user)\n end",
"def search\n if params[:search].present?\n # This is for the elastic search\n #@bid_items = BidItem.search(params[:search])\n\n # Those are Ruby SQL queries\n # This is to search item_name\n #@bid_items = BidItem.where(:item_name => params[:search])\n # This is to search price larger than\n @bid_items = BidItem.where(\"starting_price > ?\", params[:search])\n else\n @bid_items = BidItem.order(\"id DESC\").limit(30)\n end\n end",
"def show\n @user=User.find(params[:id])\n @items = @user.items\n end",
"def amazon_marketplace\n self.in(AmazonMarketplace)\n end",
"def find_user(user_descr)\n debug \"central find_user: '#{user_descr.inspect}'\"\n raise 'Method not implemented because the Central Manager just need to pass the same requisition to the other' \\\n ' brokers and create the concatenated results'\n end",
"def get_tradeline_only(user_id)\n trade_lines.each do |x|\n if x.inventory_own.user_id == user_id\n return x\n end\n end\n end",
"def find_item_by_product(product, items)\n\t\tsku = product.sap_sku.to_s.upcase\n\t\tsku_options = sku.match(/\\-?[MV]$/) ? [sku, sku.gsub(/\\-?[MV]$/, '')] : sku_options = [\"#{sku}-V\", \"#{sku}-M\", \"#{sku}V\", \"#{sku}M\", sku]\n\n\t\titem = nil\n\t\tsku_options.each do |s|\n\t\t\tif item = items[s]\n\t\t\t\treturn item\n\t\t\tend\n\t\tend\n\t\titem\n\tend",
"def podio_helper_find_item_by_expa_id(expa_id)\n attributes = {:sort_by => 'last_edit_on'}\n attributes[:filters] = {117786190 => {'from'=>expa_id,'to'=>expa_id}}\n\n response = Podio.connection.post do |req|\n req.url '/item/app/15290822/filter/'\n req.body = attributes\n end\n Podio::Item.collection(response.body).first\n end",
"def new_items_for_user(username, sitename)\n raise Envato::InvalidSiteName unless marketplace_names.include? sitename\n\n response = get \"v1/market/new-files-from-user:#{username},#{sitename}.json\"\n response[:'new-files-from-user']\n end",
"def item_requester\n participants.reject { |p| p.id == item_owner.id }.first\n end",
"def list_favourites(user_id)\n @favourites_store.where(user_id)\n end",
"def seller\n # the user owning the inventory\n offer.inventory_item.user\n end",
"def get(item_type, item_id)\n all(item_type).detect { |item| item[:id].to_i == item_id.to_i }\n end",
"def users_have_same_item(item)\n # TODO: .collect is slow? (for 100K dataset around 60secs.)\n #@users.collect { |k, u| u if u.has_item? item.id }.compact\n #@users.collect { |k, u| u if u.list.items[item.id] }.compact\n list = {}\n @users.each do |k, u|\n list[k] = u if u.has_item? item.id\n end\n list\n end",
"def set_item\n @item = @user.items.find_by id: params[:id]\n end",
"def find_by_query(&block)\n finder = block ? block.call(table) : table\n if user_data = execute_sql(:read, :user) { finder.first }\n inflate_model(user_data)\n else\n nil\n end\n end",
"def user_id_from_order_item #TODO possible refactor to purchaseable\n case item_type\n when OrderItem::TypePhoto\n photo.user_id\n when OrderItem::TypeLibrary\n collection.user_id\n when OrderItem::TypeLicense\n media_license_price.media.user_id\n when OrderItem::TypePhotoResolution\n photo_resolution_price.photo.user_id\n when OrderItem::TypeVideo\n video.user_id\n when OrderItem::TypeAudio\n audio.user_id\n else\n raise \"cannot extract use from #{item_type}\"\n #TODO host plan\n #TODO extra space\n end\n end"
] |
[
"0.648871",
"0.61292255",
"0.610452",
"0.6027122",
"0.60142154",
"0.6002811",
"0.5956876",
"0.59553874",
"0.59482074",
"0.59252876",
"0.5911572",
"0.59102464",
"0.588989",
"0.58607554",
"0.584605",
"0.5840936",
"0.5840396",
"0.58073103",
"0.57736564",
"0.57588303",
"0.57507753",
"0.5745598",
"0.5739713",
"0.56981546",
"0.5662497",
"0.565691",
"0.5644805",
"0.5638947",
"0.5624217",
"0.56214976",
"0.56190103",
"0.5612887",
"0.5612771",
"0.5612333",
"0.56064224",
"0.55876833",
"0.55827314",
"0.558204",
"0.5580142",
"0.55680156",
"0.55674464",
"0.55661154",
"0.55655235",
"0.55428857",
"0.5536224",
"0.5516821",
"0.5514392",
"0.55022424",
"0.54943633",
"0.5492439",
"0.548715",
"0.5481504",
"0.5476463",
"0.54687786",
"0.5464466",
"0.54626715",
"0.5461249",
"0.5461181",
"0.5447204",
"0.54359734",
"0.5426925",
"0.5421214",
"0.5409921",
"0.5405894",
"0.5401269",
"0.5401097",
"0.5393544",
"0.53897727",
"0.537005",
"0.5362527",
"0.5353464",
"0.5352279",
"0.53488266",
"0.534831",
"0.5345932",
"0.5337431",
"0.53309095",
"0.53281295",
"0.5327564",
"0.532194",
"0.5320506",
"0.53193915",
"0.5314054",
"0.5312318",
"0.5302847",
"0.5302513",
"0.530183",
"0.5300716",
"0.5298816",
"0.5293854",
"0.52902687",
"0.52869993",
"0.5280349",
"0.52799475",
"0.52770704",
"0.5276596",
"0.5274273",
"0.5274179",
"0.5271365",
"0.5269501"
] |
0.6501125
|
0
|
Find all new items for user based on a marketplace.
|
def new_items_for_user(username, sitename)
raise Envato::InvalidSiteName unless marketplace_names.include? sitename
response = get "v1/market/new-files-from-user:#{username},#{sitename}.json"
response[:'new-files-from-user']
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def feed_items\n # Following users\n following_user_ids = \"SELECT followed_id FROM relationships\n WHERE follower_id = :user_id\"\n # Following Tags\n following_tag_ids = \"SELECT tag_id FROM tag_follows\n WHERE user_id = :user_id\"\n # Following tag's items\n following_tag_item_ids = \"SELECT taggable_id FROM taggings WHERE taggable_type = 'Item' AND tag_id IN (#{following_tag_ids})\"\n # Stocking items\n stocking_item_ids = \"SELECT item_id FROM item_stocks WHERE user_id = :user_id\"\n\n Item.includes(:update_user).where(\"create_user_id IN (#{following_user_ids}) OR update_user_id IN (#{following_user_ids})\n OR create_user_id = :user_id OR update_user_id = :user_id\n OR id IN (#{stocking_item_ids})\n OR id IN (#{following_tag_item_ids})\", user_id: id)\n .where(active: true).limit(20)\n end",
"def get_items(user,ex_items)\r\n\t\trv = []\r\n\t\tdb.each { |x,y|\r\n\t\t\trv << y if(x==user)\r\n\t\t\t}\r\n\t\trv - ex_items\r\n\tend",
"def user_items_list\n @items = Item.find_all_by_user_id(current_user.id)\n @categories = Category.all\n @search = Item.search(params[:search])\n @keyword = params[:search]\n end",
"def user_items_by_site(username)\n response = get \"v1/market/user-items-by-site:#{username}.json\"\n response[:'user-items-by-site']\n end",
"def strategy_items(user_id, company_id, offset=0, limit=MAX_DISPLAYED_TAGS)\n query = \"select b.id from strategy_items b, taggings, tags\"\n query << \" where taggings.taggable_type = 'StrategyItem'\"\n query << \" and tags.company_id = #{company_id}\"\n query << \" and tags.id = #{self.id}\"\n query << \" and (b.private is false or (b.private is true and b.owner_id = #{user_id}))\"\n query << \" and b.id in (select strategy_item_id from permissions where group_id in (select group_id from memberships where user_id=#{user_id}))\"\n query << \" and taggings.tag_id = tags.id\"\n query << \" and taggings.taggable_id = b.id\"\n query << \" order by b.title\"\n query << \" limit #{limit} offset #{offset}\"\n StrategyItem.find_by_sql(query)\n end",
"def new_items_list\n @items = Item.where(:activated => true).sort{ |b,a| a.created_at <=> b.created_at } #TODO: Add availability\n @items = @items.first(16)\n #TODO: Once we have populated more data, maybe show 12 items instead of four\n @categories = Category.all\n @search = Item.search(params[:search])\n @keyword = params[:search]\n end",
"def list_item(item, seller_id, price)\n u = User.new(seller_id)\n @conn.multi do |multi|\n multi.srem(u.inventory_id, item)\n multi.zadd(\"market\", price, u.item_id(item))\n end\n end",
"def stocked_items_count\n # Creating items\n item_ids = \"SELECT id FROM items WHERE create_user_id = :user_id AND active = 'true'\"\n # Except for self stock\n ItemStock.where(\"item_id IN (#{item_ids}) AND user_id <> :user_id\", user_id: id).count\n end",
"def get_all_for_sale\n Listing.find_all_by_market_status( 1 , :include => :user )\n end",
"def get_unrated_items(user)\n items = []\n\n Item.all.each do |item|\n review = Review.where(user_id: user.id, item_id: item.id).first\n if not review\n items.push item\n end\n end\n\n items\n end",
"def show_user_items\n\t\t# gather user items of current user\n \t@user_items = UserItem.paginate :per_page => 8, :page => params[:page], :conditions => { :user_id => current_user.id }, :order => 'created_at DESC'\n\t\t# gather sold items of current user\n @sold = Transaction.find_all_by_seller_id(current_user.id)\n\t\t# gather bought items of current user\n @bought = Transaction.find_all_by_buyer_id(current_user.id)\n\t\t# gather all users the current user follows\n @following_users = current_user.followings\n\t\t# gather items the current user is watching\n @watched = Watch.find_all_by_watcher_id(current_user.id)\n end",
"def seller_index\n @items = Item.find_all_by_user_id(params[:id])\n end",
"def get_all_potential_trades\n result = Like.where(\"item_liked_id = ?\", self.id).pluck(:item_offered_id)\n potential = Item.find(result)\n end",
"def vendors_that_sell(query_item)\n @vendors.find_all do |vendor|\n vendor.inventory.keys.include?(query_item)\n end\n end",
"def get_store_items(storeid, item)\n \tresponse = Services::SupermarketClient.new.item_search(storeid, item)\n \tresponse.parsed_response[\"ArrayOfProduct_Commercial\"][\"Product_Commercial\"].each do |item|\n \t\tStoreItem.create(name: item[\"Itemname\"], image: item[\"ItemImage\"], description: item[\"ItemDescription\"], price: item[\"Pricing\"])\n end\n end",
"def scan(item)\n items << CheckoutItem.new(item)\n end",
"def index\n @suggestions = policy_scope(Item).order(expiration: :desc)\n\n Reservation.joins(:item)\n .where('items.pickup_time < ?', Time.now)\n .destroy_all\n\n @reservations = policy_scope(Reservation).order(created_at: :desc)\n @reservation = Reservation.new\n authorize @reservation\n\n # CAROUSEL: OTHER UNIQUE ITEMS BY SAME SUPPLIER\n @my_owned_items = Item.all.where(user: current_user)\n @same_supplier_items = []\n @in_cart = []\n @reservations.each do |reservation|\n @same_supplier_items |= reservation.item.user.items\n @in_cart << reservation.item\n end\n @same_supplier_items.select! { |item| item.pickup_time.to_datetime > DateTime.now }\n @same_supplier_items -= @in_cart\n @same_supplier_items -= @my_owned_items\n\n # CAROUSEL: OTHERS WITH SAME ITEMS IN CART ALSO HAVE THESE IN CART\n @other_reserved_items = []\n @my_reserved_items = []\n @reservations.each do |my_reservation|\n my_reservation.item.reservations.each do |same_reservation|\n same_reservation.user.reservations.each do |other_reservation|\n if other_reservation.user_id == current_user.id\n @my_reserved_items |= [other_reservation.item]\n else\n @other_reserved_items |= [other_reservation.item]\n end\n end\n end\n end\n @other_reserved_items.uniq!\n\n @other_reserved_items.select! { |item| item.pickup_time.to_datetime > DateTime.now }\n @other_reserved_items -= @my_reserved_items\n @other_reserved_items -= @my_owned_items\n\n # CAROUSEL: OTHERS WHO BOUGHT WHAT YOU'VE BOUGHT ALSO BOUGHT\n if @others_purchased_items = Order.all\n .where(state: 'paid')\n .where.not(user_id: current_user.id)\n .map(&:purchased_items)\n .flatten\n .map(&:item)\n .uniq!\n @others_purchased_items.select! { |item| item.pickup_time.to_datetime > DateTime.now }\n\n if @my_purchased_items = Order.all\n .where(state: 'paid')\n .where(user_id: current_user.id)\n .map(&:purchased_items)\n .flatten\n .map(&:item)\n .uniq!\n @others_purchased_items -= @my_purchased_items\n @others_purchased_items -= @my_owned_items\n end\n end\n\n # SHOPPING CART: SEPARATE ITEMS BY SELLER\n @reservations_suppliers = []\n @reservations.each do |reservation|\n supplier = reservation.item.user\n @reservations_suppliers |= [supplier]\n end\n @reservations_suppliers_with_reserved = @reservations_suppliers.map { |supplier|\n [\n supplier,\n @reservations\n .joins(:item)\n .where(items: { user_id: supplier.id })\n ]\n }\n\n if user_signed_in?\n @purchased_item = PurchasedItem.new\n @subtotal_price = 0\n @total_price = 0\n @total_items = 0\n @reservations.each do |reservation|\n @subtotal_price += reservation.item.price * reservation.quantity\n @total_items += reservation.quantity\n end\n @percent = 5.0\n @amount = @subtotal_price\n @subtotal_price = @subtotal_price * (1 / (1 + (@percent/100)))\n @commission = @amount - @subtotal_price\n else\n redirect_to reservations_error_path\n end\n end",
"def make_item_list\n @data = $game_system.places_unlocked;\n end",
"def amazon_marketplace\n self.in(AmazonMarketplace)\n end",
"def find_all(options = {})\n response = JSON.parse(@client.get('items', options).body)\n items = response.key?('items') ? response['items'] : []\n items.map { |attributes| Promisepay::Item.new(@client, attributes) }\n end",
"def all_items_for_sell\r\n list = Array.new\r\n items.each{ |item|\r\n if item.active == true\r\n list.push(item)\r\n end}\r\n list\r\n end",
"def favourite_places_for_user(user_id)\n where(:user_id => user_id).map(&:place_id)\n end",
"def sync_category\n \t@market_places = Spree::MarketPlace.all\n end",
"def find_bikes\n user_id = params[\"user_id\"]\n bike_ids = get_bike_ids(user_id)\n bikes = []\n bike_ids.each {|bike_id|\n bikes.push(get_bike(bike_id, user_id))\n }\n update_bike_database(bikes, user_id)\n render json: { new_bikes: bikes }\n end",
"def get_item(user, item)\r\n position = user.get_position(item)\r\n x = user.show_item(position)\r\n self.add_item(x)\r\n user.give_away_item(position)\r\n end",
"def index \n \t@items = Item.paginate(page: params[:page])\n\n @user_items = current_user.user_items.pluck(:id).uniq\n @all_user_items = UserItem.where(id: @user_items)\n end",
"def user_items(user_id=self.username, context='pack')\n response = connection.get do |req|\n req.url \"/users/#{user_id}/items\", :context => context\n end\n response.body.items\n end",
"def marketplace\n @marketplace ||= Marketplace.new self\n end",
"def wishlist\n @lineItems = LineItem.where(\"user_id = ? AND line_item_type = ?\", current_user.id, 1)\n @items = Array.new\n @lineItems.each do |lineItem|\n @items.push(lineItem.item)\n end\n end",
"def get_items(rut)\n user = User.find_by_national_id(rut)\n items= {}\n if user.smartphone_id\n sp = Smartphone.find(user.smartphone_id)\n items[:sp] = sp\n end\n if user.bam_id\n bam = Bam.find(user.bam_id)\n items[:bam] = bam\n end\n if user.sim_id\n sim = Sim.find(user.sim_id)\n items[:sim] = sim\n end\n if user.plan_id\n plan = Plan.find(user.plan_id)\n items[:plan] = plan\n end\n return items\n end",
"def index\n\t\t @items = Item.find_my_items(current_user) \n end",
"def user_list(user)\n List.find_by(restaurant: self, user: user)\n end",
"def index\n if params[:user_id].present?\n @items = current_user.items.page params[:page]\n else\n @items = Item.available.page params[:page]\n end\n end",
"def copy_offered_packages\n user_packages = PotentialUserPackage.find_all_by_user_email self.email\n user_packages.each do |user_package|\n add_package(user_package.merchant_package_id)\n end\n end",
"def search_get_available_quick_searches(user_id)\n response = xmlrpc('SearchService.getAvailableQuickSearches', user_id)\n end",
"def get_user_basket\n @user = Users.find(session[:current_user_id])\n @basket = Baskets.find_by(:user_id => @user.id)\nend",
"def index\n redirect_to(root_url) unless current_user\n\n @user = current_user\n @places = Place.where(user_id: @user).order(\"created_at DESC\")\n end",
"def create_items\n @items.each do |item|\n create_item(item) unless Item.where(name: item['name']).first\n end\n end",
"def stock_item(variant_id, user_id = nil, original_stock_location_id = nil)\n return super(variant_id) unless reserved_items?\n raise(\n UserRequiredArgumentError,\n Spree.t(:user_id_required_for_reserved_stock_location)\n ) unless user_id.present?\n items = stock_items.where(variant_id: variant_id, user_id: user_id)\n items = items.where(\n original_stock_location_id: original_stock_location_id\n ) unless original_stock_location_id.blank?\n items.order(:id).first\n end",
"def find_items_like_mine\n if self.forsale\n return Item.where('ownership_id == ? AND lower(name) == ?', WANTED, self.name.downcase)\n elsif self.wanted\n return Item.where('ownership_id == ? AND lower(name) == ?', FORSALE, self.name.downcase)\n else\n return nil\n end\n end",
"def get_user_overdue_items(user_id, org_unit_ids_CSV = nil) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/overdueItems/\"\n query_string += \"?userId=#{user_id}\"\n query_string += \"&orgUnitIdsCSV=#{org_unit_ids_CSV}\" unless org_unit_ids_CSV.nil?\n _get(query_string)\n # Returns: An ObjectListPage JSON block containing a list of OverdueItem.\nend",
"def index\n @items = Item.find_all_by_user_id(current_user.id)\n end",
"def scrape_items_from_opportunity(b, opp_id, date, place_id, inst_id, sr_id)\n category_name = nil\n\n rows = b.table(css: '.cbo_nn_itemGridTable').trs\n # use reduce to keep track of the number of new items actually saved\n count = rows.reduce(0) do |acc, row|\n if row.td(css: '.cbo_nn_itemGroupRow').exists? # update category during iteration\n category_name = row.text\n elsif row.td(css: '.cbo_nn_itemHover').exists? # create menu item with current category\n name = row.td(css: '.cbo_nn_itemHover').text\n mi = MenuItem.new(institution_id: inst_id, name: name, dining_opportunity_id: opp_id, scrape_resource_id: sr_id,\n dining_place_id: place_id, date_available: date, category: category_name)\n if mi.valid?\n result = mi.non_duplicative_save\n acc += 1 if result\n end\n end\n acc # yeild acc to continue with reduce\n end\n # logger.info \"saved #{count} new out of #{rows.count} present valid menu items from opportunity with id: #{opp_id}\"\n count\n end",
"def buyable_items(_entity)\n []\n end",
"def show_history_items_page\n \t@sold = Transaction.find_all_by_seller_id(current_user.id)\n @bought = Transaction.find_all_by_buyer_id(current_user.id)\n end",
"def find_items_like_mine\n\t\tif self.forsale\n\t\t\treturn Item.where('ownership_id == ? AND lower(name) == ?', WANTED, self.name.downcase) \n\t\telsif self.wanted \n\t\t\treturn Item.where('ownership_id == ? AND lower(name) == ?', FORSALE, self.name.downcase)\n\t else \n\t \t\treturn nil \t \n\t end \n\tend",
"def food_trucks_that_sell(desired_item)\n food_truck_list = []\n @food_trucks.each do |food_truck|\n food_truck.inventory.each do |item|\n if item.first.name == desired_item.name\n food_truck_list << food_truck\n end\n end\n end\n food_truck_list\n end",
"def get_stocks\n @stocks = Stock.where(user_id: session[:current_user_id]).order(\"ticker_symbol ASC\")\n end",
"def equipment\n @items = Item.where(user_id: params[:user_id])\n end",
"def get_user_stocks(userid)\n return $db.execute('SELECT stocks.stockname, relation_user_stock.stockid, relation_user_stock.amount FROM relation_user_stock INNER JOIN stocks ON relation_user_stock.stockid = stocks.stockid WHERE userid=?', userid)\n end",
"def modified_by_user(user_id, source_id, number_to_return = :all, starting_index = 0)\n # ids = PublicEarth::Db::Place.many.modified_by_user(user_id, source_id, number_to_return == :all && 250 || number_to_return, starting_index).map { |result| result['modified_by_user'] }\n ids = PublicEarth::Db::Place.many.modified_by_user(user_id, source_id).map { |result| result['modified_by_user'] }\n PublicEarth::Db::Place.find_from_search(*ids)\n end",
"def list_favourites(user_id)\n @favourites_store.where(user_id)\n end",
"def index\n @lcb_user_package_items = LcbUserPackageItem.all\n end",
"def saved_searches(user)\n user = Access::Validate.user(user, false)\n SavedSearch\n .where('(saved_searches.creator_id = ?)', user.id)\n .order('saved_searches.created_at DESC')\n end",
"def marketplace\n @marketplace or raise MissingMarketplace\n end",
"def index \n @user = User.find(params[:user_id])\n @order = active_order\n @user_orderitems = Orderitem.user_orderitems(@order, params[:user_id])\n store_location\n end",
"def check_for_new_items\n @new_queue.each do |item|\n matches = @previous_queue.select { |match| same_item(item, match) }\n unless matches.any?\n @new_items.push(created_at: item.created_at, service_id: item.service_id, open: true)\n end\n end\n end",
"def created_by_user(user_id, source_id, number_to_return = :all, starting_index = 0)\n # ids = PublicEarth::Db::Place.many.created_by_user(user_id, source_id, number_to_return == :all && 250 || number_to_return, starting_index).map { |result| result['created_by_user'] }\n ids = PublicEarth::Db::Place.many.created_by_user(user_id, source_id).map { |result| result['created_by_user'] }\n PublicEarth::Db::Place.find_from_search(*ids)\n end",
"def provider_items\n @provider_items ||= ProviderItem.find(provider_items_ids)\n end",
"def add_sellers_items_from_cart(items, seller)\n \t\tsellers_items = items.select {|item| item.product.user_id == seller}\n\t\tsellers_items.each do |item|\n\t\t\titem.cart_id = nil\n\t\t\titems << item\n\t\tend\n\tend",
"def manage_items\n @pending_items = Item.find_all_by_item_status_id(1)\n @for_sale_items = Item.find_all_by_item_status_id(2)\n @free_items = Item.find_all_by_item_status_id(3)\n @claimed_items = Item.find_all_by_item_status_id(4)\n @sold_items = Item.find_all_by_item_status_id(5)\n end",
"def setup_invites_for_upcoming\n if( @upcoming_near_me.blank? )\n @upcoming_near_me = Invitation.search \"#{@current_city} #{@current_state} #{@current_country}\",:with => {:start_date => Time.now.utc..Time.now.utc.advance(:days => 1000),:is_public => 1,:deactivated => 0}, :without => {:purpose_id => 19}, :order => :id, :sort_mode => :desc\n #~ @upcoming_near_me = LookUp::meetings_for_upcoming_on_user_home(:city => @current_city, :state => @current_state, :country => @current_country) \n @invites_for_map = LookUp::invites_for_map_on_user_home(@upcoming_near_me.map(&:id))\n end\n end",
"def market\n market_where_this_vendor_sells = nil\n markets_to_check = FarMar::Market.all\n markets_to_check.each do |market_to_check|\n if self.market_id == market_to_check.id\n market_where_this_vendor_sells = market_to_check\n end#of if\n end#of do\n return market_where_this_vendor_sells\n end",
"def getStocks(userId)\n stocknames = []\n Stock.where(:user_id => userId).each{ |item|\n stocknames.push(item.ticker)\n }\n if stocknames.any?\n return StockQuote::Stock.batch([\"quote\",\"logo\"],stocknames)\n else\n return '{\"company_name\" : \"No Stocks saved\", \"symbol\" : \"none\"}'\n end\n end",
"def index\n @user = User.new\n \n if params[:search].present?\n @applications = Application.near(params[:search], 100, order: 'distance')\n else\n @applications = Application.all\n end\n\n @applications_trades = @applications.group_by { |t| t.trade_id }\n end",
"def wishers\n @items = UserProductWish.includes(:account).where({product: @product}).all\n end",
"def getStocks(userId)\n stocknames = []\n Stock.where(:user_id => userId).each{ |item|\n stocknames.push(item.ticker)\n }\n if stocknames.any?\n return StockQuote::Stock.batch([\"quote\",\"logo\"],stocknames)\n else\n return '{\"company_name\" : \"No Stocks saved\", \"symbol\" : \"none\"}'\n end\n end",
"def search_items\n @resources = current_company.items.search_for(params[:name]).limit(10)\n @resources = Admin::InventoryItemDecorator.decorate(@resources)\n end",
"def sync_items\n oauth_client = OAuth::AccessToken.new($qb_oauth_consumer, current_company.access_token, current_company.access_secret)\n\n item_service = Quickeebooks::Online::Service::Item.new\n item_service.access_token = oauth_client\n item_service.realm_id = current_company.realm_id\n\n #load all the customers created in QuickBookss\n @items = []\n 500.times do |i|\n temp_item = item_service.list(filters = [], page = i+1, per_page = 500, sort = nil, options = {}).entries\n @items += temp_item\n break if temp_item.empty?\n end \n\n\n @items.each do |item|\n if !current_company.items.exists?(:name => item.name)\n current_company.items.create(:quickbook_item_id => item.id, :name => item.name, :description => item.desc, :unit_price => item.unit_price.present? ? item.unit_price.amount : 0, :unit_cost => 0, :itemtype => \"Quickbook\", :qty => 1, :number => \"-\")\n else\n @item = current_company.items.find_by_name(item.name)\n @item.update_attributes(:quickbook_item_id => item.id, :name => item.name, :description => item.desc, :unit_price => item.unit_price.present? ? item.unit_price.amount : 0, :unit_cost => 0, :itemtype => \"Quickbook\", :qty => 1, :number => \"-\")\n end\n end\n rescue OAuth::Problem\n flash[:alert] = \"OAuth::Problem - token_rejected. Please Reconnect to QBO\"\n end",
"def get_results\n \titems = self.possessions.find(:all, :limit => 20, :order => 'wants_count DESC')\n #reset data just for testing\n Possession.all.each do |item|\n item.new_owner = nil\n item.save\n end\n \t# items = prune(items)\n \tif items.count > 1\n \t\tfind_some_trades(items)\n \tend\n end",
"def non_first_time_user_feed products\n #generate raking based on the search, bookmarks and feedback \n searches = @user.searches.limit(3)\n feedbacks = @user.feedbacks\n bookmarks = @user.bookmarks\n results = Hash.new\n products.each do |product|\n score = product.internal_score\n bookmarks.each do |bookmark|\n if bookmark.product_id == product.id\n score += 2 #bookmarked products should be on top.\n end\n end\n feedbacks.each do |feedback|\n if feedback.product_id == product.id\n score += (feedback.rating - 3) #considering 3 rating as average\n elsif feedback.product.sub_category_id == product.sub_category_id\n score += (3 - feedback.rating) #For postive feedback user might not want to see other products in that sub_category at top, for negative feedback reverse\n end \n end\n searches.each do |search|\n if search.searchable_type == 'Product'\n if search.searchable_id == product.id\n score += 2 #latest search products at top\n end\n else\n if search.searchable_id == product.sub_category_id\n score += 1 #latest serach subcategory products at top\n end\n end\n end\n results[score] = results.key?(score) ? results[score] + [product] : [product]\n end\n results = results.sort.reverse.to_h\n result_array = Array.new\n results.each do |key, value| \n result_array += value\n end\n result_array\n end",
"def index\n @user = current_user\n @contract_items = ContractItem.all\n end",
"def my_marketplace\n self.class.my_marketplace\n end",
"def my_marketplace\n self.class.my_marketplace\n end",
"def get_users\n\t\t\t@users = User.all.where(:on_beverage_list => true).order('firstname, lastname')\n\t\tend",
"def getPendingItemInfo\n @output = []\n @items = Item.where(status: \"pending\")\n for item in @items do\n for cart in item.carts do\n @user = User.find(cart.user_id)\n @output << {user: @user, item: item, cart_id: cart.id }\n end\n end\n render :json => @output\n end",
"def add_item(users)\n print_item(users)\n print \"What is the name of the user you wish to edit?\".yellow\n person = gets.chomp\n users.each do |user|\n if user[:user] == person\n print \"What's the name of the new item? \".green\n added_item = gets.chomp\n user[:item].push(added_item)\n puts \"Adding #{added_item} to the user...\".red\n sleep(2)\n print_item(users)\n end\n end\nend",
"def index\n @baskets = Basket.where(user_id: current_user.id)\n end",
"def check_wishlist(item)\n #Query wish lists to see if the criteria matches\n @wish_list = search_wishlist(item)\n @notify_list = Array.new\n @wish_list.each do |wish_list_item|\n if @notify_list.size == 0\n @notify_list.push wish_list_item\n else \n @inList = false\n #Checks to see if the user of the wish list is already in the notificaiton list \n @notify_list.each do|notify_list_item| \n \t\tif notify_list_item.user_id == wish_list_item.user_id\n\t\t\t\t\t\t\t@inList = true \n\t\t\t\t\t\t\tbreak \n end \n end \n if @inList == false \n\t\t\t\t\t@notify_list.push wish_list_item \n end\n end\t\n end\n alert_user(item, @notify_list)\n end",
"def search (search_term)\n\n res = Amazon::Ecs.item_search(search_term , :search_index => 'All')\n items = res.marshal_dump\n items_return = []\n #puts res.marshal_dump\n Hash.from_xml(items)[\"ItemSearchResponse\"][\"Items\"][\"Item\"].each do |item|\n myitem = item[\"ItemAttributes\"]\n myitem.merge!(\"DetailPageURL\" => item[\"DetailPageURL\"])\n myitem.merge!(\"ASIN\" => item[\"ASIN\"])\n #m = find_prices(myitem[\"ASIN\"])\n #puts m\n #sleep(100)\n sleep 1\n myitem.merge!(\"Prices\" => self.find_prices(item[\"ASIN\"]) )\n #puts myitem[\"ASIN\"]\n #puts myitem\n\n #myitem.merge!(find_prices(myitem[\"ASIN\"]))\n items_return.push(myitem)\n end\n\n items_return\n end",
"def items\n response = JSON.parse(@client.get(\"users/#{send(:id)}/items\").body)\n users = response.key?('items') ? response['items'] : []\n users.map { |attributes| Promisepay::Item.new(@client, attributes) }\n end",
"def call_buy_orders(item)\n buy_orders_copy = Array.new\n @buy_orders.each{ |buy_order| buy_orders_copy << buy_order } #NOTE by urs: need to copy array, because a buy_order deletes itself directly from @buy_orders when done!\n buy_orders_copy.each{ |buy_order|\n buy_order.item_changed(item)\n }\n end",
"def index\n @items = Item.includes(:user).where(availability: TRUE)\n end",
"def find_some_trades(items)\n item_count = items.count\n route_count = 0\n items_in_all_routes = 0\n items_that_get_saved = 0\n while items.count > 1\n # puts \"ITEMSCOUNT = #{items.count}\"\n items = prune(items)\n # puts \"ITEMSCOUNT AFTER PRUNE = #{items.count}\"\n items_with_new_owners=[]\n items.each do |item|\n if item.new_owner\n next\n end\n #puts \"items_with_new_owners size = #{items_with_new_owners.size}\"\n #never looping past first item. so route is always true. \n \troute = find_trade(item, items)\n \tif route.count > 2 and route.first == route.last\n route_count +=1\n items_in_all_routes += route.count -1\n #-1 to adjust for index starting at 0. -1 more because 1st and last item in route is the same. only need to set owner and delete it once.\n \t\t#each item in a route now has a new owner which is the current owner of the previous item in the route\n 0.upto(route.length-2) do |i|\n \t\t\tpossession = Possession.find(route[i+1])\n puts \"POSSESSION #{i+1} IN ROUTE #{route_count}: #{possession.name}\"\n \t\t\tpossession.new_owner = route[i].user.id\n \t\t\tpossession.save\n items_that_get_saved +=1\n #puts \"Route[i] = #{route[i].name}\"\n \t\t\t#items.delete(route[i])\n items_with_new_owners << route[i]\n #puts \"and if i try to call the deleted item?\"\n # p items.include?(route[i])\n \t\tend\n #break\n \tend\n end\n items_with_new_owners.each do |item|\n puts \"deleting item: #{item.name}\"\n # puts \"item count before delete = #{items.size}\"\n # puts \"Does items include item? #{items.include?(item)}\"\n items.delete(item)\n # puts \"item count after delete = #{items.size}\"\n end\n if item_count == items.count\n break\n else\n item_count = items.count\n end\n end\n puts \"ROUTE COUNT = #{route_count}\"\n puts \"ITEMS IN ROUTES = #{items_in_all_routes}\"\n puts \"ITEMS THAT GET SAVED = #{items_that_get_saved}\"\n end",
"def add_new_itemized_users(users)\n user = users.first\n\n unless user.user_group.nil?\n user_group_select.type_text(user.user_group)\n page.driver.execute_script(\"document.querySelector('img[alt=\\\"Search-button-icon\\\"]').click()\")\n wait_until { !loading_img.visible? }\n find(:xpath,\"//li[text()='#{user.user_group}']\").click unless user.user_group == ''\n wait_until {!(find(:xpath, \"//li[text()='#{user.user_group}']\").visible?) }\n end\n\n # name/email section\n nu_name_tb.type_text(user.name) unless user.name.nil?\n nu_email_tb.type_text(user.email) unless user.email.nil?\n # quota/device section\n nu_devices_server_tb.type_text(user.devices_server) unless user.devices_server.nil?\n nu_quota_server_tb.type_text(user.quota_server) unless user.quota_server.nil?\n nu_devices_desktop_tb.type_text(user.devices_desktop) unless user.devices_desktop.nil?\n nu_quota_desktop_tb.type_text(user.quota_desktop) unless user.quota_desktop.nil?\n\n unless user.enable_stash.nil?\n if user.enable_stash.downcase.eql?('yes')\n nu_enable_stash_cb.check\n else\n nu_enable_stash_cb.uncheck\n end\n end\n\n # default quota for stash?\n unless user.stash_quota.nil?\n if user.enable_stash.downcase.eql?('yes')\n if user.stash_quota.downcase.eql?('default')\n #its default\n else\n nu_stash_quota_tb.type_text(user.stash_quota) unless user.stash_quota.nil?\n end\n else\n end\n end\n\n # send stash invite emails?\n unless user.send_invite.nil?\n if user.send_invite.downcase.eql?('yes')\n nu_send_stash_inv_cb.check\n else\n nu_send_stash_inv_cb.uncheck\n end\n end\n\n # finishing up\n nu_create_btn.click\n #wait_until_bus_section_load\n end",
"def feed_items(feed_title) \n # update last_viewed_at \n @client.query \"UPDATE feeds SET last_viewed_at = now() where title = '#{e feed_title}'\"\n query = \"SELECT items.title, guid, feed, feed_title, pub_date, word_count, starred, unread from items where items.feed_title = '#{e feed_title}' order by pub_date asc\"\n @client.query(query)\n end",
"def users_have_same_item(item)\n # TODO: .collect is slow? (for 100K dataset around 60secs.)\n #@users.collect { |k, u| u if u.has_item? item.id }.compact\n #@users.collect { |k, u| u if u.list.items[item.id] }.compact\n list = {}\n @users.each do |k, u|\n list[k] = u if u.has_item? item.id\n end\n list\n end",
"def fetch\n result = WebApi.json!('ITFItems_440', 'GetPlayerItems', 1, { :SteamID => @steam_id64 })\n\n @items = []\n result[:items][:item].each do |item_data|\n unless item_data.nil?\n item = TF2Item.new(item_data)\n @items[item.backpack_position - 1] = item\n end\n end\n end",
"def get_places(opts = {})\n @search_fields = [\n :id, :title, :city_id, :size_sqf, :size_sqm, :reviews_overall, :photos, \n :currency, :num_bedrooms, :num_bathrooms, :favorited, \n :price_per_month_usd, :price_per_month\n ]\n @user_fields = [:id, :first_name, :last_name, :avatar_file_name, :role]\n @place_type_fields = [:id,:name]\n\n if opts[:search_type] == \"recently_added\"\n search_params = self.query.merge({\"date_from\" => self.delivered_at})\n elsif opts[:search_type] == \"new_results\"\n search_params = self.query.merge({\"exclude_ids\" => self.results})\n else\n search_params = self.query\n end\n\n place_search = PlaceSearch.new(self.user, search_params)\n if !place_search.all_results.blank?\n filtered_places = filter_fields(place_search.all_results, @search_fields, { :additional_fields => {\n :user => @user_fields,\n :place_type => @place_type_fields },\n :currency => self.query['currency']\n })\n return filtered_places\n else\n return nil\n end\n end",
"def ebay_products items\n\titems.select do |item|\n\t\titem['product']['author']['name'].downcase == 'ebay'\n\tend\nend",
"def filtered_items_list(filter, params = {})\n resp = @client.access_token.get(ItemList.merge_query_string(\"/reader/api/0/stream/contents/user/#{user_id}/state/com.google/#{filter}?output=json\", params))\n raise \"unable to retrieve the list of #{filter} items for user \\\"#{user_id}\\\": #{resp.inspect}\" unless resp.code_type == Net::HTTPOK\n Google::Reader::ItemList.new(@client, resp.body)\n end",
"def find_recipes_that_use_me_and_create_link\n my_recipes = Recipe.search_recipe_ingredient_lists_for_ingredient(self)\n my_recipes.each {|recipe| self.recipes << recipe}\n end",
"def recently_saved_by(user, options = {})\n relation = user.listing_saves\n if options[:limit].present?\n relation = relation.limit(options[:limit])\n end\n if options[:exclude_sellers].present?\n exclude_seller_ids = Array.wrap(options[:exclude_sellers]).compact.map { |u| u.is_a?(User) ? u.id : u }\n relation = relation.joins(:listing).\n where(\"#{Listing.quoted_table_name}.seller_id NOT IN (?)\", exclude_seller_ids)\n end\n relation.order(\"#{ListingCollectionAttachment.quoted_table_name}.created_at DESC\")\n end",
"def index\n @items = Item.where(user: @user).order(:list_order)\n end",
"def buy_item(item_to_buy, user)\r\n fail \"only users can buy items in behalve of an organisation\" if (user.organisation)\r\n fail \"only users that are part of #{self.name} can buy items for it\" unless (is_member?(user))\r\n fail \"would exceed #{user.email}'s organisation limit for today\" unless within_limit_of?(item_to_buy, user)\r\n fail \"not enough credits\" if item_to_buy.price > self.credits\r\n fail \"Item not in System\" unless (DAOItem.instance.item_exists?(item_to_buy.id))\r\n\r\n old_owner = item_to_buy.owner\r\n\r\n #Subtracts price from buyer\r\n self.credits = self.credits - item_to_buy.price\r\n #Adds price to owner\r\n old_owner.credits += item_to_buy.price\r\n #decreases the limit of the buyer\r\n @member_limits[user.email].spend(item_to_buy.price) unless self.limit.nil? || is_admin?(user)\r\n\r\n item_to_buy.bought_by(self)\r\n end",
"def giveItem\n toLocation = Company.where(name: params[:recepCompany]).first.locations.where(address: params[:recepLocation]).first\n location = current_company.locations.where(id: params[:locationId]).first\n if(location.is_supplier === true)\n updatedItem = location.items.where(name: params[:name]).first\n toUpdatedItem = toLocation.items.where(name: params[:name]).first\n if(toUpdatedItem.present? && updatedItem.amount > params[:amount].to_i)\n updatedItem.increment!(:amount, -params[:amount].to_i)\n toUpdatedItem.increment!(:amount, params[:amount].to_i)\n elsif(updatedItem.amount > params[:amount].to_i)\n updatedItem.increment!(:amount, -params[:amount].to_i)\n item = Item.create(name: params[:name], amount:params[:amount].to_i, price: updatedItem.price, autoRestock: false, lastSupplier:location.id)\n toLocation.items << item\n end\n if(updatedItem.amount <= updatedItem.restockPoint)\n changeItemSupplier(updatedItem.id)\n end\n end\n end",
"def buy_now(item_params)\n new_item = cart_items.new(item_id: item_params[:item][:item_id], quantity: item_params[:quantity], buy_now: item_params[:buy_now], cart_id: self.id)\n end",
"def get_submissions\n puts \"== searching for whoishiring submissions ==\"\n @items ||= HiringTrends::ItemSearch.new.execute\n end",
"def checkout\n @checkouts = Array.new\n User.all.each do |user|\n url = untappd_url('/user/checkins/' + user.untappd_id)\n if user.last_checkin.blank?\n user.last_checkin = \"0\"\n else\n url += \"max_id=#{user.last_checkin}\"\n end\n json_txt = RestClient.get(url)\n json_obj = JSON.parse(json_txt)\n user_checkouts = Array.new\n failed_checkouts = Array.new\n checkout_keyword = \"#cellar\"\n checkin_max = 0\n json_obj[\"response\"][\"checkins\"][\"items\"].each do |checkin|\n checkin_id = checkin['checkin_id']\n checkin_max = checkin_id if checkin_id > checkin_max\n if checkin['checkin_comment'].include? checkout_keyword and checkin_id > user.last_checkin.to_i\n beer = Beer.find_by untappd: checkin['beer']['bid']\n if ( beer.nil? )\n failed_checkouts << checkin['beer']['beer_name']\n else\n beer.quantity = beer.quantity - 1\n beer.save\n user_checkouts << checkin['beer']['beer_name']\n end\n end\n end\n if checkin_max > user.last_checkin.to_i\n user.last_checkin = checkin_max\n user.save\n end\n @checkouts << { email: user.untappd_id,\n user_checkouts: user_checkouts,\n failed_checkouts: failed_checkouts }\n end\n end",
"def search_by_user(user)\n # d = db\n transaction do\n d.select { |_, v| v[:user] == user }\n end\n end"
] |
[
"0.6023096",
"0.5739385",
"0.5562332",
"0.55500114",
"0.55344826",
"0.54793364",
"0.54522824",
"0.5451346",
"0.5442407",
"0.5433652",
"0.54334986",
"0.54018414",
"0.53915536",
"0.5290779",
"0.5288997",
"0.5281393",
"0.527529",
"0.5266963",
"0.52580225",
"0.5252533",
"0.5248341",
"0.52357996",
"0.5211046",
"0.52005756",
"0.5192475",
"0.518421",
"0.5178985",
"0.517813",
"0.5175046",
"0.51663697",
"0.5164578",
"0.5162238",
"0.5161599",
"0.51324123",
"0.5128957",
"0.51242846",
"0.51177967",
"0.5089286",
"0.50795656",
"0.5078291",
"0.50747603",
"0.50745887",
"0.50745666",
"0.50556916",
"0.50544",
"0.5050605",
"0.5043978",
"0.50425667",
"0.5037858",
"0.5035979",
"0.5031526",
"0.5020422",
"0.50123864",
"0.50113463",
"0.5004686",
"0.5003196",
"0.49974996",
"0.4996152",
"0.49821064",
"0.4977263",
"0.49768975",
"0.4974196",
"0.49662784",
"0.49596024",
"0.49500087",
"0.49405035",
"0.49324337",
"0.49038994",
"0.48988447",
"0.48982036",
"0.48753008",
"0.48647034",
"0.48631266",
"0.48631266",
"0.4857335",
"0.485652",
"0.48560634",
"0.48527026",
"0.4850868",
"0.48470724",
"0.48449776",
"0.48421142",
"0.48386043",
"0.48338157",
"0.4832771",
"0.4831792",
"0.4827558",
"0.48184744",
"0.4806087",
"0.480479",
"0.48014173",
"0.47967902",
"0.47939125",
"0.4792761",
"0.4790359",
"0.47890794",
"0.47796017",
"0.47778845",
"0.47754794",
"0.4775213"
] |
0.65492696
|
0
|
Breakdown a users sales based on month.
|
def sales_per_month
response = get 'v1/market/private/user/earnings-and-sales-by-month.json'
response[:'earnings-and-sales-by-month']
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_monthly(user)\n weeks = get_calendar(user)\n ret = {\n '01' => 0,\n '02' => 0,\n '03' => 0,\n '04' => 0,\n '05' => 0,\n '06' => 0,\n '07' => 0,\n '08' => 0,\n '09' => 0,\n '10' => 0,\n '11' => 0,\n '12' => 0\n }\n weeks.each do |k|\n k.children.each do |day|\n date = day.attribute('data-date').value.split('-')[1]\n count = day.attribute('data-count').value\n ret[date] += count.to_i\n end\n end\n ret\n end",
"def index\n @orders = Order.all\n\n @orders_this_month = Order.where(created_at: Time.now.beginning_of_month..Time.now.end_of_month)\n @sales = []\n @orders_this_month.each do |order| \n @sales.push(order.total)\n end\n @total_sales_this_month = @sales.reduce(:+)\n end",
"def users_retention\n month_users = {}\n\t\n uret = {}\n\t\n @visits.each do |v| # all in right order\n time = Time.at(v.time_in)\n next if time < @from_day\n if time > @to_day then break end\n month = time.strftime \"%Y-%m\"\n if month_users[month].nil? then month_users[month] = {:uids => {}, :month => month} end\n if month_users[month][:uids][v.user_id].nil? then month_users[month][:uids][v.user_id] = 0 end\n month_users[month][:uids][v.user_id] += 1\n end\n \n month_users_ar = month_users.values.sort {|x,y| x[:month] <=> y[:month]} # sort by month\n\n for index in 1 ... month_users_ar.size # skip first month\n info = month_users_ar[index]\n month = info[:month]\n # how much (in %) from last month users came again in this month\n last_month_users = month_users_ar[index-1]\n uret[month] = {:count => 0, :total => last_month_users[:uids].count }\n last_month_users[:uids].each do |uid, count|\n if !(info[:uids][uid].nil?) then uret[month][:count] += 1 end\n end\n end\n \n render json: uret\n end",
"def monthly_sales(report_date = Time.now)\n date = DateTime.parse report_date.to_s\n prior_months = TimeCalculator.prior_year_period(date, {:format => '%b %Y'})\n [].tap do |results|\n prior_months.each { |mon|\n short_mon = DateTime.parse(mon).strftime('%b')\n total_sales = sold_images.sum { |image| image.sale.total_image_sales(mon) }\n results << { :month => short_mon, :sales => total_sales }\n }\n end\n end",
"def index\n @user = User.find(params[:user_id])\n @works = @user.works.order(start: :desc).paginate(:per_page => 5, :page => params[:page])\n @works_month = @user.works.group_by { |t| t.start.beginning_of_month }\n end",
"def calculated_spend_by_month\n return if !organisation.respond_to?(:payments) || organisation.payments.count == 0\n res_hsh = {}\n group_by = case ActiveRecord::Base.connection.adapter_name\n when 'MySQL'\n # https://github.com/django/django/blob/master/django/db/backends/mysql/base.py#L207\n \"CAST(DATE_FORMAT(date, '%Y-%m-01 00:00:00') AS DATETIME)\"\n else # PostgreSQL\n # https://github.com/django/django/blob/master/django/db/backends/postgresql_psycopg2/operations.py#L35\n \"DATE_TRUNC('month', date)\"\n end\n ft_sums = organisation.payments.sum(:value, :conditions => {:date_fuzziness => nil}, :group => group_by).to_a\n fuzzy_sums = organisation.payments.all(:select => 'SUM(value) AS value, date, date_fuzziness', :conditions => \"date_fuzziness IS NOT NULL\", :group => 'date, date_fuzziness')\n\n fuzzy_sums.each{ |fs| ft_sums += fs.averaged_date_and_value }\n\n ft_sums.each do |ft_sum|\n res_hsh[ft_sum.first.to_date.beginning_of_month] = res_hsh[ft_sum.first.to_date.beginning_of_month].to_f + ft_sum.last\n end\n\n months_with_vals = res_hsh.sort\n \n first_month, last_month = months_with_vals.first, months_with_vals.last\n spend_by_month_array(first_month.first, last_month.first, months_with_vals)\n end",
"def make_month_stats(month)\n rows = Account.all(:order => \"position\").map{|account|\n items = Item.all(:conditions => {\n :account_id => account.id,\n :date => month_range(month), \n :type => [\"Expense\", \"Income\"]\n }).group_by(&:category)\n\n make_row(account.name, items)\n }\n\n return rows.push make_sum_row(rows)\n end",
"def index\n # @accounts = Account.order(:buyday).all.page(params[:page]).per(5)\n @accounts = Account.all.page(params[:page]).per(5)\n @grouped_months = @accounts.group_by { |r| r.buyday.beginning_of_month}\n\n @month_num = ['1','2','3','4','5','6','7','8','9','10','11','12']\n @month_details = []\n @month_costs = []\n (0..11).each do |i|\n @month_details[i] = Account.where([\"date_part('month',buyday) = ? and date_part('year',buyday) = ?\" , @month_num[i],2015]).order('buyday desc')\n @month_costs[i] = Account.where([\"date_part('month',buyday) = ? and date_part('year',buyday) = ?\" , @month_num[i],2015]).sum(:dollar)\n end\n # @mar = Account.where(['buyday between ? and ?', '2015-03-01', '2015-03-31' ])\n \n end",
"def index\n @entries = current_user.entries.for_month(@date)\n @budgets = current_user.budgets\n end",
"def calculate_month_by_month\n return StandardError, 'Already calculated stats for period' if @calculated.include?(:month_by_month)\n check_for_dates\n\n months_list.each do |date|\n start = date.beginning_of_month\n final = date.end_of_month\n month_key = start.strftime(MONTH_KEY)\n\n calculate_stats_for(month_key, Statistic::VIEW, start, final)\n calculate_stats_for(month_key, Statistic::STREAM, start, final) if include_streaming\n calculate_stats_for(month_key, Statistic::DOWNLOAD, start, final)\n end\n @calculated << :month_by_month\n self\n end",
"def find_months_to_generate\n @dates_of_each_month = []\n @dates = Event.all.pluck(:date)\n @dates.each do |date|\n @dates_of_each_month << date.beginning_of_month\n end\n @dates_of_each_month.uniq!\n end",
"def get_average_month(user)\n monthly = get_monthly(user)\n get_average(monthly)\n end",
"def setup_months(start_month, end_month)\n @months = []\n while start_month <= end_month\n @months << start_month\n start_month += 1\n end\n end",
"def smoked_this_month\n Smoke.by_user(id).this_month(Date.today).sum(:counted) || 0\n end",
"def month_by_month_csv\n CSV.generate do |csv|\n report_details.each { |a| csv.add_row(a) }\n csv.add_row [] # Blank row\n csv.add_row ['VIEWS']\n month_by_month_table(Statistic::VIEW).each { |a| csv.add_row(a) }\n csv.add_row [] # Blank row\n csv.add_row ['DOWNLOADS']\n month_by_month_table(Statistic::DOWNLOAD).each { |a| csv.add_row(a) }\n end\n end",
"def monthly_print_usage_by_user=(value)\n @monthly_print_usage_by_user = value\n end",
"def monthly\n end",
"def generate_month_expenses\n Expense.all.each do |expense|\n MonthExpense.create(month_id: self.id, expense_id: expense.id)\n end\n end",
"def get_earning_months\n orders = self.orders.find(:all, :select => ['created_on'])\n return orders.collect{|o| o.created_on.to_date.beginning_of_month }.uniq\n end",
"def skel_monthly( path_storage, section_path )\n months = path_storage.get_months( path_storage.find )\n months.extend Hobix::Enumerable\n months.each_with_neighbors do |prev, curr, nextm| \n entries = path_storage.within( curr[0], curr[1] )\n page = Page.new( curr[0].strftime( \"%Y/%m/index\" ), section_path )\n page.prev = prev[0].strftime( \"%Y/%m/index\" ) if prev\n page.next = nextm[0].strftime( \"%Y/%m/index\" ) if nextm\n page.timestamp = curr[1]\n page.updated = path_storage.last_updated( entries )\n yield :page => page, :entries => entries\n end\n end",
"def user_count_by_month(type)\n result = Hash.new(0)\n time = type\n title_graph = ''\n x_axsis = ''\n case time\n when 'month'\n users = @users.where(:created_at => Time.now.beginning_of_month..Time.now.end_of_month)\n users.group_by{ |m| m.created_at.beginning_of_day}.each do |key, value|\n aux = key.to_s.split('-')\n result[\"#{aux[2].split(' ')[0]}-#{aux[1]}-#{aux[0]}\"] = value.count\n end\n title_graph = 'Usuarios nuevos durante el ultimo mes'\n x_axsis = 'Días'\n when 'year'\n users = @users.where(:created_at => Time.now.beginning_of_year..Time.now.end_of_year)\n users.group_by{ |m| m.created_at.beginning_of_month }.each do |key, value|\n aux = key.to_s.split('-')\n result[\"#{aux[1]}-#{aux[0]}\"] = value.count\n end\n title_graph = 'Usuarios nuevos durante el ultimo año'\n x_axsis = 'Meses'\n else\n users = @users\n users.group_by{ |m| m.created_at.beginning_of_year}.each do |key, value|\n aux = key.to_s.split('-')\n result[\"#{aux[0]}\"] = value.count\n end\n title_graph = 'Usuarios nuevos durante los años'\n x_axsis = 'Años'\n end\n line_chart result.sort, height: '80%', width: '95%', colors: [\"#FFD586\"],\n library: {\n chart: {\n borderColor: '#aaa', borderWidth: 2, type: 'line',backgroundColor: '#FEFEFA',\n style: {\n fontFamily: 'Helvetica Neue'\n }\n },\n title: {\n text: title_graph,\n style: {\n fontWeight: 'bold', fontSize: '14px'\n }\n },\n yAxis: {\n allowDecimals: false,\n title: {\n text: 'Usuarios'\n }\n },\n xAxis: {\n title: {\n text: x_axsis\n }\n }\n }\n end",
"def index\n @user_plan_months = UserPlanMonth.all\n end",
"def local_sales\n #tax = Bill.where(:tax_id => (Tax.where(:tax_type => \"VAT\")))\n chosen_month = params[:choose_month]\n #user_bills = Bill.where('created_at >= ? AND created_at <= ? AND tax_type = ? AND authuser_id = ? ',chosen_month.to_time.beginning_of_month, chosen_month.to_time.end_of_month, \"VAT\", current_authuser.id)\n #secondary_user_bills = Bill.where('created_at >= ? AND created_at <= ? AND tax_type = ? AND primary_user_id = ? ',chosen_month.to_time.beginning_of_month, chosen_month.to_time.end_of_month, \"VAT\", current_authuser.id)\n #@user_bills = user_bills + secondary_user_bills\n \n if current_authuser.main_roles.first.role_name == \"secondary_user\"\n primary_user_id = current_authuser.invited_by_id\n # bills1 is to get the user total bills\n # bills2 is to get the bills of that user for a particular month and tax type\n bills1 = Bill.where('authuser_id =? OR primary_user_id =?', primary_user_id, primary_user_id)\n bills2 = Bill.where('created_at >= ? AND created_at <= ? AND tax_type = ?', chosen_month.to_time.beginning_of_month, chosen_month.to_time.end_of_month, \"VAT\")\n @user_bills = bills1 & bills2.order('created_at ASC')\n else \n # bills1 is to get the user total bills\n # bills2 is to get the bills of that user for a particular month and tax type\n bills1 = Bill.where('authuser_id = ? OR primary_user_id = ?', current_authuser.id, current_authuser.id)\n bills2 = Bill.where('created_at >= ? AND created_at <= ? AND tax_type = ?', chosen_month.to_time.beginning_of_month, chosen_month.to_time.end_of_month, \"VAT\")\n @user_bills = bills1 & bills2.order('created_at ASC')\n end\n respond_to do |format|\n format.html\n format.xml { send_data render_to_string(:local_sales), :filename => 'local_sales.xml', :type=>\"application/xml\", :disposition => 'attachment' }\nend\n end",
"def amount_invoiced_for_month(m)\n d = Date.parse(m)\n self.invoices.within_range(d, ((d + 1.month) - 1.day)).sum(:total)\n end",
"def stats_records_by_month(*args)\n records = stats_records_by_hour(*args)\n slice_stats(records, 0, 7)\n end",
"def each_month\n @all_expenses ||= Expense.find(:all, :order => 'date')\n return if @all_expenses.empty?\n date = @all_expenses.first.date.beginning_of_month\n end_date = @all_expenses.last.date\n while date <= end_date\n yield date\n date += 1.month\n end\n end",
"def generate_invoices\n companies = Company.all\n\n companies.each do |company|\n\n last = company.last_bill\n last ||= company.created_at.prev_month.to_date\n\n actual = last.next_month.end_of_month\n\n while actual < Date.today\n\n counter = 0\n company.users.each do |user|\n\n if user.role != ROOT\n last_period = user.periods.where(\"created_at <= :end_of_last_month\",{:end_of_last_month => actual}).order(\"created_at DESC\").first\n \n if !last_period.nil?\n unless last_period.state <= STATE[:inactive] && last_period.created_at <= actual.prev_month\n counter+=1\n end\n end\n end\n\n end\n\n if counter > 0\n bill = company.bills.build\n bill.value = counter\n bill.state = -1\n bill.month = actual\n bill.save\n end\n\n company.last_bill = actual\n company.save\n\n actual = actual.next_month.end_of_month\n end\n end\n \n redirect_to backoffice_bills_path\n end",
"def index\n user = User.find params[:user_id]\n @classroom = user.classroom\n @posts_by_user = Post.where(\"user_id = #{params[:user_id]}\").order(\"created_at DESC\")\n\n # @posts = Post.all\n @posts_by_month = @posts_by_user.group_by {|post| post.created_at.beginning_of_month}\n end",
"def index\n #LOS ULTIMOS 12 MESES\n @sales_group_by_month = SalesCoffee.twelve_months_ago.group_by_month(:date_time).order(date_time: :asc ).sum(:price)\n @sales_quantity_twelve_months = SalesCoffee.twelve_months_ago.group_by_month(:date_time).order(date_time: :asc).count\n @sales_average_twelve_months = SalesCoffee.twelve_months_ago.group_by_month(:date_time).order(date_time: :asc).average(:price)\n\n #SEGUN ORIGEN\n @origen_twelve_months = SalesCoffee.twelve_months_ago\n @origen_six_months = SalesCoffee.six_months_ago\n @origen_three_months = SalesCoffee.three_months_ago\n @origen_last_month = SalesCoffee.last_month_ago\n\n #SEGUN MEZCLA\n @blend_name_twelve_months = SalesCoffee.twelve_months_ago\n @blend_name_six_months = SalesCoffee.six_months_ago\n @blend_name_three_months = SalesCoffee.three_months_ago\n @blend_name_last_month = SalesCoffee.last_month_ago\n end",
"def convertDailyToMonthlyData()\n aggregateData(ChartDirector::ArrayMath.new(@timeStamps).selectStartOfMonth())\n end",
"def get_manager_wages_for_month(month)\n events_managed = Distribution.get_events_managed(self.id)\n \n events_in_month = Event.events_in_month_ids(month)\n \n set_of_events = Event.get_event_ids_from_objects(events_managed)\n \n events_employee_managed_this_month = set_of_events & events_in_month\n \n paid_events = Event.event_ids_to_objects(events_employee_managed_this_month)\n \n Event.calc_manager_wages_for_set_of_events(paid_events)\n end",
"def monthly_sell\n @monthly_sell ||= settle_items.last_month.sum('quantity')\n end",
"def months_to_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 0.5\n elsif @population_density >= 150\n 1\n elsif @population_density >= 100\n 1.5\n elsif @population_density >= 50\n 2\n else\n 2.5\n end\n\n\n end",
"def redistribute_semi(semi_annual_val, start_month, new_data)\n six_month = []\n (0..5).each do |offset|\n date = start_month + offset.months\n value = new_data[date] || data[date]\n return if value.nil? ## bail if even a single monthly value is missing\n six_month.push(value)\n end\n diff = (semi_annual_val - six_month.average) * 2.0 ## must be float multiplication\n begin\n (new_data[start_month + 1.months] += diff) rescue raise('1')\n (new_data[start_month + 3.months] += diff) rescue raise('3')\n (new_data[start_month + 5.months] += diff) rescue raise('5')\n rescue => e\n bad_date = start_month + e.message.to_i.months\n raise \"redistribute_semi: cannot redistribute because data missing at #{bad_date}\"\n end\n end",
"def monthly_print_usage_by_user\n return @monthly_print_usage_by_user\n end",
"def each_december( n=1); each_monthnum(self.Dec,n); end",
"def monthly_payment(salary_per_annum)\n return salary_per_annum / 12\nend",
"def month_by_month_table(event)\n headers = ['Title']\n month_column_headers = months_list.map { |m| m.strftime(MONTH_KEY) }\n headers.concat(month_column_headers)\n table = [headers]\n\n each do |item|\n monthly_stats = months_list.map { |m| item.get_stat(event, m.strftime(MONTH_KEY)) }\n table << [item.document.title].concat(monthly_stats)\n end\n\n total_stats = months_list.map { |m| total_for(event, m.strftime(MONTH_KEY)) }\n table << ['Totals:'].concat(total_stats)\n\n table\n end",
"def monthly(range)\n data = range(range, :skip_bitmap_count => true)\n\n data = data.group_by { |date, value| date.beginning_of_month }\n case self.type\n when :counter\n sum_up_grouped_data(data)\n when :bitmap\n bitmap_or_grouped_data(data)\n end\n end",
"def sales\n @orders = Order.where(seller: current_user.id).order(\"created_at DESC\")\n end",
"def divide_tweets_per_month(tweets)\n result = {};\n\n # Initialize the hash to 0\n today = DateTime.now.to_date\n (0..5).to_a.reverse.each do |i|\n date = today.beginning_of_month - i.month\n\n result[date.beginning_of_month] = 0\n end\n\n # For each tweet add 1 to the number of tweets in the correct month\n tweets.each do |tweet|\n tweet_date = tweet.created_at.to_date\n\n result[tweet_date.beginning_of_month] += 1\n end\n\n return result\n end",
"def current_month_kwh_usage_by_day\n current_date = Time.now.utc.to_date\n num_days_until_yesterday = current_date.day - 1\n usage_data = []\n current_date.downto(num_days_until_yesterday.days.ago.utc.to_date).each do |date|\n usage_data << total_day_kwh_usage_on(date).round(2)\n end\n usage_data\n end",
"def monthly_bills(id)\n response = request(:get, \"/users/#{id}/monthly_bills.json\")\n end",
"def set_activities_by_month\n begin\n @start_date = Date.parse(params[\"start_date\"])\n rescue\n @start_date = Date.today\n params[\"start_date\"] = @start_date\n end\n @activities = @user.activities.where(date: @start_date.at_beginning_of_month..@start_date.at_end_of_month)\n end",
"def select_trend_by_month\n self.trend_period = 'month'\n records = []\n records = get_select_trend_by_month(month_from_date, end_date, accounts)\n records = fill_missing_rows(records, month_from_date, end_date)\n records.flatten\n end",
"def index\n #@sac_entries = SacEntry.all\n @sac_entries = SacEntry.where(user_id: current_user.id)\n @sac_entry_months = Array.new\n @months_back = 0\n @years_back = 0\n @month_sum = 0\n 12.times do\n @current = SacEntry.where('extract(month from date) = ? AND extract(year from date) = ? AND user_id = ?', Date.current.month-@months_back, Date.current.year-@years_back, current_user.id)\n unless @current.empty?\n @sac_entry_months << @current\n end\n @months_back+=1\n if Date.current.month-@months_back == 0\n @years_back+=1\n @months_back=(12-Date.current.month)*-1\n end\n end\n\n end",
"def reports\n @seek_month_start = DateTime.new(params[:year].to_i, params[:month].to_i, 1, 0, 0, 0)\n @seek_month_end = DateTime.new(params[:year].to_i, (params[:month].to_i + 1) % 13 + 1, 1, 0, 0, 0)\n @employees = []\n Employee.all.order(last_name: :asc).each do |e|\n @employees << e if e.started_at < @seek_month_end\n end\n end",
"def create_results\n loop_start_date = start_date.at_beginning_of_month\n loop_end_date = end_date.at_beginning_of_month\n\n while loop_start_date < loop_end_date\n result_start_date = loop_start_date\n result_end_date = loop_start_date.next_month\n \n results.create(start_date: result_start_date, end_date: result_end_date, amount: 0, precision: 'month', status: 0)\n\n loop_start_date = result_end_date\n end\n end",
"def cumulative_spending_by_month(date, category)\n Function.new do\n data = (Functions::DateTools.date_to_billing_period >>\n empty_cumulative_set >>\n current_date_line >>\n add_projected_spending).call(date)\n\n (get_daily_totals(category) >> get_cumulative_totals).call(data)\n end\n end",
"def month() end",
"def create_monthly_session(user)\n today = DateTime.now\n year = today.year\n month = today.month\n current_monthly_session = MonthlySession.new(:month => month, :year => year)\n current_monthly_session.user = user\n current_monthly_session.available_sessions = ENV['COMMUNITY_MONTHLY_SESSION_LIMIT']\n current_monthly_session.save!\n return current_monthly_session\n end",
"def split_bills\n\t\t@results = @group.split_total_amt(current_user)\n\tend",
"def index\n @cal_month_sales = CalMonthSale.paginate(page: params[:page])\n end",
"def update_monthly_happiness_distributions! \n HappinessEntry.beginning_of_month_days.each do |beginning_of_month_day|\n uid = uid_for_month(beginning_of_month_day)\n end_of_month_day = beginning_of_month_day.end_of_month\n entries_for_month = HappinessEntry.in_month(beginning_of_month_day, end_of_month_day)\n update_happiness_distribution! uid, :month, entries_for_month \n end\n end",
"def index\n @sales = current_user.sales.ordered_by_most_recent.includes(:groups)\n @groups = Group.all\n # @total = @sales.total\n end",
"def invoiced_for(m)\n d = Date.parse(m)\n self.invoices.within_range(d, ((d + 1.month) - 1.day)).sum(:total)\n end",
"def calories_month(db, member_id)\n total_calories= []\n this_month = Time.now.strftime(\"%m\") \n calories_date= db.execute(\"SELECT * FROM calories WHERE member_id='#{member_id}' AND month='#{this_month}' \")\n calories_date.each do |cals|\n total_calories << cals['amt_burned']\n end \n total_calories.inject(:+)\nend",
"def totals_by_month_year\n revenue = Hash.new { |hash, key| hash[key] = {} }\n leases_by_year.each do |lease|\n lease.each do |year, months|\n months.each do |month, rent|\n revenue[year][month] ? revenue[year][month] += rent : revenue[year][month] = rent\n end\n end\n end\n revenue\n end",
"def income_this_month\n Sale.past_month.sum(:total)\n end",
"def hours_for_all_users(month_nr: nil, year: nil, of_kind:)\n require 'ostruct'\n sum = []\n if month_nr && year\n users.each do |u|\n sum_hours_for_user(user: u, month_nr: month_nr, year: year, of_kind: of_kind)\n hour = build_sum_for_user(u)\n sum << hour unless hour.blank?\n end\n else\n users.each do |u|\n sum_hours_for_user_total(user: u, of_kind: of_kind)\n hour = build_sum_for_user(u)\n sum << hour unless hour.blank?\n end\n end\n sum\n end",
"def spent_hours_for_user_this_month\n return @spent_hours_for_user_this_month if defined?(@spent_hours_for_user_this_month)\n\n @spent_hours_for_user_this_month = nil\n\n return @spent_hours_for_user_this_month if user_id.blank?\n\n date_filter = Date.today\n\n @spent_hours_for_user_this_month = TimeEntry.\n where(:project_id => self.project_id).\n where(:user_id => self.user_id).\n where(:tyear => date_filter.year).\n where(:tmonth => date_filter.month).\n sum(:hours)\n end",
"def this_month(limit: 5, markdown: false, rank: :top) \r\n \r\n puts 'inside this_mponth'.info if @debug\r\n coins = sort_coins('30d', limit: limit, rank: rank)\r\n build_table coins, markdown: markdown\r\n\r\n end",
"def show\n if (!current_user.is_super_admin && !current_user.is_admin)\n redirect_to posts_path\n return\n end\n\n @user = User.find(params[:id])\n\n posts = Post.where(:created_by => @user.id)\n comments = Comment.where(:created_by => @user.id)\n votes_posts = VotesPost.where(:user_id => @user.id)\n votes_comments = VotesComment.where(:user_id => @user.id)\n\n #posts_per_month = posts.count(:group => \"strftime('%m', created_at)\")\n #comments_per_month = comments.count(:group => \"strftime('%m', created_at)\")\n #votes_posts_per_month = votes_posts.count(:group => \"strftime('%m', created_at)\")\n #votes_comments_per_month = votes_comments.count(:group => \"strftime('%m', created_at)\")\n\n\n #we need to change the method according to postgre so this method will not work in sqlite\n\n posts_per_month = posts.count(:group => \"extract(month from created_at)\")\n comments_per_month = comments.count(:group => \"extract(month from created_at)\")\n votes_posts_per_month = votes_posts.count(:group => \"extract(month from created_at)\")\n votes_comments_per_month = votes_comments.count(:group => \"extract(month from created_at)\")\n\n @a_posts_per_month = [0,0,0,0,0,0,0,0,0,0,0,0]\n @a_comments_per_month = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n @a_votes_per_month = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n\n posts_per_month.each do |key,value|\n @a_posts_per_month[key.to_i - 1] = value\n end\n\n comments_per_month.each do |key, value|\n @a_comments_per_month[key.to_i - 1] = value\n end\n\n votes_posts_per_month.each do |key, value|\n @a_votes_per_month[key.to_i - 1] = value\n end\n\n votes_comments_per_month.each do |key,value|\n @a_votes_per_month[key.to_i - 1] = @a_votes_per_month[key.to_i - 1] + value\n end\n\n puts '-----------------------------------------------------'\n puts @a_posts_per_month\n puts '-----------------------------------------------------'\n puts @a_comments_per_month\n puts '-----------------------------------------------------'\n puts @a_votes_per_month\n puts '-----------------------------------------------------'\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n format.json { render json: @a_posts_per_month}\n format.json { render json: @a_comments_per_month }\n format.json { render json: @a_votes_per_month }\n end\n end",
"def all_in_month(date)\n self.by_range(date.beginning_of_month, date.end_of_month).find(:all, :order => 'start_datetime asc, name asc')\n end",
"def monthly_stats(timeframe, end_datetime, sale_lease, type, &block)\n puts \"Monthly stats\"\n\n history = Array.new\n\n (1..number_of_months(timeframe)).each do |months_back|\n # Compute the month interval to search\n month_start = end_datetime - months_back.month\n month_end = month_start + 1.month\n\n # Push month's data to history\n puts \"Push\"\n history << block.call(month_start, month_end, sale_lease, type)\n end\n\n return history\n end",
"def months() 30 * days end",
"def converts_data(period_data = 'this_month')\n res = user_group_converts\n range, daily_report = period_data.to_s.report_period_to_range\n data = [[period_data.to_s.report_period_to_title, 'Members']]\n range.each{|d| data << [d.strftime(daily_report ? '%d' : '%Y-%m'), res.where(created_at: d.beginning_of_day..(daily_report ? d.end_of_day : d.end_of_month.end_of_day)).count(:id)] }\n data\n end",
"def single_customer_reports\n @id = params[:id] # stores customer id\n @user = User.find(@id)\n start_date = params[:start_date]\n if (start_date.nil?)\n @date_arr = @user.orders.all\n else\n end_date = params[:end_date]\n @date_arr = []\n @user.orders.each do |order|\n if (order.date.strftime(\"%Y-%m-%d\").to_date >= start_date.to_date && order.date.strftime(\"%Y-%m-%d\").to_date <= end_date.to_date)\n @date_arr.push(order)\n end\n end\n end\n end",
"def sales\n end",
"def transactions_by_month\n date = Date.parse(params[:date])\n @transactions = Order.all_transactions_for_month(date.month, date.year)\n respond_to do |format|\n format.html\n format.csv { send_data Order.transaction_csv(@transactions), { filename: \"#{date.strftime('%Y')}_#{date.strftime('%m')}_transactional_detail.csv\" } }\n end\n end",
"def fees(period = (Time.now.beginning_of_month - 1).beginning_of_month .. (Time.now.beginning_of_month - 1).end_of_month)\n subscription_payments.all(:conditions => { :created_at => period }).collect(&:affiliate_amount).sum \n end",
"def display_monthly(months:, nondiscuss:)\n months.sort.reverse.each do |month|\n data = get_mails_month(yearmonth: month, nondiscuss: nondiscuss)\n next if data.empty?\n _h1 \"board@ statistics for #{month} (total mails: #{data[MAILS].length + data[TOOLS].length})\", id: \"#{month}\"\n _div.row do\n _div.col_sm_6 do\n _ul.list_group do\n _li.list_group_item.active.list_group_item_info \"Top Ten Email Senders (from non-tool mails: #{data[MAILS].length})\"\n ctr = 0\n data[MAILCOUNT].each do |id, num|\n if num > (data[MAILS].length / 10)\n _li.list_group_item.list_group_item_warning \"#{id} wrote: #{num}\"\n else\n _li.list_group_item \"#{id} wrote: #{num}\"\n end\n ctr += 1\n break if ctr >= 10\n end\n end \n end\n _div.col_sm_6 do\n _ul.list_group do\n _li.list_group_item.list_group_item_info \"Tool Generated Emails (by type, total tool mails: #{data[TOOLS].length})\"\n data[TOOLCOUNT].each do |id, num|\n _li.list_group_item \"#{num} emails from #{id} tool\"\n end\n end\n end\n end\n end\nend",
"def each_june( n=1); each_monthnum(self.Jun,n); end",
"def index\n # still_relevent and month are define in the model\n @events = Event.still_relevent\n @event_months = @events.order(esdate: :asc).group_by(&:month)\n @page_by_mouths = @event_months.to_a.paginate(:page => params[:page], :per_page => 3)\n end",
"def get_month_trends(user, type)\n exclude = [id]\n exclude.concat user.get_voted_ids(month_range) unless user.blank?\n Fun.exclude_funs(exclude).where(published_at: month_range).filter_by_type(type).order('cached_votes_total DESC')\n end",
"def index\n billing_logs = Atmosphere::BillingLog.last_year\n\n @user = Atmosphere::User.find params[:user_id] if params[:user_id]\n billing_logs = billing_logs.where(user: @user) if @user\n\n billing_logs = billing_logs.sum_currency_by_month\n billing_logs = billing_logs.group_by { |x| x[0][0] }\n\n @data_series =\n if billing_logs.present?\n billing_logs.map do |bl_currency|\n {\n name: bl_currency.first,\n data: Atmosphere::BillingLog.month_data_series(bl_currency.second)\n }\n end\n else\n [{\n name: 'No consumption',\n data: [0] * 12\n }]\n end.to_json\n\n render partial: 'atmosphere/admin/funds/billing', format: :html\n end",
"def sales\n @sales ||= sales_history_table.css(\"tr\")[2..-2].map do |row|\n sale = Sale.new\n cells = row.search(\"td\").map(&:text)\n \n if cells.size == 4\n sale.sales_date = cells[0]\n sale.amount = cells[1][1..-1].gsub(',','').to_f\n sale.seller = cells[2]\n sale.buyer = cells[3]\n #add attribute buyer\n sale.save!\n end\n\n end\n end",
"def monthly_reset(db, user_name)\r\n add_to_cache(db, user_name)\r\n reset_actual_income(db, user_name)\r\n reset_expenses(db, user_name)\r\nend",
"def sales_quantity_amount_in_period(start_date, end_date, branch_id)\n if branch_id.present?\n sales = invoice_line_items.select(\"sum(quantity) as invoice_quantity, sum(amount) as invoice_amount\").joins(:invoice)\n .where(:invoices =>{:company_id=> company_id, :deleted => false, :invoice_status_id => [0,2,3,4], :invoice_date => start_date..end_date, :branch_id => branch_id})\n else\n sales = invoice_line_items.select(\"sum(quantity) as invoice_quantity, sum(amount) as invoice_amount\").joins(:invoice)\n .where(:invoices =>{:company_id=> company_id, :deleted => false, :invoice_status_id => [0,2,3,4], :invoice_date => start_date..end_date})\n end \n end",
"def get_product_sold_data start_date=nil, end_date=nil, step=nil\n start_date = (start_date || '2018-01-01').to_datetime.beginning_of_day\n end_date = (end_date || '2018-12-31').to_datetime.end_of_day\n step = (step || 'week').upcase\n\n Lineitem.where(\"created_at >= ? AND created_at <= ?\", start_date, end_date)\n .select(\"sku_id, #{step}(created_at) as period, SUM(quantity) as total\")\n .group('sku_id, period')\n end",
"def user_baptised_data(period_data = 'last_month')\n res = user_baptised_relationships\n range, daily_report = period_data.to_s.report_period_to_range\n data = [[period_data.to_s.report_period_to_title, 'Members']]\n range.each{|d| data << [d.strftime(daily_report ? '%d' : '%Y-%m'), res.where(baptised_at: d.beginning_of_day..(daily_report ? d.end_of_day : d.end_of_month.end_of_day)).count(:id)] }\n data\n end",
"def list_price_for_month(opts)\n #logger.debug 'enter list_price_for_month'\n if list_price == 0.0 || list_price.blank?\n return 0\n end\n startdate = start_date\n enddate = end_date\n month = opts[:month]\n year = opts[:year]\n days_in_month = BigDecimal(Time.days_in_month(month, year).to_s)\n\n #this month is before the start date\n return 0 if (startdate.month > month && startdate.year == year) || (startdate.year > year)\n #this month is after the end date\n return 0 if (enddate.month < month && enddate.year == year) || (enddate.year < year)\n\n if startdate.month == month && startdate.year == year\n #beginning month\n start_day = startdate.day\n else\n start_day = 1\n end\n\n if enddate.month == month && enddate.year == year\n #ending month\n end_day = enddate.day\n else\n end_day = days_in_month\n end\n\n days_covered = BigDecimal(((end_day - start_day) + 1).to_s)\n list_price * (days_covered / days_in_month) * BigDecimal(qty.to_s)\n end",
"def all_users\n @date = (params[:date])? Date.parse(params[:date]) : Date.today\n users_ungroup = User.all(:conditions => {:status => User::STATUS_ACTIVE}, :order => 'login').sort\n @user_counts = users_ungroup.size\n @reported = false\n @daily_todo_users_group = Array.new\n @daily_todo_groups = Group.all().sort\n @daily_todo_groups.each do |group|\n users_of_group = group.users.sort_by { |u| u.name }\n no_todo_users, todo_users = users_of_group.partition do |user|\n DailyTodo.first(:conditions => {:user_id => user.id, :date => @date}).nil?\n end\n\n hash_users_of_group = {:todo => todo_users, :no_todo => no_todo_users}\n @daily_todo_users_group.push(hash_users_of_group)\n # Check if the current user has written todo for this date\n @reported = @reported || todo_users.any? { |user|\n user.id == User.current.id\n }\n\n users_of_group.each do |user_of_group|\n users_ungroup.delete_if do |user_ungroup|\n user_ungroup.id == user_of_group.id\n end\n end\n end\n\n no_todo_ungroup_users, todo_ungroup_users = users_ungroup.partition do |user|\n DailyTodo.first(:conditions => {:user_id => user.id, :date => @date}).nil?\n end\n @daily_todo_users_ungroup = {:todo => todo_ungroup_users, :no_todo => no_todo_ungroup_users}\n @reported = @reported || todo_ungroup_users.any? do |user|\n user.id == User.current.id\n end\n end",
"def sales\n @orders = Order.where(seller: current_user).order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 48)\n respond_to do |format|\n format.html\n format.csv { send_data @orders.to_csv(@orders) } \n end\n end",
"def end_month\n @month += 1\n\n # produce\n production_vol = @factories.select { _2 }.map {|type, employees|\n case type\n when :manual\n employees[:junior] * 20 + employees[:intermediate] * 40 + employees[:senior] * 80\n when :semi\n employees[:junior] * 50 + employees[:intermediate] * 60 + employees[:senior] * 80\n when :full\n employees[:junior] * 80 + employees[:intermediate] * 80 + employees[:senior] * 80\n when :idle\n 0\n else\n raise 'Must not happen'\n end\n }.sum\n if @ingredient * 2 < production_vol\n production_vol = @ingredient * 2\n end\n\n @ingredient -= production_vol / 2\n\n if @ingredient + @product + production_vol <= @storage\n # good\n else\n # pay penalty\n @money -= 100 * (@ingredient + @product + production_vol - @storage)\n production_vol = @storage - @product - @ingredient\n end\n \n @product += production_vol\n\n # gain sales\n @contracts.each do |contract|\n (required_products, fee) = contract[current_month]\n if required_products <= @product\n # good\n @product -= required_products\n @money += fee\n else\n # penalty\n @money -= fee * 10\n end\n end\n\n # pay fees\n @money -= @storage / 100\n @money -= @factories.values.compact.map {|employees|\n employees[:junior] * 3 + employees[:intermediate] * 5 + employees[:senior] * 9\n }.sum\n\n if @money < 0\n puts 'Game over'\n elsif 1000 <= @money\n puts \"Game clear! #{month}\"\n else\n status()\n end\nend",
"def monthly_print_usage_by_user()\n return MicrosoftGraph::Reports::MonthlyPrintUsageByUser::MonthlyPrintUsageByUserRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def monthly_ledgers\n list_months.map {|my| Compta::MonthlyLedger.new(self, my)}\n end",
"def months ; self * 30.days ; end",
"def index\n @summaries = Summary.all\n @accounts = Account.all\n\n dailyTotals = DailyTotal.all\n monthlyTotals = MonthlyTotal.all\n\n # Calculating the monthly total by adding daily total values\n monthlyTotals.each { |mt|\n dailyTotals.each { |dt|\n if dt.date.year == mt.year && dt.date.month == mt.month\n mt.total += dt.total\n end\n } # end of inner dailyTotal loop\n } # end of monthlyTotal loop\n\n # For linechart to display monthly total spendings\n @mTotals = Array.new\n monthlyTotals.each { |mt|\n case mt.month\n when 1\n @mTotals.push([\"January\",mt.total.to_f])\n when 2\n @mTotals.push([\"February\",mt.total.to_f])\n when 3\n @mTotals.push([\"March\",mt.total.to_f])\n when 4\n @mTotals.push([\"April\",mt.total.to_f])\n when 5\n @mTotals.push([\"May\",mt.total.to_f])\n when 6\n @mTotals.push([\"June\",mt.total.to_f])\n when 7\n @mTotals.push([\"July\",mt.total.to_f])\n when 8\n @mTotals.push([\"August\",mt.total.to_f])\n when 9\n @mTotals.push([\"September\",mt.total.to_f])\n when 10\n @mTotals.push([\"October\",mt.total.to_f])\n when 11\n @mTotals.push([\"November\",mt.total.to_f])\n when 12\n @mTotals.push([\"December\",mt.total.to_f])\n end\n }\n\n @balanceSummary = Array.new\n @accounts.each { |account|\n @balanceSummary.push ([account.name,account.balance.to_f])\n }\n end",
"def monthly\n keys = redis.keys(\"#{prefix_monthly}:*\")\n keys.zip(redis.mget(keys)).inject({}) { |t,p| t.merge(p.first.sub(\"#{prefix_monthly}:\", '') => p.last.to_i) }\n end",
"def make_year_stats(months)\n rows = months.map{|month|\n items = Item.all(:conditions => {\n :date => month_range(month),\n :type => [\"Expense\", \"Income\"]\n }).group_by(&:category)\n\n make_row(month, items)\n }\n\n return rows.push make_sum_row(rows)\n end",
"def work_per_month(ary_work)\n nary = ary_work.group_by{ |t| \n t[:date] \n }.transform_values { |tasks|\n tasks.reduce(0) { |sum, t|\n sum + t[:time] \n }\n }.to_a.group_by { |e|\n e[0][0..6]\n }.transform_values { |tasks|\n tasks.reduce(0) { |sum, t|\n sum + t[1] \n } / tasks.length\n }\nend",
"def months_list\n unless @months_list\n months = []\n date = start_date\n while date <= end_date\n months << date\n date += 1.month\n end\n @month_list = months\n end\n\n @month_list\n end",
"def record_sales_records(report_data_file)\n\n # In case there are no records for this processor\n return if @records.nil?\n\n @records.each do |source, source_list|\n puts \"Recording sales for #{source}\"\n\n source_list.each do |year, year_list|\n year_list.each do |month, month_list|\n month_list.each do |country, country_list|\n country_list.each do |project_id, list_prices|\n list_prices.each do |list_price, projects_list|\n projects_list.each do |kdp_transaction_type, kdp_transactions|\n kdp_transactions.each do |kdp_royalty_type, records|\n\n if (! defined? @monthly_sales) || (@monthly_sales.nil?)\n @monthly_sales = ReportDataMonthlySales.new\n end\n\n # These are all of records for the project\n records.each do |row|\n\n if ! @monthly_sales.nil? && @monthly_sales.is_valid.nil?\n @monthly_sales.is_valid = true\n @monthly_sales.report_data_file = report_data_file\n @monthly_sales.report_data_source = get_report_data_source_model(source)\n @monthly_sales.report_data_country = get_report_data_country_model(country) unless country.nil?\n @monthly_sales.year = year\n @monthly_sales.month = month\n @monthly_sales.project_id = project_id unless project_id == 0\n @monthly_sales.list_price = list_price || 0.0\n @monthly_sales.report_data_kdp_type = get_report_data_kdp_transaction_type_model(kdp_transaction_type, kdp_royalty_type)\n end\n\n ## Sum the totals here\n @monthly_sales.quantity += row.quantity unless row.quantity.nil?\n @monthly_sales.revenue += row.revenue_usd unless row.revenue_usd.nil?\n\n end\n # save the record after we've totaled everything up, then reset\n @monthly_sales.save\n @monthly_sales = nil\n\n end\n end\n end\n end\n end\n end\n end\n end\n # End of @records loop\n\n end",
"def relatorio\n @users = User.all\n @total_por_usuario = []\n\n @users.each do |user| \n @pontos = Ponto.where(\"user_id = ?\", user.id)\n .by_month(Time.now.strftime(\"%B\"), field: :created_at)\n .order(\"created_at asc\")\n\n @segundos = 0\n\n @pontos.each do |ponto|\n if ponto.situacao == \"Entrada\"\n @entrada = ponto.data_hora\n else\n @saida = ponto.data_hora\n @segundos += TimeDifference.between(@entrada, @saida).in_seconds.to_i if (@entrada && @saida )\n end\n end\n\n @total_por_usuario.push ({user => (@segundos/3600).to_i.to_s.rjust(2,'0') + \":\"+Time.at(@segundos).utc.strftime(\"%M:%S\") })\n end\n end",
"def monthly_ledgers\n @monthly_ledgers ||= period.monthly_ledgers\n end",
"def event_tickets_sold_data(period_data = 'this_month')\n res = event_payments\n range, daily_report = period_data.to_s.report_period_to_range\n data = [[period_data.to_s.report_period_to_title, I18n.t('number.currency.format.unit')]]\n range.each{|d| data << [d.strftime(daily_report ? '%d' : '%Y-%m'), res.where(payment_at: d.beginning_of_day..(daily_report ? d.end_of_day : d.end_of_month.end_of_day)).sum(:amount).to_f] }\n data\n end",
"def my_sales\n @listings = current_user.listings.joins(:purchase).merge(Purchase.all).page(params[:page]).per(30)\n end",
"def month()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Month::MonthRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def each_july( n=1); each_monthnum(self.Jul,n); end"
] |
[
"0.640086",
"0.63520414",
"0.6327773",
"0.6317694",
"0.6256589",
"0.62173945",
"0.60382235",
"0.59575677",
"0.5845607",
"0.5806844",
"0.5791221",
"0.57600045",
"0.57464075",
"0.57354254",
"0.5715706",
"0.5715122",
"0.5680918",
"0.56787455",
"0.56756973",
"0.566112",
"0.5658563",
"0.56473446",
"0.5634062",
"0.5622001",
"0.5608897",
"0.5596829",
"0.55932695",
"0.55850416",
"0.5568889",
"0.55683035",
"0.5524933",
"0.55076253",
"0.5475862",
"0.5473885",
"0.54730266",
"0.54712623",
"0.54709107",
"0.54672444",
"0.54642534",
"0.5445121",
"0.54428345",
"0.5437461",
"0.54360133",
"0.5433519",
"0.5428494",
"0.54202867",
"0.54183257",
"0.5416222",
"0.53993577",
"0.5398036",
"0.5389707",
"0.53715384",
"0.53627145",
"0.535523",
"0.5352758",
"0.5342388",
"0.5328659",
"0.52991265",
"0.5291563",
"0.52908766",
"0.5287163",
"0.52698",
"0.5260057",
"0.5259628",
"0.52569884",
"0.52565193",
"0.52535",
"0.5249495",
"0.5249325",
"0.52443963",
"0.5244385",
"0.5240252",
"0.5239747",
"0.5236792",
"0.5234954",
"0.52348506",
"0.5234008",
"0.52251315",
"0.5217532",
"0.5215813",
"0.5209216",
"0.52082044",
"0.5199676",
"0.51933044",
"0.51887804",
"0.5185258",
"0.51850367",
"0.51835555",
"0.51830095",
"0.51726913",
"0.51701295",
"0.51690143",
"0.51673734",
"0.5165164",
"0.51554424",
"0.514912",
"0.5131558",
"0.51311284",
"0.51287186",
"0.51286864"
] |
0.7071074
|
0
|
Get the current user statement.
|
def user_statement
response = get 'v1/market/private/user/statement.json'
response[:statement]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def current_user\n\n sql = \"SELECT * FROM users WHERE id = $1;\"\n \n results = run_sql(sql, [session[:user_id]]) \n return results.first\n end",
"def current_user\n select_value(<<~SQL.squish, \"SCHEMA\")\n SELECT SYS_CONTEXT('userenv', 'session_user') FROM dual\n SQL\n end",
"def current_user\n ActiveRecord::Base.current_user_proc.call if ActiveRecord::Base.current_user_proc\n end",
"def current_user\n ActiveRecord::Base.current_user_proc.call if ActiveRecord::Base.current_user_proc\n end",
"def current_user\n if session[:user_id] == nil\n return {}\n end\n\n # ruby - implicit return\n return run_sql(\"SELECT * FROM users WHERE id = #{session[:user_id]};\")[0]\nend",
"def current_alchemy_user\n raise NoCurrentUserFoundError if !defined?(current_user)\n current_user\n end",
"def current_user\n get_from_options_or_controller(:current_user)\n end",
"def user\n return Etc.getlogin\n end",
"def me\n context[:current_user]\n end",
"def get_current_user\n return Account.find_by(user_name: session[:current_user].user_name)\n end",
"def user\n Thread.current[\"current_user\"] \n end",
"def current_user\n\t\t\tUser.find(session[:user_id])\n\t\tend",
"def current_user\n\t\t\tUser.find(session[:user_id])\n\t\tend",
"def user_method\n current_user\n end",
"def current_user\n\t\t@current_user ||= User.find(session[:user_id]) if session[:user_id]\n\t\tputs @current_user\t\n\tend",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def user\r\n return for_context(nil, false) { |c| c.user }\r\n end",
"def current_user\n @current_user\n end",
"def current_user\n\t\t\tUser.find_by_id(session[:user_id])\n\t\tend",
"def current_user\n User.where(id: session[:user_id]).first\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\n\t\tUser.find_by(:id => session[:user_id])\n\tend",
"def current_user\n User.get_user(session[:user_id]) if session[:user_id]\n end",
"def current_user\n @current_user ||= begin\n if session[:user_id]\n user = User.where(id: session[:user_id])\n user[0] if user.any?\n end\n end\n # @current_user ||= User.find session[:user_id] if session[:user_id]\n end",
"def current_user\n\tputs \"*** current_user ***\"\n\tif session[:user_id]\n\t\t@current_user = User.find(session[:user_id])\n\t\tputs \"@current_user: #{@current_user}\"\n\telse\n\t\t@current_user = nil\n\t\tputs \"@current_user: #{@current_user}\"\n\tend\nend",
"def current_user\n @current_user\n end",
"def current_user\n @current_user\n end",
"def current_user\n session.user\n end",
"def current_user\n return @current_user\n end",
"def operation_user\n current_user if respond_to?(:current_user)\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 if session[:user_id]\n User.find(session[:user_id])\n else\n nil\n end\n end",
"def current_user\n if session[\"warden.user.user.key\"]\n @current_user ||= User.find(session[\"warden.user.user.key\"][0][0])\n elsif session[\"warden.user.student.key\"]\n @current_user ||= User.find(session[\"warden.user.student.key\"][0][0])\n elsif session[\"warden.user.expert.key\"]\n @current_user ||= User.find(session[\"warden.user.expert.key\"][0][0])\n end\n end",
"def current_user\n User.where(email: \"[email protected]\").first\n end",
"def current_user\n @current_user\n end",
"def current_user\n current_account\n end",
"def current_user\n User::TYPES.each do |mapping|\n user = self.send(\"current_#{mapping.to_s.downcase}\")\n return user unless user.nil?\n end\n end",
"def current_user\n if session[:user_id]\n User.find_by(id: session[:user_id])\n end\n end",
"def current_user\n load_session\n @current_user\n end",
"def current_user(m)\n bot.config.authentication.logged_in[m.user]\n end",
"def user\n\t\t\treturn nil if ! logged_in?\n\n\t\t\tPicombo::Session.instance.get('user')\n\t\tend",
"def current_user\n session[:user]\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n session[:who_is_this]\n end",
"def current_user\n p session\n @current_user ||= User.find(session[\"warden.user.user.key\"][0][0]) if session[\"warden.user.user.key\"][0][0]\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 audit_user\n user = ::Sequel::Auditer::Railtie.user\n\n m = Kernel.const_get(associated_type)\n u = m.send(m.auditer_current_user_method) || send(m.auditer_current_user_method)\n return u unless u.nil?\n return user if u.nil? && !user.nil?\n\n nil\n rescue StandardError\n nil\n end",
"def current_user\n current_user ||= User.find(session[:user_id]) if session[:user_id]\n# OrderSummary.db_selection(current_user)\n return current_user\n end",
"def current_user\n if session[:user_id]\n User.find(session[:user_id])\n else\n end\n end",
"def current_user\n current_session.user\n end",
"def current_user\n @current_user if logged_in?\n end",
"def current_user\n @current_user if logged_in?\n end",
"def current_user\n if session[:type] == \"student\"\n current_student()\n elsif session[:type] == \"professor\"\n current_professor()\n else\n @current_user = \"ERROR: NO USER TYPE\"\n end\n end",
"def current_user\n User.all(public_key: security.public_key).first\n end",
"def current_user\n\tUser.find_by(id: session[:user_id])\n end",
"def current_user\n @current_user ||= ::User.send(\"find_by_#{self.identifier_attribute}!\", session[identifier_name])\n rescue ActiveRecord::RecordNotFound\n nil\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 @current_user || User.find(session[:user_id]) if session[:user_id]\n \tend",
"def current_user\n return unless session[:user_id]\n User.find(session[:user_id])\n end",
"def current_user\n session[:name]\n end",
"def current_user\n\t\t@current_user ||= User.find_by_id(session[:userId]) #CTDUserRepository.GetCTDUserById(session[:userId])\n\tend",
"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 ||= User.find(session[:user_id]) if session[:user_id]\n # ||= is used for memoization of @current_user variable\n end",
"def current_user\n @req.env['REMOTE_USER']\n end",
"def current_user\n @current_user ||= Resident.where(id: session[:user_id], community_id: session[:commune_id])\n end",
"def current_user\n\tif(session[:user_id])\n\t\t@u ||= User.first(id: session[:user_id])\n\t\treturn @u\n\telse\n\t\treturn nil\n\tend\nend",
"def current_user\n\tif(session[:user_id])\n\t\t@u ||= User.first(id: session[:user_id])\n\t\treturn @u\n\telse\n\t\treturn nil\n\tend\nend",
"def current_user\n\tif(session[:user_id])\n\t\t@u ||= User.first(id: session[:user_id])\n\t\treturn @u\n\telse\n\t\treturn nil\n\tend\nend",
"def current_user\n\tif(session[:user_id])\n\t\t@u ||= User.first(id: session[:user_id])\n\t\treturn @u\n\telse\n\t\treturn nil\n\tend\nend",
"def current_user\n authentication.account\n end",
"def current_user\n logger.warn \"WARNING: User#current is not defined, are you including SentientUser on your User model?\" unless User.respond_to?(:current)\n logger.warn \"WARNING: User#current is nil, are you including SentientController on your ApplicationController?\" unless User.current\n\n User.current\n end",
"def user\n return ENV['USER']\n end",
"def current_user\n current_login_credential\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 self.class.current_user\n end",
"def current_user\n abort \"You have no current user set!\".yellow unless current_user_exists?\n config.current_user\n end",
"def current_user\n session[:usr_id]\n end",
"def current_user_name\n logged_in? ? (user_name(current_user_id) || current_user_id) : nil\n end",
"def client_side_current_user\n if session[:user_id]\n User.select([:first_name, :last_name, :email]).find session[:user_id]\n end\n end",
"def current_user\n if session[:user_id]\n return User.find(session[:id])\n else\n return nil\n end\n end",
"def current_user\r\n\tif(session[:user_id])\r\n\t\t@u ||= User.first(id: session[:user_id])\r\n\t\treturn @u\r\n\telse\r\n\t\treturn nil\r\n\tend\r\nend",
"def current_user\n User.find(session[:user_id]) if session[:user_id]\n end",
"def current_user\n User.find(session[:user_id]) if session[:user_id]\n end",
"def current_user\n session[:name] #all i need here (looked at some other solutions to get this)\n end",
"def current_user\n if @current_user.nil?\n if ( ! session[ApplicationController::KEY_CURRENT_USER_ID].blank? )\n user_class = session[ApplicationController::KEY_CURRENT_USER_CLASS];\n return nil if user_class.blank?\n @current_user = user_class.instance_eval( \"#{user_class}.find(#{session[ApplicationController::KEY_CURRENT_USER_ID]})\" );\n end\n end\n return @current_user;\n end",
"def user_for_audit_me\n current_user rescue nil\n end",
"def current_user\n\n \tif session[:user_id].present?\n \t\tUser.find(session[:user_id])\n\n \tend\n\n end",
"def current_user\n @current_user ||= User.find_by(\n username: session[:user]['name']) unless session[:user].nil?\n end",
"def current_user(id = session[:user_id])\n User.get_one id\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 @current_user || = User.find(session[:user_id]) if session[:user_id]\n end",
"def current_user\n @current_user ||= context[:current_user]\n end",
"def current_user\n @current_user ||= current_user_session.record unless current_user_session.nil?\n end",
"def current_user\n \t@current_user || User.find(session[:user_id]) if session[:user_id]\n end",
"def current_user\n puts \"******* current_user *******\"\n if session[:user_id]\n @current_user = User.find(session[:user_id])\n else\n @current_user = nil\n end\n puts \"@current_user: #{@current_user.inspect}\"\n end",
"def current_user\n @_current ||= User.find_by(id: session[:user_id])\n end",
"def current_user\n \treturn @current_user if defined? @current_user\n \t@current_user = User.first\n end"
] |
[
"0.6978634",
"0.69378936",
"0.6421363",
"0.6327919",
"0.62573993",
"0.61917335",
"0.61510605",
"0.6137188",
"0.60869527",
"0.6051322",
"0.6030262",
"0.59958935",
"0.59958935",
"0.5987161",
"0.5957113",
"0.5948124",
"0.5948124",
"0.59389746",
"0.593767",
"0.592784",
"0.59208035",
"0.59083384",
"0.5906713",
"0.5906271",
"0.58774716",
"0.5870905",
"0.58667606",
"0.58667606",
"0.5860673",
"0.58585286",
"0.58536506",
"0.5847519",
"0.5825426",
"0.5822982",
"0.58200693",
"0.58150274",
"0.5813747",
"0.58125013",
"0.5807252",
"0.58062446",
"0.57967234",
"0.5790015",
"0.57862186",
"0.57814443",
"0.57814443",
"0.57814443",
"0.5777006",
"0.5767526",
"0.5761203",
"0.57502323",
"0.57480055",
"0.5746988",
"0.5732806",
"0.5730768",
"0.5730768",
"0.5724485",
"0.5724414",
"0.57239264",
"0.5720915",
"0.5720577",
"0.5718652",
"0.571721",
"0.5716794",
"0.57135946",
"0.5713095",
"0.5712066",
"0.5710989",
"0.5707992",
"0.56999564",
"0.56999564",
"0.56999564",
"0.56999564",
"0.56958026",
"0.56910384",
"0.56861514",
"0.56857836",
"0.56841576",
"0.5680598",
"0.56785834",
"0.5677954",
"0.5672882",
"0.5671178",
"0.56702334",
"0.5670166",
"0.56698525",
"0.56698525",
"0.56688213",
"0.5666351",
"0.5662798",
"0.5661354",
"0.56550837",
"0.5652988",
"0.5652019",
"0.56514525",
"0.5648774",
"0.56474334",
"0.5646936",
"0.5646198",
"0.5640986",
"0.56384796"
] |
0.7187033
|
0
|
The "timeslist" stores an array of decimal numbers representing the time in seconds for a worker duration time. Whenever the "timeslist" exceeds the stipulated max length it is going to remove 25% of the last values inside the array.
|
def release_cache_allocation(redis, timelist_length)
max_timelist_length = Sidekiq::Statistic.configuration.max_timelist_length
if timelist_length > max_timelist_length
redis.ltrim(@keys.timeslist, 0, (max_timelist_length * 0.75).to_i)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def remove_times(event)\n\t\tevent.times.each do |t|\n\t\t\tif t[1].to_i-t[0].to_i < event.length\n\t\t\t\tevent.times.delete(t)\n\t\t\tend\n\t\tend\n\tend",
"def most_free_time(arr)\n free_times = []\n arr = arr.map do |event|\n start_time, end_time = event.split('-')\n [time_to_minutes(start_time), time_to_minutes(end_time)]\n end.sort\n 1.upto(arr.size - 1) do |idx|\n free_times << arr[idx].first - arr[idx -1].last\n end\n most = free_times.max\n hours, mins = most.divmod(60)\n \"#{format('%02d', hours)}:#{format('%02d', mins)}\"\nend",
"def next_times(count)\n\n next_time ? [ next_time ] : []\n end",
"def recalc_times(starting_at=0, list=@events)\n\tt = (starting_at == 0) ? 0 : list[starting_at - 1].time_from_start\n\tlist[starting_at .. -1].each { | e |\n\t t += e.delta_time\n\t e.time_from_start = t\n\t}\n end",
"def get_times_array(padding = true)\n @times = (padding) ? [@start_dt - 1.hour] : [@start_dt]\n \n # and including every 1/2 hour until one hour after the selected end time\n while true do\n tmp = @times.last + 30.minutes\n (padding) ? (tmp == (@end_dt + 1.hour)) ? break : '' : (tmp == @end_dt) ? break : ''\n @times.push(tmp)\n end\n end",
"def recalc_times(starting_at=0, list=@events)\n t = (starting_at == 0) ? 0 : list[starting_at - 1].time_from_start\n list[starting_at .. -1].each do |e|\n t += e.delta_time\n e.time_from_start = t\n end\n end",
"def times\n\t\t\tprogram = pop\n\t\t\tn = pop\n\t\t\traise ArgumentError, \"TIMEs: second element is not an Array.\" unless program.is_a? Array\n\t\t\tn.times { ~program.dup }\n\t\tend",
"def sort_times(times) #takes an array of times as floats (in seconds )\n\ttimes_in_sec = times.map { |time| to_sec(time) }.sort \nend",
"def next_time_slots\n\t\ttime_slot_array = self.timeslots\n\t\ttime_slot_array.drop_while do |x|\n\t\t\tx[0].split(\"-\")[0].to_time < Time.now\n\t\tend\n\tend",
"def generate_time\n\t\tret = Array.new\n\t\tcount unless @fileinfo[:count]\n\t\ttrigger unless @fileinfo[:trigger]\n\t\tsampling unless @fileinfo[:sampling]\n\n\t\t(0..@fileinfo[:count] - @fileinfo[:trigger] - 1).each {|i| \n\t\t\tret << (i * @fileinfo[:sampling] * 1e-6)\n\t\t}\n\t\treturn ret\n\tend",
"def recalc_delta_from_times(starting_at=0, list=@events)\n\tprev_time_from_start = 0\n\tlist[starting_at .. -1].each { | e |\n\t e.delta_time = e.time_from_start - prev_time_from_start\n\t prev_time_from_start = e.time_from_start\n\t}\n end",
"def truncate_samples\n @samples.sort!{|a,b| a.duration <=> b.duration}\n @samples.slice!(0..-(max_capacity + 1))\n end",
"def times_for_send_update_requests(start_time, end_time)\n times = []\n\n task_time = start_time.beginning_of_hour + 30.minutes\n task_time += 1.hour if task_time < start_time\n\n while task_time < end_time\n times << task_time\n task_time += 1.hour\n end\n\n times\n end",
"def gs2_run_times\n\t\t\traise FluxOptionError.new(\"gs2_run_times called and flux_option != gs2\") if not flux_gs2?\n\t\t\trun_times = []\n\t\t\tFile.open(@directory + '/' + output_file, \"r\").each_line{|l| l.scan(/Job.*timer.*(\\b\\d+\\.\\d+\\b)/){run_times.push $~[1].to_f}}\n\t\t\tsz = run_times.size.to_f\n\t\t\treturn run_times.pieces((sz / n_flux_tubes.to_f).ceil)\n\n\t\tend",
"def trim_times(event,v1,v2)\n\t\tevent.times.each do |t|\n\t\t\tif t[0]==v1 && t[1]==v2\n\t\t\t\tevent.times.delete(t)\n\t\t\telsif t[0] >= v1 && t[0] < v2\n\t\t\t\tt[0] = v2\n\t\t\telsif t[1] <= v2 && t[1] > v1\n\t\t\t\tt[1] = v1\n\t\t\telsif t[0] < v1 && t[1] > v2\n\t\t\t\ttemp = t[1]\n\t\t\t\tt[1] = v1\n\t\t\t\tevent.times.push([v2,temp])\n\t\t\tend\n\t\tend\n\tend",
"def list_checker(partial_list, suggested_schedule = [], time_remaining = 8)\n partial_list.each do |meeting|\n time_remaining = time_remaining - meeting[:duration]\n\n if time_remaining < 0\n # This would be done differently in production, but I feel this is a sufficient way to end the method early for this exercise\n return [\"These meetings can't fit into one business day! Consider taking a nap.\", -1]\n else\n start_time = clock_converter(time_remaining + meeting[:duration])\n end_time = clock_converter(time_remaining)\n\n suggested_schedule << start_time + \" - \" + end_time + \" - \" + meeting[:name]\n\n time_remaining = time_remaining - 0.5 if meeting[:type] == :offsite\n end\n end\n\n return [suggested_schedule, time_remaining]\nend",
"def time\n\talltime = Array.new\n\tslices = 10\n\ti = 0\n\twhile i < slices.to_i do\n\t\talltime.push(Time.now)\n\t\ti+=1\n\tend\n\tyield\nend",
"def compact_times_available\n self.times_available = self.times_available.compact\n end",
"def recalc_delta_from_times(starting_at=0, list=@events)\n prev_time_from_start = 0\n # We need to sort the sublist. sublist.sort! does not do what we want.\n # We call mergesort instead of Array.sort because sort is not stable\n # (it can mix up the order of events that have the same start time).\n # See http://wiki.github.com/adamjmurray/cosy/midilib-notes for details.\n list[starting_at .. -1] = MIDI::Array.new(list[starting_at .. -1]).mergesort do |e1, e2|\n e1.time_from_start <=> e2.time_from_start\n end\n list[starting_at .. -1].each do |e|\n e.delta_time = e.time_from_start - prev_time_from_start\n prev_time_from_start = e.time_from_start\n end\n end",
"def terminate_timeout\n workers.map(&:stop_timeout).compact.max.to_i + 10\n end",
"def _nudge\n frames = @total\n secs = (@total.to_f/@fps).floor\n frames-=(secs*@fps)\n mins = (secs/60).floor\n secs -= (mins*60)\n hrs = (mins/60).floor\n mins-= (hrs*60)\n \n raise RangeError, \"More than 59 minutes\" if mins > 59 \n raise RangeError, \"More than 59 seconds\" if secs > 59\n raise TimecodeLibError, \"More than #{@fps.to_s} frames (#{frames}) in the last second\" if frames >= @fps\n raise RangeError, \"Timecode cannot be longer that 99 hrs\" if hrs > 99 \n \n [hrs, mins, secs, frames]\n end",
"def get_timeslots_12hrs\n \t#create the new array\n \t@timeslots_12hrs = Array.new\n\n for i in [email protected]\n @temp_holder = @timeslots[i].split(':')\n @temp_holder[0] = @temp_holder[0].to_i\n if @temp_holder[0] > 12\n @temp_holder[0] = @temp_holder[0] - 12\n @timeslots_12hrs.push(@temp_holder[0].to_s + \":\" + @temp_holder[1] + \"pm\")\n elsif @temp_holder[0] == 12\n @timeslots_12hrs.push(@temp_holder[0].to_s + \":\" + @temp_holder[1] + \"pm\")\n else\n @timeslots_12hrs.push(@timeslots[i] + \"am\")\n end\n end\n\n return @timeslots_12hrs\n end",
"def job_durations(success=true)\n Resque.redis.lrange(jobs_duration_key(success),0,durations_recorded - 1).map(&:to_f)\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 run_end_time\n end_times =\n @data['controls'].map do |control|\n control['results'].map { |result| end_time(result['start_time'], result['run_time']) }\n end\n\n end_times.flatten.max\n end",
"def queue_time(customers, n)\n checkout = Array.new(n,0)\n customers.each {|e| checkout[checkout.index(checkout.min)] += e }\n checkout.max\nend",
"def call_times(times)\n raise '#call_times should be redefined per Benchmark::IPS::Job::Entry instance'\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",
"def missing_list\n list = []\n regular_workers.each do |w|\n if w.sum_time_in_seconds(DateTime.now - 14.days, DateTime.now) == 0\n list << w\n end\n end\n return list\n end",
"def split_playtime(start)\r\r\n number = []\r\r\n number[0] = start / 60 / 60\r\r\n number[1] = start / 60 % 60\r\r\n number[2] = start % 60\r\r\n return number\r\r\n end",
"def get_timeslots_12hrs\n #create the new array\n timeslots_12hrs = Array.new\n\n for i in [email protected]\n temp_holder = @timeslots[i].split(':')\n temp_holder[0] = temp_holder[0].to_i\n\n if temp_holder[0] > 12\n temp_holder[0] = temp_holder[0] - 12\n timeslots_12hrs.push(temp_holder[0].to_s + \":\" + temp_holder[1] + \"pm\")\n elsif temp_holder[0] == 12\n timeslots_12hrs.push(temp_holder[0].to_s + \":\" + temp_holder[1] + \"pm\")\n else\n timeslots_12hrs.push(@timeslots[i] + \"am\")\n end\n end\n\n return timeslots_12hrs\n end",
"def split_playtime(start)\n number = []\n number[0] = start / 60 / 60\n number[1] = start / 60 % 60\n number[2] = start % 60\n return number\n end",
"def queue_time(customers, n)\n # n個の要素をもつ配列を作成する\n arr = Array.new(n, 0)\n # 配列の要素で最小の所にcustomerを入れていき、customersを全て格納した配列を作成する。\n # arr.index(arr.min)で配列内で最小の要素のインデックスを取得する\n customers.each do |customer|\n arr[arr.index(arr.min)] += customer \n end\n # 作成した配列の最大値(最大作業時間)を取得する\n arr.max\nend",
"def max24help(ints, time=[], rem = [])\n p 'X'\n max = {0=>2,1=>9,2=>5,3=>9}\n # binding.pry\n return format_time(time) if time.length == 4\n ints_less_than_max = ints.select do |el|\n if time.length == 1 && time[0] == 2\n el <= 3\n else\n el <= max[time.length]\n end\n end\n if ints_less_than_max.empty?\n if time.empty?\n return nil\n else\n rem << time.pop\n ints << rem.shift if rem.length > 1\n end\n else\n int = ints_less_than_max.pop\n ints.delete_at(ints.index(int) || ints.length)\n ints = ints.concat(rem).sort\n time << int\n end\n max24help(ints, time, rem)\nend",
"def watch_frequency\n starts, ends = start_times, end_times\n start_index, end_index = 0, 0\n frequencies = []\n active_intervals = 0\n return [] if end_times.empty?\n (0..end_times.last).each do |video_time|\n start_advance = elements_till(starts, start_index) { |time| time <= video_time }\n end_advance = elements_till(ends, end_index) { |time| time < video_time }\n\n active_intervals += start_advance - end_advance\n start_index += start_advance\n end_index += end_advance\n\n frequencies << active_intervals\n end\n frequencies\n end",
"def beautiful_times()\n count = @options.count\n\n # Is the target count minute aligned?\n if count % 60 != 0\n return count # Not minute aligned.\n end\n\n # Is the target count hour aligned?\n minutes = count / 60\n if 60 % minutes != 0\n return count # Not hour aligned.\n end\n\n # See if we are already suitably aligned right now.\n now = Time.now\n mm = now.min\n ss = now.sec\n if mm % minutes == 0 && 1 <= ss && ss <= 50\n return count # Now is minute aligned and within minute drift limits.\n end\n\n # Target 10 seconds into the next aligned minute.\n short_mm = minutes - (mm % minutes)\n count = (short_mm * 60) + 10 - ss\n return count\n end",
"def missing_list\n list = []\n active_workers.each do |w|\n if w.sum_time_in_seconds(DateTime.now - 14.days, DateTime.now) == 0\n list << w\n end\n end\n return list\n end",
"def len\n timevec.length\n end",
"def restore_times; end",
"def restore_times; end",
"def get_block_time_list(filename)\n to_return = []\n lines = File.open(filename, \"rb\") {|f| f.read.split(/\\n+/)}\n lines.each do |line|\n next if line !~ /^Block times/\n values = []\n # Block times are given as a space-separated list of start,end pairs. They\n # are in units of seconds * 1e5, so convert them to seconds here for\n # consistency.\n if line =~ /^[^:]+: (.*?)\\s*$/\n values = $1.split(\" \").map{|r| r.split(\",\").map{|v| v.to_f / 1e5}}\n end\n to_return << values\n end\n to_return\nend",
"def time_fragments\n []\n end",
"def get_time_slot_array\n time_slot_array = [\"07:00\", \"07:30\", \"08:00\", \"08:30\", \"09:00\", \"09:30\", \"10:00\", \"10:30\",\n \"11:00\", \"11:30\", \"12:00\", \"12:30\", \"13:00\", \"13:30\", \"14:00\", \"14:30\",\n \"15:00\", \"15:30\", \"16:00\", \"16:30\", \"17:00\", \"17:30\", \"18:00\", \"18:30\",\n \"19:00\", \"19:30\", \"20:00\", \"20:30\", \"21:00\"]\n end",
"def get_LCV(assignments, member, times)\n\t\tlcv = []\n\t\tmin_capacity = 1000000\n\t\ttimes.each do |time|\n\t\t\tcapacity = 0\n\t\t\tif assignments.has_key?(time)\n\t\t\t\tcapacity = assignments[time].length\n\t\t\tend\n\t\t\tif capacity < min_capacity\n\t\t\t\tmin_capacity = capacity\n\t\t\t\tlcv = [time]\n\t\t\telsif capacity == min_capacity\n\t\t\t\tlcv << time\n\t\t\tend\n\t\tend\n\n\t\tlcv = lcv.sample\n\t\treturn lcv\n\tend",
"def getTimes()\n return @times\n end",
"def burned_time\n minutes_to_human_readable_time(entries.internal.sum :duration)\n end",
"def prune_old_values(current_time)\n pruning_time = current_time - @time_interval\n @logger.info(\"Pruning time: #{Time.at(pruning_time).to_s}\")\n # iterate over the queue and remove values that are older than 2 minutes\n @queue.delete_if {|ts| ts < pruning_time} \n end",
"def default_time_slots\n start_time = Time.parse(\"9:00\")\n end_time = Time.parse(\"20:30\")\n slots = []\n t = start_time\n while t <= end_time\n slots << t.strftime(\"%H:%M\")\n t += 30.minutes;\n end\n\n slots\n end",
"def compute_earliest_time(file_list)\n limit_time = Time.at(0)\n return limit_time if file_list.empty?\n unless limit.nil?\n limit_time = latest_time(file_list) - limit * freq_seconds\n end\n [limit_time, file_list.last.timestamp - range].max\n end",
"def times_for_schedule_update_requests(start_time, end_time)\n times = []\n\n task_time = start_time.beginning_of_day + 15.hours\n task_time += 1.day if task_time < start_time\n\n while task_time < end_time\n times << task_time\n task_time += 1.day\n end\n\n times\n end",
"def generate_sleep_times(log)\n\n sleep_times = Array.new(60) { [] }\n current_guard = /Guard #(\\d+) begins/.match(log.first)[1]\n asleep = nil\n awake = nil\n\n log[1..-1].each do |line|\n new_guard = /Guard #(\\d+) begins/.match(line)\n minute = /\\[\\d+-\\d+-\\d+ \\d+:(\\d+)\\]/.match(line)[1].to_i\n if new_guard\n # if asleep\n # sleep_times[current_guard] = sleep_times[current_guard] << [asleep, 60]\n # end\n current_guard = new_guard[1]\n elsif /falls asleep/.match(line)\n asleep = minute\n elsif /wakes up/.match(line)\n awake = minute\n\n (asleep...awake).each do |min|\n sleep_times[min] = sleep_times[min] << current_guard\n end\n asleep = nil\n awake = nil\n end\n end\n\n sleep_times\nend",
"def timeslots\n\t\tif (self != nil)\n\t\t\tcompany = self.company\n\t\t\tstart_time = company.start_time\n\t\t\tend_time = company.end_time\n\t\t\tcompany_duration = (( end_time - start_time )/60).round(2)\n\t\t\tno_of_slots = ( company_duration / (self.time_slot.hour*60 + self.time_slot.min) ).to_i\n\t\t\ttime_slot_array =Array.new\n\t\t\tremember_hour = start_time.hour.round\n\t\t\tremember_min = start_time.min\n\t\t\tno_of_slots.times do | index |\n\t\t\t\ta = remember_hour == 0 ? \"00\" : remember_hour\n\t\t\t\tb = remember_min == 0 ? \"00\" : remember_min\n\t\t\t\tc = ((remember_min + self.time_slot.min)/60 )+remember_hour+self.time_slot.hour == 0 ? \"00\" :((remember_min + self.time_slot.min)/60 )+remember_hour+self.time_slot.hour\n\t\t\t\td = (remember_min + self.time_slot.min) % 60 == 0 ? \"00\" : (remember_min + self.time_slot.min) % 60\n\t\t\t\ttime_slot_array << [\"#{a}:#{b}-#{c}:#{d}\", index]\n\t\t\t\tremember_hour = ((remember_min + self.time_slot.min)/60 )+remember_hour+self.time_slot.hour\n\t\t\t\tremember_min = (remember_min + self.time_slot.min) % 60\n\t\t\tend\n\t\t\ttime_slot_array\n\t\tend\n\tend",
"def durations; end",
"def stock_picker_benchmarker number_of_runs, stock_array_size\n\tstart_time = Time.now\n\ttime_per_run = []\n\t\n\tnumber_of_runs.times do\n\t\tstock_input = Array.new(stock_array_size) { rand(1..20) }\n\t\tstart_iter = Time.now\n\n\t\t#p stock_picker(stock_input)\n\t\t\n\t\tend_iter \t= Time.now\n\t\ttime_per_run.push(end_iter - start_iter)\n\tend\n\n\tend_time = Time.now\n\ttotal_duration = end_time - start_time\n\taverage_time_per = time_per_run.inject(0.0) { |sum, el| sum + el} / time_per_run.size\n\n\tputs \"Number of Runs: #{number_of_runs}\"\n\tputs \"Number of Days for stock picker: #{stock_array_size}\"\n\tputs \"Total Duration of test: #{total_duration} ms\"\n\tputs \"Average time per run: #{average_time_per} ms\"\nend",
"def check_single_calling_core(time_between)\n time_between.delete_at(0)\n time_between = [0] if time_between == []\n time_between\nend",
"def retry_delay_times\n @delay_times ||= begin\n (1..Float::INFINITY)\n .lazy\n .map { |i| i**i }\n .take_while { |i| i < Proletariat.max_retry_delay }\n .to_a\n .push(Proletariat.max_retry_delay)\n .map { |seconds| seconds * 1000 }\n end\n end",
"def total_time\n entries.reduce(0) do |acc, entry|\n acc + entry.total_minutes\n end\n end",
"def time_list_to_cdf(durations)\n return [[], []] if durations.size == 0\n durations = durations.sort\n total_count = durations.size.to_f\n current_min = durations[0]\n count = 0.0\n data_list = [durations[0]]\n ratio_list = [0.0]\n durations.each do |point|\n count += 1.0\n if point > current_min\n data_list << point\n ratio_list << count / total_count\n current_min = point\n end\n end\n data_list << durations[-1]\n ratio_list << 1.0\n # Convert times to milliseconds\n data_list.map! {|v| v * 1000.0}\n # Convert ratios to percentages\n ratio_list.map! {|v| v * 100.0}\n [data_list, ratio_list]\nend",
"def report_benchmark_list(list)\n if list.size <= MAX_BENCHMARKS_TO_LIST\n list.join(\", \")\n else\n \"#{list.size} individual benchmarks affected\"\n end\nend",
"def initialize\n @count = Time.secsIn25Mins\n end",
"def time\n each_item.reduce(0) { |a, e| a + e.duration }\n end",
"def time_slots\n collection=[]\n start_time=Time.now.beginning_of_hour\n end_time=Time.now.tomorrow.midnight-1.hour\n time=start_time\n\n while time < end_time\n collection<<[time.beginning_of_hour.hour, time.beginning_of_hour]\n time=time+1.hour\n end\n\n collection\n end",
"def end_time(start) ((Time.now - start).to_f * 1000).truncate(5) end",
"def times_for(indexes)\n indexes.map { |index| index2time(index) }\n end",
"def expected_runtime_seconds(report_count:)\n runs = report_count * options[:lines_multipliers].length\n warmup_time_seconds = runs * options[:benchmark_warmup]\n bench_time_seconds = runs * options[:benchmark_time]\n\n warmup_time_seconds + bench_time_seconds\n end",
"def time_limit\n [2, problem.time_limit].min\n end",
"def queue_time(customers, n)\n if n >= customers.length && !customers.empty?\n customers.max\n elsif customers.empty?\n 0\n else\n time_steps = []\n current_queue = customers[0..(n - 1)]\n addition_to_queue = []\n until current_queue.empty?\n customers.shift(n)\n time_steps << current_queue.min\n min_wait_time = current_queue.min\n current_queue.map! { |item| item - min_wait_time }\n n = current_queue.count(0)\n current_queue.reject! { |x| x == 0 }\n addition_to_queue = customers[0..(n - 1)]\n current_queue += addition_to_queue\n end\n time_steps.sum\n end\n end",
"def start_times\n \t@start_time1 = self.start_time1\n\n @start_time2 = self.start_time2\n\n @start_time3 = self.start_time3\n\n start_times = [@start_time1, @start_time2, @start_time3]\n end",
"def pbTimingList(canvas)\n commands=[]\n cmdNewSound=-1\n cmdNewBG=-1\n cmdEditBG=-1\n cmdNewFO=-1\n cmdEditFO=-1\n for i in canvas.animation.timing\n commands.push(sprintf(\"%s\",i))\n end\n commands[cmdNewSound=commands.length]=_INTL(\"Add: Play Sound...\")\n commands[cmdNewBG=commands.length]=_INTL(\"Add: Set Background Graphic...\")\n commands[cmdEditBG=commands.length]=_INTL(\"Add: Edit Background Color/Location...\")\n commands[cmdNewFO=commands.length]=_INTL(\"Add: Set Foreground Graphic...\")\n commands[cmdEditFO=commands.length]=_INTL(\"Add: Edit Foreground Color/Location...\")\n cmdwin=pbListWindow(commands,480)\n cmdwin.x=0\n cmdwin.y=0\n cmdwin.width=640\n cmdwin.height=384\n cmdwin.opacity=200\n cmdwin.viewport=canvas.viewport\n framewindow=ControlWindow.new(0,384,640,32*4)\n framewindow.addSlider(_INTL(\"Frame:\"),1,canvas.animation.length,canvas.currentframe+1)\n framewindow.addButton(_INTL(\"Set Frame\"))\n framewindow.addButton(_INTL(\"Delete Timing\"))\n framewindow.opacity=200\n framewindow.viewport=canvas.viewport\n loop do\n Graphics.update\n Input.update\n cmdwin.update\n framewindow.update\n if cmdwin.index!=cmdNewSound &&\n cmdwin.index!=cmdNewBG &&\n cmdwin.index!=cmdEditBG &&\n cmdwin.index!=cmdNewFO &&\n cmdwin.index!=cmdEditFO\n if framewindow.changed?(1) # Set Frame\n canvas.animation.timing[cmdwin.index].frame=framewindow.value(0)-1\n cmdwin.commands[cmdwin.index]=sprintf(\"%s\",canvas.animation.timing[cmdwin.index])\n cmdwin.refresh\n next\n end\n if framewindow.changed?(2) # Delete Timing\n canvas.animation.timing.delete_at(cmdwin.index)\n cmdwin.commands.delete_at(cmdwin.index)\n cmdNewSound-=1 if cmdNewSound>=0\n cmdNewBG-=1 if cmdNewBG>=0\n cmdEditBG-=1 if cmdEditBG>=0\n cmdNewFO-=1 if cmdNewFO>=0\n cmdEditFO-=1 if cmdEditFO>=0\n cmdwin.refresh\n next\n end\n end\n if (Input.trigger?(Input::C) || (cmdwin.doubleclick? rescue false))\n redrawcmds=false\n if cmdwin.index==cmdNewSound # Add new sound\n newaudio=PBAnimTiming.new(0)\n if pbSelectSE(canvas,newaudio)\n newaudio.frame=framewindow.value(0)-1\n canvas.animation.timing.push(newaudio)\n redrawcmds=true\n end\n elsif cmdwin.index==cmdNewBG # Add new background graphic set\n newtiming=PBAnimTiming.new(1)\n if pbSelectBG(canvas,newtiming)\n newtiming.frame=framewindow.value(0)-1\n canvas.animation.timing.push(newtiming)\n redrawcmds=true\n end\n elsif cmdwin.index==cmdEditBG # Add new background edit\n newtiming=PBAnimTiming.new(2)\n if pbEditBG(canvas,newtiming)\n newtiming.frame=framewindow.value(0)-1\n canvas.animation.timing.push(newtiming)\n redrawcmds=true\n end\n elsif cmdwin.index==cmdNewFO # Add new foreground graphic set\n newtiming=PBAnimTiming.new(3)\n if pbSelectBG(canvas,newtiming)\n newtiming.frame=framewindow.value(0)-1\n canvas.animation.timing.push(newtiming)\n redrawcmds=true\n end\n elsif cmdwin.index==cmdEditFO # Add new foreground edit\n newtiming=PBAnimTiming.new(4)\n if pbEditBG(canvas,newtiming)\n newtiming.frame=framewindow.value(0)-1\n canvas.animation.timing.push(newtiming)\n redrawcmds=true\n end\n else\n # Edit a timing here\n case canvas.animation.timing[cmdwin.index].timingType\n when 0\n pbSelectSE(canvas,canvas.animation.timing[cmdwin.index])\n when 1, 3\n pbSelectBG(canvas,canvas.animation.timing[cmdwin.index])\n when 2, 4\n pbEditBG(canvas,canvas.animation.timing[cmdwin.index])\n end\n cmdwin.commands[cmdwin.index]=sprintf(\"%s\",canvas.animation.timing[cmdwin.index])\n cmdwin.refresh\n end\n if redrawcmds\n cmdwin.commands[cmdNewSound]=nil if cmdNewSound>=0\n cmdwin.commands[cmdNewBG]=nil if cmdNewBG>=0\n cmdwin.commands[cmdEditBG]=nil if cmdEditBG>=0\n cmdwin.commands[cmdNewFO]=nil if cmdNewFO>=0\n cmdwin.commands[cmdEditFO]=nil if cmdEditFO>=0\n cmdwin.commands.compact!\n cmdwin.commands.push(sprintf(\"%s\",canvas.animation.timing[canvas.animation.timing.length-1]))\n cmdwin.commands[cmdNewSound=cmdwin.commands.length]=_INTL(\"Add: Play Sound...\")\n cmdwin.commands[cmdNewBG=cmdwin.commands.length]=_INTL(\"Add: Set Background Graphic...\")\n cmdwin.commands[cmdEditBG=cmdwin.commands.length]=_INTL(\"Add: Edit Background Color/Location...\")\n cmdwin.commands[cmdNewFO=cmdwin.commands.length]=_INTL(\"Add: Set Foreground Graphic...\")\n cmdwin.commands[cmdEditFO=cmdwin.commands.length]=_INTL(\"Add: Edit Foreground Color/Location...\")\n cmdwin.refresh\n end\n elsif Input.trigger?(Input::B)\n break\n end\n end\n cmdwin.dispose\n framewindow.dispose\n return\nend",
"def __evolve_time__\n map { |value| value.__evolve_time__ }\n end",
"def queue_time(customers, n)\n return customers.inject(0, &:+) if n == 1\n time = 0\n cust_num = customers.size\n tills = Array.new(n > cust_num ? cust_num : n) \n tills = tills.map do |till|\n customers.shift\n end\n until tills.all?(&:zero?) && customers.empty?\n tills.map! do |till|\n if till == 0\n unless customers.empty?\n till = customers.shift\n till -= 1\n end \n else\n till -= 1\n end\n \n till\n end\n time += 1\n end\n \n time\nend",
"def max_talk_time_length\n 240\n end",
"def queue_time(customers, n)\r\n arr = Array.new(n, 0)\r\n customers.each { |customer| arr[arr.index(arr.min)] += customer }\r\n arr.max\r\nend",
"def load_showtimes\n available_times = {\n 10.45 => \"10:45am\", 11.00 => \"11:00am\", 11.15 => \"11:15am\", 11.30 => \"11:30am\",11.45 => \"11:45am\", 12.00 => \"12:00pm\", 12.15 => \"12:15pm\", 12.30 => \"12:30pm\", 12.45 => \"12:45pm\", \n 13.00 => \"1:00pm\", 13.15 => \"1:15pm\", 13.30 => \"1:30pm\",13.45 => \"1:45pm\",14.00 => \"2:00pm\",14.15 => \"2:15pm\",14.30 => \"2:30pm\", 14.45 => \"2:45pm\", 15.00 => \"3:00pm\",15.15 => \"3:15pm\",16.00 => \"4:00pm\", 16.15 => \"4:15pm\", 16.30 => \"4:30pm\", 16.45 => \"4:45pm\", 17.00 => \"5:00pm\",17.15 => \"5:15pm\", 17.30 => \"5:30pm\",17.45 => \"5:45pm\",18.00 => \"6:00pm\", 18.15 => \"6:15pm\", 18.30 => \"6:30pm\", 18.45 => \"6:45pm\", 19.00 => \"7:00pm\", 19.15 => \"7:15pm\", 19.30 => \"7:30pm\", 19.45 => \"7:45pm\", 20.00 => \"8:00pm\", 20.15 => \"8:15pm\", 20.30 => \"8:30pm\", 20.45 => \"8:45pm\", 21.00 => \"9:00pm\", 21.15 => \"9:15pm\", 21.30 => \"9:30pm\", \n 22.00 => \"10:00pm\", 22.15 => \"10:15pm\", 22.30 => \"10:30pm\", 22.45 => \"10:45pm\", 23.00=> \"11:00pm\", 23.15 => \"11:15pm\", \n 23.30 => \"11:30pm\", 23.45 => \"11:45pm\",24.00 => \"12:00am\"}\n\n\n\n showtimes = [10.45]\n\n if self.runtime >= 1.33 && self.runtime <= 1.5\n showtimes << 12.30 << 14.00 << 15.30 << 17.00 << 18.30 << 20.00 << 21.30 << 23.00\n\n elsif self.runtime >= 1.5 && self.runtime <= 2 \n showtimes << 13.00 << 15.00 << 17.00 << 19.00 << 21.00 << 23.00 << 24.00\n\n elsif self.runtime >= 2 && self.runtime <= 3\n showtimes << 14.15 << 17.15 << 21.15 << 24.00\n end \n\n\n\n showtimes.map! do |time|\n time = Showing.create!(military_time: time.to_f, time_string: available_times[time], movie: self)\n end\n\n self.showings = showtimes\n end",
"def clean_list(timestamp)\n while @tail && @tail.timestamp <= timestamp - 10\n @message_to_node.delete(@tail.message)\n @tail = @tail.next\n @tail&.prev = nil\n end\n\n unless @tail\n @head = nil\n end\n end",
"def time_sums(n)\n times = []\n hr = 0\n until hr == 24\n min = 0\n until min == 60\n min_sum = min.to_s.split('').map(&:to_i).reduce(&:+)\n hr_sum = hr.to_s.split('').map(&:to_i).reduce(&:+)\n sum = min_sum + hr_sum\n\n minString = min.to_s.split('')\n hrString = hr.to_s.split('')\n\n minString.unshift('0') until minString.length == 2\n hrString.unshift('0') until hrString.length == 2\n\n times << hrString.join('') + \":\" + minString.join('') if sum == n\n\n min += 1\n end\n hr += 1\n end\n times\nend",
"def pbTimingList(canvas)\r\n commands=[]\r\n cmdNewSound=-1\r\n cmdNewBG=-1\r\n cmdEditBG=-1\r\n cmdNewFO=-1\r\n cmdEditFO=-1\r\n for i in canvas.animation.timing\r\n commands.push(sprintf(\"%s\",i))\r\n end\r\n commands[cmdNewSound=commands.length]=_INTL(\"Add: Play Sound...\")\r\n commands[cmdNewBG=commands.length]=_INTL(\"Add: Set Background Graphic...\")\r\n commands[cmdEditBG=commands.length]=_INTL(\"Add: Edit Background Color/Location...\")\r\n commands[cmdNewFO=commands.length]=_INTL(\"Add: Set Foreground Graphic...\")\r\n commands[cmdEditFO=commands.length]=_INTL(\"Add: Edit Foreground Color/Location...\")\r\n cmdwin=pbListWindow(commands,480)\r\n cmdwin.x=0\r\n cmdwin.y=0\r\n cmdwin.width=640\r\n cmdwin.height=384\r\n cmdwin.opacity=200\r\n cmdwin.viewport=canvas.viewport\r\n framewindow=ControlWindow.new(0,384,640,32*4)\r\n framewindow.addSlider(_INTL(\"Frame:\"),1,canvas.animation.length,canvas.currentframe+1)\r\n framewindow.addButton(_INTL(\"Set Frame\"))\r\n framewindow.addButton(_INTL(\"Delete Timing\"))\r\n framewindow.opacity=200\r\n framewindow.viewport=canvas.viewport\r\n loop do\r\n Graphics.update\r\n Input.update\r\n cmdwin.update\r\n framewindow.update\r\n if cmdwin.index!=cmdNewSound &&\r\n cmdwin.index!=cmdNewBG &&\r\n cmdwin.index!=cmdEditBG &&\r\n cmdwin.index!=cmdNewFO &&\r\n cmdwin.index!=cmdEditFO\r\n if framewindow.changed?(1) # Set Frame\r\n canvas.animation.timing[cmdwin.index].frame=framewindow.value(0)-1\r\n cmdwin.commands[cmdwin.index]=sprintf(\"%s\",canvas.animation.timing[cmdwin.index])\r\n cmdwin.refresh\r\n next\r\n end\r\n if framewindow.changed?(2) # Delete Timing\r\n canvas.animation.timing.delete_at(cmdwin.index)\r\n cmdwin.commands.delete_at(cmdwin.index)\r\n cmdNewSound-=1 if cmdNewSound>=0\r\n cmdNewBG-=1 if cmdNewBG>=0\r\n cmdEditBG-=1 if cmdEditBG>=0\r\n cmdNewFO-=1 if cmdNewFO>=0\r\n cmdEditFO-=1 if cmdEditFO>=0\r\n cmdwin.refresh\r\n next\r\n end\r\n end\r\n if Input.trigger?(Input::USE)\r\n redrawcmds=false\r\n if cmdwin.index==cmdNewSound # Add new sound\r\n newaudio=PBAnimTiming.new(0)\r\n if pbSelectSE(canvas,newaudio)\r\n newaudio.frame=framewindow.value(0)-1\r\n canvas.animation.timing.push(newaudio)\r\n redrawcmds=true\r\n end\r\n elsif cmdwin.index==cmdNewBG # Add new background graphic set\r\n newtiming=PBAnimTiming.new(1)\r\n if pbSelectBG(canvas,newtiming)\r\n newtiming.frame=framewindow.value(0)-1\r\n canvas.animation.timing.push(newtiming)\r\n redrawcmds=true\r\n end\r\n elsif cmdwin.index==cmdEditBG # Add new background edit\r\n newtiming=PBAnimTiming.new(2)\r\n if pbEditBG(canvas,newtiming)\r\n newtiming.frame=framewindow.value(0)-1\r\n canvas.animation.timing.push(newtiming)\r\n redrawcmds=true\r\n end\r\n elsif cmdwin.index==cmdNewFO # Add new foreground graphic set\r\n newtiming=PBAnimTiming.new(3)\r\n if pbSelectBG(canvas,newtiming)\r\n newtiming.frame=framewindow.value(0)-1\r\n canvas.animation.timing.push(newtiming)\r\n redrawcmds=true\r\n end\r\n elsif cmdwin.index==cmdEditFO # Add new foreground edit\r\n newtiming=PBAnimTiming.new(4)\r\n if pbEditBG(canvas,newtiming)\r\n newtiming.frame=framewindow.value(0)-1\r\n canvas.animation.timing.push(newtiming)\r\n redrawcmds=true\r\n end\r\n else\r\n # Edit a timing here\r\n case canvas.animation.timing[cmdwin.index].timingType\r\n when 0\r\n pbSelectSE(canvas,canvas.animation.timing[cmdwin.index])\r\n when 1, 3\r\n pbSelectBG(canvas,canvas.animation.timing[cmdwin.index])\r\n when 2, 4\r\n pbEditBG(canvas,canvas.animation.timing[cmdwin.index])\r\n end\r\n cmdwin.commands[cmdwin.index]=sprintf(\"%s\",canvas.animation.timing[cmdwin.index])\r\n cmdwin.refresh\r\n end\r\n if redrawcmds\r\n cmdwin.commands[cmdNewSound]=nil if cmdNewSound>=0\r\n cmdwin.commands[cmdNewBG]=nil if cmdNewBG>=0\r\n cmdwin.commands[cmdEditBG]=nil if cmdEditBG>=0\r\n cmdwin.commands[cmdNewFO]=nil if cmdNewFO>=0\r\n cmdwin.commands[cmdEditFO]=nil if cmdEditFO>=0\r\n cmdwin.commands.compact!\r\n cmdwin.commands.push(sprintf(\"%s\",canvas.animation.timing[canvas.animation.timing.length-1]))\r\n cmdwin.commands[cmdNewSound=cmdwin.commands.length]=_INTL(\"Add: Play Sound...\")\r\n cmdwin.commands[cmdNewBG=cmdwin.commands.length]=_INTL(\"Add: Set Background Graphic...\")\r\n cmdwin.commands[cmdEditBG=cmdwin.commands.length]=_INTL(\"Add: Edit Background Color/Location...\")\r\n cmdwin.commands[cmdNewFO=cmdwin.commands.length]=_INTL(\"Add: Set Foreground Graphic...\")\r\n cmdwin.commands[cmdEditFO=cmdwin.commands.length]=_INTL(\"Add: Edit Foreground Color/Location...\")\r\n cmdwin.refresh\r\n end\r\n elsif Input.trigger?(Input::BACK)\r\n break\r\n end\r\n end\r\n cmdwin.dispose\r\n framewindow.dispose\r\n return\r\nend",
"def num_removed(list)\n full_list = (1..100).to_a\n missing_num = (full_list - list)[0]\nend",
"def max24hr_rec(ints)\n max24help(ints.sort) #O(4log4)=> 2.5 on ave 16 at worst\nend",
"def scan_for_times(token, options = T.unsafe(nil)); end",
"def series_up (n)\n length = n*(n + 1)/2 # this is the mathematical equation for the length of a series\n time = 1 # this variable counts how many times the loop runs but it needs to be reset after it is run three times so that it starts over at 1 again\n reset = 3 # this counts the number of resets\n list = [1]\n (length - 1).times do\n list = [list, time]\n time += 1\n if time == reset # refer to line 50 comment\n time =1\n reset+= 1 # after the first reset the reset needs increase each time so because the last number of the list is getting bigger and without the reset it will not print\n end\n end\n print list\nend",
"def generate_time_slots(time_entries)\n time_entries.map { |entry| extract_available_slots(entry) }.flatten\n end",
"def time_entries(options = {})\n entries = []\n time_invested(options).groups.each { |g| entries << g[\"time_entries\"] }\n\n process_list_response( entries.flatten , Unfuddled::TimeEntry )\n end",
"def times\n @stamps\n end",
"def find_time_asleep\n @total_time_asleep = 0\n @wake_times.each_with_index do |wake_time, index|\n @total_time_asleep += ( wake_time - @sleep_times[index] )\n end\n end",
"def timeslots\n unless @timeslots.present?\n timeslots = Timeslot\n .timeslots_for(@schedule_range, @form)\n .select { |ts| ts.blocks >= @blocks_needed }\n timeslots = @schedule_range.all_timeslots if timeslots.empty?\n @timeslots = timeslots.sort_by { |ts| [ts.day_id, ts.start_minute] }\n end\n\n @timeslots\n end",
"def setTimes(times)\n @times = times\n end",
"def updateTime\n\n # Cleanup phase\n @timestamps << @activestamps.map {|s| s.to_f}\n\n t1, t2, t3, t4, cfs, cfd = @activestamps\n @log.debug \"t1: #{t1.to_f}, \"\\\n \"t2: #{t2.to_f}, \"\\\n \"t3: #{t3.to_f}, \"\\\n \"t4: #{t4.to_f}, \"\\\n \"cfs: #{cfs.to_f}, \"\\\n \"cfd: #{t4.to_f}\"\n\n # Calculate link delay and average link delay\n delay = ((t2 - t1) + (t4 - t3) - cfs - cfd) / BigDecimal.new(2)\n @delay << (delay.to_f > 0 ? delay : delay * -1)\n delay_avg = @delay[-1]\n if @delay_avg[-1]\n one = BigDecimal.new(1)\n delay_avg = ALPHA * @delay_avg[-1] + (one - ALPHA) * @delay[-1]\n end\n @delay_avg << delay_avg\n\n # Calculate phase error and average phase_error\n @phase_error << ((t2 - t1) - (t4 - t3) - cfs + cfd) / BigDecimal.new(2)\n\n # Calculate average phase error if multiple data points exists\n avg = @phase_error[-1]\n if @phase_err_avg[-1]\n one = BigDecimal.new(1)\n avg = ALPHA * @phase_err_avg[-1] + (one - ALPHA) * @phase_error[-1]\n end\n @phase_err_avg << avg\n\n # Calculate frequency error\n distance = -2\n if @timestamps[distance]\n ot1 = @timestamps[distance][0]\n ot2 = @timestamps[distance][1]\n ode = @delay_avg[distance].to_f\n de = @delay_avg.last.to_f\n ocfs = @timestamps[distance][4].to_f\n error = (t1.to_f - ot1)/((t2.to_f + de + cfs.to_f)-(ot2 + ode + ocfs))\n # Do some hard filtering of data\n if error < 2 && error > 0.5\n @freq_error << error\n else\n puts \"ERROR ERROR ERROR ERROR \" + error.to_s # Why?\n @freq_error << @freq_error[-1] || 1\n end\n end\n\n # Calculate average frequency error if multiple data points exists\n if @freq_error[-1] && @flipflop - 1 < @flipflopeach\n @freq_err_avg << @freq_err_avg.last\n elsif @freq_error[-1]\n avg = @freq_error[-1]\n if @freq_err_avg[-1]\n one = BigDecimal.new(1)\n avg = ALPHA_F * @freq_err_avg[-1] + (one - ALPHA_F) * @freq_error[-1]\n end\n @freq_err_avg << avg\n end\n\n # TODO: Update system\n @log.info \"Delay: #{@delay.last.to_f} \\t\" \\\n \"Delay_avg: #{@delay_avg.last.to_f} \\t\" \\\n \"phase_err: #{@phase_error.last.to_f} \\t\"\\\n \"phase_err_avg: #{@phase_err_avg.last.to_f}, \\t\"\\\n \"freq_err: #{@freq_error.last.to_f} \\t\"\\\n \"freq_err_avg: #{@freq_err_avg.last.to_f}\"\n\n # Adjust phase\n adjOffset(@phase_err_avg.last.to_f) if @flipflop < @flipflopeach\n\n # Adjust frequency when we have some point of measurement and when we can\n # actually make adjustments in the flipflop thing.\n if @freq_err_avg[-10] && @flipflop >= @flipflopeach\n adjFreq(@freq_err_avg.last.to_f)\n end\n\n # Final cleanup\n @activestamps.fill(nil,0,4)\n\n # Adjust flipflop\n @flipflop = (@flipflop + 1) % (2 * @flipflopeach)\n end",
"def remove_time\n ticket_time = [self.ticket.actual_time - self.time, 0].max\n self.ticket.update_column :actual_time, ticket_time\n end",
"def optimize_commands(name, values, duration)\n\tlast_value = values[0];\n\ttime_since_switch = 0;\n\tvalues = values.each_with_index.collect do |v,i|\n\t\tv = v.to_i\n\t\tuniqueness = last_value != v\n\t\tlast_value = uniqueness ? v : last_value\n\t\t\n\t\t# if last element, output value and duration \n\t\tif i == values.length - 1\n\t\t\tr = [last_value, (time_since_switch + 1) * duration]\n\t\t\ttime_since_switch = 0\n\t\t\tr\n\t\telse\n\t\t\t# skip repeated values\n\t\t\tif !uniqueness \n\t\t\t\ttime_since_switch = time_since_switch + 1\n\t\t\t\tnext\n\t\t\telse\n\t\t\t\tr = [last_value, (time_since_switch + 1) * duration]\n\t\t\t\ttime_since_switch = 0\n\t\t\t\tr\n\t\t\tend\n\t\tend\n\tend\n\t# SPARSIFY\n\tvalues.compact!\n\t\n\treturn values\nend",
"def calculate_missed_runs(last_run_time, as_time)\n missed_times = []\n last_time = last_run_time\n while (next_run = next_run_time(last_time, as_time))\n missed_times << next_run\n last_time = next_run\n end\n\n generate_to_enqueue_list(missed_times)\n end",
"def calculate_missed_runs(last_run_time, as_time)\n missed_times = []\n last_time = last_run_time\n while (next_run = next_run_time(last_time, as_time))\n missed_times << next_run\n last_time = next_run\n end\n\n generate_to_enqueue_list(missed_times)\n end",
"def compact\n gu = greatest_unit\n puts \"gu: #{gu.inspect}\"\n return Compact.new(@v, gu) if gu==:hour\n i, st, v = 0, @start_time, []\n while i<@v.size\n v << @v[i]\n next_st = st+1.send(gu)\n h = (next_st-st)/3600\n i = i+h.to_i\n st = next_st\n end\n Compact.new(v, gu)\n end",
"def trim_logs!(threshold = 1000)\n m = [last_analyzed_log_entry, last_broadcasted_log_entry].min\n l = last_trimmed_log_entry\n entries = []\n\n if m - last_trimmed_log_entry >= threshold\n entries = redis.zrangebyscore(log_key, l, m, :with_scores => true)\n redis.zremrangebyscore(log_key, l, m)\n redis.hset(ident, 'last_trimmed_log_entry', m)\n end\n\n entries\n end",
"def list_set_expire(name_of_list, seconds)\n res = 0\n @redis_pool.with do |redis|\n res = redis.expire \"#{name_of_list}\", seconds\n end\n\n res\n end",
"def clear_times()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n Native.RunEditor_clear_times(@handle.ptr)\n end",
"def mtp(hash)\n time = []\n Bitcoin::MEDIAN_TIME_SPAN.times do\n entry = find_entry_by_hash(hash)\n break unless entry\n\n time << entry.header.time\n hash = entry.header.prev_hash\n end\n time.sort!\n time[time.size / 2]\n end",
"def off_times\n load_curve.count(&:zero?)\n end",
"def computeCompletionTimes(schedule)\n completionTime = 0\n completionTimesSum = 0\n schedule.each do |job|\n completionTime = completionTime + job[\"length\"]\n completionTimesSum = completionTimesSum + job[\"weight\"] * completionTime\n end\n\n puts completionTimesSum\nend"
] |
[
"0.6160547",
"0.5871985",
"0.5698223",
"0.564392",
"0.5537809",
"0.55005515",
"0.54997134",
"0.54442644",
"0.5414609",
"0.5391899",
"0.53420776",
"0.53092986",
"0.5277082",
"0.52710587",
"0.52708876",
"0.52680224",
"0.5242377",
"0.5241167",
"0.5240105",
"0.5217934",
"0.51915276",
"0.5179428",
"0.51636904",
"0.5160467",
"0.51601124",
"0.5135763",
"0.51301557",
"0.5119379",
"0.50945204",
"0.50906503",
"0.5087984",
"0.5069783",
"0.5040333",
"0.5031447",
"0.50212055",
"0.5019508",
"0.50193685",
"0.50160384",
"0.5014704",
"0.5010934",
"0.5010934",
"0.5007376",
"0.5006517",
"0.49667376",
"0.49533918",
"0.49497017",
"0.49476177",
"0.49466452",
"0.49434656",
"0.49424866",
"0.4918869",
"0.49169162",
"0.4913835",
"0.49124366",
"0.49101377",
"0.49088433",
"0.48996967",
"0.48985112",
"0.48975286",
"0.4881819",
"0.48813418",
"0.48795968",
"0.48777145",
"0.48679194",
"0.4865338",
"0.48580897",
"0.48559672",
"0.48335725",
"0.48307595",
"0.4830033",
"0.48278403",
"0.4813098",
"0.4808955",
"0.4806957",
"0.48067778",
"0.4800675",
"0.48000157",
"0.47970155",
"0.47957498",
"0.4782885",
"0.47766113",
"0.477436",
"0.4772213",
"0.47713992",
"0.47685555",
"0.47369727",
"0.47351626",
"0.47337973",
"0.47327113",
"0.47322816",
"0.47322592",
"0.47313502",
"0.47313502",
"0.47308904",
"0.47290084",
"0.47203737",
"0.47184408",
"0.4717875",
"0.47167802",
"0.47106943"
] |
0.5494094
|
7
|
constructor popSize: members in population solution: array of bytes representing solution arg: additional parameters, such as string, word, ect. => This is useful, because depending on what type of data we're searching for, we can narrow down the gene length
|
def initialize(popSize=0,solution,args)
#set desired
@@elitism = args[:elitism]
@@mutationRate = args[:mutationRate]
Fitness::setSolution(solution)
@mutationNum = 0
@population = Population.new(popSize,true,{:data =>args[:data]},Fitness)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize(popSize=0,solution=[],args= {})\n\t\tif popSize==0\n\t\t\tpopSize=100\n\t\tend\n\t\tif !solution.empty? && solution.is_a?(Array)\n\t\t\t@PopulationHandler = PopulationHandler.new(popSize,solution,args)\n\t\t\tputs \"Population Handler created\"\n\t\t\tputs \"Population Size: #{popSize}\"\n\t\t\tputs \n\t\tend\n\tend",
"def initialize(size)\n @size = get_good_size(size)\n @table = Array.new @size\n @population = 0\n @used_spaces = 0\n end",
"def load()\n return @population/@size\n end",
"def initialize (inMask, outMask, size, randomize)\n @wordBits = 0.size * 8 # size of a word on your machine\n @inMask = inMask\n @outMask = outMask\n @size = size # number of genes\n @inLen = @inMask.inject(0, :+) # sum the bits\n @outLen = @outMask.inject(0, :+) # sum the bits\n\n @geneLen = 2**@inLen * @outLen # length of gene needed for solution\n @bestGene = 0\n @bestFitness = 0 \n @genePool = []\n # allocate the genepool and seed it with random bits\n @size.times do |i|\n @genePool[i] = Gene.new(@geneLen)\n if randomize\n @genePool[i].numWords.times do |j|\n @genePool[i].setWord(j, rand(@genePool[i].wordMax))\n end\n end\n end\n end",
"def initialize(args={})\n @size = args[:size] # <- promoted from RoadBike\n end",
"def init_population\n (0...@pop_size).each do\n chromosome = Chromosome.new\n (0...@num_genes).each do |_i|\n gene = rand 0..1\n chromosome << gene\n end\n evaluate_chromosome chromosome\n @chromosomes << chromosome\n end\n end",
"def length\n genes.length\n end",
"def initialize(size)\n @size = size\n end",
"def size= length\n #This is a stub, used for indexing\n end",
"def init_population\n (0...@pop_size).each do\n chromosome = Chromosome.new\n (0...@num_genes).each do\n gene = rand 0..1\n chromosome << gene\n end\n evaluate_chromosome chromosome\n compare_func = @is_high_fit ? :> : :<\n if @best_fit.nil? ||\n chromosome.fitness.public_send(compare_func, @best_fit)\n @best_fit = chromosome.fitness\n end\n @chromosomes << chromosome\n end\n end",
"def init_chromosomes(pop_size, macro_cromosomes)\n (0...pop_size).each do |j|\n chromo = Chromosome.new\n each do |gene|\n chromo << macro_cromosomes[j][gene]\n end\n @chromosomes << chromo\n end\n @best_chromosomes_experiences = @chromosomes.clone\n end",
"def initialize(desired_length)\n @length = desired_length\n end",
"def init_population(minmax, pop_size)\r\n strategy = Array.new(minmax.size) do |i| # Make a new array called strategy that holds [0, (5 - (-5) * 0.5)] problem_size times. [[], []] Nested array\r\n [0, (minmax[i][1]-minmax[i][0]) * 0.05]\r\n end\r\n pop = Array.new(pop_size, {}) # Array of size pop, 100 in this case of empty hashes\r\n pop.each_index do |i| # For each element in pop which is a [{}, {}]\r\n pop[i][:vector] = random_vector(minmax) # Run random_vector on the original search space and put it in the pop[index][:vector]\r\n pop[i][:strategy] = random_vector(strategy) # Run random_vector on the strategy created earlier in this method and append it to pop[index][:strategy]\r\n end\r\n pop.each{|c| c[:fitness] = objective_function(c[:vector])} # Calculates a fitness for each vector using objective_function\r\n return pop\r\nend",
"def initialize(problem, population_size, mutation_rate, generations)\n @problem = problem\n @best_fitness = 0;\n @best_configuration = nil\n @error = 0\n @generations = generations\n \n @population_size = population_size\n @mutation_rate = mutation_rate\n \n \n if @population_size%2 != 0 || @population_size < 1\n raise(\"Population size must be even and higher than 1.\")\n end\n \n @population = Array.new\n for i in 0..@population_size - 1\n conf = Configuration.new(@problem)\n ch = Chromosome.new(conf)\n @population.push(ch)\n \n if @best_configuration == nil || @best_fitness < ch.fitness\n @best_configuration = ch.configuration.conf\n @best_fitness = ch.fitness\n end\n \n end\n \n @selection = TournamentSelection.new\n @reproduction = UniformReproduction.new(@problem)\n @mutation = SimpleMutation.new(@problem, @mutation_rate)\n \n \n end",
"def setup\n @target = 'To be or not to be.'\n @popmax = 150\n @mutation_rate = 0.01\n # Create a population with a target phrase, mutation rate, and population max\n @population = Population.new(@target, @mutation_rate, @popmax)\nend",
"def size\n @size ||= search.size\n end",
"def size(size)\n @value[:size] = size\n self\n end",
"def initialize size=6, mines=20\n @size = size\n @mines = mines\n end",
"def size\n @gens.size\n end",
"def size\n @gens.size\n end",
"def size; @size end",
"def size(*args); end",
"def initialize groupSize\n\t\t@groupSize=groupSize\n\t\t@arrayChromosomes=Array.new\n\tend",
"def init_population\n (0...@pop_size).each do\n chromosome = Chromosome.new\n (0...@num_genes).each do |i|\n if @beta_values == 'discrete'\n beta = rand(0..10) / 10.0\n elsif @beta_values == 'uniform distribution'\n beta = rand(0.0..1.0)\n end\n gene = @lower_bounds[i] + beta * (@upper_bounds[i] -\n @lower_bounds[i])\n # Wrong for discrete functions\n chromosome << (@continuous ? gene : gene.floor)\n end\n evaluate_chromosome chromosome\n @chromosomes << chromosome\n end\n end",
"def interpret_size(size); end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
"def size(*) end",
"def size(*) end",
"def max_size=(_arg0); end",
"def initial_population(fasta, size)\n\tpopulation = []\n\tsize.times do\n\t\tchromosome = fasta.shuffle\n\t\tpopulation << chromosome\n\tend\n\treturn population\nend",
"def initialize(name, size)\n @name = name\n @size = size\n end",
"def initialize(length)\n @length = length\n end",
"def test_020_population()\n TestVals.each do |sVal|\n bs = BitString.new(sVal)\n ones = sVal.gsub(/0/, '').length\n zeroes = sVal.gsub(/^0+(.)/, '\\1').gsub(/1/, '').length\n assert_raise(ArgumentError, 'Test exception for population(\"a\")') do\n bs.population('a')\n end\n assert_equal(ones,\n bs.population(1),\n \"Test unbounded '#{sVal}'.population(1)\")\n assert_equal(zeroes,\n bs.population(0),\n \"Test unbounded '#{sVal}'.population(0)\")\n #\n # Now bounded.\n #\n bs = BitString.new(sVal, sVal.length)\n ones = sVal.gsub(/0/, '').length\n zeroes = sVal.gsub(/1/, '').length\n assert_equal(ones,\n bs.population(1),\n \"Test bounded '#{sVal}'.population(1)\")\n assert_equal(zeroes,\n bs.population(0),\n \"Test bounded '#{sVal}'.population(0)\")\n end\n end",
"def size() end",
"def size() end",
"def size() end",
"def size() end",
"def size() end",
"def size() end",
"def size\n self[:size]\n end",
"def size=(size)\n end",
"def size=(_arg0); end",
"def size=(_arg0); end",
"def target_len; genomic.len; end",
"def size=(value)\n @size = value\n end",
"def size=(value)\n @size = value\n end",
"def search(population_size: 20, maximum_number_of_generations: 100, number_of_mutation_sites: 2, crossover_probability: 0.95, mutation_probability: 0.05)\n\n population_size = population_size.to_i unless population_size.kind_of?(Integer)\n maximum_number_of_generations = maximum_number_of_generations.to_i unless maximum_number_of_generations.kind_of?(Integer)\n # number_of_mutation_sites = BigDecimal(number_of_mutation_sites.to_s) unless number_of_mutation_sites.kind_of?(BigDecimal)\n # crossover_probability = BigDecimal(crossover_probability.to_s) unless crossover_probability.kind_of?(BigDecimal)\n # mutation_probability = BigDecimal(mutation_probability.to_s) unless mutation_probability.kind_of?(BigDecimal)\n number_of_mutation_sites = number_of_mutation_sites.to_i unless number_of_mutation_sites.kind_of?(Integer)\n crossover_probability = crossover_probability.to_f unless crossover_probability.kind_of?(Float)\n mutation_probability = mutation_probability.to_f unless mutation_probability.kind_of?(Float) \n\n initialize_population(population_size)\n\n maximum_number_of_generations.times do |generation_index|\n\n @population_copy = deep_clone_population\n\n population_size.times do |individual_index|\n\n # if bigdecimal_rand < crossover_probability\n if rand < crossover_probability\n\n # Crossover pair:\n crossover_pair_1_index = generate_random_index(population_size)\n crossover_pair_2_index = generate_random_index(population_size) \n\n crossover(crossover_pair_1_index, crossover_pair_2_index)\n\n end\n\n # if bigdecimal_rand < mutation_probability\n if rand < mutation_probability\n\n mutation_individual_index = generate_random_index(population_size)\n\n mutate(mutation_individual_index, number_of_mutation_sites)\n\n end\n\n end\n\n end\n\n objective_function_value = @population_fitness.send(@objective_method_name)\n decision_variable_values = @population[@population_fitness.index(objective_function_value)]\n\n { best_decision_variable_values: decision_variable_values, best_objective_function_value: objective_function_value }\n\n end",
"def initialize(args={})\n @params = {:elite => 0.1, :mutate => 0.02}\n @params.merge! args\n @population = []\n end",
"def initialize length\n self.length = length\n end",
"def size\n @sizes ||= strip(:size)\n end",
"def prepare(size = 100, initial_size = 1000, offspring = 80)\n @offspring = offspring\n initial = []\n initial_size.times do\n g = @genotype.new_rand_chrom\n initial << g unless initial.include?(g)\n end\n sort!(initial)\n size.times do\n self << initial.shift\n end\n\n @logger.info \"Population con #{self.size} habitantes\"\n end",
"def initialize(size)\n @size = size\n @store = Array.new(@size)\n @top = -1\n end",
"def pbSize(pokemon)\n dexdata = pbOpenDexData\n pbDexDataOffset(dexdata,pokemon.fSpecies,33)\n baseheight = dexdata.fgetw # Gets the base height in tenths of a meter\n dexdata.close\n hpiv = pokemon.iv[0]&15\n ativ = pokemon.iv[1]&15\n dfiv = pokemon.iv[2]&15\n spiv = pokemon.iv[3]&15\n saiv = pokemon.iv[4]&15\n sdiv = pokemon.iv[5]&15\n m = pokemon.personalID&0xFF\n n = (pokemon.personalID>>8)&0xFF\n s = (((ativ^dfiv)*hpiv)^m)*256+(((saiv^sdiv)*spiv)^n)\n xyz = []\n if s<10\n xyz = [290,1,0]\n elsif s<110\n xyz = [300,1,10]\n elsif s<310\n xyz = [400,2,110]\n elsif s<710\n xyz = [500,4,310]\n elsif s<2710\n xyz = [600,20,710]\n elsif s<7710\n xyz = [700,50,2710]\n elsif s<17710\n xyz = [800,100,7710]\n elsif s<32710\n xyz = [900,150,17710]\n elsif s<47710\n xyz = [1000,150,32710]\n elsif s<57710\n xyz = [1100,100,47710]\n elsif s<62710\n xyz = [1200,50,57710]\n elsif s<64710\n xyz = [1300,20,62710]\n elsif s<65210\n xyz = [1400,5,64710]\n elsif s<65410\n xyz = [1500,2,65210]\n else\n xyz = [1700,1,65510]\n end\n return (((s-xyz[2])/xyz[1]+xyz[0]).floor*baseheight/10).floor\nend",
"def size\n 4\n end",
"def initialize(type, size)\n @type = type\n @size = size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n end"
] |
[
"0.67137986",
"0.6202784",
"0.6049411",
"0.6019852",
"0.59689593",
"0.5698155",
"0.5631447",
"0.56107306",
"0.55970496",
"0.5582112",
"0.55564934",
"0.55499625",
"0.553702",
"0.55129075",
"0.54652643",
"0.54348737",
"0.54183775",
"0.5382112",
"0.53614974",
"0.53614974",
"0.5352782",
"0.534113",
"0.5336674",
"0.53232956",
"0.5312089",
"0.52954626",
"0.52954626",
"0.52954626",
"0.52954626",
"0.52954626",
"0.52954626",
"0.52954626",
"0.52954626",
"0.52954626",
"0.52954626",
"0.52954626",
"0.52954626",
"0.52954626",
"0.52954626",
"0.52954626",
"0.52954626",
"0.52954626",
"0.52954626",
"0.52954626",
"0.52954626",
"0.52954626",
"0.5284527",
"0.5284527",
"0.5262463",
"0.5227094",
"0.52103925",
"0.5205973",
"0.519372",
"0.51930726",
"0.51930726",
"0.51930726",
"0.51930726",
"0.51930726",
"0.51930726",
"0.5189705",
"0.5176095",
"0.51717424",
"0.51717424",
"0.5163146",
"0.5151811",
"0.5151811",
"0.5129696",
"0.5122974",
"0.5114014",
"0.510875",
"0.5101599",
"0.51002616",
"0.5098447",
"0.50970304",
"0.5079919",
"0.50726336",
"0.50726336",
"0.50726336",
"0.50726336",
"0.50726336",
"0.50726336",
"0.50726336",
"0.50726336",
"0.50726336",
"0.50726336",
"0.50726336",
"0.50726336",
"0.50726336",
"0.50726336",
"0.50726336",
"0.50726336",
"0.50726336",
"0.50726336",
"0.50726336",
"0.50726336",
"0.50726336",
"0.50726336",
"0.50726336",
"0.50726336",
"0.5072054"
] |
0.67410225
|
0
|
crossover heh, genetics joke below
|
def breed(xx,xy)
#x,y are parent genes
x = xx.genes
y = xy.genes
geneLength = Fitness::geneLength
#offspring
z = Array.new(geneLength)
# bit returns true or false randomly when sampled
bit = [true,false]
count = 0
while count < geneLength
if bit.sample
z[count] = x[count]
else
z[count] = y[count]
end
count+=1
end
offspring = Population::createMember(z)
offspring.fitness =Fitness::getFitness(z.join())
return offspring
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def cherty_hottish(define, henchboy, systematically_youthen)\n sprag_squamaceous(demilitarize)\n osiridean_seedily(coopering_frenzelite, columellia)\n end",
"def king_richard_iii; end",
"def mixgenes( mgenes, sgenes ) ## returns babygenes\n ## note: reverse genes strings (in kai) so index 0 is the first number\n ## index 1 is the second number etc.\n mgenes = mgenes.reverse\n sgenes = sgenes.reverse\n\n babygenes = \"?\"*48 ## string with 48 question marks (?)\n\n # PARENT GENE SWAPPING\n 12.times do |i| # loop from 0 to 11 # for(i = 0; i < 12; i++)\n puts \"parent gene swapping i: #{i}\"\n index = 4*i # index = 4 * i\n 3.downto(1) do |j| ## loop from 3 to 1 # for (j = 3; j > 0; j--)\n puts \" j: #{j}\"\n if rand(100) < 25 # if random() < 0.25:\n mgenes[index+j-1], mgenes[index+j] = # swap(mGenes, index+j, index+j-1)\n mgenes[index+j], mgenes[index+j-1]\n end\n if rand(100) < 25 # if random() < 0.25:\n sgenes[index+j-1], sgenes[index+j] = # swap(sGenes, index+j, index+j-1)\n sgenes[index+j], sgenes[index+j-1]\n end\n end\n end\n\n # BABY GENES\n 48.times do |i| # loop from 0 to 47 # for (i = 0; i < 48; i++):\n puts \"baby genes i: #{i}\"\n mutation = nil # mutation = 0\n # # CHECK MUTATION\n if i % 4 == 0 # if i % 4 == 0:\n gene1 = Kai::NUMBER[ mgenes[i] ] # gene1 = mGene[i]\n gene2 = Kai::NUMBER[ sgenes[i] ] # gene2 = sGene[i]\n if gene1 > gene2 # if gene1 > gene2:\n gene1, gene2 = gene2, gene1 # gene1, gene2 = gene2, gene1\n end\n if (gene2 - gene1) == 1 && gene1.even? # if (gene2 - gene1) == 1 and iseven(gene1):\n probability = 25 # probability = 0.25\n if gene1 > 23 # if gene1 > 23:\n probability /= 2 # probability /= 2\n end\n if rand(100) < probability # if random() < probability:\n mutation = Kai::ALPHABET[ (gene1/2)+16 ] # mutation = (gene1 / 2) + 16\n end\n end\n end\n # GIVE BABY GENES\n if mutation # if mutation:\n babygenes[i]=mutation # baby[i] = mutation\n else # else:\n if rand(100) < 50 # if random() < 0.5:\n babygenes[i] = mgenes[i] # babyGenes[i] = mGene[i]\n else # else:\n babygenes[i] = sgenes[i] # babyGenes[i] = sGene[i]\n end\n end\n end\n\n babygenes.reverse # return bagygenes (reversed back)\nend",
"def mill_motor_housing\r\n # # # # # # # # #\r\n end",
"def _hensel_lift(g0, f0, _char, height, where)\n # self in MPolynomial/ZorZp\n # g0 in Polyomial/ZorZp, candidate of factor of f0\n # f0 in Polyomial/ZoZzp, one variable reduction of self\n\n ring = self.class\n ring_one = g0.class\n\n h0, r0 = f0.divmod g0\n raise 'each_product does not work well' unless r0.zero?\n\n # where = 0\n ary = [g0, h0]\n cofacts = mk_cofacts(ary)\n fk = ary.collect { |fx| fx.value_on_one(ring, where) } # MPolynomial\n\n height.times do |k|\n c = self - fk[0] * fk[1]\n h = c.annihilate_away_from(where, k + 1)\n h_alpha0 = h.collect_away_from(where, ring_one) # Hash: ind0=>Polynomial\n h_alpha = {}\n\n h_alpha0.each do |ind, ha|\n h_alpha[ind] = yield(ha, ary, cofacts)\n end\n\n hias = ary.collect { {} }\n h_alpha.each do |ind, ha_i|\n ha_i.each_with_index do |fx, i|\n next if fx.zero?\n hias[i][ind] = fx\n end\n end\n\n hi = hias.collect do |hia|\n e = ring.zero\n hia.each do |ind, fx|\n e += ring.monomial(ind) * fx.value_on_one(ring, where)\n end\n e\n end\n fk_new = []\n hi.each_with_index do |fx, i|\n fk_new.push fk[i] + fx\n end\n fk = fk_new\n end\n fk\n end",
"def mitch_hedberg; end",
"def superweening_adorningly(counterstand_pyrenomycetales)\n end",
"def crossover\r\n @population += @crossover.times.map do\r\n pos = rand(@length)\r\n first, second = 2.times.map{ @population[rand(@population.length)][:value] }\r\n firstmap = (1<<@length)-(1<<pos)\r\n secondmap = (1<<pos)-1\r\n value = (first & firstmap) + (second & secondmap)\r\n # puts (\"%.#{@length}b\" % first) + ' cross(' + (\"%5i\" % pos) + ') ' + (\"%.#{@length}b\" % second) + ' --> ' + (\"%.#{@length}b\" % value)\r\n bear(value)\r\n end\r\n end",
"def hiddens; end",
"def hecto\n big_self * HECTO\n end",
"def work_out\n self.happiness = @happiness + 2\n self.hygiene = @hygiene - 3\n \"♪ another one bites the dust ♫\"\n end",
"def remanet(concupiscibleness, torve_resack)\n seeker(bloomery, crumbcloth_lacepod, inspirant_inalterably)\n antispadix_provencalize(galactophthysis, saintlike)\n japheth(auresca, squamatine, vitalist_pheal)\n end",
"def techno_percussion len\n self << len.Dist # bass drum\n mapee_last.clear_hits\n mapee_last << 4.eqly_spaced\n # max len is full, min quarter\n h_num = mapee_last.hits.count\n h_num = 1 if h_num == 0\n mapee_last.length= rand_range(len*0.666/h_num, len*0.11/h_num) \n\n self << len.Dist # snare\n mapee_last.clear_hits\n mapee_last << [0.25,0.75]\n h_num = mapee_last.hits.count\n h_num = 1 if h_num == 0\n mapee_last.length= rand_range(len/h_num, len/h_num/2) \n \n self << len.Dist # hi\n mapee_last.clear_hits\n mapee_last << 4.eqly_spaced\n mapee_last.hits.move(0.125) # offbeats\n h_num = mapee_last.hits.count\n h_num = 1 if h_num == 0\n mapee_last.length= rand_range(len*0.666/h_num, len*0.666/h_num/2) \n \n self\n end",
"def gunfire_nominee(peridiastolic_proctor, scabland_shakenly, hypoalimentation_ensweep)\n petricola_foraminifer(henry_speculatrix, underwrite)\n laconic_cagayan_swarty(semitaur_documentize, papilionaceous)\n end",
"def walkhigh(i,j,object)\r\n w=0\r\n counter =4\r\n while w < 4\r\n if @nha2[i][j+w] == object\r\n counter =counter -1\r\n end\r\n w+=1\r\n end\r\n return counter\r\n end",
"def jack_handey; end",
"def huella\n\t\tindice1 = 0\n\t\t#dependiendo del vct de cada ingrediente, se le pone un indice\n\t\tif vct < 670\n\t\t\tindice1 = 1\n\t\t\t\n\t\telsif vct > 830\n\t\t\tindice1 = 3\n\t\telse \n\t\t\tindice1 = 2\n\t\tend \n\t\tindice2 = 0\n\t\t#dependiendo de los gases emitidos de cada ingrediente, \n\t\t#se le pone un indice\n\t\tif emisiones < 800\n\t\t\tindice2 = 1\n\t\telsif emisiones > 1200\n\t\t\tindice2 = 3\n\t\telse \n\t\t\tindice2 = 2\n\t\tend\n\t\t#hace la media de los indices sacados\n\t\tindiceres = (indice1+indice2)/2\n\t\t\n\n\tend",
"def crossover\n p1 = rand(@elements)\n p2 = rand(@elements)\n # to modify to p1 must be smaller than p2\n p1, p2 = p2, p1 if p2 < p1\n (p1..p2).each do |index|\n @tg[@s1][index], @tg[@s2][index] = @tg[@s2][index], @tg[@s1][index]\n end\n end",
"def difficultly(qoph_ridding, fadedness_santalaceae)\n biopsychologist_hamidian_tachardiinae()\n inigo()\n huddock_konde(phrenitic, mistake, condurango_cymoscope)\n end",
"def sittinae_hooey(scrawny_appulsion, termly)\n end",
"def crossover(mom, dad)\r\n\t\t# Just return the parents as offspring depending on the xover rate or\r\n\t\t# if the parents are the same, or if @chromo_length is zero.\r\n\t\treturn mom, dad if ( mom == dad || @chromo_length.zero? || rand(0..1.0) > @xover_rate )\r\n\r\n\t\t# Determine a xover point.\r\n\t\txover_point = rand(0..@chromo_length - 1)\r\n\r\n\t\t# Create the offspring.\r\n\t\tfred, george = Genome.new, Genome.new\r\n\r\n\t\t# Copy into baby1 the section of mom's genome ending (and excluding)\r\n\t\t# the xover_point.\r\n\t\tfred.concat mom[0...xover_point]\r\n\t\t# Copy into baby2 the section of dad's genome ending (and excluding)\r\n\t\t# the xover_point.\r\n\t\tgeorge.concat dad[0...xover_point]\r\n\r\n\t\t# Copy the remainder of dad and mom into fred and george, respectively.\r\n\t\t# Notice both Fred and George get half of mom and half of dad.\r\n\t\tfred.concat dad[xover_point..-1]\r\n\t\tgeorge.concat mom[xover_point..-1]\r\n\r\n\t\treturn fred, george\r\n\tend",
"def joke; end",
"def hatch\n @status = Idle\n @target = nil\n @virility = 0\n babies = []\n rand(MaxBabiesFromEgg).to_i.times {babies << baby_salmon}\n babies\n end",
"def look_at_tie(hand1,hand2)\n\t# Empty face_value1 array created for hand1 faces\n\tface_value1 = []\n\t# Empty face_value2 array created for hand2 faces\n\tface_value2 = []\n\n\thand1.each do |card|\n\t\t# Pushing the face of each card into the empty array and grabbing it by the first index. Ex: \"Kd\" => \"K\" (\"[0][1]\")\n\t\tface_value1 << card[0]\n\tend \n\t# Setting the face_changer function equal to the hand1_faces variable\n\thand1_faces = face_changer(face_value1)\n\t# Sorting the array of faces(after they go through facechanger they turn into integers)\n \tsorted_faces1 = hand1_faces.sort\n \tsorted_faces_sum1 = sorted_faces1.sum\n \t# new_hand1 puts non-duplicated elements into an array\n \tnew_hand1 =\tsorted_faces1.group_by { |card| card }.select { |k, v| v.size.eql? 1 }.keys\n \t# Finds the duplicates and returns one\n \thand1_dupes = sorted_faces1.select{|item| sorted_faces1.count(item) > 1}.uniq\n \t# Adds duplicates together\n \thand1_dupes_sum = hand1_dupes.sum\n \tnext_kicker1 = new_hand1.pop\n\thand2.each do |card|\n\t\tface_value2 << card[0]\n\tend\n\thand2_faces = face_changer(face_value2)\n \tsorted_faces2 = hand2_faces.sort\n \tsorted_faces_sum2 = sorted_faces2.sum\n \tnew_hand2 = sorted_faces2.group_by { |card| card }.select { |k, v| v.size.eql? 1 }.keys\n \thand2_dupes = sorted_faces2.select{|item| sorted_faces2.count(item) > 1}.uniq\n \thand2_dupes_sum = hand2_dupes.sum\n \tnext_kicker2 = new_hand2.pop\n\n \t# If hand1's duplicate sum is greater than hand2's duplicate sum then return the \"hand1 wins string\"\n\tif hand1_dupes_sum > hand2_dupes_sum \n\t\t\"Player One(hand1) wins!\" \n \t# If hand1's duplicate sum is less than hand2's duplicate sum then return the \"hand2 wins string\"\n\telsif hand1_dupes_sum < hand2_dupes_sum\n\t \t \"Player Two(hand2) wins!\"\n \t# If hand1's duplicate sum is equal to hand2's duplicate sum then go to next conditional\n\telse \n \tsplit_the_pot(hand1,hand2)\n end\nend",
"def heroine; end",
"def tongue_twister; end",
"def horloges_parties\n cmd = []\n cmd << %Q{-stroke gray50 -fill -pointsize 6.5 -strokewidth 2}\n # Pour le paradigme absolu\n decs = [0,30,60,90,120] # on en aura besoin ci-dessous\n decs.each do |dec|\n h = Horloge.new(horloge:realtime(dec).to_horloge, top:self.class.top_horloge_part_absolue, left:realpos(dec), bgcolor:'gray50', color:'gray90')\n cmd << h.magick_code\n end\n\n # Pour le paradigme propre au film\n [ne(:dv), ne(:d2)||ne(:cv), ne(:dn)].each_with_index do |neu, idx|\n next if neu.nil?\n dec = decs[idx+1]\n leftpos = realpos(dec)\n top = self.class.top_horloge_part_relative\n h = Horloge.new(horloge:neu.time.to_i.to_horloge, top:top, left:leftpos, bgcolor:'gray20', color:'white')\n cmd << h.magick_code\n # Pour le décalage\n leftdec = realpos(dec + 2.5)\n diff = neu.time.to_i - realtime(dec)\n pref = diff > 0 ? '+' : '−'\n cmd << %Q{-stroke black -fill black -draw \"text #{leftdec},#{top+LINE_HEIGHT/5} '#{pref}#{diff.abs.to_horloge}'\"}\n end\n\n return cmd.join(' ')\nend",
"def debuterHypothese\n\t\t0.upto(@n-1) do|x| \n\t\t\t0.upto(@n-1) {|y| \n\t\t\t\t@hypothese[x][y] = @plateauJoueur[x][y].couleur\n\t\t\t}\n\t\tend\n\tend",
"def toughish(homogeneously_meum)\n end",
"def honk_horn\n @horn\n end",
"def triple_crown_winner_formula\n # TODO: implement\n end",
"def josephus(n,m)\n\n while n.size>0\n puts n.rotate!(m-1).shift(1)\n josephus(n,m)\n end\nend",
"def happy_unhappy_unhappiness\n # The distance between 'i' and 'y' is 0.5. The distance between and two\n # other non-equal phone pairs is 1. This ensures that 'i' and 'y' will tend\n # align with each other.\n happy_unhappy_phones =<<-EOTEXT\n FORM, LETTER, CLASS\n i, i, iy\n y, y, iy\n a, a, a\n e, e, e\n h, h, h\n n, n, n\n p, p, p\n s, s, s\n u, u, u\n EOTEXT\n phone_table = PhoneticAlign::PhoneTable.new(happy_unhappy_phones)\n # Phonetic sequences\n # Meanings\n un_meaning = PhoneticAlign::FeatureValueMatrix[:POL => :neg]\n happy_meaning = PhoneticAlign::FeatureValueMatrix[:LEMMA => :happy]\n ness_meaning = PhoneticAlign::FeatureValueMatrix[:POS => :noun]\n # Morphemes\n un_morph = PhoneticAlign::SurfaceMorpheme.new(un_meaning, phone_table.phone_sequence(\"un\"))\n happy_morph = PhoneticAlign::SurfaceMorpheme.new(happy_meaning, phone_table.phone_sequence(\"happy\"))\n happy_happi_morph = PhoneticAlign::SurfaceMorpheme.new(happy_meaning, phone_table.phone_sequence(\"happi\"), \n [phone_table.phone_sequence(\"happy\"),\n phone_table.phone_sequence(\"happi\")])\n ness_morph = PhoneticAlign::SurfaceMorpheme.new(ness_meaning, phone_table.phone_sequence(\"ness\"))\n # Words consisting of all phones.\n happy_p = PhoneticAlign::Word.new(phone_table.phone_sequence(\"happy\"), happy_meaning)\n unhappy_p = PhoneticAlign::Word.new(phone_table.phone_sequence(\"unhappy\"), un_meaning + happy_meaning)\n unhappiness_p = PhoneticAlign::Word.new(phone_table.phone_sequence(\"unhappiness\"), un_meaning + happy_meaning + ness_meaning)\n # Words consisting of phones and morphemes.\n unhappy_pm = PhoneticAlign::Word.new([un_morph] + phone_table.phone_sequence(\"happy\"), un_meaning + happy_meaning)\n # Words consisting of all morphemes\n happy_m = PhoneticAlign::Word.new([happy_morph], happy_meaning)\n unhappy_m = PhoneticAlign::Word.new([un_morph, happy_morph], un_meaning + happy_meaning)\n happy_happi_ness_m = PhoneticAlign::Word.new([happy_happi_morph, ness_morph], happy_meaning)\n unhappy_happi_ness_m = PhoneticAlign::Word.new([un_morph, happy_happi_morph, ness_morph], un_meaning + happy_meaning + ness_meaning)\n return Struct.new(:phone_table,\n :happy_p, :unhappy_p, :unhappiness_p,\n :unhappy_pm,\n :happy_m, :unhappy_m, :happy_happi_ness_m, :unhappy_happi_ness_m,\n :un_meaning, :happy_meaning, :ness_meaning).new(\n phone_table,\n happy_p, unhappy_p, unhappiness_p,\n unhappy_pm,\n happy_m, unhappy_m, happy_happi_ness_m, unhappy_happi_ness_m,\n un_meaning, happy_meaning, ness_meaning)\nend",
"def hire_thief\r\n\t\t@thieves += 1\r\n\t\tputs \"*\"*50\r\n\t\tputs \"You just hired a new thief, you now have #{@thieves} thieves working for you.\"\r\n\t\tputs \"*\"*50\r\n\tend",
"def forkless(interspinous_interdevour, cladodontid_michel)\n end",
"def chord; end",
"def hornlike(adet_mortification, hyperconscious)\n shadowiness_priceable(disinterment, pericellular_homogenization)\n counterbreastwork_knickerbockered()\n subspecialty_universalian(whereon, ciliated_papaverous, eurhodine)\n end",
"def generate_offspring_by_taguchi_method\n expected_number = 0.5 * @pop_size * @cross_rate\n n = 0\n m = @chromosomes.size\n while n < expected_number\n loop do\n x = rand(0...m)\n y = rand(0...m)\n next if x == y\n\n chromosome_x = @chromosomes[x]\n chromosome_y = @chromosomes[y]\n opt_chromosome = generate_optimal_chromosome chromosome_x, chromosome_y\n @chromosomes << opt_chromosome\n break\n end\n n += 1\n end\n end",
"def step\r\n crossover\r\n mutation\r\n # Compute selection order based on energy\r\n p = @population.map{ |i| [i, i[:energy] * (1 - @selection + rand * @selection) ] }\r\n # Select next generation: fitter individuals (lower energy number)\r\n # will be selected with higher propability \r\n @population = p.sort{ |a,b| a[1] <=> b[1] }[0..@size].map{|i, o| i}\r\n end",
"def towerofhanoi(pieces, sourcepeg, destinationpeg, extrapeg)\n if pieces == 0 then\n return \"no pieces to move\"\n end\n towerofhanoi(pieces-1,sourcepeg,extrapeg,destinationpeg)\n puts \"moved #{pieces} from \" + \"#{sourcepeg} to #{destinationpeg}\"\n towerofhanoi(pieces-1,extrapeg,destinationpeg,sourcepeg)\nend",
"def strokes_gained(hcp)\n if handicap <= (hcp%18)\n hcp/18 + 1\n else\n hcp/18\n end\n end",
"def kexy_corebel?(sheikdom_sanguinarily)\n unsyringed?(swotter_uncoherentness, tetartoid)\n end",
"def victory(joueur)\n\t\t# On définit les 8 possibilités de victoires si elles se vérifient les 3 dans la combinaison donnée alors la partie s'arrête\n\t\tif (plateau[0] == joueur.value) && (plateau[1] == joueur.value) && (plateau[2] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\n\t\telsif (plateau[3] == joueur.value) && (plateau[4] == joueur.value) && (plateau[5] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telsif (plateau[0] == joueur.value) && (plateau[3] == joueur.value) && (plateau[6] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telsif (plateau[2] == joueur.value) && (plateau[4] == joueur.value) && (plateau[6] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telsif (plateau[0] == joueur.value) && (plateau[4] == joueur.value) && (plateau[8] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telsif (plateau[2] == joueur.value) && (plateau[5] == joueur.value) && (plateau[8] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telsif (plateau[1] == joueur.value) && (plateau[4] == joueur.value) && (plateau[7] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telse\n\t\t\treturn\n\t\tend\n\tend",
"def cuddle\n attempt = [0, 1]\n hug = attempt.sample\n end",
"def haul\n @totalhaul = @silvercounter * SILVERVAL + @goldcounter * GOLDVAL\n @totalhaul\n end",
"def crossover(p0, p1)\n children = []\n if rand < @rate\n c0, c1 = Chromosome.new, Chromosome.new\n min = [p0.length, p1.length].min\n index = rand(min)\n for i in index...min\n c0 << p0[i].copy\n c1 << p1[i].copy\n end\n children << fill(c0, p1)\n children << fill(c1, p0)\n end\n children\n end",
"def point_crossover(other, n)\n indexes = (0...self.size).to_a # Insieme degli indici possibili\n points = [] # Insieme di punti di taglio del crossover\n n.times { points.push(indexes.delete_at(rand(indexes.size))) } # Prende casualmente n indici (diversi) possibili e li include in points\n a, b = self, other \n son_str = (0...self.size).map do |i|\n a, b = b, a if points.include?(i) # Se incontra un punto di crossover effettua uno swap\n a[i] # Elemento da includere in son\n end\n son_str\n end",
"def prepare_thermo_soe(groupby_out_collection)\n oa_temp = operations.map {|op| op.input(OVERLAP_Tm).val}.uniq.first\n f_amplicon_arr = operations.map {|op| op.output(OUTPUT).sample.properties.length}\n final_ave_amplicon_len = f_amplicon_arr.reduce(:+).to_f / f_amplicon_arr.size\n # Referance: https://www.ncbi.nlm.nih.gov/pubmed/28959292\n show do\n title \"Setting Up Theromcycler\"\n separator\n note \"Go to an open thermocycler and select program: <b>#{SOE_THERMO_TEMPLATE}</b>\"\n note \"<b>Thermocycler Conditions</b>:\"\n bullet \"Pre-heat lid to 100#{DEGREES_C}\"\n bullet \"95#{DEGREES_C} for 1 minute\"\n note \"<b>10 Cycles of</b>:\"\n bullet \"95#{DEGREES_C} for 45 seconds\"\n bullet \"45#{DEGREES_C} for 1:30 min\"\n # bullet \"#{oa_temp}#{DEGREES_C} for 15 seconds\"\n bullet \"68#{DEGREES_C} for 45 seconds\"\n note \"<b>25 Cycles of</b>:\"\n bullet \"95#{DEGREES_C} for 45 seconds\"\n bullet \"#{oa_temp}#{DEGREES_C} for 1 min\"\n bullet \"72#{DEGREES_C} for 1:30 minutes\"\n note \"<b>Final Extension</b>\"\n bullet \"72#{DEGREES_C} for #{((final_ave_amplicon_len * 45) / 60).ceil}:#{((final_ave_amplicon_len * 45) % 60).ceil} minutes\"\n bullet \"Hold at 4#{DEGREES_C}\"\n check \"Place prepped samples #{groupby_out_collection.map {|coll, ops| coll.id} } on the thermocycler\"\n end\n groupby_out_collection.each {|coll, ops| coll.location = 'Thermocycler'}\n end",
"def hiss; end",
"def dish; end",
"def crossover(genome)\n\t\tself_values = @values\n\t\tother_values = genome.values\n\n\t\tvalues =\n\t\t\tArray.new(self_values.size) do |i|\n\t\t\t\t[self_values, other_values][rand(2)][i]\n\t\t\tend\n\n\t\tGenomeValues.new(values)\n\tend",
"def work_out\n self.happiness += 2\n self.hygiene -= 3\n return \"♪ another one bites the dust ♫\" \n end",
"def electromechanical; end",
"def take_fish_from_river\n @stomach.concact(fish_count)\n end",
"def prox\n\t\trandom_weighted @jugadas\n\t\t\n\tend",
"def uniform_crossover(other)\n size = self.size\n model = \"%0#{size}b\" # Stringa binaria di una definita dimensione con 0 come riempitivo\n mask = (model % (rand(2**size))) # Crea una maschera binaria casuale\n son_str = (0...size).map do |i| # Crea il figlio\n mask[i,1] == \"1\" ? self[i] : other[i] # Analizza la maschera: 1->self , 0->other\n end\n son_str\n end",
"def cross_phase other\n complex2 other, :cross_phase\n end",
"def validerHypothese()\n\t\[email protected]\n\t\[email protected]\n\t\[email protected](tmp)\n\t\treturn @grillesHypothese.last\n\tend",
"def inv_hilbert(shape, opts={})\n opts = {:dtype => :float64}.merge(opts)\n m = NMatrix.new([shape,shape],opts)\n combination = NMatrix.new([2*shape,2*shape],opts)\n #combinations refers to the combination of n things taken k at a time\n 0.upto(2*shape-1) do |i|\n 0.upto(i) do |j|\n if j != 0 and j != i\n combination[i,j] = combination[i-1,j] + combination[i-1,j-1]\n else\n combination[i,j] = 1\n end\n end\n end\n\n 0.upto(shape-1) do |i|\n 0.upto(i) do |j|\n m[i,j] = combination[shape + j,shape - i - 1] * ((i+j)+1) * \\\n combination[shape + i,shape - j - 1] * (-1) ** ((i+j)) * \\\n combination[(i+j),i] * combination[(i+j),i]\n m[j,i] = m[i,j] if i != j\n end\n end\n m\n end",
"def gethashespersec\n coind.gethashespersec\n end",
"def test_portsmouth_recurve_scoring # Recurve\n\n portsmouth_std_definition = [\n {'range_in_meters' => 18.288, 'total_shots' => 60, 'target_diameter_cm' => 60, 'scoring_scheme' => 'METRIC'}\n ]\n\n # 599 sin tables = 5\n [ [308, 71], [501, 47], [587, 18], [599, 4] ].each do | score, expected_hc |\n result = AgbHandicap.calculate(score, portsmouth_std_definition)\n assert_equal expected_hc, result, \"Portsmouth #{score} score should be #{expected_hc}\"\n end\n end",
"def complex_super_heroe\n heroes = [\"iron man\", \"hulk\", \"black widow\", \"thor\", \"captain marvel\"]\nend",
"def calculate_hyperballs\n while hyperball_once\n @ball_size += 1\n end\n\n print_centralities\n end",
"def honk_horn\n\n @honk_horn = \"Whoop\"\n end",
"def alg; end",
"def rest(hours)\n\t\t#permanently add strength up to a point\n\t\thours.times do\n\t\t\tif @strength < 20\n\t\t\t\t@strength += rand(0..3)\n\t\t\t\tputs \"#{self.name} feels stronger!\"\n\t\t\tend\n\t\tend\n\t\t@caffeine_level = 51\n\tend",
"def huella\n huella = @alimentos.inject([0,0,0]) do |acc, i|\n if i.kcal_total < 670\n acc[0] += (1.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n elsif i.kcal_total > 830\n acc[0] += (3.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n else acc[0] += (2.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n end\n if (i.gases * 1000.0) < 800\n acc[0] += (1.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n elsif (i.gases * 1000.0) > 1200\n acc[0] += (3.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n else\n acc[0] += (2.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n\t\t\tend\n\n\t\t\tacc[2] += (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos))\n acc[1] += 1\n acc\n\t\tend\n\n\t\treturn (huella[0] / (2.0 * huella[2])).round(2)\n\tend",
"def h_hug(pos)\n shape = shape_in_pos(pos)\n is_empty = make_empty_test(shape)\n #score = 0\n cardinals = [Up, Down, Left, Right]\n shape.reduce(0) do |scr, point|\n cardinals.reduce(0) do |score, dir|\n adj_point = plus(point, dir)\n if [email protected]_at(adj_point)\n then score + 2\n elsif is_empty.(adj_point) &&\n !leads_up?(adj_point, is_empty, 2)\n then score - 1\n else score\n end\n end + scr\n end\n end",
"def he(e1, e2)\n heByDiving(e1, e2) || heByCoupling(e1, e2)\n end",
"def sharkteeth(c,h)\n polygon([[0,0],[(h*0.02).to_i,(h*0.015).to_i],[0,(h*0.03).to_i]],:stroke=>\"none\",:fill=>c) # sharktooth from left to right\n end",
"def jumps_sees\n phones =<<-EOTEXT\nFORM, VOWEL, NASAL, VOICED\ndʒ,-,-,+\nm,-,+,-\nŋ,-,+,+\np,-,-,-\ns,-,-,-\nz,-,-,+\ni,+,-,+\nʌ,+,-,+\nEOTEXT\n words =<<-EOTEXT\nFORM, LEMMA, PERNUM, ASPECT\ndʒʌmp,jump, non-3sg, perfect\ndʒʌmps,jump, 3sg, perfect\ndʒʌmpiŋ,jump,, imperfect\nsi,see, non-3sg, perfect\nsiz,see, 3sg, perfect\nsiiŋ,see,, imperfect\nEOTEXT\n [phones, words]\nend",
"def linked_genes (parent1, parent2, w, p1, p2, p)\n #First, we perform a chi square test\n observed = [w.to_f, p1.to_f, p2.to_f, p.to_f]\n total = observed[0] + observed[1] + observed[2] + observed[3]\n expected = [total*9/16, total*3/16, total*3/16, total*1/16]\n chi = 0\n for i in 0..3\n val = ((observed[i]-expected[i])**2)/expected[i]\n chi = chi + val\n end\n case\n when chi>7.815 #Given three degrees of freedom, a p-value of 0.05 corresponds to 7.815\n #First, we call the method SeedStock.gene_from_seed, which using the seed stock returns the ID of the associated gene\n mutant_gene_1 = SeedStock.gene_from_seed(parent1)\n mutant_gene_2 = SeedStock.gene_from_seed(parent2)\n #Then, we call the method Gene.gene_from_id, which using the gene ID returns the corresponding gene\n gene_1 = Gene.gene_from_id(mutant_gene_1)\n gene_2 = Gene.gene_from_id(mutant_gene_2)\n #We add the linked gene to the gene_name property\n if gene_1.linked_genes == 'no linked genes'\n gene_1.linked_genes = [gene_2.gene_name]\n else\n gene_1.linked_genes.push(gene_2.gene_name)\n end\n if gene_2.linked_genes == 'no linked genes'\n gene_2.linked_genes = [gene_1.gene_name]\n else\n gene_2.linked_genes.push(gene_1.gene_name)\n end\n #Prints which genes are linked\n puts \"RECORDING: #{gene_1.gene_name} is genetically linked to #{gene_2.gene_name} with chisquare score #{chi}\"\n end\n end",
"def convolution_cyclopeptide_sequencing(spectrum, n, m, integer_mass)\n convolution = spectral_convolution(spectrum)\n extended_alphabet = restrict(convolution, m)\n #puts extended_alphabet.join(' ')\n leaderboard = Set.new\n leader_peptide = []\n leaderboard << leader_peptide\n leader_score = 0\n mass_parent = spectrum.last.to_i\n puts \"mass_parent #{mass_parent}\"\n # due to consistency constraints, we can only expand by integer masses that appear\n # in the spectrum and in the extended alphabet\n expandables = extended_alphabet & integer_mass\n #puts expandables.join(' ')\n while !leaderboard.empty?\n leaderboard = expand(leaderboard, expandables)\n leaderboard.each do |peptide|\n mass_peptide = mass(peptide)\n if mass_peptide == mass_parent\n # score the peptide cyclospectrum with experimental spectrum\n pep_score = cyclopeptide_scoring(peptide, spectrum)\n if pep_score > leader_score\n leader_peptide = peptide\n leader_score = pep_score\n puts \"new leader with score #{pep_score}: #{leader_peptide.join(' ')}\"\n end \n elsif mass_peptide > mass_parent\n leaderboard.delete(peptide)\n end\n end\n leaderboard = trim(leaderboard.to_set, spectrum, n)\n end\n leader_peptide\nend",
"def gameover\n op_hand.clear\n end",
"def take_bath\n self.hygiene += 4\n return \"♪ Rub-a-dub just relaxing in the tub ♫\"\n @hygiene\n end",
"def potion; end",
"def champagne_tower(gp, qr, qc)\n pyramid = []\n (1..qr + 1).each do |i|\n pyramid << Array.new(i, 0)\n end\n pyramid[0][0] = gp\n (0..qr + 1).each do |r|\n (0..r + 1).each do |c|\n q = (pyramid[r][c] - 1.0) / 2.0\n if q > 0\n pyramid[r + 1][c] += q\n pyramid[r + 1][c + 1] += q\n end\n end\n end\n return min(1, pyramid[qr][qc])\nend",
"def meow\r\n\t\t# output: prints string of # of meows based on talkative-ness\r\n\t\t\t# IF mild (1 to 3) , meows once\r\n\t\t\tputs \"meowww\" if (1..3).include?(@meowiness)\r\n\t\t\t# IF medium (4 to 6), meows 3 times\r\n\t\t\t3.times { print \"meowww \"} if (4..6).include?(@meowiness)\r\n\t\t\t# IF high (7 to 8), meows 5 times,\r\n\t\t\t5.times { print \"meowwww \" } if (7..8).include?(@meowiness)\r\n\t\t\t# IF really high (9 to 10), meows 5 times, CAPS\r\n\t\t\t5.times { print \"meowwww \".upcase } if (9..10).include?(@meowiness)\r\n\t\tend",
"def acosh\n math :acosh\n end",
"def hseq; @genomic.seq; end",
"def take_bath\n #increment hygiene_points by 4\n #return string \"♪ Rub-a-dub just relaxing in the tub ♫\"..\n self.hygiene +=4\n return \"♪ Rub-a-dub just relaxing in the tub ♫\"\n end",
"def josephus(items,k)\n n = -1\n out = []\n while items.length > 0 do \n n = (n + k) % items.length \n out.push(items.slice!(n))\n n -= 1 \n end\n out\nend",
"def procreate(mate, crossover_prob, mutation_prob, crossover_method_name)\n mate_str = mate.genestring\n son_str = self.genestring.dup # La stringa del figlio e' per ora un clone di quella del padre\n if crossover_prob >= rand # Se rientra nella probabilita esegue il crossover se no usa se stesso\n son_str = son_str.send(crossover_method_name, mate_str) # [Reflection] Esegue il metodo di crossover scelto con parametro 'mate'\n end\n son_str.mutation!(mutation_prob) # Mutazione del figlio con una data probabilita\n son_str\n end",
"def geck_gutling(frivolous, endways)\n meteogram?(galatae, eisteddfodism, spital)\n end",
"def get_product_of_lego_pieces(\n lego_hash:\n )\n lego_hash[:gave_her_friend].each do |num|\n lego_hash[:count_of_lego].delete_at(lego_hash[:count_of_lego].find_index(num))\n end\n # return result\n lego_hash[:count_of_lego][0] * lego_hash[:count_of_lego][1]\nend",
"def win_hp\n maxhp * features_sum(:hp_on_win)\n end",
"def roll_over\n\t\tputs \"Look I am upside down, scratch my belly\"\n\tend",
"def phase_one\n introduction\n title \"Phase One\"\n losers = 0\n immune_members = []\n 8.times do\n losing_tribe = @borneo.tribes.shuffle.first\n puts \"The losing tribe is #{losing_tribe}\".red\n loser = losing_tribe.tribal_council()#no immune members\n puts \" The loser member is #{loser}\"\n losers += 1\n counting = 0\n @borneo.tribes.each{|tribe| counting += tribe.members.length}\n puts \" #{losers} gone!\"\n puts \" #{counting} remaining players\"\n end\nend",
"def skew(genome)\n # Note that we can compute Skewi+1(Genome) from Skewi(Genome) according to the nucleotide in position i of Genome. \n # If this nucleotide is G, then Skewi+1(Genome) = Skewi(Genome) + 1; \n # if this nucleotide is C, then Skewi+1(Genome)= Skewi(Genome) – 1; otherwise, Skewi+1(Genome) = Skewi(Genome). \n\n skew = []\n g_minus_c = 0\n skew << g_minus_c\n genome.chars.each do |dna|\n if dna == \"C\"\n g_minus_c = g_minus_c - 1 \n elsif dna == \"G\"\n g_minus_c = g_minus_c + 1 \n end\n skew << g_minus_c\n end \n\n return skew\n end",
"def spouse; end",
"def check_target_in_exon(exon_id,strand_target,strand,len_bioseq,exones_site)\r\n #we are going to keep the exon_id, the strand and the location of the target for the gff file\r\n target_in_exon = Hash.new\r\n strand_target.each do |pos|\r\n #c=[]--> vector auxiliar \r\n c=[]\r\n pos.zip(exones_site).map { |x, y| c << x-y}\r\n if c[0] >=0 && c[1] <= 0\r\n if strand == 'reverse'\r\n #the target is in the exon\r\n #for the format of ebi we have to change again our start and final points \r\n e_start = len_bioseq - pos[1].to_i\r\n e_final = len_bioseq - pos[0].to_i\r\n target_in_exon[[e_start,e_final]] = [exon_id,'-']\r\n else\r\n target_in_exon[[pos[0],pos[1]]] = [exon_id,'+']\r\n end\r\n end\r\n end\r\n if not target_in_exon.empty? # We check there are targets inside the exon\r\n return target_in_exon\r\n end\r\nend",
"def surge; end",
"def resetHypothese()\n\t\[email protected]\n\tend",
"def check_best_targs\n if @oriented == \"h\"\n @consec_hits = @consec_hits.sort\n letter = @consec_hits[0][0]\n num1 = @consec_hits[0].gsub(/[A-Z]/,\"\").to_i\n num2 = @consec_hits[1].gsub(/[A-Z]/,\"\").to_i\n # Add a shot to the left 2 hits\n @best_targs << letter + \"#{num1 - 1}\"\n # Add a shot to the right of the 2 hits\n @best_targs << letter + \"#{num2 + 1}\"\n elsif @oriented == \"v\"\n number = @consec_hits[0].gsub(/[A-Z]/,\"\")\n letter1 = @consec_hits[0][0].ord\n letter2 = @consec_hits[1][0].ord\n # Add a shot above the two hits\n @best_targs << (letter1 - 1).chr + number\n # Add a shot below the two hits\n @best_targs << (letter1 + 1).chr + number\n end\n @best_targs\n end",
"def herald; end",
"def ChenThongDiep (pixel)\n\t\t\t\n\t\t\tred = pixel.red.to_bin(8).chars #pixel.red kieu integer -> nhi phan -> array char\n\t\t\tred[7] = @thongdiep[@dem] # chen 1 bit cua thong diep vao bit cuoi cua pixel.red\n\t\t\tpixel.red = red.join.to_i(2) # array char -> string -> integer\n\t\t\t@dem += 1 # dem \n\t\t\t\n\t\t\tif @dem == @thongdiep.length # kiem tra da chen het thong diep chua\n\t\t\t\treturn \n\t\t\tend\n\t\t\tgreen = pixel.green.to_bin(8).chars\n\t\t\tgreen[7] = @thongdiep[@dem]\n\t\t\tpixel.green = green.join.to_i(2)\n\t\t\t@dem += 1\n\t\t\t\n\t\t\tif @dem == @thongdiep.length\n\t\t\t\treturn \n\t\t\tend\n\t\t\tblue = pixel.blue.to_bin(8).chars\n\t\t\tblue[7] = @thongdiep[@dem]\n\t\t\tpixel.blue = blue.join.to_i(2)\n\t\t\t@dem += 1\n\t\t\tif @dem == @thongdiep.length\n\t\t\t\treturn \n\t\t\tend\n\n\t\t\n\tend",
"def display_egg_hatch(pokemon)\n call_scene(GamePlay::Hatch, pokemon)\n $quests.hatch_egg\n end",
"def rejeterHypothese()\n\t\[email protected]\n\n\t\tif @grillesHypothese.empty?\n\t\t\treturn @grillePrim\n\t\telse\n\t\t\treturn @grillesHypothese.last\n\t\tend\n\tend",
"def reproduction(selected_to_breed)\n 0.upto(selected_to_breed.length/2-1).map do |i|\n offspring = Chromosome.reproduce(selected_to_breed[2*i], selected_to_breed[2*i+1])\n offspring.age = -1\n offspring \n end\n end",
"def check_conflict_horse(start_item, end_item)\r\n res = ''\r\n horse_list = get_piece_list(:cav, start_item.color_piece)\r\n if horse_list.size > 2\r\n raise \"Error More then 2 horses. why?\"\r\n end\r\n # iterate horses \r\n horse_list.each do |horse|\r\n if horse.row == start_item.row and \r\n horse.col == start_item.col\r\n # same pice as start_item\r\n next\r\n end\r\n # the second piece, check if the end position is compatible\r\n if (end_item.row == horse.row - 1 or end_item.row == horse.row + 1) and\r\n (end_item.col == horse.col - 2 or end_item.col == horse.col + 2)\r\n # end position compatible with the first\r\n #p \"extra info horse column #{start_item.color_piece}\"\r\n #print_board\r\n if start_item.col == horse.col\r\n res = \"#{start_item.row + 1}\"\r\n else\r\n res = start_item.colix_tostr\r\n end\r\n end \r\n # another possibility\r\n if (end_item.row == horse.row - 2 or end_item.row == horse.row + 2) and\r\n (end_item.col == horse.col - 1 or end_item.col == horse.col + 1)\r\n # end position compatible with the first\r\n #p \"extra info horse column #{start_item.color_piece}\"\r\n #print_board\r\n if start_item.col == horse.col\r\n res = \"#{start_item.row + 1}\"\r\n else\r\n res = start_item.colix_tostr\r\n end\r\n end\r\n end\r\n \r\n return res\r\n end",
"def wizards_trial()\n\n\t#Initialize hats and gnomes\n\thats = [\"red\", \"white\"]\n\tgnomes = [\"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\", \"ten\"]\n\n\t#Line up gnomes and place hats on them\n\thatted_gnomes = {}\n\tgnomes.each do |gnome|\n\t\thatted_gnomes[gnome] = hats.sample\n\tend\n\n\t#Have gnomes guess which color hats they have on\n\tguesses = gnome_guesses(hatted_gnomes)\n\n\t#Judge the gnomes\n\tjudge_the_gnomes(guesses, hatted_gnomes)\n\nend"
] |
[
"0.59347844",
"0.5621788",
"0.5465388",
"0.54503626",
"0.5357019",
"0.5343498",
"0.5335991",
"0.53165025",
"0.52779514",
"0.5262449",
"0.52537465",
"0.5250839",
"0.523483",
"0.5174462",
"0.51702744",
"0.51432186",
"0.51346135",
"0.5128135",
"0.51277333",
"0.5114139",
"0.51038146",
"0.5090749",
"0.50899196",
"0.50876266",
"0.50684774",
"0.5066111",
"0.5056905",
"0.5054895",
"0.50522125",
"0.5050345",
"0.50273395",
"0.50081325",
"0.5007353",
"0.50018364",
"0.4995257",
"0.49911535",
"0.4990129",
"0.49864292",
"0.49830034",
"0.4975196",
"0.49717036",
"0.49708194",
"0.4964965",
"0.49600282",
"0.49526092",
"0.494157",
"0.49348795",
"0.4924541",
"0.4921795",
"0.49161202",
"0.49088228",
"0.48924267",
"0.48871118",
"0.48818353",
"0.48804703",
"0.48783332",
"0.487597",
"0.487276",
"0.4871929",
"0.4870814",
"0.4867914",
"0.48663408",
"0.4863583",
"0.4862086",
"0.4857489",
"0.48550126",
"0.48534012",
"0.48504865",
"0.48498526",
"0.48471013",
"0.48427492",
"0.48405302",
"0.4833433",
"0.48319292",
"0.4831889",
"0.4831866",
"0.48294482",
"0.48274496",
"0.4819061",
"0.48178378",
"0.481734",
"0.48170424",
"0.48122936",
"0.48055056",
"0.48017344",
"0.47979066",
"0.47874597",
"0.4772186",
"0.4772052",
"0.4771034",
"0.47704574",
"0.47686937",
"0.47681928",
"0.47639593",
"0.4763913",
"0.4763726",
"0.47636646",
"0.47576421",
"0.47528797",
"0.47469735",
"0.47380674"
] |
0.0
|
-1
|
fight for fitness and glory. Winners get to breed
|
def compete(population,size=5)
#fight to the death
competition = Population.new(size,false)
size.times do
competition.addMember(population.getRandomMember())
end
return competition.getFittest
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def fight (game)\n @state.fight(self, game)\n end",
"def battle\n # Runden auf 0 setzen, continue auf true (Für die Schleife)\n round = 0\n continue = true\n victory = false\n # Bilde Arrays mit allen nötigen Werten für den Kampf\n turn_fleet = build_array(@attacker, @attacker_fleet)\n target_fleet = build_array(@defender, @defender_fleet)\n emp_phase(@attacker)\n emp_phase(@defender)\n # Angreifer beginnt\n turn_user = @attacker\n target_user = @defender\n while (round < 1000 && continue ) do\n round = round + 1\n if target_user == @defender\n @fight_shield = @defender_shield\n else\n @fight_shield = @attacker_shield\n end\n # Damit alle Gruppen in einer Runde nur auf das Schild feuern können\n shield = @fight_shield\n # Für die Ausgabe der Runden-Berichte\n turn_fleet.each do |fleet|\n # Nur Einheiten mit Anzahl > 0 und Schaden > 0 können kämpfen\n if fleet[1] > 0 && fleet[2] > 0 \n # Bestimme Ziel anhand von id.\n # -2 ist Miss\n # -1 ist Schild\n target = hit(target_fleet, turn_user)\n if(target==-1)\n mult = 1\n # Falls Ionenwaffe, wird Schaden an Schild erhöht\n if fleet[3] == 2\n mult = DamageType.find(fleet[3]).shield_mult\n end\n damage = fleet[2] * mult\n # Abzug des Schilds. Übernahme erst bei nächster Runde\n @fight_shield = @fight_shield - damage\n else\n mult = 1\n # Falls Laserwaffe, wird Schaden an Hülle erhöht\n # TABELLE DAMAGETYPE EINFÜGEN\n if (fleet[3] == 1)\n mult = DamageType.find(fleet[3]).shell_mult\n end \n if fleet[3] == 3 and !fleet[6]\n mult = DamageType.find(fleet[3]).station_mult\n end\n if fleet[3] == 4 and fleet[0] == @plattform_id\n mult = DamageType.find(fleet[3]).plattform_mult\n end \n # Bestimme welche Einheit getroffen wurde\n victim = target_fleet[target]\n # Schadensberechnung\n damage = fleet[2] * mult\n # Berechne neue HP\n hit_points = victim[-2]\n victim[-2] = hit_points-damage\n # Berechne Anzahl und Schaden neu\n update_ship_group(victim, target_user)\n end\n end \n end\n # Füge Runden-Bericht ein\n # Testet, ob Spieler noch Truppen besitzt\n if (defeat(target_fleet))\n continue = false\n if turn_user == @attacker\n victory = true \n end\n else\n # Falls Schild unter 0, wird er auf 0 gesetzt\n if @fight_shield < 0\n @fight_shield = 0\n end\n # Kampf-Schild für nächste Runde\n if target_user == @attacker\n @attacker_shield = @fight_shield\n else\n @defender_shield = @fight_shield\n end\n # Tausche Rolle des Angreifers aus\n tmp_fleet = turn_fleet\n tmp_user = turn_user\n turn_fleet = target_fleet\n turn_user = target_user\n target_fleet = tmp_fleet\n target_user = tmp_user\n end\n # Füge alle Runden-Berichte hinzu\n end\n if continue\n @report << \"Unentschieden! \"\n @report << \"Es konnte kein Sieger ermittelt werden \"\n else \n @report << \"Die Flotte von #{target_user.username} unterlag. \"\n @report << \" #{turn_user.username} war siegreich! \"\n end\n # Generiere Verlustrechnung\n attacker_fleet_ary = []\n defender_fleet_ary = []\n if turn_user == @attacker\n lost_report(turn_fleet, @attacker) \n lost_report(target_fleet, @defender) \n attacker_fleet_ary = turn_fleet\n defender_fleet_ary = target_fleet\n else\n lost_report(target_fleet, @attacker) \n lost_report(turn_fleet, @defender) \n\n attacker_fleet_ary = target_fleet\n defender_fleet_ary = turn_fleet\n end\n update_fighting_fleet(@attacker_fleet, attacker_fleet_ary)\n update_fighting_fleet(@defender_fleet, defender_fleet_ary)\n ary = [@attacker_fleet, @defender_fleet] \n return [@report, @spy_report]\n end",
"def fight\n @state.fight(self)\n end",
"def fight\n display_hero_attack(attack_resolver(hero, monster))\n if monster.current_health > 0\n display_monster_attack(attack_resolver(monster, hero))\n else\n hero_win\n end\n end",
"def fight\n # TODO: Add this back in, in a curses way\n #puts\n #puts \"========FIGHT========\"\n #puts \"#{@hero.name} Vs #{@monster.name}\"\n #puts\n\n # Populate an array with X number of levels Hero is and Y number of levels Monster is\n # This way whoever is a higher level has a better chance of attacking \n attack_arr = []\n @hero.level.to_i.times { attack_arr.push(\"Hero\") }\n @monster.level.to_i.times { attack_arr.push(\"Monster\") }\n\n # Loop until one character dies\n while @hero.cur_health > 0 && @monster.cur_health > 0\n case attack_arr.shuffle.first\n when \"Hero\" then @monster.cur_health -= @hero.strength\n when \"Monster\" then @hero.cur_health -= @monster.strength\n end\n end\n\n return (@hero.cur_health > @monster.cur_health)\n end",
"def fight\n if !is_able?\n return false\n end\n if maximus?\n return gladiators.pop\n end\n if is_tie?\n return true\n end\n sort_win()\n return gladiators.pop\n end",
"def fight()\n\tputs \"--------------------\"\n\tputs \"Let's fight, but first we go to the coffe shop.\"\n\tgo_to_coffee_shop()\n\tnumber_of_turns = 10 + rand(20)\n\tputs \"------------------\"\n\tputs \"TIME TO FIGHT! There are #{number_of_turns} rounds in this fight!\"\n\tnumber_of_turns.times do |x|\n\t\tputs \"------------------\"\n\t\tputs \"Round #{x+1}, FIGHT!\"\n\t\tcurrent_fighter = Person.person_array.sample\n\t\t\n\t\tif current_fighter.is_a?(PowerRanger)\n\t\t\trandom_roll = rand(10)\n\t\t\tcurrent_fighter.run() if random_roll==0\n\t\t\tcurrent_fighter.scream() if random_roll==1\n\t\t\tcurrent_fighter.punch() if random_roll >= 2 && random_roll <= 6\n\t\t\tcurrent_fighter.megazord() if random_roll >= 7 && random_roll <=9\n\t\telsif current_fighter.is_a?(EvilNinja)\n\t\t\trandom_roll = rand(10)\n\t\t\tcurrent_fighter.run() if random_roll==0\n\t\t\tcurrent_fighter.scream() if random_roll==1\n\t\t\tcurrent_fighter.punch() if random_roll >= 2 && random_roll <= 6\n\t\t\tcurrent_fighter.cause_mayhem() if random_roll >= 7 && random_roll <=9\n\t\telse\n\t\t\trandom_roll = rand(2)\n\t\t\tcurrent_fighter.run() if random_roll==0\n\t\t\tcurrent_fighter.scream() if random_roll==1\n\t\tend\n\tend\n\tputs \"-------------------\"\nend",
"def win_fight\n if $boss_hp <= 0\n puts \"You win!\"\n $in_combat = false\n $in_boss = false\n $dead_boss = true #add a unique dialogue somewhere if this is true\n $in_forest = true\n end\nend",
"def battle\n # Runden auf 0 setzen, continue auf true (Für die Schleife)\n round = 0\n continue = true\n # Bilde Arrays mit allen nötigen Werten für den Kampf\n turn_fleet = build_array(@attacker, @attacker_fleet)\n target_fleet = build_array(@defender, @defender_fleet)\n # Angreifer beginnt\n turn_user = @attacker\n target_user = @defender\n while (round < 1000 && continue ) do\n round = round + 1\n if target_user == @defender\n @fight_shield = @defender_shield\n else\n @fight_shield = @attacker_shield\n end\n # Damit alle Gruppen in einer Runde nur auf das Schild feuern können\n shield = @fight_shield\n # Für die Ausgabe der Runden-Berichte\n round_report = []\n round_report << \"Runde #{round+1}: \"\n round_report << \"#{turn_user.username} ist am Zug.\"\n if shield > 0\n round_report << \"Schild von #{target_user.username} ist aktiv.\"\n round_report << \"Schild hält noch #{shield} Schaden aus.\"\n round_report << \"Alle Truppen schießen auf den Schildt!\"\n else \n round_report << \"Schild von #{target_user.username} ist inaktiv.\"\n round_report << \"Angriffe werden nicht abgewehrt!\"\n round_report << \" \"\n end\n turn_fleet.each do |a|\n # Nur Einheiten mit Anzahl > 0 und Schaden > 0 können kämpfen\n if a[1] > 0 && a[2] > 0 \n round_report << \"Die Gruppe #{a[5]} trifft... \"\n # Bestimme Ziel anhand von id.\n # -2 ist Miss\n # -1 ist Schild\n target = hit(target_fleet, turn_user)\n if(target == -2)\n round_report << \"nicht. Der Angriff ging daneben. \"\n round_report << \" \"\n round_report << \" \"\n elsif(target==-1)\n round_report << \"das Schild. Der Schaden beträgt: \"\n mult = 1\n # Falls Ionenwaffe, wird Schaden an Schild erhöht\n if a[3] == 2\n mult = 1.5\n end\n damage = a[2] * mult\n round_report << \"#{damage} \"\n round_report << \" \"\n # Abzug des Schilds. Übernahme erst bei nächster Runde\n @fight_shield = @fight_shield - damage\n else\n mult=1\n # Falls Laserwaffe, wird Schaden an Hülle erhöht\n # TABELLE DAMAGETYPE EINFÜGEN\n if(a[3]==1)\n mult=1.5\n end \n # Bestimme welche Einheit getroffen wurde\n victim=target_fleet[target]\n # round_report << \"#{victim[5]}. Der Schaden beträgt: \"\n # Schadensberechnung\n damage=a[2]*mult\n round_report << \"#{damage} \"\n # Berechne neue HP\n hit_points=victim[-2]\n victim[-2]=hit_points-damage\n # Berechne Anzahl und Schaden neu\n update_ship_group(victim)\n round_report << \"#{victim[4]} Einheiten wurden zerstört. \"\n end\n end \n # Füge Runden-Bericht ein\n # @round_reports << round_report\n end\n # Testet, ob Spieler noch Truppen besitzt\n if (defeat(target_fleet))\n continue=false\n else\n # Falls Schild unter 0, wird er auf 0 gesetzt\n if @fight_shield < 0\n @fight_shield = 0\n end\n # Kampf-Schild für nächste Runde\n if target_user==@attacker\n @attacker_shield=@fight_shield\n else\n @defender_shield=@fight_shield\n end\n # Tausche Rolle des Angreifers aus\n tmp_fleet=turn_fleet\n tmp_user=turn_user\n turn_fleet=target_fleet\n turn_user=target_user\n target_fleet=tmp_fleet\n target_user=tmp_user\n end\n # Füge alle Runden-Berichte hinzu\n @report << @round_reports\n end\n if continue\n @report << \"Unentschieden! \"\n @report << \"Es konnte kein Sieger ermittelt werden \"\n else \n @report << \"Die Flotte von #{target_user.username} unterlag. \"\n @report << \" #{turn_user.username} war siegreich! \"\n end\n # Generiere Verlustrechnung\n if turn_user == @attacker\n lost_report(turn_fleet, @attacker) \n lost_report(target_fleet, @defender) \n else\n lost_report(target_fleet, @attacker) \n lost_report(turn_fleet, @defender) \n end\n end",
"def battle\n # Your failures might strengthen the enemy\n rune_charges = 0\n if @artifact_rune == 0\n puts \"Rune of Dwayna provides Balthazar regeneration\"\n puts \"When he is about to die, he will use this artifact\"\n puts\n rune_charges = 3\n end\n\n puts \"Don't be afraid of fighting a God, #{@gladiator.name}\"\n puts \"As just a mere mortal, you brought him upon your feet!\"\n puts \"And after all you can gaze into his eyes without any trouble\"\n puts \"Still be careful and choose your weapon wisely.\"\n puts \"Don't forget, he draws his powers from Fire.\"\n puts \"When you are ready, enter any key to continue...\"\n gets\n # User character's base values\n gladiator_str = @gladiator.strength+10\n gladiator_heal = @gladiator.health*10\n\n puts \"Commander, your initial strength is #{gladiator_str}\"\n puts \"Commander, your initial health is #{gladiator_heal}\"\n puts \"Enchant your weapon with the sigil of your choice:\"\n\n puts \"1) Sigil of Water\"\n puts \"2) Sigil of Earth\"\n puts \"3) Sigil of Fire\"\n puts \"4) Sigil of Air\"\n puts \"5) No Sigil\"\n # Enemy base values\n enemy_str = 5\n enemy_heal = 150\n # Character may get a buff/nerf according to his choice\n sigil = gets.to_i\n\n if sigil == 1\n puts \"Sigil Of Water, very good choice against the God of Fire...\"\n gladiator_str += 10\n puts \"Your strength has decreased to #{gladiator_str}\"\n elsif sigil == 2\n puts \"Sigil Of Earth, kind of a good choice against the God of Fire...\"\n gladiator_str += 5\n puts \"Your strength has decreased to #{gladiator_str}\"\n elsif sigil == 3\n puts \"Sigil Of Fire, very bad choice against the God of Fire...\"\n gladiator_str -= 10\n puts \"Your strength has increased to #{gladiator_str}\"\n elsif sigil == 4\n puts \"Sigil Of Air, not a good choice against the God of Fire...\"\n gladiator_str -= 5\n puts \"Your strength has increased to #{gladiator_str}\"\n else\n puts \"You decided to use no sigil on your weapon.\"\n end\n\n puts \"When you are ready, enter any key to continue...\"\n gets\n\n puts \"The battle has begun!\"\n # Battle continues while enemy and gladiator are alive\n while enemy_heal > 0 && gladiator_heal > 0\n\n puts \"You attack Balthazar successfully\"\n enemy_heal -= gladiator_str\n puts \"Balthazar's health is #{enemy_heal}\"\n # In enemy possesses a special item, he can heal back several times.\n if enemy_heal <= 0 && rune_charges > 0\n puts \"Balthazar uses Rune of Dwayna to heal the killing blow\"\n enemy_heal += gladiator_str\n rune_charges -= 1\n end\n # Enemy always strikes last\n if enemy_heal > 0\n puts \"Balthazar strikes at you\"\n gladiator_heal -= enemy_str\n puts \"Your health is #{gladiator_heal}\"\n @gladiator.notify(\"harm\")\n puts\n end\n end\n # Outcome of final battle is designated here.\n # User has several retry changes before losing completely.\n if enemy_heal <= 0\n @gladiator.notify(\"win\")\n puts \"You have defeated Balthazar! Now the world is safe.\"\n puts \"Or is it?\"\n puts \"...\"\n\n elsif @retries > 0\n @gladiator.notify(\"lose\")\n puts \"Balthazar has beaten you... You'll return again.\"\n @retries -= 1\n battle\n else\n @gladiator.notify(\"lose\")\n puts \"You are dead... Game Over!\"\n end\n end",
"def fight( enemy, weapon )\n if life <= 0\n puts \"[#{ self.class } is too dead to fight!]\"\n return\n end\n \n # Attack the opponent\n your_hit = rand( strength + weapon )\n puts \"[You hit with #{ your_hit } points of damage!]\"\n enemy.hit( your_hit )\n\n # Retaliation\n puts \"[#{ enemy.class } has #{enemy.life} life remaining!!]\"\n if enemy.life > 0\n enemy_hit = rand( enemy.strength + enemy.weapon )\n puts \"[Your enemy hit with #{ enemy_hit } points of damage!]\"\n self.hit( enemy_hit )\n end\n end",
"def monsterfight(user, monster, mAtk, enemy)\n\n#make a loop with a boolean value. The loop will keep running unless somebody's health goes to zero or \n#the user runs away\n\n\tenemy['name'] = monster.sample\n\tcombat = true\n\n\tif enemy['name'] == 'Mutated Octopus'\n\t\tenemy['hp'] = 7\n\t\tenemy['atkSpd'] = 6\n\t\tenemy['armor'] = 1\n\n\telsif enemy['name'] == 'Sabertooth Goldfish'\n\t\tenemy['hp'] = 6\n\t\tenemy['atkSpd'] = 5\n\t\tenemy['armor'] = 1\n\n\telsif enemy ['name'] == 'Lady Gaga'\n\t\tenemy['hp'] = 8\n\t\tenemy['atkSpd'] = 8\n\t\tenemy['armor'] = 1\n\n\telsif enemy ['name'] == 'Hannah Montana'\n\t\tenemy['hp'] = 10\n\t\tenemy['atkSpd'] = 10\n\t\tenemy['armor'] = 1\n\tend\n\n\tputs ''\n\n# choosing the random attack of the monster. no need to push into a hash\n\tdef monsterAttack(user, mAtk, enemy)\n\t\trandAttack = mAtk.sample\n\n\t\tif randAttack == 'Slap'\n\t\t\tmonsterDmg = 1\n\t\t\tuser['health'] -= 1\n\n\t\telsif randAttack == 'Bite'\n\t\t\tmonsterDmg = 2\n\t\t\tuser['health'] -= 1\n\n\t\telsif randAttack == 'Eyepoke'\n\t\t\tmonsterDmg = 3\n\t\t\tuser['health'] -= 1\n\t\tend\n\n\t\tputs \"You get hit by #{enemy['name']} for #{monsterDmg}. Your health is now #{user['health']}\"\n\t\t\n\tend\n\n\tdef heroAttack(user, enemy)\n\n\t\theroAttack = user['weapon']\n\n\t\tif heroAttack == 'Sword'\n\t\t\thitDmg = rand(2...5)\n\t\t\tenemy['hp'] -= hitDmg\n\n\t\telsif heroAttack == 'Spear'\n\t\t\thitDmg = rand(1...6)\n\t\t\tenemy['hp'] -= hitDmg\n\n\t\telsif heroAttack == 'Axe'\n\t\t\thitDmg = rand(3...4)\n\t\t\tenemy['hp'] -= hitDmg\n\t\tend\n\t\t\n\t\tputs \"You hit the #{enemy['name']} for #{hitDmg}. Their health is now #{enemy['hp']}\"\n\tend\n\n\tputs \"A wild #{enemy['name']} has appeared. Do you choose to fight or run? (enter 'fight' or 'run')\"\n\n\tchoice = gets.chomp.downcase\n\n\twhile (user['health'] > 0 && enemy['hp'] > 0 && combat == true)\n\n\t\tif choice == 'fight'\n\t\t\tputs 'Alright lets do this!'\n\t\t\tmonsterAttack(user, mAtk, enemy)\n\t\t\theroAttack(user, enemy)\n\n\t\telsif choice == 'run'\n\t\t\tputs 'You attempt to escape'\n\n\t\telsif choice != 'fight' || choice != 'run' \n\t\t\tputs 'Please enter \"fight\" or \"run\"'\n\t\t\tchoice = gets.chomp.downcase\n\t\tend\n\n\t\tif enemy['hp'] > 0 && user['health']\n\t\t\tputs \"Continue fighting? (fight or run)\"\n\t\t\tchoice = gets.chomp.downcase\n\n\t\telsif enemy['hp'] <= 0\n\t\t\tputs \"You have killed #{enemy['name']}\"\n\t\t\tcombat == false\n\n\t\telsif user['health'] <= 0\n\t\t\tputs \"You have died\"\n\t\t\tcombat == false\n\t\tend\n\tend\n\nend",
"def fight(enemy, weapon)\n if life <= 0\n puts \"[#{self.class} is too dead!]\"\n return\n end\n\n #Attack the opponent\n your_hit = rand(strength+weapon)\n puts \"[you hit with #{your_hit} points of damage!]\"\n enemy.hit(your_hit)\n\n #Retaliation\n p enemy\n if enemy.life >0\n enemy_hit = rand(enemy.strength + enemy.weapon)\n puts \"[your enemy hit with #{enemy_hit} points of damage!]\"\n self.hit(enemy_hit)\n end\n end",
"def _fight(p1, p2, context)\n msg = context[:msg]\n \n \n \n msg += line \"<div> 战斗开始!</div>\"\n \n # calculate temporary fight prop\n # p1.tmp[:apply_damage] = p1.query_weapon_damage\n # p1.tmp[:apply_dodge] = 0-p1.query_all_weight\n # p1.tmp[:apply_defense] = p1.query_armo_defense \n \n \n \n calc_apply_var(p1)\n p \"====>p1 load: #{p1.tmp[:apply_dodge]} damage:#{p1.tmp[:apply_damage]} defense:#{p1.tmp[:apply_defense] }\"\n calc_apply_var(p2)\n p \"====>p2 load: #{p2.tmp[:apply_dodge]} damage:#{p2.tmp[:apply_damage]} defense:#{p2.tmp[:apply_defense] }\"\n \n # calculate who attach first \n # TODO need improve\n if (p1.query_temp(\"dext\")+p1.tmp[:apply_dodge] > p1.query_temp(\"dext\")+p2.tmp[:apply_dodge])\n attacker = p1\n #attacker_gain = gain_p1\n defenser = p2\n # defenser_gain = gain_p2\n else\n attacker = p2\n #attacker_gain = gain_p2\n defenser = p1\n #defenser_gain = gain_p1\n end\n \n p \"attacker is #{attacker.name}\"\n msg += translate_msg(line(\"<div>$N抢先发动进攻!</div>\"), {:user=>attacker, :target=>defenser})\n \n \n # what weapon attacker is wielding\n hand_right_weapon = p1.query_wearing(\"handright\")\n hand_left_weapon = p1.query_wearing(\"handleft\")\n p1.tmp[:right_hand_weapon] = hand_right_weapon\n p1.tmp[:left_hand_weapon] = hand_left_weapon\n p \"=>righthand weapons #{hand_right_weapon}\"\n p \"=>lefthand weapons #{hand_left_weapon}\"\n # defaut is unarmed\n weapon_skill_type = 'unarmed'\n if (hand_right_weapon)\n weapon_skill_type = hand_right_weapon.skill_type\n p1.tmp[:main_weapon] = hand_right_weapon\n \n elsif hand_left_weapon\n weapon_skill_type = hand_left_weapon.skill_type\n p1.tmp[:main_weapon] = hand_left_weapon\n end\n \n=begin\n reg = /unarmed/i\n if (hand_right_weapon)\n weapon_type = hand_right_weapon.type\n reg = Regexp.new(\"#{weapon_type}\", true)\n end\n=end \n context_p1 = {\n :user => p1,\n :thisskill => nil,\n :skills=>p1.query_all_skills,\n :target => p2\n }\n # attacker choose the best dodge skill\n p1[:dodge_skill] = choosBestDodgeSkill(context_p1)\n # attacker choose the skill have best damage\n p1[:attack_skill] = choosBestAttackSkill(context_p1, weapon_skill_type)\n # attacker choose best defense skill\n p1[:defense_skill] = choosBestDefenseSkill(context_p1, weapon_skill_type)\n \n # choose perform for p1\n skill_types = []\n if p1.tmp[:left_hand_weapon]\n skill_types.push(p1.tmp[:left_hand_weapon].skill_type)\n else\n skill_types.push(\"unarmed\")\n end\n if p1.tmp[:right_hand_weapon]\n skill_types.push(p1.tmp[:right_hand_weapon].skill_type)\n else\n skill_types.push(\"unarmed\") if !skill_types.include?\"unarmed\"\n end\n p1.tmp[:perform] = chooseBestPerform(p1, skill_types)\n \n \n \n \n # choose skills for deffenser\n hand_right_weapon = p2.query_wearing(\"handright\")\n hand_left_weapon = p2.query_wearing(\"handleft\")\n p2.tmp[:right_hand_weapon] = hand_right_weapon\n p2.tmp[:left_hand_weapon] = hand_left_weapon\n p \"=>#{defenser.name} righthand weapons #{hand_right_weapon}\"\n p \"=>#{defenser.name} lefthand weapons #{hand_left_weapon}\"\n # defaut is unarmed\n weapon_skill_type = 'unarmed'\n if (hand_right_weapon)\n weapon_skill_type = hand_right_weapon.skill_type\n p2.tmp[:main_weapon] = hand_right_weapon\n elsif hand_left_weapon\n weapon_skill_type = hand_left_weapon.skill_type\n p2.tmp[:main_weapon] = hand_left_weapon\n end\n context_p2 = {\n :user => p2,\n :thisskill => nil,\n :skills=>p2.query_all_skills,\n :target => p1\n }\n # defenser choose the best dodge skill\n p2[:dodge_skill] = choosBestDodgeSkill(context_p2)\n # defenser choose the skill have best damage\n p2[:attack_skill] = choosBestAttackSkill(context_p2, weapon_skill_type)\n # defenser choose best defense skill\n p2[:defense_skill] = choosBestDefenseSkill(context_p2, weapon_skill_type) \n \n # choose perform for p2\n skill_types = []\n if p2.tmp[:left_hand_weapon]\n skill_types.push(p2.tmp[:left_hand_weapon].skill_type)\n else\n skill_types.push(\"unarmed\")\n end\n if p2.tmp[:right_hand_weapon]\n skill_types.push(p2.tmp[:right_hand_weapon].skill_type)\n else\n skill_types.push(\"unarmed\") if !skill_types.include?\"unarmed\"\n end\n p2.tmp[:perform] = chooseBestPerform(p2, skill_types)\n \n \n gain_p1 = {\n :exp =>0,\n # :hp =>0,\n # :stam =>0,\n :pot => 0,\n :level =>0,\n :skills =>{\n p1[:dodge_skill][:skill][:skname] =>\n {\n :skill => p1[:dodge_skill][:skill][:skname],\n :point => 0,\n :level => 0,\n :dname =>p1[:dodge_skill][:skill].dname\n },\n p1[:attack_skill][:skill][:skname] =>\n {\n :skill => p1[:attack_skill][:skill][:skname],\n :point => 0,\n :level => 0,\n :dname =>p1[:attack_skill][:skill].dname\n },\n p1[:defense_skill][:skill][:skname]=>\n {\n :skill => p1[:defense_skill][:skill][:skname],\n :point => 0,\n :level => 0,\n :dname =>p1[:defense_skill][:skill].dname\n }\n }\n }\n gain_p2 = {\n :exp =>0,\n # :hp =>0,\n # :stam =>0,\n :pot => 0,\n :level =>0,\n :skills =>{\n p2[:dodge_skill][:skill][:skname] =>\n {\n :skill => p2[:dodge_skill][:skill][:skname],\n :point => 0,\n :level => 0,\n :dname =>p2[:dodge_skill][:skill].dname\n },\n p2[:attack_skill][:skill][:skname] =>\n {\n :skill => p2[:attack_skill][:skill][:skname],\n :point => 0,\n :level => 0,\n :dname =>p2[:attack_skill][:skill].dname\n },\n p2[:defense_skill][:skill][:skname]=>\n {\n :skill => p2[:defense_skill][:skill][:skname],\n :point => 0,\n :level => 0,\n :dname =>p2[:defense_skill][:skill].dname\n }\n }\n }\n p \"==>gain.skill #{gain_p1.inspect}\"\n p \"==>gain.skill #{gain_p2.inspect}\"\n # context[:gain_p1] = gain_p1\n # context[:gain_p2] = gain_p2\n p1[:gain] = gain_p1\n p2[:gain] = gain_p2\n \n if (attacker == p1)\n attacker_gain = gain_p1\n defenser_gain = gain_p2\n else\n attacker_gain = gain_p2\n defenser_gain = gain_p1\n end\n \n p1.tmp[:willperform]=0\n p2.tmp[:willperform]=0\n\n \n srand(Time.now.tv_usec.to_i)\n i = 0\n style_c = \"user\"\n \n # show status\n msg += status_lines(attacker, defenser)\n \n winner = nil\n=begin\n while (i < 100 ) # max 100 turn\n if style_c == \"user\"\n style_c = \"enemy\"\n else\n style_c = \"user\"\n end\n \n # msg += \"<!--1--><div class=\\\"#{style_c}\\\">\\n#{__fight(attacker, defenser)}\\n</div>\\n\";\n msg += \"\\n<div class=\\\"#{style_c}\\\">\\n#{__fight(attacker, defenser)}</div>\\n\"\n \n \n i = i+1\n \n \n \n if (defenser.tmp[:hp] <=0 )\n msg += line \"<div>#{defenser.name}战斗不能</div>\"\n winner = attacker\n break;\n end\n \n if (defenser.tmp[:stam] <=0 && attacker.tmp[:stam]<=0)\n msg += line \"<div>双方都已经精疲力尽了!</div>\"\n break;\n end\n \n # swap\n t = defenser\n defenser = attacker\n attacker = t\n \n \n \n end #while\n=end \n f_context={\n :style=>style_c,\n :round=>0,\n # :winner=>nil\n }\n msg += __fight(attacker, defenser, f_context)\n i = f_context[:round]\n # winner = f_context[:winner]\n context[:round] = f_context[:round]\n \n if (p1.tmp[:hp] >= 0 and p2.tmp[:hp] >=0) || (p1.tmp[:hp] < 0 and p2.tmp[:hp] <0)\n winner = nil\n elsif p1.tmp[:hp] >=0 \n winner = p1\n else \n winner = p2\n end\n #\n # save to db # TODO should the enemy also save gain ?\n #\n if attacker[:isUser]\n copyExt(attacker)\n end\n if defenser[:isUser]\n copyExt(defenser)\n end\n if (attacker[:canGain])\n receive_gain(attacker, attacker[:gain])\n end\n if (defenser[:canGain])\n receive_gain(defenser, defenser[:gain])\n end\n\n win = 0\n msg += \"<!--1-->\\n<div class='fight_result'><div class='win'>\\n\"\n if !winner\n win = -1\n if attacker[:isUser]\n msg += \"你和#{defenser.name}战成平手!}\"\n elsif defenser[:isUser]\n msg += \"你和#{attacker.name}战成平手!\"\n else\n msg += \"#{attacker.name}和#{defenser.name}战成平手!\"\n end\n else\n if winner == p1\n win = 1\n else\n win = 0\n end\n if (winner[:isUser])\n msg += \"You(#{winner.name}) <span class='f_win'>Win</span> !\"\n elsif (defenser[:isUser])\n msg += \"You(#{defenser.name}) <span class='f_lose'>Lose</span> !\"\n else\n msg += \"#{winner.name} <span class='f_win'>Win</span> !\"\n end\n end\n p attacker.tmp\n msg += \"(in #{i} rounds)</div>\\n\"\n msg += \"</div><!--0-->\"\n if (context[:msg])\n context[:msg] += msg\n else\n context[:msg] = msg\n end\n p context[:msg]\n # return attacker[:isUser]\n # return attacker == p1\n return win\n end",
"def fight\n return false if gladiators.size != 2\n\n # The names of each gladiator\n n1 = gladiators[0].name\n n2 = gladiators[1].name\n\n # Check for the special case that Maximus is around\n if n1 == \"Maximus\"\n remove(n2)\n return\n end\n\n if n2 == \"Maximus\"\n remove(n1)\n return\n end\n\n # If no Maximus, get weapons for each gladiator\n w1 = gladiators[0].weapon\n w2 = gladiators[1].weapon\n\n # If weapons are the same, remove both gladiators\n if w1 == w2\n remove(n1)\n remove(n2)\n else\n case w1\n when \"Spear\"\n # Spear loses to Trident but beats Club\n (w2 == \"Trident\") ? remove(n1) : remove(n2)\n when \"Trident\"\n # Trident loses to Club but beats Spear\n (w2 == \"Club\") ? remove(n1) : remove(n2)\n when \"Club\"\n # Club loses to Spear but beats Trident\n (w2 == \"Spear\") ? remove(n1) : remove(n2)\n end\n end\n end",
"def fight_scene\n\tjason = PowerRanger.new(\"Jason\", \"Red\")\n\ttommy = PowerRanger.new(\"tommy\", \"Green\")\n\tjon = Person.new(\"Jon\")\n\thoward = Person.new(\"Howard\")\n\tevilGuy_a = EvilNinja.new(\"Evil Guy 1\")\n\tevilGuy_b = EvilNinja.new(\"Evil Guy 2\")\n\n\tputs \"Two innocent bystanders are attacked by evil ninjas.\"\n\tjon.scream\n\thoward.scream\n\tjon.run\n\thoward.drink_coffee\n\thoward.run\n\n\tputs \"The Power Rangers arrive!\"\n\tjason.punch(evilGuy_a)\n\ttommy.punch(evilGuy_b)\n\tjason.rest(2)\n\ttommy.drink_coffee\n\n\tputs \"The Evil Ninjas fight back.\"\n\tevilGuy_a.punch(tommy)\n\tevilGuy_b.punch(tommy)\n\tevilGuy_a.cause_mayhem(jason)\n\n\tputs \"The Power Rangers try Megazord\"\n\tjason.use_megazord(evilGuy_a)\n\tevilGuy_a.punch(jason)\n\n\tputs \"Cmon Tommy!\"\n\ttommy.use_megazord(evilGuy_a)\n\ttommy.drink_coffee(10)\n\ttommy.use_megazord(evilGuy_b)\n\n\tputs \"Did the Power Rangers save the day?\"\n\n\tninja_array = [evilGuy_a, evilGuy_b]\n\twin = \"yes\"\n\n\tninja_array.each do |ninja|\n\t\t# p ninja.show_caffeine_level\n\t\tif ninja.caffeine_level > 0\n\t\t\twin = \"no\"\n\t\tend\n\tend\n\n\tif win == \"yes\"\n\t\tputs \"Yes!\"\n\telse\n\t\tputs \"No :(.\"\n\tend\n\nend",
"def fight(enemy, weapon)\n if life <= 0\n puts \"[#{self.class} is too dead to fight!]\"\n return\n end\n\n # Attack the opponent\n your_hit = rand(strength + weapon)\n puts \"[You hit with #{your_hit} points of damage!]\"\n enemy.hit(your_hit)\n\n # Retaliation\n p enemy\n if enemy.life > 0\n enemy_hit = rand(enemy.strength + enemy.weapon)\n puts \"[Your enemy hit with #{enemy_hit} points of damage!]\"\n hit(enemy_hit)\n end\n end",
"def attack(target)\n\n #check to see if there is any target\n if target == nil\n puts \"Invite some friends to play this awesome game.\".blue\n\n else\n #print fighting for the user\n\n puts Artii::Base.new.asciify \"Fight\"\n\n\n\n ###methods for determining probability of victory\n ###and damage to the opponent or current user#####\n\n #if the characters have the same attack power\n if self.power == target.power\n\n #if the player wins the battle\n if rand > 0.5\n\n #reduce the target's hp by 10\n target.update_hp(-10)\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Defeated #{target.name}\".green.on_light_blue.bold\n puts \"#{self.name} HP: #{self.hp}\"\n\n #see if the target is still alive\n if target.hp > 0\n puts \"#{target.name} HP: #{target.hp}\"\n end\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n\n #if the player loses the battle\n #reduce the player's hp\n else\n self.update_hp(-10)\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Lost Battle to #{target.name}\".black.on_light_red\n puts \"#{self.name} HP: #{self.hp}\"\n puts \"#{target.name} HP: #{target.hp}\"\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n end\n\n #if the player has a greater attack power than that of the target\n elsif self.power > target.power\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n\n #if the player wins the battle\n #calculation based on distance between the attack powers\n #of the player and target\n if rand < (0.4 + ((self.power - target.power).to_f/4))\n\n #reduce hp of the target\n target.update_hp(-5*(self.power - target.power))\n\n #print outcome of the battle\n puts \"#{self.name} Has Defeated #{target.name}\".green.on_light_blue.bold\n puts \"#{self.name} HP: #{self.hp}\"\n\n #check if target still alive\n if target.hp > 0\n puts \"#{target.name} HP: #{target.hp}\"\n end\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n\n #if the player loses the battle\n #reduce the player's hp\n else\n self.update_hp(-10)\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Lost Battle to #{target.name}\".black.on_light_red\n puts \"#{self.name} HP: #{self.hp}\"\n puts \"#{target.name} HP: #{target.hp}\"\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n end\n\n #if the player has a lower attack power than that of the target\n else\n\n #if the player wins the battle\n #calculation based on distance between the attack powers\n #of the player and target\n if rand > (0.45 + ((target.power - self.power).to_f/4))\n\n #reduce hp of the target\n target.update_hp(-2*(-self.power + target.power))\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Defeated #{target.name}\".green.on_light_blue.bold\n puts \"#{self.name} HP: #{self.hp}\"\n\n #check if target still alive\n if target.hp > 0\n puts \"#{target.name} HP: #{target.hp}\"\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n end\n\n #if the player loses the battle\n #reduce the player's hp\n else\n self.update_hp(-3*(-self.power + target.power))\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Lost Battle to #{target.name}\".black.on_light_red\n puts \"#{self.name} HP: #{self.hp}\"\n puts \"#{target.name} HP: #{target.hp}\"\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n end\n end\n end\n end",
"def fight(room, game)\n @fight_b.call(room, game)\n end",
"def battle\n\n puts \"You have reached the dragon's domain! You will fight him here.\"\n puts \"Mordremoth's biggest weakness if that he is made of plants.\"\n # User character's base values\n gladiator_str = @gladiator.strength+10\n gladiator_heal = @gladiator.health*10\n\n puts \"Commander, your initial strength is #{gladiator_str}\"\n puts \"Commander, your initial health is #{gladiator_heal}\"\n puts \"Enchant your weapon with the sigil of your choice:\"\n\n puts \"1) Sigil of Water\"\n puts \"2) Sigil of Earth\"\n puts \"3) Sigil of Fire\"\n puts \"4) Sigil of Air\"\n puts \"5) No Sigil\"\n # Enemy base values\n enemy_str = 5\n enemy_heal = 150\n # Character may get a buff/nerf according to his choice\n sigil = gets.to_i\n\n if sigil == 1\n puts \"Sigil Of Water, very bad choice against a plant enemy...\"\n gladiator_str -= 10\n puts \"Your strength has decreased to #{gladiator_str}\"\n elsif sigil == 2\n puts \"Sigil Of Earth, not a good choice against a plant enemy...\"\n gladiator_str -= 5\n puts \"Your strength has decreased to #{gladiator_str}\"\n elsif sigil == 3\n puts \"Sigil Of Fire, very good choice against a plant enemy...\"\n gladiator_str += 10\n puts \"Your strength has increased to #{gladiator_str}\"\n elsif sigil == 4\n puts \"Sigil Of Air, kind of good choice against a plant enemy...\"\n gladiator_str += 5\n puts \"Your strength has increased to #{gladiator_str}\"\n else\n puts \"You decided to use no sigil on your weapon.\"\n end\n\n puts \"When you are ready, enter any key to continue...\"\n gets\n\n puts \"The battle has begun!\"\n # Battle continues while enemy and gladiator are alive\n while enemy_heal > 0 && gladiator_heal > 0\n\n puts \"You attack Mordremoth successfully\"\n enemy_heal -= gladiator_str\n puts \"Mordremoth's health is #{enemy_heal}\"\n # Enemy always strikes last\n if enemy_heal> 0\n puts \"Mordremoth strikes at you\"\n gladiator_heal -= enemy_str\n puts \"Your health is #{gladiator_heal}\"\n @gladiator.notify(\"harm\")\n puts\n end\n end\n # Outcome of final battle is designated here.\n # User has several retry changes before losing completely.\n if enemy_heal <= 0\n @gladiator.notify(\"win\")\n puts\n puts \"You have defeated Mordremoth! Now the world is safe.\"\n puts \"Or is it? Find out in the next episode: Path Of Fire!\"\n\n elsif @retries > 0\n @gladiator.notify(\"lose\")\n puts \"Mordremoth has beaten you... You'll return again.\"\n @retries -= 1\n battle\n else\n @gladiator.notify(\"lose\")\n puts \"You are dead... Game Over!\"\n end\n end",
"def fight(user, enemies, player1, player2)\n while user.life_points >0 && (player1.life_points > 0 || player2.life_points >0)\n user.show_state\n puts \"\n Quelle action veux-tu effectuer ?\n\n a - chercher une meilleure arme\n s - chercher à se soigner \n \n attaquer un joueur en vue :\n\n 0 - Josiane a #{player1.life_points} points de vie\n 1 - José a #{player2.life_points} points de vie\"\n puts \"*******************************************************************\" \n choice = gets.chomp \n puts \"***********************************************************************\" \n \n if choice == \"a\" \n user.search_weapon\n elsif choice == \"s\"\n user.search_health_pack\n elsif choice == \"0\"\n user.attacks(player1)\n elsif choice == \"1\"\n user.attacks(player2)\n end\n\n puts \"***********************************************************************\" \n enemies.each do |x|\n break if x.life_points <= 0\n x.attacks(user)\n puts \"Les autres joueurs t'attaquent !\"\n end\n end \n if user.life_points > 0\n puts \"BRAVO ! TU AS GAGNE !\"\n else \n puts \"Loser ! Tu as perdu !\"\n end\nend",
"def fight\n monster = @game.current_room_model.monster\n player = @game.player\n return unless monster\n\n @game.state = FightingState.new @game\n\n if not player.weapons.empty?\n @game.state.status # Ask for weapon\n else\n @game.state.handle( nil ) # Start the fight directly\n end\n end",
"def fight\n if @gladiators.length == 2\n if @gladiators.first.weapon == @gladiators.last.weapon\n @gladiators.pop(2)\n elsif @gladiators.first.weapon == \"Spear\" && @gladiators.last.weapon == \"Trident\"\n @gladiators.shift(1)\n elsif @gladiators.first.weapon == \"Spear\" && @gladiators.last.weapon == \"Club\"\n @gladiators.pop(1)\n elsif @gladiators.first.weapon == \"Trident\" && @gladiators.last.weapon == \"Club\"\n @gladiators.shift(1)\n end\n end\n end",
"def /(enemy)\n fight(enemy, rand(4 + ((enemy.life % 10)**2)))\n end",
"def fight enemy, weapon\n if life <= 0\n return \"You are dead.\"\n end\n \n out = ''\n\n # Attack the opponent\n your_hit = rand(strength + weapon)\n out << \"[You hit the #{enemy.name} with #{your_hit} points of damage!]\\n\"\n out << enemy.hit(your_hit)\n\n # Retaliation\n if enemy.life > 0\n enemy_hit = rand(enemy.strength + enemy.weapon)\n out << \"[The #{enemy.name} hit with #{enemy_hit} points of damage!]\\n\"\n out << self.hit(enemy_hit)\n end\n out\n end",
"def /(enemy)\n fight(enemy, rand(4+((enemy.life%10) ** 2)))\n end",
"def /( enemy )\n fight( enemy, rand( 4 + ( ( enemy.life % 10 ) ** 2 ) ) )\n end",
"def /( enemy )\n fight( enemy, rand( 4 + ( ( enemy.life % 10 ) ** 2 ) ) )\n end",
"def cheats\n win if @gilbert.x > 2995 && @gilbert.y == 846.5\n end",
"def taking_damage_action\n if @warrior.feel(:backward).empty? && @health < 10\n @warrior.walk!(:backward)\n elsif @warrior.feel.empty?\n @warrior.walk!\n elsif @warrior.feel.enemy?\n @warrior.attack!\n end\n end",
"def gameflow\n \n end",
"def battle\n playerset($testing)\n fieldmonsters = []\n efieldmonsters = []\n @@monsterfield.each { |x| \n if x[:type] == \"monster\"\n fieldmonsters.push(x)\n end\n }\n if fieldmonsters.empty? == true\t\n puts \"There are no monsters to battle with\".red\n return\n end\n @@emonsterfield.each { |x| \t\t\t\n if x[:type] == \"monster\"\n efieldmonsters.push(x)\n end\n }\n if efieldmonsters.empty? == true\t\n puts \"There are no enemy monsters to battle\".red\n return\n end\n puts \"What monster do you choose?\"\n fieldmonsters.each {|x| puts x[:name]}\n response1 = gets.to_i\n response1 -= 1\n puts \"You have selected #{@@monsterfield[response1][:name]}\"\n puts \"What monster do you want to battle?\"\n efieldmonsters.each {|x| puts x[:name]}\n response2 = gets.to_i\n response2 -= 1\n answer = @@monsterfield[response1][:atk] - @@emonsterfield[response2][:atk]\n puts answer\n if answer < 0\n puts \"Your monster lost the battle\"\n $file.puts(\"#{@@name} loss a battle against #{@@ename}\")\n end\n if answer == 0\n puts \"Draw\"\n @@graveyard.push(@@monsterfield[response1])\n @@monsterfield.delete(@@monsterfield[response1])\n @@egraveyard.push(@@emonsterfield[response2])\n @@emonsterfield.delete(@@emonsterfield[response2])\n $file.puts(\"#{@@name} drew in a battle against #{@@ename}\")\n end\n if answer > 0\n puts \"Your monster won the battle\"\n $file.puts(\"#{@@name} won a battle against #{@@ename}\")\n decreaselp('enemy', answer)\n end\nend",
"def team_fight(team1, team2, context)\n # # sort by level\n # sort_team(team1, \"level\", true)\n # sort_team(team2, \"level\", true)\n index_player_team1 = 0\n index_player_team2 = 0\n p \"team1 size #{team1.size}\"\n p \"team2.size #{team2.size}\"\n i =0 \n while index_player_team2 < team2.size && index_player_team1 < team1.size\n p \"===>team1 player index #{index_player_team1}\"\n p \"===>team2 player index #{index_player_team2}\"\n p1 = team1[index_player_team1]\n p2 = team2[index_player_team2]\n \n p1_hp = p1.tmp[:hp]\n p2_hp = p2.tmp[:hp]\n p1_st = p1.tmp[:stam]\n p2_st = p2.tmp[:stam]\n if !p1.tmp[:contrib]\n p1.tmp[:contrib] = {\n :score =>0,\n :win => 0\n }\n end\n \n if !p2.tmp[:contrib]\n p2.tmp[:contrib] = {\n :score =>0,\n :win => 0\n }\n end\n \n context[:msg] += \"<div class='baomu'>第#{i+1}阵 <span class='user'>#{p1.name}</span> VS <span class='user'>#{p2.name}</span></div>\"\n \n fight_context = {:msg=>\"\"}\n win = _fight(p1, p2, fight_context)\n \n context[:msg] += fight_context[:msg]\n \n p1_hp_delta = 0-(p1.tmp[:hp]-p1_hp)\n p2_hp_delta = 0-(p2.tmp[:hp]-p2_hp)\n p1_st_delta = 0-(p1.tmp[:stam] - p1_st)\n p2_st_delta = 0-(p2.tmp[:stam] - p2_st)\n \n if win == 1\n p1.tmp[:contrib][:score] += calc_zhanli(p2)\n p1.tmp[:contrib][:win] += 1\n if p1_hp_delta >0\n p2.tmp[:contrib][:score] += calc_zhanli(p1)*p1_hp_delta\n end\n \n context[:msg] += \"<div><span class='user'>#{p1.name}稍作休息,体力有所恢复...</span></div>\"\n p1.tmp[:hp] += p1_hp_delta/3\n p1.tmp[:stam] += p1_hp_delta/2\n index_player_team2 += 1\n context[:team1win] += 1\n elsif win == 0\n p2.tmp[:contrib][:score] += calc_zhanli(p1)\n p2.tmp[:contrib][:win] += 1\n if p2_hp_delta > 0\n p1.tmp[:contrib][:score] += calc_zhanli(p2)*p2_hp_delta\n end\n context[:msg] += \"<div><span class='user'>#{p2.name}稍作休息,体力有所恢复...</span></div>\"\n p2.tmp[:hp] += p2_hp_delta/3\n p2.tmp[:stam] += p2_hp_delta/2\n index_player_team1 += 1\n context[:team2win] += 1\n elsif win == -1 # duce\n p1.tmp[:contrib][:score] += calc_zhanli(p2)*p2_hp_delta\n # p1.tmp[:contrib][:win] += 1\n p2.tmp[:contrib][:score] += calc_zhanli(p1)*p1_hp_delta\n # p2.tmp[:contrib][:win] += 1\n index_player_team2 += 1\n index_player_team1 += 1\n end\n if context[:observer]\n context[:observer].notify(context)\n context[:msg]=\"\"\n end\n i += 1\n end\n \n if index_player_team2 > index_player_team1\n return 0\n elsif index_player_team2 < index_player_team1\n return 1\n elsif index_player_team2 == index_player_team1\n return -1\n end\n \n \n end",
"def batten_hatches\n puts \"Batten the hatches\"\n end",
"def pbAfterBattle(decision,canlose)\n for i in $Trainer.party\n (i.makeUnmega rescue nil); (i.makeUnprimal rescue nil)\n end\n if $PokemonGlobal.partner\n pbHealAll\n for i in $PokemonGlobal.partner[3]\n i.heal\n (i.makeUnmega rescue nil); (i.makeUnprimal rescue nil)\n end\n end\n if decision==2 || decision==5 # if loss or draw\n if canlose\n for i in $Trainer.party; i.heal; end\n for i in 0...10\n Graphics.update\n end\n end\n end\n Events.onEndBattle.trigger(nil,decision,canlose)\nend",
"def being_attacked\n\tif @enemy_health > 0\n\t\t@enemy_power -= rand(-3..3)\n\t\tputs \"The #{@enemy} attacks again, doing #{@enemy_power - @defense} damage.\"\n\t\t@health -= (@enemy_power - @defense)\n\t\tfight\n\telse\n\t\tputs \"You beat the #{@enemy}!\"\n\t\tputs \"\"\n\t\tputs \"+#{@enemy_power + rand(9) + (@luck * @luck_points)} pointless points!\"\n\t\t@pointless_points += (@enemy_power + rand(9) + (@luck * @luck_points))\n\t\tcontroller\n\tend\nend",
"def battle(monster)\n system(\"clear\") unless ENV['TEST']\n puts \"#{monster.message}\\n\"\n type(\"You've run into a vicious #{monster.name}!\\n\\n\")\n\n while hp > 0\n # Both choose an attack.\n player_attack = choose_attack\n\n # Prevents the user from using \"bad\" commands.\n # Example: \"Use\" with an empty inventory.\n while (player_attack.fails?(self))\n player_attack = choose_attack\n end\n\n monster_attack = monster.choose_attack\n\n attackers = Array.new\n attacks = Array.new\n\n if sample_agilities(monster)\n attackers << self << monster\n attacks << player_attack << monster_attack\n else\n attackers << monster << self\n attacks << monster_attack << player_attack\n end\n\n 2.times do |i|\n # The attacker runs its attack on the other attacker.\n attacks[i].run(attackers[i], attackers[(i + 1) % 2])\n\n if (attackers[i].escaped)\n attackers[i].escaped = false\n return\n end\n\n break if monster.hp <= 0 || hp <= 0\n\n end\n\n break if monster.hp <= 0 || hp <= 0\n\n end\n\n die if hp <= 0\n\n if monster.hp <= 0\n type(\"You defeated the #{monster.name}!\\n\")\n\n # Determine the rewards for defeating the monster.\n rewards = monster.sample_rewards\n\n gold = rewards.first\n treasure = rewards.second\n\n # Output some helpful text and give the rewards to the player.\n if ((gold > 0) || treasure)\n type(\"Rewards:\\n\")\n if (gold > 0)\n type(\"* #{gold} gold\\n\")\n @gold += gold\n end\n if (treasure)\n type(\"* #{treasure.name}\\n\")\n add_item(treasure)\n end\n end\n print \"\\n\"\n end\n\n end",
"def generate_fighter(name, initial_health, type)\n if type == \"Runner\"\n Fighter.new(name, initial_health, rand(200..300), rand(20..50))\n elsif type == \"Viking\"\n Fighter.new(name, initial_health, rand(1..50), rand(50..100))\n else\n puts \"check fighter type...\"\n end\nend",
"def gotAttack(damage)\r\n @@probsDeflects = Array['deflect', 'deflect', 'deflect', 'deflect', 'deflect',\r\n 'deflect', 'deflect', 'deflect', 'got hit', 'got hit' ]\r\n\r\n @@probs = @@probsDeflects[rand(0..9)]\r\n if @role.upcase == \"HERO\"\r\n if @@probs == 'deflect'\r\n puts \"#{@name} deflects the attack.\"\r\n @hitpoint += damage\r\n end\r\n end\r\n @hitpoint -= damage\r\n end",
"def hatch\n @status = Idle\n @target = nil\n @virility = 0\n babies = []\n rand(MaxBabiesFromEgg).to_i.times {babies << baby_salmon}\n babies\n end",
"def fight\n while \n player_turn = rand(2)\n if player_turn == 1\n player_1_attack\n break unless @player_2.is_alive?\n else\n player_2_attack\n break unless @player_1.is_alive?\n end\n\n end\n\n # Outcome of fight\n if @player_1.is_alive?\n puts \"#{@player_2.name} has been KO'd!\"\n puts \"#{@player_1.name} is the WINNER!!!\"\n else\n puts \"#{@player_1.name} has been KO'd!\"\n puts \"#{@player_2.name} is the WINNER!!!\"\n end\n\n end",
"def full_battle(w1, w2)\n w1.heal\n w2.heal\n\n attacker = w1\n defender = w2\n\n puts \"#{w1.name} vs #{w2.name}\"\n\n while w1.alive? && w2.alive? #both alive FIGHT!\n damage_done = damage(attacker, defender)\n defender.take_dmg(damage_done)\n\n puts log(attacker, defender, damage_done)\n\n #swap attacker and defender\n attacker, defender = [defender, attacker]\n end\n\n if w1.alive?\n puts \"#{w1.name} Wins!\"\n w1\n else\n puts \"#{w2.name} Wins!\"\n w2\n end\n end",
"def %( enemy )\n lettuce = rand( charisma )\n puts \"[Healthy lettuce gives you #{ lettuce } life points!!]\"\n @life += lettuce\n fight( enemy, 0 )\n end",
"def %( enemy )\n lettuce = rand( charisma )\n puts \"[Healthy lettuce gives you #{ lettuce } life points!!]\"\n @life += lettuce\n fight( enemy, 0 )\n end",
"def gain_battle_spoil(gold, treasures)\n $game_party.gain_gold(gold)\n for item in treasures\n case item\n when RPG::Item\n $game_party.gain_item(item.id, 1)\n when RPG::Weapon\n $game_party.gain_weapon(item.id, 1)\n when RPG::Armor\n $game_party.gain_armor(item.id, 1)\n end\n end\n end",
"def generate_scenario(difficulty) \r\n Logger.debug \"Difficulty: #{difficulty}\"\r\n @killer = @npcs.sample\r\n @victim = @killer\r\n @victim = npcs.sample while @victim == @killer\r\n @victim.die\r\n @victim.map_id = MANSION_MAP_ID\r\n Logger.log \"Victim: #{@victim.name}\"\r\n Logger.debug \"Killer: #{@killer.name}\"\r\n \r\n non_victims = @npcs - [@victim]\r\n non_killers = non_victims - [@killer] \r\n non_killers.shuffle!\r\n \r\n num_signals = 3 + (2 * difficulty)\r\n evidence_counts = {}\r\n generate_signals_and_profiles(num_signals, non_victims, difficulty)\r\n \r\n Logger.debug \"Initial distribution: #{non_victims} v=#{non_victims.collect { |n| n.evidence_count }.variance}\"\r\n initial_sum = 0\r\n non_victims.map { |n| initial_sum += n.evidence_count }\r\n \r\n non_victims.each { |n| n.augment_profile }\r\n @victim.evidence_count = rand(2) # 0 or 1 signal, just \"for fun\"\r\n @victim.augment_profile\r\n \r\n # Everyone needs an alibi. Weak alibis are a signal.\r\n generate_killers_alibi(non_killers)\r\n generate_alibis(non_killers)\r\n murder_weapon_in_whose_house = nil\r\n # 50% chance to put the murder weapon in the house of an NPC\r\n if rand(50) <= 100\r\n # Pick a suitable NPC first\r\n suitable_npcs = non_victims.select { |n| n.evidence_count >= 2 }\r\n if !suitable_npcs.empty?\r\n npc = suitable_npcs.sample\r\n npc.evidence_count -= 2\r\n # Pick something on their map as the murder weapon\r\n @murder_weapon = @potential_murder_weapons.select { |weapon, map| map == npc.map_id }.keys.sample\r\n Logger.debug \"Murder weapon (#{npc.name}'s house): #{@murder_weapon}\"\r\n murder_weapon_in_whose_house = npc\r\n end\r\n end\r\n \r\n if murder_weapon_in_whose_house.nil?\r\n # goes in the mansion\r\n @murder_weapon = @potential_murder_weapons.select { |weapon, map| map == MANSION_MAP_ID }.keys.sample\r\n Logger.debug \"Murder weapon (mansion): #{@murder_weapon}\"\r\n end\r\n \r\n raise \"Something went terribly wrong with murder weapon selection\" if @murder_weapon.nil?\r\n @evidences = EvidenceGenerator::distribute_evidence(non_victims, @victim, @npc_maps, MANSION_MAP_ID, @notebook, @potential_murder_weapons.keys, @murder_weapon, murder_weapon_in_whose_house) \r\n EvidenceGenerator::complete_profiles_with_criminology(non_victims)\r\n \r\n Logger.debug '-' * 80\r\n Logger.debug \"Final distribution: #{non_victims}\" \r\n final_sum = 0\r\n non_victims.map { |n| final_sum += n.evidence_count }\r\n Logger.debug \"Signals consumed: #{initial_sum - final_sum}\"\r\n end",
"def attack #basic attack for now\r\n attack_value = strength + rand(25..50)\r\n puts \"#{@name} SWINGS his Weapon for #{attack_value} Points of Damage!\"\r\n end",
"def %(enemy)\n lettuce = rand(charisma)\n puts \"[healthy lettuce gives you #{lettuce} life points]\"\n @life +=lettuce\n fight(enemy, 0)\n end",
"def behavior_hungry\n @world.food.each do |food|\n if distance_from_point(food.position) < (food.quantity + ROID_SIZE*5)\n @delta -= self.position - food.position\n end \n if distance_from_point(food.position) <= food.quantity + 5\n eat food\n end \n end \n end",
"def resting_level4\n\t\tif @warrior.feel.enemy?\n\t\t\[email protected]!\n\t\telse\n\t\t\tif hurt? and healthstats >= @healthy\n\t\t\t\[email protected]!\n\t\t\telse\n\t\t\t\[email protected]!\n\t\t\tend\n\t\tend\n\tend",
"def attack(offender, defender, fight_time)\n if defender.health > 0 && offender.is_dead == false\n defender.health = defender.health - offender.power\n if defender.health < 0\n defender.health = 0\n end\n elsif defender.health > 0 && offender.is_dead == true\n nil\n elsif\n defender.is_dead = true\n defender.health = 0\n end\n if fight_time > offender.stamina && offender.power > 1\n offender.power = offender.power - 1\n offender.is_tired = true\n end\n fighters = {offender: offender, defende: defender}\nend",
"def enemies_attack\n total_bots_damage = 0\n @enemies.each do |bots_player|\n bots_damage = rand(1..6)\n @human_player.gets_damage(bots_damage)\n total_bots_damage += bots_damage\n end\n puts \"le(s) #{@enemies.length} inflige(nt) #{total_bots_damage} points de vie a #{@human_player.name}\"\n end",
"def handle(weapon)\n weapon = weapon.to_sym if weapon\n output = \"\"\n return \"No monster here\\n\" unless @game.current_room_model.monster\n # Get the input for the user\n\n player = @game.player\n items = @game.player.items\n weapons = items[:weapons]\n # Omitted double ask for key line 740\n new_ferocity = @game.current_room_model.monster.ferocity\n\n if items.has_key? :suit\n output << \"Your armor increases your chance of success.\\n\"\n new_ferocity = 3 * (@game.current_room_model.monster.ferocity / 4).to_i\n end\n\n has_sword = weapons.include? :sword\n has_axe = weapons.include? :axe\n\n has_two_weapons = has_axe && has_sword\n if not has_two_weapons\n output << \"You must fight with bare hands.\\n\"\n new_ferocity = (new_ferocity + new_ferocity / 5).to_i\n end\n\n has_just_axe = has_axe && !has_sword\n if has_just_axe\n output << \"You has only an axe to fight.\\n\"\n new_ferocity = 4 * (new_ferocity / 5).to_i\n end\n\n has_just_sword = has_sword && !has_axe\n\n if has_just_sword\n output << \"You must fight with your sword.\\n\"\n new_ferocity = 3 * (new_ferocity / 4).to_i\n end\n\n #change to face 2\n #store first axe before sword\n unless weapons.empty?\n new_ferocity = 4 * (new_ferocity / 5).to_i if weapon == :axe\n new_ferocity = 3 * (new_ferocity / 4).to_i if weapon == :sword\n end\n\n #change to face 3 THE BATTLE\n # TODO loop do line 940\n if rand() > 0.5\n output << \"Attacks.\\n\"\n else\n output << \"You attack.\\n\"\n end\n\n if rand() > 0.5 && player.has_torch?\n output << \"Your Torch was knocked from your hand.\\n\"\n items.delete :torch\n end\n\n if rand() > 0.5 && items.has_key?(:axe)\n output << \"You drop your ace in the heat of battle\\n\"\n items.delete :axe\n new_ferocity = 5 * (new_ferocity / 4).to_i\n end\n\n if rand() > 0.5 && items.has_key?(:sword)\n output << \"Your Sword is knocked from your hand!!!\\n\"\n items.delete :sword\n new_ferocity = 4 * (new_ferocity / 3).to_i\n end\n\n if rand() > 0.5\n output << \"You manage to wound it\\n\"\n new_ferocity = (5 * new_ferocity / 6).to_i\n end\n\n if rand() > 0.95\n output << \"Aaaaargh!!\\n\"\n output << \"Rip! Tear! Rip!\\n\"\n end\n\n output << \"You Want to run but you stand your ground...\\n\" if rand() > 0.9\n\n output << '*&%%$#$% $%# !! @ #$$# #$@! #$ $#$' if rand() > 0.9\n\n output << \"Will this be a battle to the death?\\n\" if rand() > 0.7\n\n output << \"His eyes flash fearfully\\n\" if rand() > 0.7\n\n output << \"Blood drips from his claws\\n\" if rand() > 0.7\n\n output << \"You smell the sulphur on his breath\\n\" if rand() > 0.7\n\n output << \"He strikes wildly, madly......\\n\" if rand() > 0.7\n\n output << \"You have never fought and opponent like this!!\\n\" if rand() > 0.7\n\n if rand() > 0.5\n output << \"The monster wounds you!!!\\n\"\n player.strength -= 5\n end\n\n #if the condition of the loop do is false\n if rand() * 16 > new_ferocity\n # TODO implement the to_s from monster\n output << \"And you managed to kill the #{@game.current_room_model.monster.name}\\n\"\n player.monsters_killed += 1\n # TODO update game room status\n else\n output << \"The #{@game.current_room_model.monster.name} defeated you\\n\"\n player.strength /= 2\n end\n @game.state = ExploringState.new @game\n\n output << \"\\n\"\n output << @game.state.status\n\n output\n end",
"def attack()\r\n @warrior.attack!\r\n end",
"def attack()\r\n @warrior.attack!\r\n end",
"def *( enemy )\n if @bombs.zero?\n puts \"[UHN!! You're out of bombs!!]\"\n return\n end\n @bombs -= 1\n fight( enemy, 86 )\n end",
"def *( enemy )\n if @bombs.zero?\n puts \"[UHN!! You're out of bombs!!]\"\n return\n end\n @bombs -= 1\n fight( enemy, 86 )\n end",
"def battle(attacker, defender)\n if accuracy_check(attacker.accuracy) \n defender.hull - attacker.firepower\n else\n return false\n end\nend",
"def sample_agilities(fighter)\n sum = fighter.stats[:agility] + stats[:agility]\n Random.rand(sum) < stats[:agility]\n end",
"def attack( opponent)\n \n # skip turn if disarmed\n [:disarmed, :knockback].each do | condition |\n if self.hasCondition? condition\n self.removeCondition condition\n FightRecord.addEvent( self, :skip, nil )\n return\n end\n end\n \n if( opponent.is_a? Array )\n self.attack( opponent.last )\n if( !opponent.last.alive? )\n opponent.pop\n end\n return\n end\n \n self.rollWeaponSkill\n\n tn = self.tnFor opponent\n \n FightRecord.addEvent( self, :attack, {:dice => @dice.clone, :tn => tn, :called => self.hasCondition?(:called_shot) } )\n \n if( self.hit?(opponent) && opponent.hit_by?(self)) # give opponent one last chance to avoid...\n self.hit opponent\n elsif self.hasCondition? :called_shot\n if self.dice.sauron?\n self.addCondition :fumble\n FightRecord.addEvent( self, :fumble, nil )\n end\n self.removeCondition :called_shot\n end\n\n if( @dice.sauron? )\n opponent.attackerRolledSauron\n end\n \n if !opponent.alive?\n FightRecord.addEvent( opponent, :dies, nil )\n end \n \n end",
"def hero_win\n puts \"#{monster.name} defeated! You gain #{monster.experience} experience.\"\n hero.update(experience: hero.experience + monster.experience)\n reward\n end",
"def fight(w1, w2)\n while w1.is_alive && w2.is_alive\n w1.hit(w2)\n w2.hit(w1)\n puts w1.status\n puts w2.status\n end\n\n if w1.is_alive\n puts \"#{w1.name} Won!\" \n else\n puts \"#{w2.name} Won!\"\n end\nend",
"def heal()\r\n @warrior.rest!\r\n end",
"def heal()\r\n @warrior.rest!\r\n end",
"def heal()\r\n @warrior.rest!\r\n end",
"def heal()\r\n @warrior.rest!\r\n end",
"def action\n if taking_damage?\n taking_damage_action\n elsif @warrior.feel.stairs? #&& ground_covered?\n @warrior.walk!\n elsif @warrior.feel.empty? && @warrior.health < MAX_HEALTH\n @warrior.rest!\n elsif @warrior.feel.enemy?\n @warrior.attack!\n elsif @warrior.feel.captive?\n @warrior.rescue!\n elsif @warrior.feel.empty?\n @warrior.walk!\n elsif @warrior.feel.wall?\n @warrior.pivot!(:backward)\n end\n end",
"def turn\n # start with simplest model of food consumption and creation\n if @food_production >= @population\n food_surplus = @food_production - @population\n else\n food_deficit = @population - @food_production\n end\n\n if food_surplus\n @food_storage += food_surplus\n elsif food_deficit\n if @food_storage >= food_deficit\n @food_storage -= food_deficit\n else\n shortage = food_deficit - @food_storage\n @food_storage = 0\n @population -= shortage # that many people starve\n end\n end\n\n @population += (@population * @@fertility_rate).floor\n end",
"def resting\n\t\tprint \"hurt: #{hurt?} healthstats: #{healthstats} >= #{@healthy} \\n\"\n\t\tif hurt?\n# if my actual health is more than the health before and there is not a stairs. this check if I'm beeing hurt and if there is not a staris backward. If I'm near of the wall I can rest\n\t\t\tif healthstats >= @healthy and @warrior.feel.stairs? == false\n\t\t\t\tif @warrior.feel(:backward).wall?\n\t\t\t\t\tif @warrior.health < 20\n\t\t\t\t\t\[email protected]!\n\t\t\t\t\t\tprint \"descanso \\n\"\n\t\t\t\t\telse\n\t\t\t\t\t\[email protected]!\n\t\t\t\t\t\tprint \"camino adelante \\n\"\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tif @warrior.feel(:backward).enemy?\n\t\t\t\t\t\[email protected]!(:backward)\n\t\t\t\t\t\tprint \"ataco atras \\n\"\n\t\t\t\t\telsif @warrior.feel(:backward).captive?\n\t\t\t\t\t\[email protected]!(:backward)\n\t\t\t\t\t\tprint \"rescato atras \\n\"\n\t\t\t\t\telse\n\t\t\t\t\t\[email protected]!(:backward)\n\t\t\t\t\t\tprint \"camino atras \\n\"\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\telsif @warrior.health < 11\n\t\t\t\[email protected]!(:backward)\n\t\t\telse\n\t\t\t\tif @warrior.feel.enemy?\n\t\t\t\t\[email protected]!\n\t\t\t\telse\n\t\t\t\t\[email protected]!\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\[email protected]!\n\t\tend\n\tend",
"def search_health_pack\n\t\thealing = rand(1..6)\n\t\tif healing == 1\n\t\t\tputs \"Tu n'as rien trouvé... \"\n\t\telsif healing >= 2 && healing <= 5\n\t\t\tif self.life_points > 50 # Test si les points ajoutés feront passer au dessus de 100 pts\n\t\t\t\tself.life_points = 100\n\t\t\telse\n\t\t\t\tself.life_points += 50\n\t\t\tend\n\t\t\tputs \"Bravo, tu as trouvé un pack de +50 points de vie !\"\n\t\telsif healing == 6\n\t\t\tif self.life_points > 20 # Test si les points ajoutés feront passer au dessus de 100 pts\n\t\t\t\tself.life_points = 100\n\t\t\telse\n\t\t\t\tself.life_points += 80\n\t\t\tend\n\t\t\tputs \"Champagne! Tu as trouvé un pack de +80 points de vie !\"\n\t\tend\n\t\t\n\tend",
"def humanplayer_attack_selected_bots(x)\n human_damage = @human_player.compute_damage\n @enemies[x].gets_damage(human_damage)\n puts \"#{@human_player.name} inflige #{human_damage} point(s) de dégât au bots #{x + 1}\" # #####\n if @enemies[x].life_points <= 0 \n puts \"- le bots #{@enemies[x].name} est mort\"\n kill_player(x)\n end\n #show_bots_state\n end",
"def flee(monster)\n if dice_roll < @agility\n puts \"----- Nice! -----\".top_border\n puts \"You've made a deft escape.\".bottom_border\n return true \n else\n puts \"Oh no! Your escape was blocked.\"\n monster.attack(self)\n return false\n end \n end",
"def *(enemy)\n if @bombs.zero?\n puts \"[rut roh! no bombs left!]\"\n return\n end\n @bombs -= 1\n fight(enemy, 86)\n end",
"def hero_battle_sequence(hero, villain)\n Battle.start_a_battle(hero, villain)\n battle = Battle.all.last\n hero_hp = hero.hp\n villain_hp = villain.hp\n while villain.hp > 0 && hero.hp > 0 do\n attack(hero, villain)\n line\n puts \"The hero's health is #{hero.hp}\"\n puts \"The villain's health is #{villain.hp}\"\n end\n #if villain and hero looses battle, hero dies and villain gets sent to insane asylum\n if villain.hp <= 0 && hero.hp <= 0\n battle.villain_lost(villain)\n line\n puts \"'Today, we lost a great hero. #{hero.name}, or as many of you knew them as #{hero.alter_ego}, was one of the best of us. It is a sad day for #{battle.location}'\"\n line\n battle.hero_lost(hero)\n battle.update(hero_win: false)\n villain.update(hp: villain_hp)\n line\n puts \"'Darn foiled again, but you'll never end me!' said #{villain.name} as they were lead to the asylum.\"\n puts \"GAME OVER\"\n line\n elsif villain.hp <=0 \n battle.villain_lost(villain)\n battle.update(hero_win: true)\n hero.update(hp: hero_hp)\n villain.update(hp: villain_hp)\n line\n puts \"#{hero.alter_ego} has won the battle\"\n puts \"'Darn foiled again, but you'll never end me!' said #{villain.name} as they were lead to the asylum.\"\n line\n battle.destruction\n hero_main_menu(hero)\n #destroys the hero, the hero lost and died \n elsif hero.hp <= 0\n puts \"#{villain.alter_ego} has won the battle\"\n puts \"'Today, we lost a great hero. #{hero.name}, or as many of you knew them as #{hero.alter_ego}, was one of the best of us. It is a sad day for #{battle.location}'\"\n puts \"GAME OVER\"\n line\n battle.hero_lost(hero)\n battle.update(hero_win: false)\n villain.update(hp: villain_hp)\n end\n end",
"def %(enemy)\n lettuce = rand(charisma)\n puts \"[Healthy lettuce gives you #{lettuce} life points!!]\"\n @life += lettuce\n fight(enemy, 0)\n end",
"def do_battle(damage)\n @health_points = @health_points - damage\n if @health_points < 1\n @lives -= 1\n @health_points = 10\n end\n\n if @lives == 0\n reset\n end\n\n end",
"def ^( enemy )\n fight( enemy, 13)\n end",
"def weapon_reward(available_weapons)\n\n #reward is 1 random choice from this array\n reward = available_weapons.sample\n\n #create to CharacterWeapon object to show that player obtains weaopn\n CharacterWeapon.new_character_weapon(self.id, reward.id)\n\n #print weapon details to player\n puts \"#{reward.name}\".bold.blue\n puts \"Weapon Power: #{reward.attack_power}\"\n puts\"#####################################\".blink\n\n #actually equip the weapon, if it will increase this player's attack power\n if reward.attack_power > self.power - 1 || self.power == 1\n #increase the player's attack power\n self.update(power: 1+reward.attack_power)\n end\n end",
"def strategy\n\n attacks_in_last_24_hours = Action.where([\"type_id = ? OR type_id = ?\", Action::TYPE_ATTACK_USER, Action::TYPE_ATTACK_USER_DDOS]).where(target_id: id, target_type: \"User\", completed: true).where(\"completed_at >= ?\", DateTime.now-24.hours).count\n\n # how often was the player succesfully attacked in the last 24 hours?\n if successful_attacks_in_last_24_hours > 0 && !counterattack_successful?\n agressiveness = (successful_attacks_in_last_24_hours.to_f/attacks_in_last_24_hours.to_f*100).to_i\n else\n agressiveness = 50\n end\n\n # how many other players can be attacked by this player?\n other_players = User.where([\"id != ?\", id])\n attack_opportunities = 0\n stronger_opportunities = 0\n weaker_opportunities = 0\n total_opportunities = other_players.count*2\n other_players.each do |player|\n [:hack, :ddos].each do |type|\n attack_opportunities += 1 if can_attack?(player, type)\n weaker_opportunities += 1 if to_strong_for(player, type)\n stronger_opportunities += 1 if to_weak_for(player, type)\n end\n end\n\n # assume that own defense is too low if defense is less than 33% of all attributes and more than 25% of other players are stronger\n if (hacking_ratio+defense_ratio+botnet_ratio) > 0 && \n ((defense_ratio.to_f/(hacking_ratio.to_f+defense_ratio.to_f+botnet_ratio.to_f)*100).round(0) < 33) &&\n (stronger_opportunities.to_f/total_opportunities.to_f*100).round(0) > 25\n defensiveness = 100\n else\n defensiveness = 50\n end\n\n # determine strategy according to relation between agressiveness and defensiveness\n if agressiveness > defensiveness\nRails.logger.info(\"---> AI: my strategy is agressive\")\n :agressive\n elsif agressiveness < defensiveness\nRails.logger.info(\"---> AI: my strategy is defensive\")\n :defensive\n else\nRails.logger.info(\"---> AI: my strategy is moderate\")\n :moderate\n end\n end",
"def run_round\n\t\t\tm, random_end = set_up_round\n\t\t\tactive_players = @players.select { |id, player| player[:food] > 0 }\n\t\t\t\n\t\t\tall_choices = Hash.new\n\t\t\ttotal_hunt_choices = 0\n\t\t\tactive_players.each do |id, player|\n\t\t\t\topponents = active_players.keys.shuffle\n\t\t\t\treps = opponents.map {|opp_id| @players[opp_id][:reputation]}\n\t\t\t\tchoices = player[:player].hunt_choices(@round, player[:food], player[:reputation], m, reps)\n\t\t\t\tall_choices[id] = Hash.new\n\t\t\t\topponents.each_with_index do |opp_id, index|\n\t\t\t\t\tall_choices[id][opp_id] = choices[index]\n\t\t\t\t\tif choices[index] == 'h'\n\t\t\t\t\t\t@players[id][:hunts] += 1\n\t\t\t\t\t\t@players[id][:food] -= 6\n\t\t\t\t\t\ttotal_hunt_choices += 1\n\t\t\t\t\telse\n\t\t\t\t\t\t@players[id][:slacks] += 1\n\t\t\t\t\t\t@players[id][:food] -= 2\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treward_hunt_bounties(all_choices)\n\t\t\treward_extra_bounty(active_players, m, total_hunt_choices)\n\t\t\tset_players_remaining\n\t\t\tupdate_reputations\t\n\n\t\t\t@players_remaining < 2 || random_end\n\t\tend",
"def monster_attack\n #set up monster distance and next move\n distance_x = @mon_x - @cur_x\n distance_y = @mon_y - @cur_y\n sign_x = distance_x <=> 0\n sign_y = distance_y <=> 0\n new_x = @mon_x-(1*sign_x)\n new_y = @mon_y-(1*sign_y)\n next_square = @room[new_x][new_y]\n #move monster closer to hero unless blocked or next to hero\n if next_square == CHAR_FLOOR && (distance_x.abs > 1 || distance_y.abs > 1)\n @room[@mon_x][@mon_y] = CHAR_FLOOR\n draw_map(@mon_x, @mon_y)\n @mon_x, @mon_y = new_x, new_y\n @room[@mon_x][@mon_y] = @mon_type\n draw_map(@mon_x, @mon_y)\n end\n #hit hero if close enough and hero not on saftey square\n if (distance_x.abs <= 1 && distance_y.abs <= 1) && @room[@cur_x][@cur_y] != CHAR_SAFE\n hit = @mon_attack * 1.5\n #hit if not dodged\n skill = @stats[:luck]+@stats[:agility]\n clear_message_box\n if Random.rand(skill+(@mon_attack*3)) > skill\n @ui.place_text(MSG_DAMGAGE.ljust(20),1,2)\n damage = hit / (2+@defence)\n @stats[:strength] -= damage\n @stats[:vitality] -= damage/10\n #see if hit weapon\n if Random.rand(7) == @mon_attack #1 in 7 chance of loosing item\n item_found = false\n until item_found\n #get a random item, keep trying until found on hero\n object = ['2 HAND SWORD', 'BROADSWORD', 'SHORTSWORD', 'AXE', 'MACE', 'FLAIL', 'DAGGER', 'GAUNTLET',\n 'HEAVY ARMOUR', 'CHAIN ARMOUR'].rotate(Random.rand(10)+1).first\n item = @objects.find { |obj| obj[:name]==object }\n if item\n if object == 'HEAVY ARMOUR' || object == 'CHAIN ARMOUR'\n @defence -= item[:power]\n else\n @attack -= item[:power]\n end\n @ui.place_text(\"#{object}!!\".ljust(20), 1, 3)\n @objects.delete(item)\n item_found = true\n end\n end\n end\n else\n @ui.place_text(MSG_MMISS.ljust(20),1,2)\n end\n sleep 0.5 #slow everything down\n end\n end",
"def die\n sleep(2) unless ENV['TEST']\n\n # TODO: fix next line. regen_location could be nil or \"bad.\"\n @location = @map.regen_location\n\n type(\"After being knocked out in battle,\\n\")\n type(\"you wake up in #{@map.name}.\\n\\n\")\n \n # Reduce gold if the player has any.\n if @gold > 0\n type(\"Looks like you lost some gold...\\n\\n\")\n @gold /= 2\n end\n\n sleep(2) unless ENV['TEST']\n\n # Heal the player.\n @hp = @max_hp\n end",
"def F\r\n if get_room_stuff(6) >= 9\r\n puts(\"THERE IS NOTHING TO FIGHT HERE\")\r\n else\r\n preparation_method\r\n actual_fight\r\n end \r\nend",
"def defeat\n @current_player = @players[\"plyr2\"]\n if @it == 12\n puts \" \"\n puts \" Code-breaker #{@current_player} loses!!\"\n puts \" \"\n puts \"Solution is #{@result}\"\n puts \" \"\n end\n end",
"def fight\n return \"Punch to the chops!\"\n end",
"def tour(attacking_gang, defending_gang, max_attack_count )\n units_actions_log = []\n\n dice = ActionDicePool.new( attacking_gang )\n p dice.to_s if @verbose\n\n while dice.remaining_action_dice? && defending_gang.has_units?\n # p dice.to_s\n\n next_attacking_unit, used_die = attacking_gang.get_next_unit_to_activate( dice )\n # p \"priority = #{next_attacking_unit[0]}, #{next_attacking_unit[1].to_s}\"\n # p next_attacking_unit\n\n if next_attacking_unit\n next_attacking_unit = next_attacking_unit[1]\n\n dice.consume_die!( used_die )\n\n ad = ActionDecision.new(\n attacking_gang, defending_gang,next_attacking_unit, verbose: @verbose )\n units_actions_log << ad.do_something\n\n next_attacking_unit.already_activate_this_turn = true\n\n puts if @verbose\n else\n puts 'No more units could be activated' if @verbose\n break\n end\n end\n\n units_actions_log\n end",
"def action\n if player_hand.collect{|x| x.value}.inject(:+) < 21 && player_hand.length == 6\n lengthwin\n else\n puts \"Would you like to 'hit' or 'stay'?\"\n answer = STDIN.gets.chomp.downcase\n until answer == \"hit\" || answer == \"stay\"\n puts \"Simply let me know if you would like to 'hit' or 'stay', sir.\"\n answer = STDIN.gets.chomp\n end\n if answer == \"hit\"\n hit = bjdeck.draw\n player_hand << hit\n blind_score\n if player_hand.collect{|x| x.value}.inject(:+) > 21\n puts \"It appears you have busted.\"\n lose\n else\n action\n end\n else\n computer_turn\n end\n end\n end",
"def update_fitness(goal=nil)\n if goal\n @fitness += goal.value\n @goals_reached += 1\n end\n # Slowly die.\n slowly_die\n # Return updated fitness.\n @fitness\n end",
"def set_target_battlers(scope)\r\n # If battler performing action is enemy\r\n if @active_battler.is_a?(Game_Enemy)\r\n # Branch by effect scope\r\n case scope\r\n when 1 # single enemy\r\n index = @active_battler.current_action.target_index\r\n @target_battlers.push($game_party.smooth_target_actor(index))\r\n when 2 # all enemies\r\n for actor in $game_party.actors\r\n if actor.exist?\r\n @target_battlers.push(actor)\r\n end\r\n end\r\n when 3 # single ally\r\n index = @active_battler.current_action.target_index\r\n @target_battlers.push($game_troop.smooth_target_enemy(index))\r\n when 4 # all allies\r\n for enemy in $game_troop.enemies\r\n if enemy.exist?\r\n @target_battlers.push(enemy)\r\n end\r\n end\r\n when 5 # single ally (HP 0) \r\n index = @active_battler.current_action.target_index\r\n enemy = $game_troop.enemies[index]\r\n if enemy != nil and enemy.hp0?\r\n @target_battlers.push(enemy)\r\n end\r\n when 6 # all allies (HP 0) \r\n for enemy in $game_troop.enemies\r\n if enemy != nil and enemy.hp0?\r\n @target_battlers.push(enemy)\r\n end\r\n end\r\n when 7 # user\r\n @target_battlers.push(@active_battler)\r\n end\r\n end\r\n # If battler performing action is actor\r\n if @active_battler.is_a?(Game_Actor)\r\n # Branch by effect scope\r\n case scope\r\n when 1 # single enemy\r\n index = @active_battler.current_action.target_index\r\n @target_battlers.push($game_troop.smooth_target_enemy(index))\r\n when 2 # all enemies\r\n for enemy in $game_troop.enemies\r\n if enemy.exist?\r\n @target_battlers.push(enemy)\r\n end\r\n end\r\n when 3 # single ally\r\n index = @active_battler.current_action.target_index\r\n @target_battlers.push($game_party.smooth_target_actor(index))\r\n when 4 # all allies\r\n for actor in $game_party.actors\r\n if actor.exist?\r\n @target_battlers.push(actor)\r\n end\r\n end\r\n when 5 # single ally (HP 0) \r\n index = @active_battler.current_action.target_index\r\n actor = $game_party.actors[index]\r\n if actor != nil and actor.hp0?\r\n @target_battlers.push(actor)\r\n end\r\n when 6 # all allies (HP 0) \r\n for actor in $game_party.actors\r\n if actor != nil and actor.hp0?\r\n @target_battlers.push(actor)\r\n end\r\n end\r\n when 7 # user\r\n @target_battlers.push(@active_battler)\r\n end\r\n end\r\n end",
"def fight(other, initial_health, walking = true)\n unless fought_in_turn.include?(other)\n self.fought_in_turn << other\n other.fought_in_turn << self\n self.damage(other.health)\n other.damage(initial_health)\n if self.health > 0 && walking\n @grid.move_token(self.x, self.y, other.x, other.y)\n end\n end\n end",
"def fight\n \n \n while @human.life_points >0 && (@player1.life_points > 0 || @player2.life_points >0)\n\n\n puts \"**********Menu**************\"\n puts \"a - find a better weapon\"\n puts \"s - find more points of life\" \n puts \"0 - attack player 1\"\n puts \"1 - attack player 2\"\n puts \"2 - receive attacks\"\n puts \"****************************\"\n puts \"Select an option:\"\n option = gets.chomp.to_s\n\n if option == \"a\"\n @human.search_weapon\n elsif option == \"s\"\n @human.search_health_pack\n elsif option == \"0\"\n @human.attacks(@player1)\n elsif option == \"1\"\n @human.attacks(@player2)\n elsif option == \"2\"\n puts \"You are under attack!\"\n @enemies.each { |i| i.life_points <= 0 ? break : i.attacks(@human)}\n @human.show_state\n else\n end\n end\n puts \"Game over\"\n puts \"You won\"\nend",
"def battle(k)\n puts \"#{self.name} vs #{k.name}\"\n # Pick randomly which goes first\n while k.hp > 0 && self.hp >0\n kodomon_turn = rand(100) >= 50 ? self : k\n other = kodomon_turn === self ? k : self\n attack(kodomon_turn, other)\n if(other.hp > 0) # if other is still alive, it can attack\n attack(other, kodomon_turn)\n end\n end\n winner = self.hp > 0 ? self : k\n puts \"Winner: #{winner.name}\"\n return winner\n end",
"def villain_battle_sequence(hero, villain)\n Battle.start_a_battle(hero, villain)\n battle = Battle.all.last\n hero_hp = hero.hp\n villain_hp = villain.hp\n while villain.hp > 0 && hero.hp > 0 do\n attack(hero, villain)\n line\n puts \"The hero's health is #{hero.hp}\"\n puts \"The villain's health is #{villain.hp}\"\n end\n #if villain and hero looses battle, hero dies and villain gets sent to insane asylum\n if villain.hp <= 0 && hero.hp <= 0\n battle.villain_lost(villain)\n line\n puts \"'Today, we lost a great hero. #{hero.name}, or as many of you knew them as #{hero.alter_ego}, was one of the best of us. It is a sad day for #{battle.location}'\"\n battle.hero_lost(hero)\n battle.update(hero_win: false)\n villain.update(hp: villain_hp)\n line\n puts \"'Darn foiled again, but you'll never end me!' said #{villain.name} as they were lead to the asylum.\"\n puts \"GAME OVER\"\n line\n elsif villain.hp <=0 \n battle.villain_lost(villain)\n battle.update(hero_win: true)\n hero.update(hp: hero_hp)\n villain.update(hp: villain_hp)\n line\n puts \"#{hero.alter_ego} has won the battle\"\n puts \"'Darn foiled again, but you'll never end me!' said #{villain.name} as they were lead to the asylum.\"\n puts \"GAME OVER\"\n line\n #destroys the hero, the hero lost and died, sends villain to the main menu\n elsif hero.hp <= 0\n line\n puts \"#{villain.alter_ego} has won the battle\"\n puts \"'Today, we lost a great hero. #{hero.name}, or as many of you knew them as #{hero.alter_ego}, was one of the best of us. It is a sad day for #{battle.location}'\"\n line\n battle.hero_lost(hero)\n battle.update(hero_win: false)\n villain.update(hp: villain_hp)\n battle.destruction\n villain_main_menu(villain)\n end\n end",
"def fight(p1, p2)\n while p1.isAlive && p2.isAlive\n p1.hit(p2)\n p2.hit(p1)\n p1.wpnhit(p2)\n p2.wpnhit(p1)\n show_info(p1, p2)\nend\n\nif p1.isAlive\n puts \"#{p1.name} WON!!\"\nelsif p2.isAlive\n puts \"#{p2.name} WON!!\"\nelse\n puts \"TIE!!\"\nend\nend",
"def decide_target(char, dmg, heal, neutral, attack, defend, escape)\n # temporary variables\n x, y, ai = char.x, char.y, char.ai\n # get alignment setup\n negative, positive = ai.negative, ai.positive\n # invert setup if confused\n negative, positive = positive, negative if char.restriction == 3\n # initialize arrays\n allies, enemies = [char], []\n # if enemy\n if char.is_a?(Map_Enemy)\n # find all allies and all enemies in memory\n ai.memory.each_key {|b|\n allies.push(b) if positive.include?(b.ai.group)\n enemies.push(b) if negative.include?(b.ai.group)}\n # if actor\n elsif char.is_a?(Map_Actor)\n # find all allies and all enemies in sight\n ai.sight.each {|b|\n allies.push(b) if positive.include?(b.ai.group)\n enemies.push(b) if negative.include?(b.ai.group)}\n end\n # find all allies who need healing\n to_heal = allies.find_all {|b| b.valid? && b.battler.hp < b.battler.maxhp}\n # if decided to heal\n if (heal.size > 0 && to_heal.size > 0 && (ai.healer || rand(3) == 0) &&\n rand(5) == 0)\n # find all skills that heal all allies\n allheal = heal.find_all {|id|\n $data_skills[id].scope == 2 || $data_skills[id].scope == 4 ||\n $data_skills[id].scope == 6}\n # test again flag\n test_again = true\n # if more than 1 ally who needs healing exists and allheal skills exist\n if to_heal.size > 1 && allheal.size > 0\n # initialize data\n decided, now, new = nil, [], []\n # iterate through all all-healing skills\n allheal.each {|id|\n # fake Blizz-ABS action setup\n ai.act.set(Skills.range(id), ACTSkill, id, Skills.type(id)[0],\n ai.delay_time)\n # all allies who can be targeted by this skill\n new = to_heal.find_all {|b| $BlizzABS.can_execute?(char, b, ai.act)}\n # if not decided yet\n if decided == nil\n # decide this skill and those allies\n decided, now = id, new\n # 50% chance\n elsif rand(2) == 0\n # intialize damage counters\n dmg1 = dmg2 = 0\n # sum up all damage for last decided targets\n now.each {|b| dmg1 += b.battler.maxhp - b.battler.hp}\n # sum up all damage for new targets\n new.each {|b| dmg2 += b.battler.maxhp - b.battler.hp}\n # decide this skill if it contains battlers with more damaged HP\n decided, now = id, new if dmg2 > dmg1\n # if more battlers would be affected by this skill\n elsif new.size > now.size\n # decide this skill and those allies\n decided, now = id, new\n end}\n # if more than one battler can be healed\n if now.size > 1\n # setup Blizz-ABS action\n ai.act.set(Skills.range(decided), ACTSkill, decided,\n Skills.type(decided)[0], ai.delay_time / 2)\n # don't test for one battler\n test_again = false\n end\n end\n # if should test for one battler\n if test_again\n # find all skills that heal one ally\n oneheal = heal.find_all {|id|\n $data_skills[id].scope == 1 || $data_skills[id].scope == 3 ||\n $data_skills[id].scope == 5}\n # if any skill exists\n if oneheal.size > 0\n # decided action\n decided = oneheal[rand(oneheal.size)]\n # decided target\n ai.target = to_heal[rand(to_heal.size)]\n else\n # decided action\n decided = heal[rand(heal.size)]\n end\n # stop execution if no skill decided\n return false if decided == nil\n # setup Blizz-ABS action\n ai.act.set(Skills.range(decided), ACTSkill, decided,\n Skills.type(decided)[0], ai.delay_time / 2)\n end\n # confirm execution\n return true\n end\n # not decided to escape yet\n escaping = false\n # if able to run away\n if escape && rand(5) == 0\n # if observation attribute is active\n if ai.observe && char.restriction != 3\n # iterate through all enemies\n enemies.each {|b|\n # if actor\n if b.is_a?(Map_Actor) && ai.observation[b.battler] != nil\n # get damage per second rate\n dps = get_observation(b.battler, ai.observation[b.battler].clone)\n # 20% chance or damage per second-distance rate high enough\n if rand(5) == 0 || dps * 128 / Math.hypot(b.real_x-\n char.real_x, b.real_y-char.real_y) > char.battler.hp / 2\n # set this battler as escape reference\n ai.target = b\n # running away\n escaping = true\n # abort iteration\n break\n end\n end}\n # 20% chance\n elsif rand(5) == 0\n # initialize minimum range\n min = nil\n # iterate through all enemies\n enemies.each {|b|\n # if closer than anybody else\n if (b.is_a?(Map_Actor) && (min == nil ||\n Math.hypot(b.real_x-char.real_x, b.real_y-char.real_y) < min))\n # set this battler as escape reference\n ai.target = b\n # set new minimum range\n min = Math.hypot(b.real_x-char.real_x, b.real_y-char.real_y)\n # running away\n escaping = true\n # abort iteration\n break\n end}\n end\n end\n # if decided to escape\n if escaping\n # set AI state\n ai.state = Escape\n # set action data\n ai.act.set(ai.view_range - 1, ACTEscape, 0, 0, 80)\n # confirm execution\n return true\n end\n # not decided to defend yet\n defending = false\n # if able to defend\n if defend && rand(5) == 0\n # probability factor if higher if defensive and reset defend flag\n factor = rand(ai.defensive ? 10 : 30)\n # if decided to defend\n if char.battler.hp * 100 / char.battler.maxhp < factor\n # if observation attribute is active\n if ai.observe && char.restriction != 3\n # iterate through all enemies\n enemies.each {|b|\n # if actor\n if b.is_a?(Map_Actor) && ai.observation[b.battler] != nil\n # get damage per second rate\n dps = get_observation(b.battler,\n ai.observation[b.battler].clone)\n # 20% chance or damage per second-distance rate high enough\n if rand(5) == 0 || dps * 128 / Math.hypot(b.real_x-\n char.real_x, b.real_y-char.real_y) > char.battler.hp / 3\n # defending\n defending = true\n # abort iteration\n break\n end\n end}\n # 33% chance\n elsif enemies.size > 0 && rand(5) == 0\n # decided to defend\n defending = true\n end\n end\n end\n # if decided to defend\n if defending\n # set AI state\n ai.state = Defend\n # target the closest enemy\n ai.target = enemies.min {|a, b|\n Math.hypot(x-b.x, y-b.y) <=> Math.hypot(x-a.x, y-a.y)}\n # turn toward the target if target exists and not being force moved\n char.turn_toward(ai.target) if ai.target != nil && char.move_type != 3\n # use defend action\n char.use_defend\n # set action data\n ai.act.set(3, ACTDefend, 0, 0, rand(31) + 70)\n # confirm execution\n return true\n end\n # number of skills\n skill_number = dmg.size + heal.size + neutral.size\n # if able to attack and chosen to attack\n if attack && (skill_number == 0 || rand(skill_number) == 0)\n # if enemy\n if char.is_a?(Map_Enemy)\n # set AI state\n ai.state = Ready\n # setup Blizz-ABS action\n ai.act.set(Enemies.range(char.battler_id), ACTAttack, 0,\n Enemies.type(char.battler_id), ai.delay_time)\n # if observing attribute and not confused\n if ai.observe && char.restriction != 3\n # decide a target based upon observation experience\n observation_target(char, ai, enemies)\n end\n # if actor\n elsif char.is_a?(Map_Actor)\n # set AI state\n ai.state = Ready\n # setup Blizz-ABS action\n ai.act.set(Weapons.range(char.battler.weapon_id), ACTAttack, 0,\n Weapons.type(char.battler.weapon_id), ai.delay_time)\n end\n # if no target exists\n if ai.target == nil || !ai.target.valid?\n # get any enemy\n ai.target = enemies[rand(enemies.size)]\n end\n # confirm execution\n return true\n end\n # decide a random skill action\n decided = (dmg + neutral)[rand(dmg.size + neutral.size)]\n # if action exists\n if decided != nil\n # if observing\n if ai.observe && char.restriction != 3\n # decide a target based upon observation experience\n observation_target(char, ai, enemies)\n end\n # if no target was decided\n if ai.target == nil || !ai.target.valid?\n # if targeting enemies\n if $data_skills[decided].scope == 0 ||\n $data_skills[decided].scope == 1 ||\n $data_skills[decided].scope == 2\n # select a random enemy target\n ai.target = enemies[rand(enemies.size)]\n else\n # select a random ally target\n ai.target = allies[rand(allies.size)]\n end\n end\n end\n # stop execution if no target selected\n return false if ai.target == nil || !ai.target.valid?\n # setup Blizz-ABS action\n ai.act.set(Skills.range(decided), ACTSkill, decided,\n Skills.type(decided)[0], ai.delay_time)\n # confirm execution\n return true\n end",
"def *(enemy)\n if @bombs.zero?\n puts \"[UHN!! You're out of bombs!!]\"\n return\n end\n @bombs -= 1\n fight(enemy, 86)\n end",
"def apply(game)\n end",
"def take_action(game)\n @game = game\n if rand(100) < 50\n fold\n else\n bet(game[:current_high_bet])\n end\n end",
"def set_goals\n # doing simple: give the goal \"kill this ant\" for each ant\n $map = @map # FIXME\n x = nil\n @map.ennemies_each { |e|\n x = e\n break\n }\n raise \"oops\" if x == nil\n i = 0\n @map.allies_each{ |a|\n a.goal = [KILL, x]\n i += 1\n break if i == 4\n }\n return\n\n # get state of the game\n #calculate each top goals weight\n @top_goals.each { |g|\n get_weight(g)\n }\n end",
"def play\n\n # TODO: for all loops below, precalculate all the sums, instead of looping them\n\n # if deploying, do nothing else\n @tentacles.each { |t| return if t.state==:deploying }\n\n ots = occupied_tentacles.size\n ets = ennemies_tentacles.size\n ats = active_tentacles.size\n\n # remove useless tentacles: to same team not attacked with more life (attention to rule below when connecting friends with less life)\n occupied_tentacles.each { |t|\n next if t.state == :retracting\n t.retract if t.to.team == @team and t.to.life+t.to.tentacles_life > @life+tentacles_life+deploy_cost(t.to) and t.to.ennemies_tentacles.size == 0\n }\n\n # remove useless tentacles: from neutral or not dueling when attacked\n if ennemies_tentacles.size > 0 and occupied_tentacles.size >= 0\n occupied_tentacles.each { |t|\n return if (remove_neutral or remove_not_dueling)\n }\n end\n\n # attack if attacked\n if ets > 0 and ots < @nb_t and ots == ats\n ennemies_tentacles.each { |t|\n return if enough_life?(t.from, :half) and add_tentacle(t.from)\n }\n end\n\n # attack neutral\n if ots < @nb_t\n n = nearest { |v| v.team == :neutral and enough_life?(v)}\n return if n and enough_life?(n) and add_tentacle(n)\n end\n\n # attack nearest ennemy\n if ots < @nb_t\n e = nearest { |v| v.team != @team and v.team != :neutral and enough_life?(v) }\n return if e and add_tentacle(e)\n end\n\n # recharge friends\n if ots < @nb_t\n e = nearest { |v| v.team == @team and v != self and not find_all(v) and v.life < (@life-deploy_cost(v))-1 }\n return if e and add_tentacle(e)\n end\n\n end",
"def hit( damage )\n p_up = rand( charisma )\n if p_up % 9 == 7\n @life += p_up / 4\n puts \"[#{ self.class } magick powers up #{ p_up }!]\"\n end\n @life -= damage\n puts \"[#{ self.class } has died.]\" if @life <= 0\n end"
] |
[
"0.71260923",
"0.711013",
"0.7103374",
"0.6968889",
"0.6915633",
"0.6858511",
"0.6849031",
"0.67684984",
"0.67621857",
"0.6755314",
"0.6733031",
"0.67050546",
"0.6702012",
"0.669596",
"0.667046",
"0.66464204",
"0.6623142",
"0.6607663",
"0.65761817",
"0.65279776",
"0.65090704",
"0.64910066",
"0.6406653",
"0.6406578",
"0.6405255",
"0.6388841",
"0.6373722",
"0.6373722",
"0.63713396",
"0.6330909",
"0.63150346",
"0.63121593",
"0.6275263",
"0.62603974",
"0.62344366",
"0.6232062",
"0.6230648",
"0.62164146",
"0.62109244",
"0.6208998",
"0.62050354",
"0.6204682",
"0.6200515",
"0.6200515",
"0.6186937",
"0.61799353",
"0.6179086",
"0.617132",
"0.6168343",
"0.61504894",
"0.6133648",
"0.61171824",
"0.61146",
"0.6113758",
"0.6113758",
"0.6113569",
"0.6113569",
"0.6105573",
"0.6105559",
"0.61052054",
"0.6101387",
"0.6100694",
"0.60987496",
"0.60987496",
"0.60987496",
"0.60987496",
"0.60941374",
"0.609354",
"0.6069259",
"0.6064963",
"0.60511285",
"0.6049106",
"0.6040371",
"0.6030161",
"0.6025245",
"0.60168236",
"0.60134614",
"0.6013172",
"0.5999713",
"0.59990764",
"0.59900004",
"0.59785646",
"0.59773713",
"0.59729326",
"0.597219",
"0.5969809",
"0.5968492",
"0.5965536",
"0.5964786",
"0.5964353",
"0.5963796",
"0.59602094",
"0.5951153",
"0.5947129",
"0.5940219",
"0.59334314",
"0.59267426",
"0.5919405",
"0.59162086",
"0.5914543",
"0.59108555"
] |
0.0
|
-1
|
Iterate through all elements in nums Try if hash_table has the key for pop If not, set up key/value pair In the end, there is only one element in hash_table, so use popitem to get it 2
|
def single_number(nums)
result = {}
nums.each do |n|
# delete in ruby is slow... this one isn't as fast as mine
result[n].nil? ? result[n] = n : result.delete(n)
end
result.shift.first
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def pop_values()\n value_hash.values.each { |val_vec| val_vec.pop }\n end",
"def drops(number)\n#Iterating through de prime_drops hash thanks to the Public Instance Method .each_with_object\n prime_drops.each_with_object(\"\") {|(prime, drop), drops|\n#While we iterate we check the number looking for the prime factor and storing it if TRUE\n drops << drop if number % prime == 0\n }\n end",
"def missing_number_hsh(nums)\n hsh = {}\n nums.each do |n|\n hsh[n] = 1\n end\n for i in (0..nums.length)\n return i if !hsh.include?(i)\n end\n -1\nend",
"def find_error_nums(nums)\n hash = {}\n \n nums.each do |num|\n hash[num] = hash[num] ? hash[num] +=1 : 1\n end\n \n output1 = hash.key(2)\n output2 = nil\n \n i = 1\n while true\n if !hash[i]\n output2 = i\n break\n else\n i+=1\n end\n end\n [output1, output2]\nend",
"def remove(key)\n \txk = key % 10001 \n xk = (xk + 1) % 10001 while @arr[xk].first != nil && @arr[xk].first != key \n @arr[xk] = [nil, -1] if @arr[xk].first == key\n end",
"def two_sum(nums, target)\r\n numsLen = nums.size\r\n returnArr = Array.new(2,0)\r\n myHashTable = {nums[0]=>0}\r\n temp = 0\r\n \r\n if numsLen < 2\r\n return returnArr\r\n else\r\n for i in 1..numsLen-1\r\n temp = target - nums[i]\r\n if myHashTable.has_key?(temp) == true\r\n returnArr[0] = myHashTable[temp]\r\n returnArr[1] = i\r\n break\r\n else\r\n myHashTable.store(nums[i],i)\r\n end\r\n end\r\n end\r\n return returnArr\r\nend",
"def solution(arr)\n temp_hash_odd_balls = {}\n\n arr.each { |el| temp_hash_odd_balls[el] ? temp_hash_odd_balls.delete(el) : temp_hash_odd_balls[el] = 0 }\n\n temp_hash_odd_balls.keys.first\nend",
"def removeElement(nums, val)\n if nums.nil? then\n 0\n else\n fast = slow = 0\n while fast < nums.size do\n if not nums[fast]==val then\n nums[slow] = nums[fast]\n slow += 1\n end\n fast += 1\n end\n slow\n end\nend",
"def remove_duplicates(nums)\n return 0 if nums.empty?\n cur = nums.first\n primary = 1\n nums.each_with_index do |num, _idx|\n next if num == cur\n nums[primary] = num\n cur = num\n primary += 1\n end\n primary\nend",
"def single_number(nums)\n num_hash = {}\n \n nums.each do |num|\n if num_hash[num]\n num_hash[num] += 1\n else\n num_hash[num] = 1\n end\n end\n \n num_hash.each do |num, quantity|\n if quantity == 1\n return num\n end\n end\nend",
"def solution(a)\n return nil unless a || a.empty?\n num_hash = {}\n a.each do |num|\n num_hash[num] = 1\n end\n\n 1.upto(a.size + 1) do |item|\n return item if !num_hash.has_key? item \n end\n\nend",
"def next_greater_element(nums1, nums2)\n stack = []\n # create new hash where default is -1 when key is not found\n next_greater_ele = Hash.new(-1)\n result = []\n\n# create hash with nums2 as keys and their value is the next grater element of the same array\n nums2.each { |n|\n #while stask and stack.last is smaller than current item\n while( stack.any? && stack.last < n )\n # add last item in stack as key and the next greater item as value on the hash\n next_greater_ele[stack.pop] = n\n end\n stack.push(n)\n }\n nums1.each { |n|\n result << next_greater_ele[n]\n }\n result\nend",
"def single_number(nums)\n hash = Hash.new(0)\n nums.each do |val|\n if nums.include?val \n hash[val] += 1\n end\n end\n p hash.keys\nend",
"def on_2(numbers)\n hash_table = {}\n\n numbers.each do |number|\n return true if hash_table.key?(number)\n hash_table[number] = nil\n end\n\n false\n end",
"def unique(mylist)\r\n\r\n counts = Hash.new(0)\r\n\r\n mylist.each { |item|\r\n # if item is Not in the hash\r\n puts \"looking in hash for #{item}\"\r\n if counts[item] == 0\r\n puts \"#{item} is not in hash. Adding it!\"\r\n counts[item] = 1\r\n end\r\n # counts[item] +=1\r\n # puts counts\r\n # if counts[item] > 1\r\n # end\r\n}\r\n\r\n # if element you are testing is the same\r\n # remove the element you are testing\r\n # else redo the loop\r\n \r\nend",
"def single_number(nums)\n number_hash = Hash.new(0) \n nums.each do |num|\n number_hash[num] += 1\n end \n number_hash.each do |k, v|\n return k if v == 1 \n end \nend",
"def single_number(nums)\n counts = Hash.new(0)\n nums.each do |num|\n if counts[num] == 0\n counts[num] += 1\n elsif counts[num] == 1\n counts.delete(num)\n end\n end\n counts.first[0]\nend",
"def delete(key)\n self.map_var.each_with_index do |pair, idx|\n if pair[0] == key \n first_half = self.map_var[0...idx] \n second_half = self.map_var[idx+1..-1]\n self.map_var = first_half + second_half\n break\n end \n end\n end",
"def remove_element(nums, val)\n instance_val_pointer = 0\n\n for i in (0...nums.size) do\n if nums[i] != val\n nums[instance_val_pointer] = nums[i]\n instance_val_pointer += 1\n end\n end\n \n return instance_val_pointer\nend",
"def remove_element(nums, val)\n pointer1 = 0\n nums.each_with_index do |num, pointer2|\n if val != num\n nums[pointer1] = nums[pointer2]\n pointer1 += 1\n end\n end\n pointer1\nend",
"def generate_with_hash_length\n @numberHash.clear\n while @numberHash.length < @count\n @numberHash[rand(@limit)] = nil\n end\n @numbers = @numberHash.keys\n end",
"def remove(val)\n return false unless @number_index_map.key?(val)\n index = @number_index_map[val]\n last_element = @number_list[-1]\n @number_list[index] = last_element\n\n @number_list.pop\n @number_index_map[last_element] = index\n @number_index_map.delete(val)\n true\n end",
"def hash_delete(groceries_hash)\r\nreturn groceries_hash.delete_if {|items, values| items.length <= 7}\r\nend",
"def remove_item(item_to_remove)\n $list_hash.delete_if{|current_item, quantity|item_to_remove==current_item} #goes through entire item in delete if hash if item in hash delete from hash\nend",
"def remove_item(hash, key)\n hash.delete(key)\n p hash\nend",
"def remove_dup(arr)\n hash_map = {}\n arr.each do |num|\n hash_map[num] = true\n end\n arr = []\n hash_map.each do |key, value|\n arr << key\n end\n return arr\nend",
"def remove_element(nums, val)\n nums.each_with_index do |num, i|\n if num == val\n nums[i] = nil\n end\n end\n nums.compact!\n nums.length\nend",
"def remove(item, hash)\n hash.delete(item)\n puts hash\nend",
"def remove_element(arr, key)\n next_element = 0\n\n for i in 0..(arr.length - 1) \n if arr[i] != key\n arr[next_element] = arr[i]\n next_element += 1\n end\n\n end\n return next_element\nend",
"def remove_item(hash_list, item)\n hash_list.delete(item)\n p hash_list\nend",
"def hash_table(arr)\n dict = hash(arr)\n arr_dict = []\n (0..10).each do |key|\n next unless dict[key]\n\n list = dict[key]\n list.each do |item|\n arr_dict << item\n end\n end\n arr_dict\nend",
"def two_sum(nums, target)\n table = {}\n i = 0\n while i < nums.length\n table[target - nums[i]] = i\n i += 1\n end\n \n j = 0\n while j < nums.length\n if table.key?(nums[j]) && j != table[nums[j]]\n return [j, table[nums[j]]] \n end\n j += 1\n end\nend",
"def unseen\n table.reject do |k, v|\n v[2]\n end\n end",
"def remove_item(hash, item)\r\n\thash.delete(item)\r\n\thash\r\nend",
"def numUnique list\n if list.length == 0\n return \"**0**\"\n end\n counter = Hash.new\n counter[list[0]] = 1\n\n list.each do |num|\n number_exists = false\n counter.each do |key, count|\n if num == key\n count += 1\n number_exists = true\n end\n end\n\n if !number_exists\n counter[num] = 1\n end\n\n end\n\n puts \"counter #{counter}\"\n unique_nums = []\n\n counter.each do |key, value|\n unique_nums << key\n end\n\n return \"**#{unique_nums.length}**\"\n\nend",
"def item_remover(hash, item, quantity = 1)\n hash[item] -= quantity\n if hash[item] <= 0\n hash.delete(item) \n end\n hash\nend",
"def dehash(hash, depth); end",
"def removePastX myhash, xval\n\t\trtn = Hash.new\n\t\tmyhash.each do |key, value|\n\t\t\tif key < xval\n\t\t\t\trtn.store(key, value)\n\t\t\tend\t\n\t\tend\n\t\trtn\n\tend",
"def contains_duplicate(nums)\n hash_table = {}\n (0..nums.length).each do |i|\n if hash_table.include? nums[i]\n return true\n else\n hash_table[nums[i]] = 1\n end\n end\n return false\nend",
"def two_sum(nums, target)\n\n numsSearch = {}\n nums.each_with_index do |value, index|\n ### Storing the value as index of hash\n second_value = numsSearch[target - value]\n\n ### checking if hash return value\n if second_value != nil\n return [second_value, index]\n end\n\n ### inserting the value as index and index as value in hash map\n numsSearch[value] = index\n end\n\n return []\nend",
"def pair_sum_using_hash_table(input, target_sum)\n # hash which will store nos\n hash_table = {}\n \n # target sum should be 10\n #target_sum = 10\n\n # put both no's in array which sums up to 10\n result = []\n \n for i in input do\n tmp_result = target_sum - i\n # if tmp_result is present in hash then break , we found our nos\n if hash_table.has_key?(tmp_result)\n result << i \n result << tmp_result\n break\n else\n # if equation result is not present in hash then put i in hash\n hash_table[i] = true\n end\n end\n ap \"Out put #{result}\"\n return result\nend",
"def lpop(key, count = T.unsafe(nil)); end",
"def lpop(key, count = T.unsafe(nil)); end",
"def rpop(key, count = T.unsafe(nil)); end",
"def rpop(key, count = T.unsafe(nil)); end",
"def delete_hash_item(hash, item)\n [item, hash.delete(item)]\nend",
"def remove(key)\n unless get(key) == -1\n @count -= 1\n bucket = @map[key.hash % @size]\n bucket.reject! {|k, v| k == key}\n end\n end",
"def unique_number(arr)\n existing_numbers = []\n not_unique = []\n arr.each do |entry|\n if existing_numbers[entry] === nil\n existing_numbers[entry] = true\n else\n not_unique[entry] = true\n end\n end\n arr.each do |entry|\n if not_unique[entry] == nil\n return entry\n end\n end\nend",
"def single_number(nums)\n hash = {}\n nums.each do |n|\n if !hash[n]\n hash[n] = 1\n else\n hash[n] += 1\n end\n end\n hash.each do |k, v|\n if v == 1\n return k\n end\n end\n return 0\nend",
"def missing_num(arr)\n hashy = {1=>0, 2=>0, 3=>0,4=>0, 5=>0, 6=>0,7=>0, 8=>0, 9=>0, 10=>0}\n arr.each do |num|\n hashy[num] += 1\n end\n hashy.each do |k, v|\n if v == 0\n return k\n end\n end\nend",
"def remove_duplicates(nums)\n nums_size, cursor = 0, 0\n\n while cursor < nums.size\n num = nums[cursor]\n cursor += 1\n while nums[cursor] == num\n cursor += 1\n end\n\n nums[nums_size] = num; nums_size += 1\n end\n\n nums_size\nend",
"def single_number(nums)\n uniques = []\n nums.each do |num|\n uniques.include?(num) ? uniques.delete(num) : uniques << num\n end\n uniques\nend",
"def remove(hash, item)\n hash.delete(item)\nend",
"def remove(hash, item)\n hash.delete(item)\nend",
"def remove(val)\n if map.key?(val)\n idx = map.delete(val)\n if idx != size - 1\n arr[idx], arr[size - 1] = arr[size - 1], arr[idx]\n map[arr[idx]] = idx\n end\n self.size -= 1\n true\n else\n false\n end\n end",
"def remove_item(hash, item)\n hash.delete(item)\n hash\nend",
"def remove_item(hash, item)\n hash.delete(item)\n hash\nend",
"def shoppingList\n a = []\n x = 1\n y = 1\n puts \"insert an item\"\n 5.times do\n a << gets.strip.upcase\n \n end\n b = a.sort.uniq\n\n 5.times do \n \n b.insert(x,y)\n x += 2\n y += 1\n # binding.pry\n end\n h=Hash[*b.flatten(1)]\n puts h\n end",
"def remove_item(hash, item)\n hash.delete(item)\n return hash\nend",
"def remove_element(nums, val)\n return nil if !nums \n # while nums.delete(val)\n # # nums.delete(val)\n # end\n nums.each {|element| nums.delete(element) if val == element}\n return nums.length\nend",
"def two_sum_3(nums, target)\n len = nums.length\n hash = {}\n\n for i in (0...len)\n elt = nums[i]\n diff = target - elt\n # check to see if diff is in the hash; if so we found 2 numbers that add up to sum, that is diff and elt\n if hash[diff]\n index1 = nums.index(diff)\n puts \"index1=#{index1+1}, index2=#{i+1}\"\n return\n else\n hash[elt] = 1 # add the key elt to the hash\n end\n end\nend",
"def rehash(growth_multiple = DEFAULT_GROWTH_MULTIPLE)\n puts \"Rehashing\"\n new_size = (table.length * growth_multiple).to_i\n @table = table.each_with_object(HashTable.new(new_size)) do |value, result|\n result.insert(value) unless value == TOMBSTONE_MARKER\n end.dump_table\n end",
"def ordered_array_generator(array)\n ordered_hash = {}\n array_length = high_number_finder(array) + 1\n \n array_length.times do |i|\n\n# # check for integer in unordered array by seeing if index = nil\n# # if it's there, create a corresponding key in the hash\n\n if array.index(i) != nil\n ordered_hash[i] = []\n end\n\n end\n\n# # push instance of integer into corresponding key\n# # print values\n\n array.each do |integer|\n ordered_hash[integer] << integer\n end\n \n p ordered_hash.values\n\nend",
"def lrem(key, count, value); end",
"def lrem(key, count, value); end",
"def missing_nums(a,b)\n ahash = {}\n bhash = {}\n while i < a.size do\n if ahash.has_key?(a[i]) then\n ahash[a[i]] += 1\n else\n ahash[a[i]] = 1\n end\n if bhash.has_key?(b[i]) then\n bhash[b[i]] += 1\n else\n bhash[b[i]] = 1\n end\n i += 1\n end\n while i < b.size do\n if bhash.has_key?(b[i]) then\n bhash[b[i]] += 1\n else\n bhash[b[i]] = 1\n end\n i += 1\n end\n result = []\n bhash.keys.each do |key|\n result.push(key) if (!ahash.has_key?(key) || bhash[key] > ahash[key])\n end\n result.sort\nend",
"def printhash(hash)\n puts \"-----------------------\"\n hash.each { |item, qty| \n puts \"#{item},\\n qty: #{qty}\"\n puts \"\"\n }\n puts \"-----------------------\"\nend",
"def CheckUniqDigits(n)\n\n h1 = Hash.new\n\n arr = n.digits\n\n for onedig in arr\n\n h1.key?(onedig) ? (return 0) : (h1[onedig] = 1)\n\n end\n\n return 1\n\nend",
"def get_product_of_lego_pieces(\n lego_hash:\n )\n lego_hash[:gave_her_friend].each do |num|\n lego_hash[:count_of_lego].delete_at(lego_hash[:count_of_lego].find_index(num))\n end\n # return result\n lego_hash[:count_of_lego][0] * lego_hash[:count_of_lego][1]\nend",
"def remove(num)\n self[num].delete(num) if include?(num)\n end",
"def remove(num)\n @count -= 1\n self[num].delete(num)\n end",
"def player_stats(player_n)\n # binding.pry\n game_hash.map do |location,team| \n team[:players].map do |player|\n if player[:player_name] == player_n\n #binding.pry\n # return player.delete_if {|stats, value| == player[:player_name]}\n return player.delete_if { |stat, value| [:player_name].include?(stat)}\n end \n end \n end \n return \"you idiot, your numbers are wrong\"\nend",
"def remove_item(item, hash)\n hash.delete(item)\n return hash\nend",
"def prime_drops\n {3 => \"Pling\", 5 => \"Plang\", 7 => \"Plong\"}\n end",
"def remove_element(nums, val)\n n = nums.length\n pointer = 0\n\n while pointer < n\n if nums[pointer] == val\n nums[pointer] = nums[n - 1]\n n -= 1\n else\n pointer += 1\n end\n end\n\n pointer\nend",
"def single_one (input_array)\n the_one = nil\n sorted = input_array.sort \n # puts sorted\n\n hash_map = {}\n\n sorted.each do |num|\n #if num [1] is not in the hash as a key, add & set value to 1\n if hash_map[num] != nil\n # hash_map.key?(num)\n hash_map[num] += 1\n else \n hash_map[num] = 1\n end \n end\n\n #loop through hash\n hash_map.each do |key,value|\n #check for values that == 1\n if value == 1\n #return the key\n the_one = key\n return the_one\n end\n end\n\n return the_one\nend",
"def fix_numerals\n hash = self.clone\n traverse hash\n hash\n end",
"def big_shoe_rebounds\n shoe_sizes = []\n output = nil\n game_hash.each do |team, att|\n game_hash[team][:players].each { |k, v| shoe_sizes << k[:shoe] }\n game_hash[team][:players].each { |k, v|\n k[:shoe] == shoe_sizes.sort.pop ? output = k[:rebounds] : nil }\n end\n output \nend",
"def remove_odd_hashes(array, key_1, key_2) #function name: remove_odd_hashes, input params: array, key_1, key_2\n array.delete_if do |h| #delete if for a absolute value of char h\n (h[key_1] + h[key_2]).odd? #key1 and 2 sum to an odd\n end #end loop\nend",
"def _process_hashed(hashed)\n hashed.each_pair do |key, value|\n if value.equal?(Utils::DeletedMarker)\n hashed.delete(key)\n elsif Utils.hashable?(value)\n _process_hashed(value.to_hash).freeze\n end\n end\n\n hashed\n end",
"def search1(num)\n @numbers.each_with_index do |number, i|\n if @hash[number]\n puts \"Indexes: #{@hash[number]}, #{i}\"\n break\n else\n @hash[num - number] = i\n end\n puts 'loop'\n end\n end",
"def pairs_given_sum num, arr\n the_hash, indices = Hash.new, []\n arr.each_with_index do |x,xi|\n complement = num - x\n lookup = the_hash[complement]\n lookup.nil? ? the_hash[x] = xi : indices << [lookup, xi]\n # puts the_hash\n end\n indices\nend",
"def player_nums(team, hashketball)\r\n sym = team.to_sym\r\n player_numbers = []\r\n \r\n hashketball[sym][:players].each_value do |x|\r\n player_numbers << x[:number]\r\n end\r\n player_numbers\r\nend",
"def ele_replace!(array, hash)\n array.map! do |ele| #go through the array\n if hash.has_key?(ele) #hash contains a key thats also in the array arr = [4,2,0,2] vs hash = {2=>two, 0 => zero} \n hash[ele] #convert array values with corresponding hash values -> [ ... ,two,zero,two]\n else\n ele #if array value doesnt correspond with hash key, place array index back to original position -> [ 4,...,...,...]\n end\n end\nend",
"def remove_item(hash, item)\n hash.delete(item)\nend",
"def remove_duplicates(nums)\n prev = nil\n count = 0\n nums.each do |num|\n if num == prev\n next\n else\n nums[count] = num\n prev = num\n count+=1\n end\n end\n\n return count\nend",
"def drop!(n)\n dropped_elements = @list.values.first(n)\n @list = Hash[@list.drop(n)]\n return dropped_elements\n end",
"def remove_item(hash_of_items, item)\n hash_of_items.delete(item)\n hash_of_items\nend",
"def remove()\n return if @store.empty?\n if @store.size == 1\n return @store.pop\n end\n # swap the first and the last element in the underlying array\n @store[-1], @store[0] = @store[0], @store[-1]\n removed = @store.pop\n heap_down(0)\n return removed.value\n end",
"def sort_scores_hash(unsorted_scores, highest_possible_score)\n score_counts = {}\n unsorted_scores.each do |score|\n score_counts[score] = 0 unless score_counts[score]\n score_counts[score] += 1\n end\n\n sorted_scores = []\n i = HIGHEST_POSSIBLE_SCORE\n while i >= 0\n unless score_counts[i]\n i = i - 1\n next\n end\n\n score_counts[i].times { sorted_scores << i }\n i = i - 1\n end\n\n sorted_scores\nend",
"def hash_two_sum(arr,target_sum)\n #creates a new hash with each element that is satisfying the target_sum\n hash = Hash.new(0) #{|h,k| h[k] = []}\n (0...arr.length).each { |i| hash[i] = arr[i]} #O(n)\nend",
"def single_number(nums)\n return 0 if nums.length == 0\n hash = Hash.new(0)\n nums.each do |val|\n if nums.include?(val)\n hash[val] += 1\n end\n end\n p hash.default\n # hash.key(hash.values.min)\nend",
"def remove_element(nums, val)\n nums.delete(val)\n nums.length\nend",
"def dup_hash(ary)\r\n new_hash = ary.inject(Hash.new(0)) { |h,e| h[e] += 1; h }.select { |_k,v| v > 1 }.inject({}) { |r, e| r[e.first] = e.last; r }\r\n new_hash.each{ |k,v| new_hash[k] = v - 1}\r\n return new_hash\r\nend",
"def make_menu_hash(item_hash, max_price_hash, row, item_counter)\n row[2..-1].each do |item|\n if item_hash.has_key?(item) \n if item_hash[item].has_key?(row[0])\n item_hash[item][row[0]].merge!({item_counter => row[1].to_f}) \n else\n item_hash[item].merge!({row[0] => {item_counter => row[1].to_f}}) \n end\n else\n item_hash.merge!({item => {row[0] => {item_counter => row[1].to_f}}})\n end\n end\n\n max_price_hash.has_key?(row[0]) ? (max_price_hash.merge!({row[0] => row[1].to_f}) if max_price_hash[row[0]] < row[1].to_f ): max_price_hash.merge!({row[0] => row[1].to_f})\n\n [item_hash, max_price_hash]\nend",
"def remove_element_in_place(nums, val)\n\nend",
"def pop key = nil\n value = @degrees.pop\n return_value_using_key value, key\n end",
"def process_to_hash(ip, numbers)\n if @hash_of_merged_data.has_key?(ip)\n store_values_in_existing_key(ip, numbers)\n else\n @hash_of_merged_data.store(ip, numbers)\n end\n end",
"def calcIt\n a = [\"1\",\"5\",\"2\",\"3\",\"4\"]\n h = Hash.new(0)\n a.each do |v|\n h[v] += 1\n end\n h\n end",
"def delete_nth(order,max_e)\n #your code here\n counter = Hash.new(0)\n solution = []\n order.each {|x| counter[x] += 1}\n counter.each do |k, v|\n solution.push(k)\n v = max_e if v > max_e\n if v > 1\n v -= 1\n v.times do\n solution.push(k)\n end\n end\n end\n return solution\nend"
] |
[
"0.57777625",
"0.5756144",
"0.5665419",
"0.56167895",
"0.56075037",
"0.5581523",
"0.5580626",
"0.5571361",
"0.55547184",
"0.5500372",
"0.5496856",
"0.54590255",
"0.54457533",
"0.54456484",
"0.5438338",
"0.5430839",
"0.54292667",
"0.5394167",
"0.53863055",
"0.5330129",
"0.5305306",
"0.5284994",
"0.5284355",
"0.5282577",
"0.52772576",
"0.5275178",
"0.52681136",
"0.52548933",
"0.5248841",
"0.52449405",
"0.5238005",
"0.523769",
"0.52289164",
"0.52147084",
"0.5213969",
"0.5209862",
"0.5205412",
"0.5187462",
"0.5178515",
"0.5176443",
"0.5176083",
"0.5173667",
"0.5173667",
"0.5172304",
"0.5172304",
"0.51580113",
"0.51576656",
"0.51524144",
"0.5152223",
"0.514554",
"0.51259685",
"0.51202095",
"0.5115794",
"0.5115794",
"0.5113096",
"0.5110289",
"0.5110289",
"0.5106548",
"0.5106441",
"0.51023144",
"0.50985837",
"0.50948805",
"0.50829756",
"0.50687677",
"0.50687677",
"0.5061852",
"0.50508475",
"0.5041366",
"0.50384146",
"0.50349355",
"0.5032219",
"0.50281537",
"0.5028038",
"0.5001126",
"0.49914718",
"0.4988966",
"0.4985844",
"0.49827468",
"0.49815094",
"0.4981276",
"0.49809873",
"0.49705318",
"0.49699584",
"0.49601376",
"0.49588585",
"0.49576744",
"0.49548268",
"0.49529716",
"0.4949766",
"0.4948757",
"0.49405473",
"0.49403152",
"0.49390584",
"0.493351",
"0.49287495",
"0.4927322",
"0.49248114",
"0.49206293",
"0.49188724",
"0.49183857"
] |
0.5987485
|
0
|
Time complexity: O(n + 1? idk about .delete()) Space: O(n) Math solution 2 (A + B + C) (A + A + B + B + C) = C 3
|
def single_number(nums)
2 * nums.uniq.reduce(:+) - nums.reduce(:+)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end",
"def three_sum(nums)\n n = nums.length\n result = []\n for i in 0...n-2\n req_sum = 0\n hsh = Hash.new\n curr_sum = req_sum - nums[i]\n \n for j in (i+1)...n\n num = curr_sum - nums[j]\n if hsh[num]\n elements = [nums[i], num, nums[j]].sort\n result << elements unless result.include?(elements)\n end\n hsh[nums[j]] = true\n end \n end\n result\nend",
"def three_sum_fastest(arr)\n count = 0\n\n (0..arr.length - 2).each { |i|\n set = Set.new\n\n (i + 1..arr.length - 1).each { |j|\n if set.include?(-arr[i] - arr[j])\n count += 1\n end\n\n set.add(arr[j])\n }\n }\n count\nend",
"def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend",
"def find3(a, X)\n # scan through array\n # build hash storing complement in each key\n complements = {}\n a.each_with_index do |val, ind|\n if complements[X - val]\n complements[X - val].push(ind)\n else\n complements[X - val] = [ind]\n end\n end\n\n # scan through the array again\n # get complement\n # for each value scan the remainder of the arrray\n # for a value such taht a + b = the complement\n\n # for each character we have built a dictionary such that, we can find\n # x = a + complement\n\n # [1, 2, 3]\n # 1 + 2 = 3\n # 1 + 3 = 4 =>\n\n # for each value in the array (a) look at all following values (b) and see if a + b\n # is in the dictionary, if it is, check that their indices do not collide with the index\n # stored at dict(a+b)\n\n a.each_with_index do |va, i|\n a.each_with_index do |vb, j|\n break if i == j\n\n complement = va + vb\n indices = complements[complement]\n\n indices.each do |z|\n # every index is unique\n return [i, j, z] unless z == i || z == j\n end\n end\n end\n\n return nil\nend",
"def recessive k, m, n\n all = k + m + n\n mix = m + n\n total = 4.0 * triangle(all) # 2 * squareish all = 2 * 2 * triangle all\n\n lhs = triangle n\n mid = n * mix - n\n rhs = triangle mix\n\n 1 - (lhs+mid+rhs) / total\n end",
"def removNb(n)\n numbers = (1..n).to_a\n all_combinations = numbers.combination(2).to_a\n possible_pairs = []\n sum = numbers.reduce(:+)\n all_combinations.each do |pair|\n if (sum - pair.reduce(:+)) == pair.reduce(:*)\n possible_pairs << pair\n possible_pairs << pair.reverse\n end\n end\n possible_pairs\nend",
"def pythagoreans(n)\n triples = []\n hypot = (5..n).to_a.map!{|x| x ** 2}\n #iterate through both a and b values up to n\n (3..n).each do |a|\n (4..n).each do |b|\n c2 = a ** 2 + b ** 2\n if hypot.include? (c2)\n c = Math.sqrt(c2).to_i\n #puts a, b, c, \"\\n\" if hypot.include? (c2)\n triples.push([a,b,c])\n #this delete insures that the triple is only added once\n hypot.delete(c2)\n end\n end\n end\n return triples\nend",
"def four_sum?(arr, sum)\n possible_additives = possible_additives(sum)\n answer = false\n\n possible_additives.each do |list|\n num1, num2 = list\n indices_to_remove = index_hash_two_sum(arr, num1)\n if indices_to_remove != false\n temp_arr = []\n temp_arr += arr\n indices_to_remove.each do |index|\n temp_arr.delete_at(index)\n end\n p temp_arr\n answer ||=hash_two_sum?(temp_arr, num2)\n end\n end\n\n answer\nend",
"def solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_000 if result >= 1_000_000_000\n end\n numbers[a[back] - 1] = false\n }\n result\nend",
"def three_sum(nums)\n return [] if nums.length < 3\n three_sums = []\n length = nums.length\n num_hash = Hash.new { |hash, key| hash[key] = [] }\n nums.each_with_index do |num, index|\n num_hash[num] << index\n end\n nums[0 ... length - 1].each_with_index do |first_num, first_index|\n nums[first_index + 1 ... length].each_with_index do |second_num, second_index|\n looking_for = -1 * (first_num + second_num)\n indices = [first_num, second_num, looking_for]\n if !num_hash[looking_for].reject {|x| x == first_index || x == second_index + first_index + 1}.empty?\n three_sums << [first_num, second_num, -1 * (first_num + second_num)].sort\n end\n end\n end\n three_sums.uniq\nend",
"def three_sum2(nums)\n sorted_nums = nums.sort\n\n results = Set.new\n\n sorted_nums[0...sorted_nums.size - 2].each_with_index do |num, index|\n break if num > 0 # 已经排序,并且只看右面,所以大于0就不需要继续了。\n next if index > 0 && num == sorted_nums[index - 1] # 可以减少重复的计算\n\n find_two_sum(index, sorted_nums, results)\n end\n\n results.to_a\nend",
"def solution2\n n = 1000\n\n hsh = Hash.new([])\n\n (1..n).each do |x|\n (1..n).each do |y|\n hsh[x**3 + y**3] += [x, y]\n end\n end\n\n hsh.values\nend",
"def three_sum(nums)\n nums = nums.sort\n res = []\n nums.each_index do |idx|\n if nums[idx] > 0\n break\n end\n if idx > 0 && nums[idx]== nums[idx - 1]\n next\n end\n\n left, right = idx + 1, nums.length - 1\n total = nums[idx] + nums[left] + nums[right]\n while left < right\n if total > 0\n right -= 1\n elsif total < 0\n left += 1\n else\n\n res << [nums[idx], nums[left], nums[right]]\n # We want to move on from the current left and right values to avoid\n # duplicates. Both the while loop and final adjustment are required\n # for this matter.\n while left < right && nums[left] == nums[left + 1]\n left += 1\n end\n while left < right && nums[right] == nums[right + 1]\n right -= 1\n end\n left += 1\n right -= 1\n end\n end\n end\n res\nend",
"def solution(a)\n counter = Hash.new(0)\n a.each do |elem|\n counter[elem] += 1\n end\n\n (1..a.size).each do |number|\n return 0 if counter[number] != 1\n end\n\n 1\nend",
"def solution(a)\n n = a.size\n passing_cars = 0\n\n suffix_sums = Array.new(n + 1, 0)\n\n a.reverse.each_with_index do |elem, i|\n suffix_sums[i + 1] = suffix_sums[i] + elem\n end\n suffix_sums.reverse!\n\n a.each_with_index do |car, i|\n if car == 0\n passing_cars += suffix_sums[i]\n end\n end\n\n passing_cars > 1_000_000_000 ? -1 : passing_cars\nend",
"def four_sum_count(a, b, c, d)\n result = 0\n cached_ab_sum = {}\n 0.upto(a.size - 1) do |pa|\n 0.upto(b.size - 1) do |pb|\n cached_ab_sum[a[pa] + b[pb]] ||= []\n cached_ab_sum[a[pa] + b[pb]] << [pa, pb]\n end\n end\n\n 0.upto(c.size - 1) do |pc|\n 0.upto(d.size - 1) do |pd|\n findings = cached_ab_sum[-(c[pc] + d[pd])]\n result += findings.size if findings\n end\n end\n\n result\nend",
"def solution(a)\n len = a.size\n unique = {}\n i = 0\n while i < len\n item = a[i]\n if unique.has_key?(item)\n unique[item] += 1\n else\n unique[item] = 1\n end\n i += 1\n end\n pairs = 0\n unique.each do |key,count|\n (1...count).step {|n| pairs += n }\n end\n return pairs > 1_000_000_000 ? 1_000_000_000 : pairs\nend",
"def three_sum(arr)\n sorted = arr.sort()\n results = []\n # 3 index tracking tools, i to start and scan array 1 by one\n # start to always be one ahead and step till we hit a greater condition\n # finish to always start from the back and work its way to the front\n # these will work if the array is sorted\n\n (0..sorted.length - 3).each do |i| # step up until last 2 elements (reserved for next 2 pointers)\n start = i + 1\n finish = sorted.length - 1\n\n a = sorted[i]\n while start < finish\n b = sorted[start]\n c = sorted[finish]\n p a, b, c\n p sorted\n if (a + b + c) == 0 # found one, put this in our results\n results << [a, b, c] unless results[-1] == [a, b, c] \n if b == sorted[start + 1] # is the next element for b the same\n start += 1\n else\n finish -= 1\n end\n elsif (a + b + c) > 0 # too big so decrement our finish\n finish -= 1\n else # increment our middle pointer\n start += 1\n end\n end \n\n end\n\n results\nend",
"def solution1\n n = 1000\n\n (1..n).each do |a|\n (1..n).each do |b|\n (1..n).each do |c|\n # d = 3rd root of (a**3 + b**3 - c**3)\n d = (a**3 + b**3 - c**3)**(1 / 3)\n print [a, b, c, d] if a**3 + b**3 == c**3 + d**3\n end\n end\n end\nend",
"def solution(a)\n return 0 if a.count < 3\n \n a.sort!\n for i in (2...a.count)\n x = a[i - 2]\n y = a[i - 1]\n z = a[i]\n \n return 1 if x + y > z && x + z > y && z + y > x\n end\n \n return 0\nend",
"def three_sum(nums)\n return [] if !nums || nums.size < 3\n ans = []\n i = 0 \n size = nums.size\n nums = nums.sort\n while i < size do \n if nums[i] == nums[i - 1] && i > 0 \n i += 1\n next\n end\n\n a = nums[i]\n target = -1 * a\n two_sum(nums[(i + 1)...size], target, a, ans)\n i += 1\n end\n ans\nend",
"def solution(a, b)\n a.size > b.size ? b+a+b : a+b+a\nend",
"def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend",
"def solution(a)\n length = a.length\n sum = (length + 1) * (length + 1 + 1) / 2\n\n sum - a.inject(0) { |acc, e| acc += e }\nend",
"def c v1, v2, o\n m = false\n d = []\n (0...v2.size).each{ |j|\n if !v1.include? v2[j] + o\n d << v2[j]\n m = true\n end\n }\n for x in d\n v2.delete x\n end\n m\nend",
"def solution(a)\n return 0 if a.uniq.size != a.size\n \n max = a.size \n sum = (1 + max) * max / 2\n \n array_sum = a.inject(0, &:+) \n sum == array_sum ? 1 : 0 \nend",
"def solution(a)\n return 1 if a.count == 0\n \n real_sum = a.inject(:+)\n expected_sum = (a.count + 1) * (a.count + 2) / 2.0\n (expected_sum - real_sum).to_i\nend",
"def solve\n s = Hash[(1...1000).map { |i| [i, i * i] }]\n (1...1000).each do |c|\n (1...c).each do |b|\n (1..b).each do |a|\n return a * b * c if (a + b + c) == 1000 && (s[a] + s[b]) == s[c]\n end\n end\n end\nend",
"def problem_60a\n num_cut = 5\n# simple\n pairs = {}\n seen_primes = []\n num_primes = 0\n last = start = Time.now\n Primes.each do |p|\n next if p == 2\n b = p.to_s\n seen_primes.each_index do |sp_i|\n sp = seen_primes[sp_i]\n a = sp.to_s\n ai,bi = a.to_i,b.to_i\n ab = (a + b).to_i\n ba = (b + a).to_i\n\n if ba.prime? && ab.prime?\n # We have a pair that works both ways so add the peer to each prime\n pairs[ai] = aa = ((pairs[ai] || []) << bi).uniq\n pairs[bi] = bb = ((pairs[bi] || []) << ai).uniq\n next unless pairs[bi].length >= num_cut - 1 # bi is biggest of pair\n\n check = ([ai] + aa) & ([bi] + bb)\n if check.length >= num_cut\n puts \"Try #{check.inspect}\"\n perm = check.permutation(2).to_a\n new = perm.select do |x,y|\n (x.to_s + y.to_s).to_i.prime? && (x.to_s + y.to_s).to_i.prime?\n end\n if new.length == perm.length\n n = new.flatten.uniq\n sum = n.reduce(&:+)\n puts \"#{n.inspect} *** #{sum}\"\n return sum\n end\n end\n end\n end\n seen_primes << p\n end\n nil\nend",
"def three_sum(nums)\n nums.sort!\n res = []\n # for each num, find the two constituent targets\n for i in 0..nums.length - 3 do\n next if i > 0 && nums[i] == nums[i - 1]\n\n partial_target = 0 - nums[i]\n j = i + 1\n k = nums.length - 1\n while j < k\n if nums[j] + nums[k] == partial_target\n res.push([nums[i], nums[j], nums[k]])\n j+=1 while j < k && nums[j] == nums[j+1]\n k-=1 while j < k && nums[k] == nums[k-1]\n j+=1\n k-=1\n elsif nums[j] + nums[k] > partial_target\n k-=1 while j < k && nums[k] == nums[k-1]\n k-=1\n else\n j+=1 while j < k && nums[j] == nums[j+1]\n j+=1\n end\n end\n end\n return res\nend",
"def calculate_optimal_k\n k=0\n @k_optimal = Array.new(@size)\n (3..@size).each{|n|\n k+=1 while(cost(n,k)<cost(n,k+1))\n @k_optimal[n]=k\n }\n end",
"def solution(a)\n # write your code in Ruby 2.2\n \n is_perm = 0\n \n n = a.length\n b = [0]*n\n \n \n a.each do |v|\n break if v > n \n break if b[v] == 1 \n b[v] = 1\n end\n \n sum = b.inject(:+)\n if sum == n\n is_perm = 1\n end\n \n is_perm\nend",
"def good_tuples(nums)\n count = 0\n (0..nums.size - 3).each do |i|\n first, second, third = nums[i], nums[i + 1], nums[i + 2]\n next if 3 * first == first + second + third\n count += 1 if [first, second, third].include?(first ^ second ^ third)\n\n # next if nums[i] == nums[i + 1] && nums[i + 1] == nums[i + 2]\n # next if nums[i] != nums[i + 1] && nums[i + 1] != nums[i + 2] && nums[i] != nums[i + 2]\n end\n\n count\nend",
"def solve\n dp = H.times.map { [nil] * W }\n dp[0][0] = 1 << 60\n dp[1][0] = A[0][0] + A[1][0] + C\n dp[0][1] = A[0][0] + A[0][1] + C\n\n (1...W).each do |x|\n dp[0][x] = [A[0][x - 1] + C + A[0][x],\n dp[0][x - 1] + C + A[0][x] - A[0][x - 1]].min\n end\n (1...H).each do |y|\n dp[y][0] = [A[y - 1][0] + C + A[y][0],\n dp[y - 1][0] + C + A[y][0] - A[y - 1][0]].min\n end\n (1...H).each do |y|\n (1...W).each do |x|\n now = A[y][x]\n dp[y][x] = [\n A[y - 1][x] + C + now,\n A[y][x - 1] + C + now,\n dp[y - 1][x] + C + now - A[y - 1][x],\n dp[y][x - 1] + C + now - A[y][x - 1]\n ].min\n end\n end\n\n dp.flatten.min\nend",
"def solution(a)\n a.uniq.count\nend",
"def find_amicables(n)\n pairs = []\n sum = 0\n for i in 0..n do \n next if pairs.include? i\n d = sum_proper_divisors(i)\n next if d == i\n p = sum_proper_divisors(d)\n if p == i \n pairs << d\n pairs << i\n sum += d + i\n end\n end\n return sum\nend",
"def solve_again_with_more_issues(array, sum)\n array.combination(2).find_all do |one, two|\n one + two == sum\n end.size\nend",
"def solution(a)\n # In production environment this will be my solution:\n # a.uniq.size\n #\n # But since this is a coding challenge, my assumption\n # is that you're looking for a by-hand O(N*logN) solution\n\n return 0 if a.empty?\n\n n = a.size\n ary = a.sort\n uniques = 1\n (1...n).each do |i|\n uniques += 1 if ary[i] != ary[i - 1]\n end\n uniques\nend",
"def solution(size=5)\n ([1] + (3..size).select(&:odd?).map do |x|\n 4*x**2 - 6*x + 6\n end).reduce(:+)\nend",
"def solve\n perms = (1..9).to_a.permutation.map {|p| p.join}\n prods = []\n\n perms.each do |p|\n (1..2).each do |len|\n a, b, c = p[0, len].to_i, p[len..4].to_i, p[5, 4].to_i\n prods << c if a * b == c\n end\n end\n \n prods.uniq.reduce( :+ )\n end",
"def adds_up(array1, array2, array3)\n result = []\n sum = 0\n\n comb = (array1 + array2).combination(2).to_a\n\n comb.each do |y|\n array3.each do |z|\n if y[0] + y[1] == z\n result.push(y.push(y[0] + y[1]))\n end\n end\n end\n\nreturn result\n\nend",
"def solution(a)\n return 1 if a.empty?\n a.sort!\n return 1 if a.first > 1\n return a.first + 1 if a.length <2\n (0..(a.length)).each do |index|\n return a[index] + 1 if a[index] + 1 != a[index + 1]\n end\n return a.last + 1\nend",
"def compute(n)\n a = []\n a.push(1)\n a.push(1)\n n -=1\n first = 1\n second = 1\n n.times do\n third = first + second\n first = second\n second = third\n a.push(third)\n end\n #first\n a\nend",
"def reduce_associativity_array(p_old, n_old)\n p_del, n_del = [], []\n p_old.each do |p|\n n_old.each do |n|\n if p == n\n p_del << p\n n_del << n\n end\n end\n end\n\n return (p_old - p_del), (n_old - n_del)\n end",
"def equal(arr)\n size = arr.size\n hash = Hash.new{|h,k| h[k] = []}\n (0...size).each do |i|\n (i + 1...size - 1).each do |j|\n sum = arr[i] + arr[j]\n if hash.has_key?(sum)\n values = hash[sum]\n values << i\n values << j\n return values\n else\n hash[sum] = [i, j]\n end\n end\n end\nend",
"def solution(a)\r\n # write your code in Ruby 2.2\r\n #trangular\r\n # a[0] = 10\r\n # a[2] = 5\r\n # a[4] = 8\r\n # 10 + 5 > 8\r\n # 5 + 8 > 10\r\n #8 + 10 > 5\r\n \r\n \r\n l=a.count\r\n \r\n i=0\r\n while(i<l) do\r\n j=i+1\r\n while(j<l) do\r\n k=j+1\r\n \r\n \r\n while(k<l) do\r\n if((a[i] + a[j] > a[k]) && (a[j] +a[k] > a[i]) && (a[k] + a[i] >a[j]))\r\n return 1\r\n end\r\n k+=1 \r\n end \r\n \r\n j+=1 \r\n end\r\n i+=1\r\n end\r\n \r\n return 0\r\n \r\nend",
"def delete_nth(order,max_e)\n #your code here\n counter = Hash.new(0)\n solution = []\n order.each {|x| counter[x] += 1}\n counter.each do |k, v|\n solution.push(k)\n v = max_e if v > max_e\n if v > 1\n v -= 1\n v.times do\n solution.push(k)\n end\n end\n end\n return solution\nend",
"def solution(a, k)\n # write your code in Ruby 2.2\n \n unless a.empty?\n for i in 1..k\n last = a.pop\n a.insert(0, last)\n end\n end\n \n return a\nend",
"def solve( n = 1_000_000_000_000 )\n # From the problem statement, n = dq + r and d = kr, q = kd for some k.\n # (We could set q = kr and d = kq instead, but it doesn't really matter\n # which convention we adopt.) From this we infer r < d < q. We also know\n # k must be rational or d, q wouldn't be integer values, so k = a/b. Then\n # d = ar/b and q = ad/b = (a^2)r/(b^2). Since a and b are coprime (other-\n # wise k could be reduced until they were), b^2 must divide r, which means\n # r = cb^2 for some c.\n #\n # Combining these facts, we have r = (b^2)c, d = ar/b = a(b^2)c/b = abc,\n # and q = (a^2)(b^2)c/(b^2) = (a^2)c. Substituting into n = dq + r we ob-\n # tain n = (abc)(a^2)c + (b^2)c = (a^3)b(c^2) + (b^2)c. The dominant term\n # is a^3, which must be < n, so use it as an outer limit as we search for\n # b, c values that generate perfect squares.\n\n # Create a hash of perfect squares to simplify future checks.\n sq = {}\n (1..Math.sqrt( n )).each {|i| sq[i*i] = i}\n\n # Upper bound on values of a.\n lim = Math.cbrt( n )\n sum = []\n\n (2...lim).each do |a|\n a3 = a*a*a\n (1...a).each do |b|\n m = b*(a3 + b)\n break if m > n\n next unless b.coprime?( a )\n\n c = 1\n while m < n\n sum << m if sq.has_key?( m )\n c += 1\n m = b*c*(a3*c + b)\n end\n end\n end\n\n sum.reduce( :+ )\n end",
"def ptn(a)\n if a.size == 1 then\n return [a]\n end\n ret = Array.new\n # 重ならないパターン\n ret += a.perms\n # 重なるパターン\n h1 = Hash.new\n for i in 0..a.size - 1\n for j in i + 1..a.size - 1\n key = [a[i], 0, a[j]].to_s\n if !h1.key?(key) then\n h1.store(key, nil)\n h2 = Hash.new\n # a[i]とa[j]を範囲をずらしながら重ねる\n for k in 0..a[i].size + a[j].size\n t = [0] * a[j].size + a[i] + [0] * a[j].size\n for m in 0..a[j].size - 1\n t[k + m] += a[j][m]\n end\n # 余分な0を取り除く\n t.delete(0)\n # 4より大きい値がないかチェック\n next if t.any? {|v| v > 4}\n # 9より長くないかチェック\n next if t.size > 9\n # 重複チェック\n if !h2.key?(t.to_s) then\n h2.store(t.to_s, nil)\n # 残り\n t2 = a.dup\n t2.delete_at(i)\n t2.delete_at(j - 1)\n # 再帰呼び出し\n ret += ptn([t] + t2)\n end\n end\n end\n end\n end\n return ret\nend",
"def largest_contiguous_subsum_2(list)# [2, 3, -6, 7, -6, 7]\n largest_num = list[0]#2 O(1)\n running_sum = list[0]#2 - 5 after entering loop. O(1)\n\n (1...list.length).each do |i| #O(n) \n running_sum = 0 if running_sum < 0 #O(1)\n running_sum += list[i] #O(1)\n largest_num = running_sum if running_sum > largest_num #O(1)\n end\n return largest_num #O(1)\nend",
"def solution(a)\n n = a.size\n starting = Array.new(n, 0)\n ending = Array.new(n, 0)\n\n (1..n - 2).each {|i| starting[i] = [starting[i - 1] + a[i], 0].max}\n (1..n - 2).reverse_each {|i| ending[i] = [ending[i + 1] + a[i], 0].max}\n\n sum = 0\n (1..n - 2).each {|i| sum = [sum, starting[i - 1] + ending[i + 1]].max}\n sum\nend",
"def slow_solution(a)\n m = 0\n a.size.times do |i|\n a[i] = a[i].abs\n m = [a[i], m].max\n end\n maxsum = a.sum # sum of absolute val of all nums in array\n # maxsum = a.map(&:abs).sum <- Ruby shortcut\n\n # If dp = 1 at an index, it means some combo of elements in a add up to that index\n dp = [0] * (maxsum + 1)\n dp[0] = 1\n\n a.size.times do |j|\n maxsum.downto(0).each do |possible_sum|\n puts \"a[j]: #{a[j]}, possible sum: #{possible_sum}\"\n if (dp[possible_sum] == 1) and (possible_sum + a[j] <= maxsum)\n\n # if possible_sum + new element a[j] is possible sum, dp = 1!\n dp[possible_sum + a[j]] = 1\n puts \"Mark #{possible_sum + a[j]} as possible sum in dp\"\n end\n end\n puts \"row: #{j}, a[j]: #{a[j]}, dp: #{dp}\"\n puts\n end\n\n min_q_minus_p = maxsum\n\n # Divide array a into 2 parts, where P = sum of part 1 and Q = sum of part 2,\n # P + Q = maxsum, and P <= maxsum / 2 <= Q.\n # We want largest possible P to get smallest possible Q-P.\n\n # loop from 0 to maxsum / 2, covering every possible P, Q division\n (maxsum / 2 + 1).times do |possible_half_sum|\n # puts \"possible_half_sum: #{possible_half_sum}\"\n if dp[possible_half_sum] == 1 # means P or Q = possible_half_sum\n q_minus_p = maxsum - 2 * possible_half_sum\n # puts \"Q - P: #{q_minus_p}\"\n min_q_minus_p = [min_q_minus_p, q_minus_p].min\n # puts \"min Q - P: #{min_q_minus_p}\"\n end\n end\n\n min_q_minus_p\nend",
"def hash_four_sum(arr, sum, n = 4)\n return hash_two_sum(arr, sum) if n == 2\n arr.each_with_index do |el,idx|\n arr_dup = arr.dup\n arr_dup.delete_at(idx)\n return true if hash_four_sum(arr_dup, (sum - el), n-1)\n end\n false\nend",
"def solution(a)\n # we could do radix sort and then loop over all the items in order to find the missing element\n # in the ordered list or use the Gauss theorem: https://study.com/academy/lesson/finding-the-sum-of-consecutive-numbers.html\n #\n # if we use the Gauss theorem we can do:\n # sum = (1 + N+1) * ( N / 2 )\n #\n # if (1 + N+1) % 2 == 1 we need to sum also (n+1+1)/2 + 1\n #\n # then remove every item from the sum: the remainder is the missing number\n len = a.length\n sum = (1 + len + 1) * ((len + 1) / 2)\n sum += ((len + 1) / 2.0).ceil unless (len + 1) % 2 == 0\n\n a.reduce(sum) do |sum, i|\n sum - i\n end\nend",
"def delete(arr,index)\n # res = arr.clone;\n res = arr[0,index] + arr[index+1,arr.size-(index+1)];\n return res;\nend",
"def find_solution(arr)\n arr.each_with_index do |e, i|\n rest = arr[0..i - 1] + arr[i + 1..-1]\n prod = rest.reduce(:*)\n arr[i] = prod\n end\n\n arr\nend",
"def pythagoreans (n)\n triples = []\n a = 1\n b = 1\n c = 1\n\n for c in (1..n)\n for b in (1..c)\n for a in (1..b)\n if a**2 + b**2 == c**2\n triples << [a,b,c]\n end\n end\n end\n end\n\n return triples.sort\nend",
"def solution(a)\n first_sum = a[0]\n second_sum = a.inject(&:+) - a.first\n result = (first_sum - second_sum).abs\n\n a[1..-2].each do |elem|\n first_sum = first_sum + elem\n second_sum = second_sum - elem\n tmp_result = (first_sum - second_sum).abs\n result = tmp_result if tmp_result < result\n end\n\n result\nend",
"def solution(a)\n n = a.size\n a.sort!\n\n count = 0\n for i in 0...n-2 do\n k = i+2\n for j in i+1...n-1 do\n while k < n and a[i] + a[j] > a[k] do\n k += 1\n end\n count += k - j - 1\n end\n end\n count\nend",
"def solve(nums)\n arr = nums.map {|num| num * num}\n arr.each_with_index do |el1, idx1|\n arr.each_with_index do |el2, idx2|\n if idx2 > idx1\n if arr.include?(el1 + el2)\n if (arr.index(el1 + el2) != idx1) && (arr.index(el1 + el2) != idx2)\n return true\n end\n end\n end\n end\n end\n false\nend",
"def solution(x, a)\n perm = (1..x).to_a\n return -1 unless (perm - a).empty?\n a.index(a.uniq.last)\nend",
"def divisible_sum_pairs(n,k,a)\n count = 0\n i = 0\n\n while (i < n)\n j = i + 1\n\n while (j < n)\n if ((a[i] + a[j]) % k == 0)\n count += 1\n end\n j+=1\n end\n\n i += 1\n end\n count\nend",
"def dp_possible_trees(n)\n array = Array.new(n+2) { Array.new(n+1) { 0 } }\n (0...n+2).to_a.each do |i|\n array[i][0] = 1\n end\n\n sum = 0\n (1...n+1).to_a.each do |i|\n sum = 0\n (1..i).to_a.each do |j|\n array[j][i] = array[n+1][i-j] * array[n+1][j-1]\n sum += array[j][i]\n end\n array[n+1][i] = sum\n end\n array[n+1].last\nend",
"def solve_part_two\n input = File.read(ARGV[0])\n\n grid = Grid.from_puzzle_input(input)\n grid.create_all_carts\n\n until grid.carts.one?\n # Deleting elements while iterating them really confuses Ruby by the\n # looks of things; keep track of elements we need to delete using a \n # Set instead, ignoring them on future iterations then deleting at the\n # end\n scheduled_for_deletion = Set.new\n\n grid.carts.each do |cart|\n next if scheduled_for_deletion.include? cart\n\n cart.tick\n next unless grid.collision\n colls = grid.collisions\n\n colls.each do |coll|\n scheduled_for_deletion << coll[0] << coll[1]\n end\n end\n\n scheduled_for_deletion.each do |deleted_cart|\n grid.carts.delete(deleted_cart)\n end \n\n # Re-sort the array following the deletions\n grid.carts.sort_by! { |c| c.position.top * 1000 + c.position.left }\n end\n\n p grid.carts.first.position\nend",
"def solution(a)\n left = 0\n right = a.sum\n a.each_with_index do |element, index|\n right -= element\n return index if left == right\n left += element\n end\n -1\nend",
"def cantor_pairing(n, m)\n (n + m) * (n + m + 1) / 2 + m\nend",
"def efficient_contiguous_subsum(list)\n current_sum = list[0] #0\n largest_sum = list[0] #5\n # debugger\n (1...list.length).each do |i| \n if current_sum + list[i] > 0 \n current_sum += list[i] \n largest_sum = current_sum if current_sum > largest_sum\n else \n current_sum = 0\n end \n end \n largest_sum\nend",
"def solve_for_d_optimized\n hash = {}\n for a in (1..5)\n for b in (1..5)\n result = (a**2) + (b**2)\n if hash[result].nil?\n hash[result] = [\"(#{a}, #{b})\"]\n else\n hash[result] << \"(#{a}, #{b})\"\n end\n end\n end\n\n hash.each do |key, array|\n if array.length > 1\n puts \"This is the result (#{array})\"\n end\n end\nend",
"def three_sums(nums)\n nums.sort!\n l = 0\n r = nums.length - 1\n result = []\n\n i = 0\n until r < l\n sum = nums[r] + nums[l]\n end\n\n result.uniq\nend",
"def solution(a)\n # write your code in Ruby 2.2\n permutation = Array(1..a.size)\n # puts permutation\n return 1 if permutation - a == []\n 0\nend",
"def two_sum_v3?(arr, target) \n hash = Hash.new\n arr.each { |ele| hash[ele] = ele } #o(n)\n arr.each do |ele| #o(n)\n search_value = target - ele\n return true if !hash[search_value].nil? && hash[search_value] != ele\n end\n false\nend",
"def findDiffSquares(n)\n sum = 0\n (1..n).each { |i|\n (1..n).each { |j|\n sum += i*j unless i == j\n }\n }\n sum\nend",
"def largest_contiguous_sub_sum2(arr)\n #one varable tracks largest sum\n #one variable tracks current sum\n #O(n) + O(1)\n # list = [2, 3, -6, 7, -6, 7]\n\n # largest_sum= arr.first\n\n # i = 0\n # arr_end = true\n\n # while arr_end\n # current_sum = arr[i]\n # if arr[i+1] == nil\n # arr_end = false\n # puts \"This is current sum: #{current_sum}\"\n # else\n # if current_sum > largest_sum\n # current_sum += arr[i+1]\n # largest_sum = current_sum\n # end\n # end\n # if i < arr.length\n # arr_end = true\n # i += 1\n # end\n # end\n # largest_sum\n \n\n\n # arr.each_with_index do |ele, idx|\n # if ele > largest_sum\n # largest_sum = ele\n # end\n\n # i = idx\n # sum = ele\n # while i < arr.length - 1\n # if sum <= sum + arr[i+1]\n # largest_sum = sum + arr[i+1]\n # end\n # sum = sum + arr[i+1]\n # i+=1\n # end\n # end\n # largest_sum\n\nend",
"def eliminacion_gaussianda(n, a)\n n = n - 1\n\n for j in (0..n - 1)\n k = (j..n).select { |i| !a[i][j].zero? }.first\n\n if k.nil?\n puts \"El sistema no tiene solucion unica.\"\n return\n end\n\n if !k.eql?(j)\n a[k], a[j] = a[j], a[k]\n end\n\n for i in (j + 1..n)\n m = a[i][j].fdiv(a[j][j])\n resta = a[i].map.with_index { |x, index| x - m * a[j][index] }\n a[i].replace(resta)\n end\n end\n\n if a[n][n].zero?\n puts \"El sistema no tiene solucion unica.\"\n return\n end\n\n x = Array.new(n + 1)\n x[n] = a[n][n + 1].fdiv(a[n][n])\n\n (0..n - 1).reverse_each do |i|\n sumatoria = (i + 1..n).inject(0) { |sum, k| sum + a[i][k] * x[k] }\n x[i] = (a[i][n + 1] - sumatoria).fdiv(a[i][i])\n end\n\n puts \"Una solucion aproximada del sistema es X = #{x}\"\n return x\nend",
"def solution(a)\n return 0 if a.length < 3\n a.sort.each_cons(3) { |e| return 1 if e[0] + e[1] > e[2] }\n return 0\nend",
"def solve_again_with_issues(array, sum)\n result = {}\n freq = {}\n count = 0\n\n array.each do |el|\n freq[el] ? freq[el] += 1 : freq[el] = 1\n end\n\n array.each do |el|\n if freq[sum - el] && !result[sum - el]\n count += freq[sum - el]\n end\n end\n count/2\nend",
"def solve( n = 10_000 )\n (1..n).select {|i| i.amicable?}.reduce( :+ )\n end",
"def array_addition(arr)\n max = arr.max\n arr.delete(max)\n (2..arr.length).each do |i|\n combinations = arr.combination(i)\n combinations.each do |comb|\n if comb.inject(:+) == max\n return true\n break\n end\n end\n end\n return false\nend",
"def remove_duplicates(nums)\n record_leng = 0\n uniq_arr = nums.uniq\n uniq_arr.each do |i|\n record_leng += 1 if count_great_two?(nums, i)\n end\n return (record_leng + uniq_arr.size)\nend",
"def pytha_tri\n for i in (0...500)\n for j in (i+1...500)\n for k in (j+1...500)\n if (i+j+k == 1000) && (i*i + j*j == k*k)\n return i*j*k\n end\n end\n end\n end\nend",
"def largest_contiguous_subsum_2(list)\n largest_sum = 0\n current_sum = 0\n\n list.each do |el|\n largest_sum = current_sum \n current_sum += el \n if current_sum < el \n current_sum = el \n end \n largest_sum = current_sum if largest_sum < current_sum\n end\n\n largest_sum\nend",
"def problem_60\n prime_check = lambda do |a,b|\n (a + b).to_i.prime? && (b + a).to_i.prime?\n end\n\n find_match = lambda do |a,k|\n r = a.select {|p| k != p && prime_check.call(k,p) }\n end\n\n primes = Primes.upto(10_000).map(&:to_s)\n primes.delete(\"2\")\n\n hit = {}\n\n primes.each do |p1|\n p1a = find_match.call(primes,p1)\n p1a.each do |p2|\n p2a = find_match.call(p1a,p2)\n p2a.each do |p3|\n p3a = find_match.call(p2a,p2)\n p3a.each do |p3|\n p4a = find_match.call(p3a,p3)\n p4a.each do |p4|\n p5a = find_match.call(p4a,p4)\n if p5a.length > 0\n p5a.each do |p5|\n a = [p1,p2,p3,p4,p5]\n sum = a.map(&:to_i).reduce(&:+)\n unless hit[sum]\n puts \"#{sum} #{a.inspect}\"\n else\n hit[sum] = true\n end\n return sum\n end\n end\n end\n end\n end\n end\n end\nend",
"def number_of_combinations2(pos)\n if pos == list.length - 1\n 1\n elsif @cache[pos] != nil\n @cache[pos]\n else\n total = 0\n (pos + 1..list.length - 1).each do |index|\n if list[index] - list[pos] <= 3\n total += number_of_combinations2(index)\n end\n end\n\n @cache[pos] = total\n total\n end\n end",
"def solve( n = 16 )\n max = 0\n \n (1..10).each do |a|\n (1..10).each do |b|\n next if b == a\n (1..10).each do |c|\n next if c == b || c == a\n (1..10).each do |d|\n next if d == c || d == b || d == a\n (1..10).each do |e|\n next if e == d || e == c || e == b || e == a\n\n rotate = 3*[a, b, c, d, e].each_with_index.min[1]\n (1..10).each do |f|\n next if f == e || f == d || f == c || f == b || f == a\n (1..10).each do |g|\n next if g == f || g == e || g == d || g == c || g == b || g == a\n \n t = a + f + g\n (1..10).each do |h|\n next if h == g || h == f || h == e || h == d || h == c || h == b || h == a\n next unless t == b + g + h\n\n (1..10).each do |i|\n next if i == h || i == g || i == f || i == e || i == d || i == c || i == b || i == a\n next unless t == c + h + i\n\n (1..10).each do |j|\n next if j == i || j == h || j == g || j == f || j == e || j == d || j == c || j == b || j == a\n next unless t == d + i + j && t == e + j + f\n\n s = [a, f, g, b, g, h, c, h, i, d, i, j, e, j, f]\n rotate.times {s.push s.shift}\n\n s = s.join\n next if n != s.length\n\n max = [max, s.to_i].max\n end\n end\n end\n end\n end\n end\n end\n end\n end\n end\n\n max\n end",
"def solve2( n = 150_000_000 )\n # Brute force.\n sum = 10\n i = 20\n\n while i < n\n if 0 != i % 3\n i2 = i*i\n\n # Must verify that the primes are consecutive (i.e. there aren't any\n # primes hiding between entries).\n if (i2 + 1).miller_rabin? &&\n (i2 + 3).miller_rabin? &&\n (i2 + 7).miller_rabin? &&\n (i2 + 9).miller_rabin? &&\n !(i2 + 11).miller_rabin? &&\n (i2 + 13).miller_rabin? &&\n !(i2 + 17).miller_rabin? &&\n !(i2 + 19).miller_rabin? &&\n !(i2 + 21).miller_rabin? &&\n !(i2 + 23).miller_rabin? &&\n (i2 + 27).miller_rabin?\n \n sum += i\n i += 315410\n end\n end\n\n # From observation that 10 | a_n in similar sequences.\n i += 10\n end\n\n sum\n end",
"def solution(a)\n ans = 0\n for i in 1 .. (a.length - 1)\n ans += a[i]\n end \n ans\nend",
"def main\n\n sum = 0\n\n (0..999).each do |i|\n sum += check(i)\n end\n\n puts \"Total - O(n) #{sum}\"\n\n # Needed to refresh following: https://en.wikipedia.org/wiki/Arithmetic_progression\n sum2 = sum_multiples(3, 1000) + sum_multiples(5, 1000) - sum_multiples(15, 1000)\n\n # Refreshed Big O too : http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o \n puts \"Total - O(1) #{sum2}\"\n\nend",
"def solve( n = 100_000_000 )\n # Assuming the largest valid sum of squares is S = a^2 + (a - 1)^2 < n,\n # first find a and set aside space to cache that many running sums.\n len = (1 + Math.sqrt( 2*n )) / 2\n sos = Array.new( len )\n\n seen = []\n sos[0] = 1\n\n (1...len).each do |i|\n # Precompute the ∑ i^2 for all i <= a. \n ds = i*i + 2*i + 1\n sos[i] = sos[i - 1] + ds\n\n seen << sos[i] if sos[i].palindrome?\n\n # Most of the sum of square values will exceed n, so subtract lower sums\n # to check shorter runs.\n (i - 2).downto( 0 ) do |j|\n diff = sos[i] - sos[j]\n break unless diff < n\n\n # Update our total if the shorter run a[j] + a[j + 1] + ... + a[i] is\n # a palindrome.\n seen << diff if diff.palindrome?\n end\n end\n\n seen.uniq.reduce( :+ )\n end",
"def largest_contiguous_subsum2(list)\n # O(N) ==> Time\n # O(1) ==> Space\n largest = list.first\n curr = list.first\n\n len = list.length\n (1...len).each do |i|\n curr = 0 if curr < 0 \n curr += list[i]\n largest = curr if curr > largest\n end\n largest\nend",
"def problem_106\n a = [1,2,3,4]\n a = [1,2,3,4,5,6,7]\n a = [1,2,3,4,5,6,7,8,9,10,11,12] \n \n num = 0\n seen = {}\n # Don't do length of 1, they are ordered\n # Because they are size ordered, and 2 smalls are bigger than a large\n 2.upto(a.length/2) do |n|\n puts \"n = #{n}\"\n a.combination(n) do |set_a|\n b = a - set_a\n break if b.length < n\n b.combination(n) do |set_b|\n key = [set_a,set_b].sort\n next if seen[key]\n seen[key] = true\n index = 0\n state = 0\n 0.upto(set_a.length-1) do |i|\n break unless set_b[i] && set_a[i]\n if set_a[i] < set_b[i]\n state -= 1\n else\n state += 1\n end\n end\n\n# print \"#{set_a.inspect} #{set_b.inspect} #{state}\"\n if state.abs <= (set_a.length - 2) ||\n (state < 0 && set_a.last > set_b.last) ||\n (state > 0 && set_a.first < set_b.first)\n# puts \" good\"\n num += 1\n else\n# puts \"\"\n end\n end\n end\n end\n num\nend",
"def solution(a)\n counts = {}\n for i in a\n counts[i] ||= 0\n counts[i] += 1\n end\n for i in (1..a.count)\n return 0 if counts[i] != 1\n end\n return 1\nend",
"def euler29(n)\n terms = []\n 2.upto(n) do |i|\n 2.upto(n) do |j|\n if terms.include?(i ** j) == false\n terms << i ** j\n end\n end\n end\n \n terms.length\nend",
"def solution_3(num)\n starting_time = Time.now\n\n # actual sieve of eratosthenes\n potential_primes = (2..num).to_a\n potential_primes.each_with_index do |val, index|\n if val\n index += val\n while index < num\n potential_primes[index] = nil\n index += val\n end\n else\n next\n end\n end\n\n primes = potential_primes.compact\n\n p \"Sum of first #{num} primes: #{primes.reduce(:+)}\"\n\n p \"In #{Time.now - starting_time} seconds\"\nend",
"def answer(n, a)\n count = 0\n n.times do |nn|\n next if a[nn] != nn + 1\n a[nn], a[nn + 1] = a[nn + 1], a[nn]\n count += 1\n end\n count\nend",
"def josephus_survivor(n,k)\n result = 1\n for i in 1...n + 1\n result = (result + k - 1) % i + 1\n end\n \n result\nend",
"def solution(a)\n return 0 if a.length < 3\n a.sort!\n\n for i in 0..(a.length - 3)\n return 1 if a[i] + a[i + 1] > a[i + 2]\n end\n return 0\nend",
"def josephus_survivor(n,k)\n arr = (1..n).to_a\n\n while arr.length > 1\n idx = k % arr.length\n\n if arr.length > k\n arr = arr.drop(k) + arr.take(k - 1)\n elsif arr.length == k \n arr = arr[0...-1]\n else\n arr = arr.drop(idx) + arr.take(idx - 1)\n end\n end\n \n arr[0]\nend",
"def three_sum(r)\n r.combination(3).select { |a,b,c| a+b+c = 0 }\nend",
"def solution0(a)\n\n total_count = 0\n elem_counts = Hash.new(0)\n\n a.each do |elem|\n elem_counts[elem] += 1\n total_count += 1 if elem_counts[elem] == 2\n end\n\n return total_count\n\nend"
] |
[
"0.641257",
"0.62326336",
"0.6130321",
"0.6128333",
"0.6127051",
"0.5954614",
"0.5940014",
"0.5918606",
"0.59178686",
"0.5907201",
"0.5906092",
"0.58871794",
"0.58857304",
"0.5877406",
"0.5864017",
"0.58618265",
"0.5848513",
"0.5846755",
"0.5837095",
"0.5834333",
"0.58334404",
"0.5805715",
"0.57947993",
"0.57848936",
"0.5757643",
"0.575562",
"0.5706603",
"0.5663915",
"0.565531",
"0.5634025",
"0.5617272",
"0.5614559",
"0.5611076",
"0.56000465",
"0.55963373",
"0.55802387",
"0.5568425",
"0.55667794",
"0.55636024",
"0.55606073",
"0.55573696",
"0.5557338",
"0.5549124",
"0.5545318",
"0.55275637",
"0.5527385",
"0.5526797",
"0.5514118",
"0.55091316",
"0.5507155",
"0.55061686",
"0.5500383",
"0.5493623",
"0.5493555",
"0.5477201",
"0.5460255",
"0.5456492",
"0.54541856",
"0.5447534",
"0.5438412",
"0.5437661",
"0.5435799",
"0.54356396",
"0.5434791",
"0.54315406",
"0.54300267",
"0.5427574",
"0.5426619",
"0.54234946",
"0.54216695",
"0.54166174",
"0.5412221",
"0.5387522",
"0.53863376",
"0.53829855",
"0.5381149",
"0.53751755",
"0.5373726",
"0.53701884",
"0.53694427",
"0.5368893",
"0.53680086",
"0.53656316",
"0.5364592",
"0.53644174",
"0.5354104",
"0.535357",
"0.5342445",
"0.5341361",
"0.5339488",
"0.5337311",
"0.532688",
"0.53181994",
"0.5306025",
"0.5305028",
"0.5302462",
"0.5302421",
"0.53007436",
"0.53003573",
"0.52998286",
"0.5299316"
] |
0.0
|
-1
|
Time complexity: O(n + n) = O(n) Space complexity: O(n + n) = O(n). the set needs space for the elements in nums Ruby bitwise XOR If we take XOR of zero and some bit, it will return that bit a ^ 0 = a If we take XOR of two same bits, it will return 0 a ^ a = 0 a ^ b ^ a = (a ^ a) ^ b = 0 ^ b = b So we can XOR all bits together to find the unique number. For each bit in the binary representation of the operands, a bitwise XOR will get a 1 bit if one of the corresponding bits in the operands is 1, but not both, otherwise the XOR will get a 0 bit. Here's an example: 5 is 101, 6 is 110, 5 ^ 6 = 011 = 3 5 ^ 5 = 0 4 The first element in the array is taken as the memo and the second element is taken as the num. memo takes the result of the comparison, compares to the 3rd element, and so on. the idea is that the pairs of integers will cancel out with XOR, leaving only the number of interest e.g. 5 ^ 5 ^ 6 ^ 7 ^ 7 => 6
|
def single_number(nums)
nums.reduce(:^) # { |memo, num| memo ^ num }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def find_duplicates(a)\n len=a.length\n n=len-2\n xor= 0\n x,y=0,0 #variables to store duplicates\n \n #xor of all numbers from 1 to n\n for i in 1..n \n xor^=i\n end\n #xor of all array elements\n for i in 0...len \n xor^=a[i]\n end\n #Rightmost set bit\n set_bit_pos= xor & ~(xor-1)\n #Divinding array in two sets ,one with set bit at set_bit_pos and other with 0.\n for i in 0...len\n if (a[i] & set_bit_pos == 0)\n x^=a[i] # XOR of first-set(with 0 at set_bit_pos) in array\n else\n y^=a[i] # XOR of second-set(with 1 at set_bit_pos) in array\n end\n end\n \n for i in 0..n\n if (i & set_bit_pos == 0)\n x^=i # XOR of first-set(with 0 at set_bit_pos) in range\n else\n y^=i # XOR of second-set(with 1 at set_bit_pos) in range\n end\n end\n print \"#{x} #{y}\"\n\treturn\nend",
"def uniq_integer(input_array)\n unique = 0\n input_array.each do |num|\n unique = unique ^ num\n end\n\n unique\nend",
"def find_unique(array)\n unique_id = 0\n\n array.each do |num|\n unique_id ^= num\n end\n\n unique_id\nend",
"def single_number(nums)\n sum = 0\n nums.each do |num|\n sum ^= num\n end\n\n sum\nend",
"def single_number(nums)\n ones = 0\n twos = 0\n nums.each do |n|\n ones = (ones^n)&(~twos)\n twos = (twos^n)&(~ones)\n end\n\n ones\nend",
"def find_unique(numbers)\n numbers.reduce(:^)\nend",
"def find_two_missing_numbers(array, n)\n # after this, we would have the ^ of the two missing numbers\n # as they are different we would have at least one set bit\n # we want to find the first starting from the left\n i = xor_arrays(array, (1..n).to_a)\n\n set_bit_position = 0\n\n loop do\n break if ((1 << set_bit_position) & i) != 0\n set_bit_position += 1\n end\n\n array_numbers_with_bits_set = numbers_from_array_with_bit_set_at_position(array, set_bit_position)\n sequence_numbers_with_bits_set = numbers_from_array_with_bit_set_at_position((1..n), set_bit_position)\n\n first_missing_number = xor_arrays array_numbers_with_bits_set, sequence_numbers_with_bits_set\n second_missing_number = xor_arrays (array << first_missing_number), (1..n).to_a\n\n [first_missing_number, second_missing_number].sort\nend",
"def find_unique_x(numbers)\n numbers.reduce(:^)\nend",
"def odd_duplicates(array)\n xor = array.reduce(0, :^)\nend",
"def pair_sum(array, k)\n result = Set.new\n hash_num = Hash.new\n\n array.each{|n| hash_num[n] = k - n}\n\n array.each do |n|\n unless hash_num[hash_num[n]].nil?\n result.add([hash_num[n], n].sort)\n end\n end\n\n result\nend",
"def single_number(nums)\n a = 0\n for i in nums\n a ^= i\n end\n a\nend",
"def complement_2(array, sum)\n elements = Set.new(array)\n complements = {}\n array.each do |num|\n complement = sum - num\n complements[num] = complement if elements.include?(complement)\n end\n complements\nend",
"def two_sum(arr) #o(ns)\n set = Set.new\n arr.each{|el| set << el}\n arr.select{|el| set.include?(-1 * el)}\nend",
"def find_lis_brute_force array\n max_count = -1\n # Generate all the possible sets. This is done by generating all binary numbers from 1 to 2^n.\n # The presence of a 0 in the binary number at a position will grant entry to the element at that position to the set\n for i in 1..((2**array.count) - 1)\n itr = array.count - 1\n set = []\n while i > 0\n if i%2 == 1\n set << array[itr]\n end\n i = i/2\n itr -= 1\n end\n max_count = max(max_count, evaluate(set))\n end\n return max_count\nend",
"def single_number2(nums)\n nums.reduce do |collect, num|\n collect ^= num\n end\nend",
"def solve(nums)\n arr = nums.map {|num| num * num}\n arr.each_with_index do |el1, idx1|\n arr.each_with_index do |el2, idx2|\n if idx2 > idx1\n if arr.include?(el1 + el2)\n if (arr.index(el1 + el2) != idx1) && (arr.index(el1 + el2) != idx2)\n return true\n end\n end\n end\n end\n end\n false\nend",
"def problem_106\n a = [1,2,3,4]\n a = [1,2,3,4,5,6,7]\n a = [1,2,3,4,5,6,7,8,9,10,11,12] \n \n num = 0\n seen = {}\n # Don't do length of 1, they are ordered\n # Because they are size ordered, and 2 smalls are bigger than a large\n 2.upto(a.length/2) do |n|\n puts \"n = #{n}\"\n a.combination(n) do |set_a|\n b = a - set_a\n break if b.length < n\n b.combination(n) do |set_b|\n key = [set_a,set_b].sort\n next if seen[key]\n seen[key] = true\n index = 0\n state = 0\n 0.upto(set_a.length-1) do |i|\n break unless set_b[i] && set_a[i]\n if set_a[i] < set_b[i]\n state -= 1\n else\n state += 1\n end\n end\n\n# print \"#{set_a.inspect} #{set_b.inspect} #{state}\"\n if state.abs <= (set_a.length - 2) ||\n (state < 0 && set_a.last > set_b.last) ||\n (state > 0 && set_a.first < set_b.first)\n# puts \" good\"\n num += 1\n else\n# puts \"\"\n end\n end\n end\n end\n num\nend",
"def missing_number(nums)\n missing = nums.size\n nums.each_with_index do |num, index|\n missing ^= index ^ num\n end\n missing\nend",
"def two_sums?(arr, target)\n # number_count = Hash.new(0)\n #\n # arr.each do |num|\n # number_count[num] += 1\n # end\n #\n # arr.each do |num|\n # other_num = target - num\n # number_count[num] -= 1\n # return true if number_count.include?(other_num) && number_count[other_num] > 0\n # end\n #\n # false\n set = Set.new(arr)\n arr.each do |num|\n set.delete(num)\n return true if set.include?(target - num)\n end\n false\nend",
"def better_sum1(arr, target) # this one is going to return true or false\n pairs = Set.new\n\n arr.each do |ele|\n if pairs.include?(ele)\n return true\n else\n pairs << target - ele\n end\n end\n false\nend",
"def better_sum?(arr, target)\n pair_set = Set.new\n\n arr.each do |ele|\n if pair_set.include?(ele)\n return true\n else\n pair_set << target - ele\n end\n end\n\n false\n\nend",
"def three_sum(nums)\n n = nums.length\n result = []\n for i in 0...n-2\n req_sum = 0\n hsh = Hash.new\n curr_sum = req_sum - nums[i]\n \n for j in (i+1)...n\n num = curr_sum - nums[j]\n if hsh[num]\n elements = [nums[i], num, nums[j]].sort\n result << elements unless result.include?(elements)\n end\n hsh[nums[j]] = true\n end \n end\n result\nend",
"def solution(a)\n # write your code in Ruby 2.2\n seen = {}\n\n a.each do |number|\n seen[number] = true\n end\n\n max = a.max\n\n for i in 1..(max + 1)\n return i unless seen[i]\n end\n\n 1\nend",
"def single_number(nums)\n uniques = []\n nums.each do |num|\n uniques.include?(num) ? uniques.delete(num) : uniques << num\n end\n uniques\nend",
"def single_number(nums)\n 2 * nums.uniq.reduce(:+) - nums.reduce(:+)\nend",
"def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend",
"def find3(a, X)\n # scan through array\n # build hash storing complement in each key\n complements = {}\n a.each_with_index do |val, ind|\n if complements[X - val]\n complements[X - val].push(ind)\n else\n complements[X - val] = [ind]\n end\n end\n\n # scan through the array again\n # get complement\n # for each value scan the remainder of the arrray\n # for a value such taht a + b = the complement\n\n # for each character we have built a dictionary such that, we can find\n # x = a + complement\n\n # [1, 2, 3]\n # 1 + 2 = 3\n # 1 + 3 = 4 =>\n\n # for each value in the array (a) look at all following values (b) and see if a + b\n # is in the dictionary, if it is, check that their indices do not collide with the index\n # stored at dict(a+b)\n\n a.each_with_index do |va, i|\n a.each_with_index do |vb, j|\n break if i == j\n\n complement = va + vb\n indices = complements[complement]\n\n indices.each do |z|\n # every index is unique\n return [i, j, z] unless z == i || z == j\n end\n end\n end\n\n return nil\nend",
"def solution(a)\n counter = Hash.new(0)\n a.each do |elem|\n counter[elem] += 1\n end\n\n (1..a.size).each do |number|\n return 0 if counter[number] != 1\n end\n\n 1\nend",
"def three_sum_fastest(arr)\n count = 0\n\n (0..arr.length - 2).each { |i|\n set = Set.new\n\n (i + 1..arr.length - 1).each { |j|\n if set.include?(-arr[i] - arr[j])\n count += 1\n end\n\n set.add(arr[j])\n }\n }\n count\nend",
"def pairs(k, arr)\n # set = Set.new(arr)\n set = arr.to_h { |num| [num, true] }\n\n result = 0\n arr.each do |num|\n target = num + k\n if set.include?(target)\n result += 1\n end\n end\n\n result\nend",
"def two_sum(nums, target)\n target_indexes = []\n nums.each_with_index do |primary, index|\n nums.each_with_index do |num, i|\n if primary + num == target && index != i\n target_indexes << index\n target_indexes << i\n end\n end\n end\n return target_indexes.uniq\nend",
"def solution(a)\n # In production environment this will be my solution:\n # a.uniq.size\n #\n # But since this is a coding challenge, my assumption\n # is that you're looking for a by-hand O(N*logN) solution\n\n return 0 if a.empty?\n\n n = a.size\n ary = a.sort\n uniques = 1\n (1...n).each do |i|\n uniques += 1 if ary[i] != ary[i - 1]\n end\n uniques\nend",
"def find_complements1(numbers, target_sum: 2020)\n complements = numbers.map { |n| [n, target_sum - n] }.to_h\n complements.find { |_n, c| complements.key?(c) }\nend",
"def opposite_count(array)\n count = 0 \n array.combination(2).to_a.each do |nums|\n count += 1 if nums.sum == 0\n end\n\n count\nend",
"def unique(arr)\n uniq = Hash.new(0)\n arr.each { |x| uniq[x] += 1 }\n uniq.select { |k, v| v == 1 }.keys\nend",
"def remove_duplicates(nums)\n record_leng = 0\n uniq_arr = nums.uniq\n uniq_arr.each do |i|\n record_leng += 1 if count_great_two?(nums, i)\n end\n return (record_leng + uniq_arr.size)\nend",
"def three_sum2(nums)\n sorted_nums = nums.sort\n\n results = Set.new\n\n sorted_nums[0...sorted_nums.size - 2].each_with_index do |num, index|\n break if num > 0 # 已经排序,并且只看右面,所以大于0就不需要继续了。\n next if index > 0 && num == sorted_nums[index - 1] # 可以减少重复的计算\n\n find_two_sum(index, sorted_nums, results)\n end\n\n results.to_a\nend",
"def pairs(k, arr)\n ha = {}\n pairs = Set.new\n count = 0\n arr.to_set.each do |element|\n ha[element] = 1\n end\n arr.to_set.each do |element|\n sum = (k + element)\n if ha.key? sum\n count += 1\n end\n end\n count\nend",
"def find_abundant_numbers(max)\n\tabundant_nums = Set.new\n\n\t# all numbers to check if they are abundant\n\trange_arr = (2...max).to_a\n\n\tuntil range_arr.empty?\n\t\tnum = range_arr.shift\n\n\t\tif is_abundant?(num)\n\t\t\t# store num in set of abundant nums\n\t\t\tabundant_nums.add?(num)\n\n\t\t\t# all multiples of abundant nums will be also be abundant, so store those too\n\t\t\t# this enhances efficiency by avoiding having to build a list of proper divisors for those numbers\n\t\t\tmultiple = num\n\t\t\twhile multiple < range_arr.length\n\t\t\t\tabundant_nums.add?(range_arr[multiple - 1]) if range_arr[multiple - 1]\n\t\t\t\t# mark as already stored\n\t\t\t\trange_arr[multiple - 1] = false\n\t\t\t\t# get index+1 of next multiple\n\t\t\t\tmultiple += num\n\t\t\tend\n\t\tend\n\n\t\t# find next number that hasn't already been added to abundant_nums\n\t\trange_arr.shift while range_arr[0] == false\n\tend\n\n\t# return set of abundant nums\n\tabundant_nums\nend",
"def min_unique(arr)\n arr.sort! #[1,2,2,3,7]\n uniq = []\n dups = []\n (arr.length ).times do |i|\n if arr[i] == arr[i+1]\n dups << arr[i]\n else \n uniq << arr[i]\n end \n end \n\n dups.each do |el|\n while uniq.include?(el)\n el+=1\n end \n uniq << el\n p uniq\n end \n p uniq.reduce(:+)\nend",
"def unique(integers)\n new_int = []\n \n \n integers.each do |val1|\n integers.each do |val2|\n if (val1 != val2 && (not (new_int.include?(val1))))\n new_int << val1\n end\n end\n \n end\n\n return new_int\nend",
"def good_tuples(nums)\n count = 0\n (0..nums.size - 3).each do |i|\n first, second, third = nums[i], nums[i + 1], nums[i + 2]\n next if 3 * first == first + second + third\n count += 1 if [first, second, third].include?(first ^ second ^ third)\n\n # next if nums[i] == nums[i + 1] && nums[i + 1] == nums[i + 2]\n # next if nums[i] != nums[i + 1] && nums[i + 1] != nums[i + 2] && nums[i] != nums[i + 2]\n end\n\n count\nend",
"def unique(numbers)\r\n output = []\r\n \r\n numbers.each do |num|\r\n if output.include?(num)\r\n\r\n else\r\n output.push(num)\r\n end\r\n end\r\n\r\n return output\r\nend",
"def remove_duplicates(nums)\n return 0 if nums.length === 0\n\n curr_idx = 0\n j = 0\n val = nums[j]\n\n while curr_idx < nums.length\n curr_val = nums[curr_idx]\n if curr_val === val\n curr_idx += 1\n next\n else\n val = curr_val\n j += 1\n nums[j] = curr_val\n end\n end\n\n j + 1\nend",
"def find_triples(num)\n triples = []\n (1..num).each do |n|\n (2..num).each do |m|\n # Using the formula which states that for integers m,n where m > n,\n # the Pythagorean triple is 2mn, (m**2 - n**2), (m**2 + n**2)\n a = 2*m*n\n b = m**2 - n**2\n c = m**2 + n**2\n triple = [a, b, c].sort\n # passes if any element in triple exceeds the given number, or is not positive\n if triple.any? {|x| x <= 0 } or triple.any? {|x| x > num }\n next\n else\n triples.push triple\n # Takes into account non-primitive Pythagorian triples that are not generated by formula\n factor = 2\n while triple.last * factor <= num\n non_prim = triple.map { |t| factor * t }\n triples.push non_prim\n factor += 1\n end\n end\n end\n end\n triples.uniq\nend",
"def unique(integers)\n integers.to_set.to_a\nend",
"def naive(set)\n solutions = []\n indexes = (0..set.size-1).to_a\n\n Backtracker.generate do\n candidates { |a| indexes - a }\n solution? { |a| a.size == set.size }\n found_solution do |a| \n solution = a.map { |i| set[i] } \n solutions << solution unless solutions.include? solution\n end\n end\n\n return solutions\nend",
"def intersection(nums1, nums2)\n unique = {}\n res = []\n nums1.each do |num|\n if !(unique[num])\n unique[num] = true\n end\n end\n \n nums2.each do |num|\n if unique[num] && !(res.include?(num))\n res.push(num)\n end\n end\n \n res\n end",
"def amicable_numbers(n)\r\n numbers = Array.new\r\n 2.upto(n) do |x|\r\n y = d(x)\r\n if !numbers.include?(y)\r\n numbers.push(x,y) if d(y) == x && y != x\r\n end\r\n end\r\n return numbers\r\nend",
"def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend",
"def uniq_pairs(array, target)\n return 0 if array.size <= 1\n array = array.sort\n ans = 0\n count = 0\n left = 0\n right = array.size - 1\n while left < right do \n if array[left] + array[right] == target\n count += 1\n left += 1\n right -= 1\n while left < right && array[left] == array[left - 1]\n left += 1\n end\n\n while left < right && array[right] == array[right + 1]\n right -= 1\n end\n elsif array[left] + array[right] < target\n left += 1\n else\n right -= 1\n end\n end\n count\nend",
"def find_unique_elements(arr)\n freq = Hash.new #hash to count integers in using key as integer and value as count\n answer = Array.new #array to store the answer to be returned in\n\n \n arr.each {|a| #loop through every element in array \n if freq[a] != nil #check to see if hash value exists\n freq[a] = freq[a] + 1 #add 1 to the hash value\n else \n freq[a] = 1 #create the hash value\n end\n }\n\n\n freq.each {|key, value| #loop through all key and value combinations in hash\n if value == 1 #If the value is 1 it is unique so add it to the answer array to be returned\n answer << key\n end\n } \n return answer\n\nend",
"def remove_duplicates(nums)\n return 0 if nums.empty?\n cur = nums.first\n primary = 1\n nums.each_with_index do |num, _idx|\n next if num == cur\n nums[primary] = num\n cur = num\n primary += 1\n end\n primary\nend",
"def no_dupes?(arr)\n hash = Hash.new(0)\n arr.each do |ele|\n hash[ele] += 1\n end\n #can use the select method\n # hash.keys.select {|ele| hash[ele] == 1}\n new = []\n hash.each do |k, v|\n new << k if v == 1\n end\n new\n #another way to do it is sort and if there are adjacent pairs\n # we know that it is not a unique pair\nend",
"def two_sum?(array, target)\n #O(n)\n hash = Hash.new(0)\n i = 1\n array.each do |ele|\n hash[ele] = i \n i += 1\n end\n hash.each_key do |k|\n return true if hash.has_key?(target - k) && hash[k] != hash[target - k]\n end\n false \nend",
"def solution(a)\n a.uniq.count\nend",
"def two_sum(numbers, target)\n ##set hash\n hash = {}\n ##set array\n arr = []\n\n numbers.each_with_index do |val, idx|\n if hash.key?(target - val)\n arr.push(hash[target - val])\n arr.push(idx + 1)\n break\n else\n hash[val] = idx + 1\n end\n end\n\n arr\nend",
"def removNb(n)\n numbers = (1..n).to_a\n all_combinations = numbers.combination(2).to_a\n possible_pairs = []\n sum = numbers.reduce(:+)\n all_combinations.each do |pair|\n if (sum - pair.reduce(:+)) == pair.reduce(:*)\n possible_pairs << pair\n possible_pairs << pair.reverse\n end\n end\n possible_pairs\nend",
"def single_number(nums)\n (3 * nums.uniq.sum - nums.sum) / 2\nend",
"def find_unique_elements(arr)\n arr_unique = []\n arr.each do |elem1|\n var1 = 0\n arr.each do |elem2|\n if elem1 == elem2\n var1 = var1 + 1\n end\n end\n if var1 <= 1\n arr_unique.push(elem1)\n end\n end\nend",
"def unique_items(arr) #O(n)\n hash = Hash.new(0)\n results = []\n arr.each do |el|\n hash[el] += 1\n end\n hash.select { |k, v| k if v == 1 }.keys\nend",
"def permute_unique(nums, solution = [], results = [], visited_indices = {}, found = {}, start = 0)\n\n # if solution.size == nums.size && !found[solution]\n # found[solution] = 1\n # return results << solution.clone\n # end\n\n return results << solution.clone if solution.size == nums.size\n\n (0...nums.length).each do |idx|\n next if nums[idx] == nums[idx - 1] && idx != start\n\n next if visited_indices[idx]\n visited_indices[idx] = 1\n solution << nums[idx]\n\n permute_unique(nums, solution, results, visited_indices, found, idx + 1)\n\n visited_indices.delete(idx)\n solution.pop\n end\n results\nend",
"def pythagoreans (n)\n return (1..n).to_a.permutation(3).to_a.select { |a,b,c| a**2 + b**2 == c**2 }.each(&:sort!).uniq\nend",
"def equal(arr)\n size = arr.size\n hash = Hash.new{|h,k| h[k] = []}\n (0...size).each do |i|\n (i + 1...size - 1).each do |j|\n sum = arr[i] + arr[j]\n if hash.has_key?(sum)\n values = hash[sum]\n values << i\n values << j\n return values\n else\n hash[sum] = [i, j]\n end\n end\n end\nend",
"def two_sum?(arr, target_sum) # O(N)\n hash = Hash.new(0)\n count = Hash.new(0)\n\n arr.each do |num|\n hash[num] = target_sum - num\n count[num] += 1\n end\n\n hash.each do |key, value|\n if hash.has_key?(value) \n if key == value \n if count[value] > 1\n return true\n end\n else\n return true\n end\n end\n end\n\n false\nend",
"def intersection(nums1, nums2)\n present = Hash.new\n intersection_array = []\n\n nums1.each do |num|\n present[num] = 1\n end\n\n nums2.each do |num|\n if present[num]\n present.delete(num)\n intersection_array << num\n end\n end\n\n intersection_array\nend",
"def find_missing(array, n)\n i = 0\n\n (1..n).each { |number| i = i ^ number }\n array.each { |number| i = i ^ number }\n\n i\nend",
"def solution(a)\n len = a.size\n unique = {}\n i = 0\n while i < len\n item = a[i]\n if unique.has_key?(item)\n unique[item] += 1\n else\n unique[item] = 1\n end\n i += 1\n end\n pairs = 0\n unique.each do |key,count|\n (1...count).step {|n| pairs += n }\n end\n return pairs > 1_000_000_000 ? 1_000_000_000 : pairs\nend",
"def hash_two_sum?(arr, target)\n hash_of_elements = Hash.new { |h,k| h[k] = 0 }\n\n arr.each do |el|\n complement = target - el\n return true if hash_of_elements.has_key?(complement)\n hash_of_elements[el] += 1\n end\n false\nend",
"def subarray_bitwise_o_rs(a)\n result_set = Set.new()\n a.size.times do |i|\n (1..a.size-i).each do |length|\n subarray = a[i, length]\n #puts subarray.inspect\n result = subarray.reduce(0) do |bor, elem|\n bor | elem\n end\n #puts result\n result_set << result\n end\n end\n result_set.size\nend",
"def solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_000 if result >= 1_000_000_000\n end\n numbers[a[back] - 1] = false\n }\n result\nend",
"def hash_two_sum(arr,sum)\n arr_hash = Hash.new(0)\n arr.each do |el|\n arr_hash[el] += 1\n end\n\n arr.each do |el|\n return true if arr_hash[sum - el] > 0 &&\n (sum - el != el || arr_hash[sum - el] > 1)\n end\n false\nend",
"def subsets_with_dup(nums)\n result = []\n nums.sort!\n subsets_helper(nums, [], result, 0, {})\n result\nend",
"def answer(input_nums)\n [2,3].each do |set_size|\n all_combinations = input_nums.combination(set_size)\n\n target_set = all_combinations.to_a.find do |x|\n x.sum == 2020\n end\n\n puts \"Answer for set size #{set_size} is #{target_set.reduce(:*)}\"\n end\nend",
"def find_complements2(numbers, target_sum: 2020)\n numbers.combination(3).find { |x, y, z| x + y + z == target_sum }\nend",
"def intersect nums1, nums2\n result = []\n return result if nums1.size == 0 or nums2.size == 0\n\n counter_cache = {}\n counter_cache = nums1.inject({}) { |result, n|\n result[n] ||= 0\n result[n] += 1\n result\n }\n\n nums2.each do |n|\n if counter_cache[n] and counter_cache[n] > 0\n result << n\n counter_cache[n] -= 1\n end\n end\n result\nend",
"def find_unique_elements (arr)\n n = Hash.new(0)\n return_array = []\n arr.each do |element|\n n[element] += 1\n end\n n.each_pair { |k,v| \n if v == 1\n return_array << k\n end\n }\n \n return return_array\nend",
"def remove_duplicates(nums)\n prev = nil\n count = 0\n nums.each do |num|\n if num == prev\n next\n else\n nums[count] = num\n prev = num\n count+=1\n end\n end\n\n return count\nend",
"def sum_pairs(numbers, sum)\n # Numbers witch we select as checked that we have in array.\n # Selected number is the index of array. So if we want to select\n # number 4 as chekced we do it so with putting checked[4] = 1 and so on.\n checked = []\n # Iterate over each number\n numbers.each do |n|\n # check what is the difference between searching sum and current number\n temp = sum - n\n # ... and if we already checked such number (checked[temp] == 1)\n # and it is grater or equal 0 (because we are looking for sum )\n # then there is our pair of numbers ([temp, n])\n return [temp, n] if (temp >= 0) && (checked[temp] == 1)\n checked[n] = 1\n end\n nil\nend",
"def find_unique_elements(arr)\n \n#Algorithmic Process\n#Create an array that includes elements without the repeats\n#Create a hash that pairs each element of the new array with how many times it appears in the original array\n#Any key-value pair that has 1 for a value is unique and gets placed in the desired array\n \nnew_hash = {}\narr.each do |x|\n new_hash[x] = 0 if new_hash[x].nil?\n new_hash[x] = new_hash[x] + 1\nend\n\nnew_hash.delete_if {|key, value| value != 1}\nnew_hash.each_key {|key| puts key}\n\nend",
"def find_uniq_int(array)\n\tuniq_id = 0\n\n\tarray.each do |element|\n\t\tuniq_id ^= element\n\tend \n\n\treturn uniq_id\nend",
"def findPairs(set)\n 0.upto(@size-1) do |n|\n (n+1).upto(@size-1) do |m|\n if (set[n].possible.size == 2 && set[n].possible ==\nset[m].possible)\n eliminateExcept(set, [m,n], set[n].possible)\n end\n end\n end\n end",
"def find_first_dup(num_arr)\r\n set = []\r\n num_arr.each do |value|\r\n return value if set[value] #return value if it exists already in the set 'Array'\r\n set[value] = true \r\n end\r\n return -1 \r\nend",
"def pairs_given_sum num, arr\n the_hash, indices = Hash.new, []\n arr.each_with_index do |x,xi|\n complement = num - x\n lookup = the_hash[complement]\n lookup.nil? ? the_hash[x] = xi : indices << [lookup, xi]\n # puts the_hash\n end\n indices\nend",
"def hash_two_sum(array, target)\n numbers = Hash.new(0)\n array.each { |num| numbers[num] = true }\n numbers.each { |k, v| return true if numbers.has_key?(target - k)}\nend",
"def solution(a)\n return 1 if a.empty?\n a.sort!\n return 1 if a.first > 1\n return a.first + 1 if a.length <2\n (0..(a.length)).each do |index|\n return a[index] + 1 if a[index] + 1 != a[index + 1]\n end\n return a.last + 1\nend",
"def hash_map_two_sum?(arr, target_sum)\n hash = Hash.new(0)\n arr.each do |num|\n hash[num] += 1\n end\n arr.each do |num|\n target = target_sum - num\n hash[num] -= 1\n return true if hash[target] > 0\n hash[num] += 1\n end\n false\nend",
"def find_amicables(n)\n pairs = []\n sum = 0\n for i in 0..n do \n next if pairs.include? i\n d = sum_proper_divisors(i)\n next if d == i\n p = sum_proper_divisors(d)\n if p == i \n pairs << d\n pairs << i\n sum += d + i\n end\n end\n return sum\nend",
"def two_sum(nums, target)\n map = {}\n len = nums.length\n len.times do |i|\n complement = target - nums[i]\n if map.include? complement\n return [i, map[complement]]\n end\n map[nums[i]] = i\n end\n raise \"No solution !\"\nend",
"def unique_number(arr)\n existing_numbers = []\n not_unique = []\n arr.each do |entry|\n if existing_numbers[entry] === nil\n existing_numbers[entry] = true\n else\n not_unique[entry] = true\n end\n end\n arr.each do |entry|\n if not_unique[entry] == nil\n return entry\n end\n end\nend",
"def hash_two_sum(arr, target)\n h = Hash.new { |h, k| h[k] = [] }\n arr.each_with_index do |num, i|\n return true unless h[target - num].empty?\n h[num] << i\n end\n\n false\nend",
"def complement_1(array, sum)\n complements = []\n array.each do |operand|\n complement = sum - operand\n complements.push [operand, complement] if array.include? complement\n end\n complements\nend",
"def single_number(nums)\n if nums.empty?\n return 0\n end\n\n num = nums[0]\n\n for i in 1..nums.length-1\n num = num^nums[i]\n end\n\n return num\nend",
"def unique(integers)\n integers.reduce([]) do |collection,integer|\n !(collection.include? integer) ? collection.push(integer) : collection\n end\nend",
"def xor_missing_element array1, array2\n return nil if array1.length == 0 && array2.length == 0\n result = 0\n (array1 + array2).each do |number|\n result ^= number\n end\n return result\nend",
"def two_sum(array, target)\n\n !!array.uniq.combination(2).detect { |a, b| a + b == target }\nend",
"def unique_number(arr)\n arr.uniq.find { |e| arr.count(e) == 1 }\nend",
"def find_unique_elements(arr)\n collect = Hash.new 0\n \n arr.each do |elt|\n collect[elt] += 1\n end\n\n unique_hash = Hash(collect.select {|k,v| v == 1})\n \n unique_hash.keys\nend",
"def CheckUniqDigits(n)\n\n h1 = Hash.new\n\n arr = n.digits\n\n for onedig in arr\n\n h1.key?(onedig) ? (return 0) : (h1[onedig] = 1)\n\n end\n\n return 1\n\nend",
"def better_solution_to_multiples\n set.to_a.combination(2) do |number, number1|\n remainder = TOTAL - number - number1\n\n if set.include?(remainder)\n puts remainder * number * number1\n break\n end\n end\n end"
] |
[
"0.75167465",
"0.692845",
"0.6776778",
"0.67381006",
"0.67377204",
"0.67156535",
"0.6705688",
"0.6654707",
"0.6635193",
"0.65842426",
"0.6580074",
"0.6577946",
"0.6534031",
"0.6515348",
"0.648503",
"0.64838165",
"0.64497906",
"0.64448565",
"0.6423581",
"0.64231586",
"0.6422607",
"0.64224577",
"0.64076537",
"0.6366571",
"0.63644594",
"0.6349987",
"0.6335158",
"0.63241065",
"0.63198245",
"0.6318074",
"0.6313398",
"0.6297965",
"0.62516284",
"0.62514347",
"0.62164944",
"0.62063694",
"0.6194265",
"0.6187735",
"0.6186467",
"0.61839247",
"0.61676806",
"0.6163684",
"0.61628425",
"0.61610174",
"0.61575335",
"0.6144605",
"0.61189544",
"0.61184716",
"0.6114549",
"0.60987246",
"0.60959333",
"0.609532",
"0.60861295",
"0.60825294",
"0.6074902",
"0.6068086",
"0.606511",
"0.6051196",
"0.6048155",
"0.6038974",
"0.6027472",
"0.60217977",
"0.60161775",
"0.6003284",
"0.59981704",
"0.59929514",
"0.59921646",
"0.5987302",
"0.59864384",
"0.59832424",
"0.5982262",
"0.59803396",
"0.59797055",
"0.5975039",
"0.5973598",
"0.59703255",
"0.5963147",
"0.596213",
"0.59591293",
"0.5955347",
"0.5953006",
"0.59492236",
"0.5945346",
"0.59389937",
"0.5933223",
"0.5930375",
"0.592385",
"0.5919241",
"0.59153396",
"0.59142876",
"0.5913642",
"0.5910869",
"0.59108627",
"0.5902776",
"0.5902344",
"0.5901237",
"0.58980674",
"0.5895091",
"0.58933043",
"0.5893011"
] |
0.6234756
|
34
|
Initialize a new `Metadata` object
|
def initialize(name: nil, istreams: [], ostreams: [])
self.name = name
self.istreams = istreams
self.ostreams = ostreams
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize(metadata)\n @metadata = metadata\n end",
"def initialize()\n @metadata = Hash.new()\n return self\n end",
"def initialize(metadata = YAMLMetadata.new)\n @metadata = metadata\n end",
"def initialize(metadata, fields = {})\n @metadata = JSON.parse(metadata).merge(fields)\n end",
"def metadata\n @metadata ||= Metadata.new(self)\n end",
"def initialize(metadata = {}, text = nil)\n @metadata = metadata\n @text = text\n end",
"def metadata\n Metadata.new(self)\n end",
"def initialize(definition)\n process_metadata(definition)\n end",
"def initialize(metadata, instance)\n @metadata, @instance = metadata, instance\n end",
"def initialize metadata = nil, files = nil\n @metadata = metadata || Metadata.new\n @files = files || []\n end",
"def metadata=(_); end",
"def initialize dependencies = nil, framework_assemblies = nil\n @set_fields = Set.new\n @dependencies = dependencies || Hash.new\n @framework_assemblies = framework_assemblies || Hash.new\n @has_group = false\n\n debug \"creating new metadata with dependencies: #{dependencies} [nuget model: metadata]\" unless dependencies.nil?\n debug \"creating new metadata (same as prev) with fw asms: #{framework_assemblies} [nuget model: metadata]\" unless framework_assemblies.nil?\n end",
"def initialize(metadata_file)\n eval(IO.read(metadata_file), nil, metadata_file)\n end",
"def metadata\n @metadata ||= Mash.new\n end",
"def initialize(context)\n @context = context\n @name = metadata[:name]\n @points = metadata[:points]\n @icon = metadata[:icon]\n end",
"def metadata=(_arg0); end",
"def initialize(client, address, other_metadata = {})\n super(client, address)\n @written_md_vars = {}\n @metadata_loaded = false\n @metadata = {}\n \n key_lookup = self.class.md_key_map\n type_lookup = self.class.md_type_coercion_map\n other_metadata.each do |key, value|\n insert_metadata key, value, key_lookup, type_lookup\n end\n end",
"def initialize\n @meta_tags = ActiveSupport::HashWithIndifferentAccess.new\n end",
"def metadata\n @metadata ||= {}\n end",
"def initialize(metadata)\n @metadata = JSON.parse(metadata)\n @geometry = @metadata['extent']['coordinates']\n end",
"def metadata\n @metadata ||= lambda { read_metadata }.call\n end",
"def metadata\n @metadata ||= lambda { read_metadata }.call\n end",
"def initialize(metadata={})\n @table = {}\n\n case metadata\n when Hash\n update(metadata)\n else\n @table[:location] = metadata.to_s\n load_metadata\n end\n end",
"def metadata\n @metadata ||= {}\n end",
"def initialize(project, name, is_ref=true, metadata={})\n raise \"Invalid name '#{name}', please use only alphanumerics and \" +\n \"underscores.\" unless name.miga_name?\n @project = project\n @name = name\n metadata[:ref] = is_ref\n @metadata = MiGA::Metadata.new(\n File.expand_path(\"metadata/#{name}.json\", project.path), metadata )\n end",
"def initialize(parser)\n document = parser.metadata_document\n return if document.nil?\n document.remove_namespaces!\n metadata = document.css('metadata')\n self.version = document.css('package')[0]['version']\n self.titles = metadata.xpath('.//title').map(&:content)\n self.creators = metadata.xpath('.//creator').map {|c| EPUBInfo::Models::Person.new(c) }\n self.subjects = metadata.xpath('.//subject').map(&:content)\n self.description = metadata.xpath('.//description').first.content rescue nil\n self.publisher = metadata.xpath('.//publisher').first.content rescue nil\n self.contributors = metadata.xpath('.//contributor').map {|c| EPUBInfo::Models::Person.new(c) }\n self.dates = metadata.xpath('.//date').map { |d| EPUBInfo::Models::Date.new(d) }\n modified_date = metadata.xpath(\".//meta[@property='dcterms:modified']\").map do |d|\n date = EPUBInfo::Models::Date.new(d)\n date.event = 'modification'\n date\n end\n self.dates += modified_date;\n self.identifiers = metadata.xpath('.//identifier').map { |i| EPUBInfo::Models::Identifier.new(i) }\n self.source = metadata.xpath('.//source').first.content rescue nil\n self.languages = metadata.xpath('.//language').map(&:content)\n self.rights = metadata.xpath('.//rights').first.content rescue nil\n self.drm_protected = parser.drm_protected?\n self.cover = EPUBInfo::Models::Cover.new(parser)\n end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def initialize(name, metadata = {})\n super\n @files = {}\n end",
"def metadata=(value)\n @metadata = value\n end",
"def metadata=(value)\n @metadata = value\n end",
"def metadata=(metadata)\n @metadata = metadata\n end",
"def metadata=(metadata)\n @metadata = metadata\n end",
"def metadata=(metadata)\n @metadata = metadata\n end",
"def metadata=(metadata)\n @metadata = metadata\n end",
"def metadata\n self[:metadata] || {}\n end",
"def with_metadata(metadata)\n self.class.new(world, radius: radius, center: center, metadata: metadata)\n end",
"def metadata\n hash.inject([]){ |list, data| list << MetaData.new(data[0], data[1][0]) }\n end",
"def initialize(base, target, metadata)\n @base, @target, @metadata = base, target, metadata\n end",
"def initialize(metadata, options = {})\n $log.info 'Initializing DummyDownloader'\n raise ArgumentError, 'Metadata must be present.' unless metadata.is_a?(Metadata::Metadata)\n @runtime_cache = metadata.load_cache('previous_runtimes')\n\n super(metadata, options)\n end",
"def initialize(options={})\n @options = options\n add_metadata\n add_labels\n\n options.delete('metadata')\n options.delete('labels')\n super(options)\n end",
"def metadata\n attributes['metadata'] ||= {}\n attributes['metadata']\n end",
"def metadata(rft_id)\n Djatoka::Metadata.new(self, rft_id)\n end",
"def metadata\n # TODO Move into {NRSER::Props::Metadata}?\n # \n unless NRSER::Props::Metadata.has_metadata? self\n instance_variable_set \\\n NRSER::Props::Metadata::VARIABLE_NAME,\n NRSER::Props::Metadata.new( self )\n end\n \n NRSER::Props::Metadata.metadata_for self\n end",
"def metadata\n @metadata ||= Metaforce::Metadata::Client.new(@options)\n end",
"def initialize(document, metadata)\n @document, @metadata = document, metadata\n @relation = document.send(metadata.name)\n end",
"def initialize(key, data={})\n \n @path = model.build_path(key)\n @metadata = {}\n \n # Store the properties defined in the model in the metadata\n properties.each do |property_name, property|\n @metadata.store(property.name, '')\n end\n \n # Assign the values\n self.attributes=(data)\n \n end",
"def initialize\n @metadata = {}\n @comment = ''\n @parent = nil\n @parent_name = nil # for loading\n @parent_class = nil # for loading\n @section = nil\n @section_title = nil # for loading\n @file = nil\n @full_name = nil\n @store = nil\n @track_visibility = true\n\n initialize_visibility\n end",
"def initialize(request, config, metadata)\n @sp_metadata = (eval \"Rack::Saml::#{config['assertion_handler'].to_s.capitalize}Metadata\").new(request, config, metadata)\n end",
"def update_initial_metadata(metadata)\n end",
"def initialize(iType, iContent, iMetadata, iTags)\n @Type = iType\n @Content = iContent\n @Metadata = iMetadata\n @Tags = iTags\n end",
"def make_emma_record(data, **)\n Search::Record::MetadataRecord.new(data)\n end",
"def initialize metadata, steps\n @metadata = metadata\n @steps = steps\n @ingredients = self.ingredients\n end",
"def set_metadata(*args)\n self.metadata.set(*args)\n end",
"def initialize( *args )\n super\n @meta_end = end_of_meta_data\n end",
"def metadata\n parse_tarball_metadata do |parsing_errors, metadata|\n if parsing_errors.any?\n Metadata.new\n else\n metadata\n end\n end\n end",
"def with_metadata &block\n yield @metadata if block_given?\n self\n end",
"def initialize(hash={})\n \t@id = hash[:_id].to_s if !hash[:_id].nil?\n \tif !hash[:metadata].nil?\n \t\t@location = Point.new(hash[:metadata][:location]) if !hash[:metadata][:location].nil?\n \t\t@place = hash[:metadata][:place]\n \tend\n end",
"def initialize_copy(other)\n super(other)\n @metadata = other.metadata\n end",
"def metadata\n self.class.metadata[__name__] || {}\n end",
"def generate_metadata\n data = Hash.new\n data['id'] = self.id\n data['title'] = self.title\n data['author'] = self.author\n data['updated_at'] = self.updated_at\n return data\n end",
"def initialize(canon, file_loc, title, composer, bpm)\n @canon = canon\n @time_sig = canon.get_metadata.get_time_signature\n @key_sig_note = canon.get_metadata.get_key_note\n @key_sig_type = canon.get_metadata.get_key_type\n @num_voices = canon.get_metadata.get_number_of_voices\n @file_loc = file_loc\n @title = title\n @composer = composer\n @bpm = bpm\n @notes = []\n @canon_internal_rep = canon.get_canon_as_array\n return self\n end",
"def metadata\n return unless self[:metadata]\n\n self[:metadata].deep_symbolize_keys\n end",
"def initialize\n super()\n init_data()\n end",
"def initialize(params=nil)\n @id = params[:_id].to_s if !params.nil? && !params[:_id].nil?\n @location = Point.new(params[:metadata][:location]) if !params.nil? && !params[:metadata].nil?\n @place = params[:metadata][:place] if !params.nil? && !params[:metadata].nil?\n end",
"def metadata\n @metadata.tap do |h|\n # This represents the minimal set of attribute methods that should be available in every subclass.\n h[:mime_type] = mime_type if mime_type\n h[:filename] = filename if filename\n h[:digest] = digest if digest\n h[:size] = size if size\n h[:last_modified] = last_modified if last_modified\n end\n end",
"def initialize(document, drm_protected = false)\n return if document.nil?\n metadata = document.css('metadata')\n self.titles = metadata.xpath('.//dc:title', EPUBInfo::Utils::DC_NAMESPACE).map(&:content)\n self.creators = metadata.xpath('.//dc:creator', EPUBInfo::Utils::DC_NAMESPACE).map {|c| EPUBInfo::Models::Person.new(c) }\n self.subjects = metadata.xpath('.//dc:subject', EPUBInfo::Utils::DC_NAMESPACE).map(&:content)\n self.description = metadata.xpath('.//dc:description', EPUBInfo::Utils::DC_NAMESPACE).first.content rescue nil\n self.publisher = metadata.xpath('.//dc:publisher', EPUBInfo::Utils::DC_NAMESPACE).first.content rescue nil\n self.contributors = metadata.xpath('.//dc:contributor', EPUBInfo::Utils::DC_NAMESPACE).map {|c| EPUBInfo::Models::Person.new(c) }\n self.dates = metadata.xpath('.//dc:date', EPUBInfo::Utils::DC_NAMESPACE).map { |d| EPUBInfo::Models::Date.new(d) }\n self.identifiers = metadata.xpath('.//dc:identifier', EPUBInfo::Utils::DC_NAMESPACE).map { |i| EPUBInfo::Models::Identifier.new(i) }\n self.source = metadata.xpath('.//dc:source', EPUBInfo::Utils::DC_NAMESPACE).first.content rescue nil\n self.languages = metadata.xpath('.//dc:language', EPUBInfo::Utils::DC_NAMESPACE).map(&:content)\n self.rights = metadata.xpath('.//dc:rights', EPUBInfo::Utils::DC_NAMESPACE).first.content rescue nil\n self.drm_protected = drm_protected\n end",
"def init\n # Guard against doing this more than once.\n unless @config.nil?\n return\n end\n\n if Config.config_files.nil?\n raise \"No configuration file provided, set LapisLazuli::WorldModule::Config.config_files\"\n end\n\n load_config(Config.config_files)\n # In case there was no config file found an empty @config needs to be set to prevent infinite looping.\n if @config.nil?\n warn 'Unable to find a configuration file, defaulting to empty config.yml.'\n @config = {}\n end\n\n @metadata = Runtime.instance.set_if(self, :metadata) do\n log.debug \"Creating metadata storage\"\n Storage.new(\"metadata\")\n end\n end",
"def metadata\n @metadata.clone.freeze\n end",
"def metadata\n return @metadata if defined? @metadata\n\n @metadata = Henkei.read :metadata, data\n end",
"def metadata\n return @metadata if defined? @metadata\n\n @metadata = Henkei.read :metadata, data\n end",
"def metadata_file; end",
"def metadata_file; end",
"def metadata\n @meta_data\n end",
"def initialize\n @annotation_schema = nil\n @schema_version = nil\n @sources = []\n @dictionaries = []\n\n @source_index = {}\n @div_index = {}\n @sentence_index = {}\n @token_index = {}\n end",
"def metadata\n self.class.metadata\n end",
"def initialize\n initialize!\n end",
"def initialize\n initialize!\n end",
"def metadata(*args)\n opts = args.extract_options!\n args.each do |name|\n self.add_metadata(name, opts)\n end\n end",
"def construct(loader: nil)\n loader ||= MeasureDefinitionLoader.new(data_path: self.class.data_path)\n @loader = loader\n @measure_definitions_lookup = HashWithIndifferentAccess.new\n end",
"def initialize(filename, start_date, duration=Float::MAX, offset=0.0)\n data = RubyUtils::FileReader.new(filename, \" \").data\n # create meta data from first entry\n meta_data = MetaData.new(data[0], start_date)\n data.delete_at(0)\n @data_repository = RubyUtils::DataRepository.new(meta_data)\n fill_repository(data, duration, offset, start_date)\n end",
"def initialize(attrs={})\n load_attributes!(attrs)\n end",
"def initialize()\n end",
"def initialize(name, provider, version, directory, **opts)\n @name = name\n @version = version\n @provider = provider\n @directory = directory\n @metadata_url = opts[:metadata_url]\n\n metadata_file = directory.join(\"metadata.json\")\n raise Errors::BoxMetadataFileNotFound, name: @name if !metadata_file.file?\n\n begin\n @metadata = JSON.parse(directory.join(\"metadata.json\").read)\n rescue JSON::ParserError\n raise Errors::BoxMetadataCorrupted, name: @name\n end\n\n @logger = Log4r::Logger.new(\"vagrant::box\")\n end",
"def initialize(meta_tags)\n @meta_tags = meta_tags\n @normalized_meta_tags = {}\n end",
"def initialize(meta_tags)\n @meta_tags = meta_tags\n @normalized_meta_tags = {}\n end",
"def initialize(attrs={})\n from_hash(attrs)\n end",
"def initialize\n @ptr = EXIF.exif_loader_new\n end",
"def rdf_metadata\n @rdf_metadata ||= RDFMetadata.new(orm_object.metadata).result\n end",
"def initialize(attributes = {})\n @attributes = attributes\n @content_type = attributes[:content_type]\n @filename = attributes[:filename]\n @id = attributes[:id]\n @load_path = attributes[:load_path]\n @logical_path = attributes[:logical_path]\n @metadata = attributes[:metadata]\n @name = attributes[:name]\n @source = attributes[:source]\n @uri = attributes[:uri]\n end",
"def initialize\n end",
"def load_metadata\n begin\n load RAILS_ROOT + '/app/metadata/' + self.name.to_s.underscore + '.rb'\n rescue MissingSourceFile\n end\n end",
"def metadata\n @metadata\n end",
"def initialize()\n #@ch = Concept.init_concept_hash()\n #Indexer.initialize_dict()\n #@ch = Indexer.init_concept_hash\n end",
"def initialize() end",
"def metadata\n {\n title: flickr_title,\n description: description\n }\n end"
] |
[
"0.8099518",
"0.7998378",
"0.78235877",
"0.73209095",
"0.71387964",
"0.70273036",
"0.7008813",
"0.7001572",
"0.69312155",
"0.6864706",
"0.6780098",
"0.6764959",
"0.67156583",
"0.6656389",
"0.6653615",
"0.66287243",
"0.66151905",
"0.6614583",
"0.6594828",
"0.6551262",
"0.6469914",
"0.6469914",
"0.64695835",
"0.64444935",
"0.63952816",
"0.6391529",
"0.6372649",
"0.6372649",
"0.6372649",
"0.6372649",
"0.6372649",
"0.6372649",
"0.6372649",
"0.63658935",
"0.63632023",
"0.63632023",
"0.6341137",
"0.6341137",
"0.6341137",
"0.6341137",
"0.6311872",
"0.63052446",
"0.62776417",
"0.6263208",
"0.62430143",
"0.6207899",
"0.61938214",
"0.6188068",
"0.6183099",
"0.61743194",
"0.612698",
"0.60971546",
"0.60857713",
"0.60774535",
"0.6063056",
"0.6023846",
"0.59969515",
"0.5968251",
"0.5955491",
"0.595378",
"0.59518456",
"0.59463394",
"0.5938836",
"0.5936822",
"0.59312373",
"0.58998877",
"0.5891976",
"0.58840734",
"0.5879009",
"0.58577126",
"0.58499986",
"0.5842574",
"0.58313894",
"0.58188576",
"0.581729",
"0.581729",
"0.5799976",
"0.5799976",
"0.5799838",
"0.57485366",
"0.57463974",
"0.57462454",
"0.57462454",
"0.5740423",
"0.5729249",
"0.5714863",
"0.57115567",
"0.5710422",
"0.57087064",
"0.5707802",
"0.5707802",
"0.5706216",
"0.57013506",
"0.5696985",
"0.5694298",
"0.5690615",
"0.5684923",
"0.5684569",
"0.5680906",
"0.5679453",
"0.5675421"
] |
0.0
|
-1
|
Initialize a new `ComputationContext`
|
def initialize(computation)
self.computation = computation
self.transaction = ::Concord::Thrift::ComputationTx.new
self.transaction.records = []
self.transaction.timers = {}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize\n self.context = Context.new\n end",
"def execution_context\n initialize_context!(Object.new)\n end",
"def context\n @_context ||= begin\n ptr = MemoryPointer::new( Context )\n error = OpenCL.clGetProgramInfo(self, CONTEXT, Context.size, ptr, nil)\n error_check(error)\n Context::new( ptr.read_pointer )\n end\n end",
"def context\n @_context ||= begin\n ptr = MemoryPointer::new( Context )\n error = OpenCL.clGetKernelInfo(self, CONTEXT, Context.size, ptr, nil)\n error_check(error)\n Context::new( ptr.read_pointer )\n end\n end",
"def initialize(context, *args)\n @context = context\n @result = nil\n builder_setup(*args)\n end",
"def init\n ctx = ComputationContext.new(self)\n log_failure do\n handler.init(ctx)\n end\n ctx.transaction\n end",
"def build_context(operation, dependencies)\n RailsWorkflow::Context.new(\n parent: operation,\n data: prepare_context_data(dependencies) || operation.process.data\n )\n end",
"def initialize(env)\n @env = env\n @params = _compute_params\n freeze\n end",
"def initialize(context)\n @context = context\n end",
"def initialize(context)\n @context = context\n end",
"def initialize(context)\n @context = context\n end",
"def initialize(context)\r\n @context = context\r\n end",
"def initialize(context)\n @context = context\n end",
"def initialize(context_hash, extra_inputs={})\n raise \"Nil context hash\" unless context_hash\n raise \"Need a hash\" unless context_hash.kind_of?(Hash)\n [ \"[]\", \"keys\" ].each do |mname|\n unless extra_inputs.respond_to?(mname)\n raise \"Extra inputs must respond to hash-like [] operator and methods #keys and #each\"\n end\n end\n\n # store extra inputs\n if extra_inputs.kind_of?(Hash)\n @extra_inputs= {}\n extra_inputs.each { |k,v| @extra_inputs[k.to_s] = v } # smooth out the names\n else\n @extra_inputs = extra_inputs\n end\n\n collect_object_and_subcontext_defs context_hash\n\n # init the cache\n @cache = {}\n @cache['this_context'] = self\n end",
"def initialize(env)\n @env = env\n super(_compute_params)\n # freeze\n end",
"def initialize(ctx)\n @ctx = ctx\n end",
"def initialize(ctx)\n @ctx = ctx\n end",
"def context\n @_context ||= begin\n ptr = MemoryPointer::new( Context )\n error = OpenCL.clGetSamplerInfo(self, CONTEXT, Context.size, ptr, nil)\n error_check(error)\n Context::new( ptr.read_pointer )\n end\n end",
"def initialize(context, &run_block)\n @__context = context\n # Ruby cannot marshal procs or lambdas, so we need to define a method.\n # Binding to self allows us to intercept logging calls.\n define_singleton_method(:call, run_block.bind(self))\n end",
"def initialize(context)\n @context = context\n components\n end",
"def context\n ptr = FFI::MemoryPointer::new( Context )\n error = OpenCL.clGetKernelInfo(self, CONTEXT, Context.size, ptr, nil)\n error_check(error)\n return Context::new( ptr.read_pointer )\n end",
"def initialize(context = nil)\n @context = context\n super\n end",
"def initialize(ctx)\n @ctx = ctx\n end",
"def context\n init\n @context\n end",
"def initialize(context)\n super()\n self.context = context\n end",
"def initialize(ptr, retain = true)\n super(ptr)\n OpenCL.clRetainContext(ptr) if retain\n #STDERR.puts \"Allocating Context: #{ptr}\"\n end",
"def initial_context(ctx)\n InitialContext.new(self.properties(ctx))\n end",
"def create_execution_context()\n app_ctx = self.application_context\n app_ctx ||= VAPI::Core.create_default_application_context()\n sec_ctx = self.security_context\n sec_ctx ||= VAPI::Core::SecurityContext.new\n return VAPI::Core::ExecutionContext.new(app_ctx, sec_ctx)\n end",
"def initialize(opts = {})\r\n @context = opts[:context] || 3\r\n end",
"def context\n @_context ||= {\n :argv => START_CTX[:argv].map { |arg| arg.dup },\n :cwd => START_CTX[:cwd].dup,\n 0 => START_CTX[0].dup,\n }.tap do |ctx|\n rewrite_context(ctx)\n end\n end",
"def initialize(ctx)\r\n @verbose = false\r\n @context = ctx\r\n end",
"def initialize(builder:, context:)\n @cache = {}\n @builder = builder\n @context = context\n end",
"def initialize(*args, &block)\n super(*args)\n instance_exec(_context, &block)\n end",
"def context(worker_threads = 1)\n return @context if @context\n @context = ::ZMQ::Context.new(worker_threads)\n end",
"def context\n @context ||= new_context_mock(context_options, &finalize_proc)\n end",
"def initialize(context, timeout = DEFAULT_TIMEOUT)\n @store = {}\n @mutex = Mutex.new\n\n @timeout = timeout\n @context = context\n\n start_thread\n end",
"def initialize_ctx\n Binding.ctx_datakey_init(self)\n end",
"def initialize(context = nil, engine = nil)\n @context = context\n @engine = engine || Pigeon::Engine.default_engine\n @created_at = Time.now\n @state = nil\n\n unless (@engine)\n raise EngineRequired, \"Task creation requires an active Pigeon::Engine\"\n end\n \n after_initialized\n end",
"def initialize(context={})\n self.context = context\n self.target = context[:target]\n self.output = context[:output]\n self.eval_string = context[:eval_string]\n self.command_set = context[:command_set]\n self._pry_ = context[:pry_instance]\n end",
"def context\n unless @instance_context\n @instance_context = CompositionContext.new(@version, @params['sid'], )\n end\n @instance_context\n end",
"def context\n @context ||= Context.new(self)\n end",
"def initialize context\n @context = context\n @store = context.store\n\n @seen = {}\n end",
"def compile\n prep\n client.setup_run_context\n end",
"def main_context\n @main_context ||= Context.new\n end",
"def initialize(context, owner, file)\n# puts \"calling Compiler on #{file}\"\n @context = context\n @owner = owner\n @file = file\n utterance = ''\n File.open(file) do |f|\n f.each_line { |l| utterance << l }\n end\n # Since this is a new compiler, we need to wipe out any old compiler catalog stuff\n # Compiler.init_catalog(context)\n planner = OverlogPlanner.new(@context, utterance)\n planner.plan\n @the_program = planner.program\t\t\n\n # typeChecker = TypeChecker.new(@runtime, @the_program)\n # This is an XTC-ism\n # args = [\"-no-exit\", \"-silent\", file]\n # run(args)\n\n # if (runtime.errorCount > 0) then\n # @the_program.definitions.each { |table| Table.drop(table.name) }\n # end\n end",
"def context\n unless @instance_context\n @instance_context = CpsContext.new(@version, )\n end\n @instance_context\n end",
"def context(key = nil)\n current_context = key.nil? ? @context.local : @context.local(key)\n\n # Rebuild/reset context after a fork\n #\n # We don't want forked processes to copy and retransmit spans\n # that were generated from the parent process. Reset it such\n # that it acts like a distributed trace.\n current_context.after_fork! do\n current_context = self.context = current_context.fork_clone\n end\n\n current_context\n end",
"def context\n unless @instance_context\n @instance_context = CurrentCallContext.new(@version, )\n end\n @instance_context\n end",
"def context\n @context ||= Context.new(self)\n end",
"def initialize(initial_hash = nil)\n super\n @optional_method_names = %i[context workDoneToken]\n end",
"def initialize(context)\n @context = context\n @out = context.output_buffer\n end",
"def initialize(*contexts, **locals)\n @contexts = contexts.flatten\n\n # Local variables take precedence\n @contexts.unshift ::OpenStruct.new(**locals) if locals.any?\n end",
"def initialize(runtime_, path:)\n unless runtime_.is_a?(MiniRacer::Context)\n raise TypeError, \"Expected a MiniRacer::Context, got #{runtime_.class}\"\n end\n @runtime = runtime_\n @paths = [path].flatten.map {|pth| File.expand_path(pth) }\n setup(@runtime, @paths)\n end",
"def initialize(runtime_, path:)\n unless runtime_.is_a?(MiniRacer::Context)\n raise TypeError, \"Expected a MiniRacer::Context, got #{runtime_.class}\"\n end\n @runtime = runtime_\n @paths = [path].flatten.map {|pth| File.expand_path(pth) }\n setup(@runtime, @paths)\n end",
"def initialize(default_action = :kill, tsync: true, optimize: false)\n @context = init!(default_action)\n self.tsync = tsync\n self.optimize = optimize\n\n yield self if block_given?\n end",
"def context\n unless @instance_context\n @instance_context = TaskContext.new(@version, @params['workspace_sid'], @params['sid'], )\n end\n @instance_context\n end",
"def context\n Thread.current[:ctx] ||= {}\n Thread.current[:ctx]\n end",
"def initialize\n super\n @actions = [].freeze\n @prepared = false\n @context = Context.new(stack: self)\n @hooks = Hooks.new(stack: self)\n @started = false\n @parallel = false\n end",
"def local(thread = Thread.current)\n thread[@key] ||= Datadog::Context.new\n end",
"def at(*args, &block)\n\tRPoint::Contexts::ContextFactory.create_context(*args, &block)\nend",
"def initialize(context, offset = T.unsafe(nil), decrypter = T.unsafe(nil)); end",
"def default_context\n @@default_context = Graph.new(:identifier => @store.identifier, :store => @store)\n end",
"def reset_ctx(ctx)\n ctx = Array(ctx || MXNet::Context.current)\n if @_data\n data = _reduce()\n Autograd.pause do\n _init_impl(data, ctx)\n end\n elsif @_deferred_init\n @_deferred_init[1] = ctx\n else\n raise ArgumentError,\n \"Cannot reset context for Parameter '#{@name}' because it \" +\n \"has not been initialized.\"\n end\n end",
"def initialize_context(**opt)\n ctx = opt.delete(:context)&.merge(opt) || opt\n ctx[:controller] &&= ctx[:controller].to_sym\n ctx[:action] &&= ctx[:action].to_sym\n ctx\n end",
"def initialize(initial_hash = nil)\n super\n @optional_method_names = %i[context workDoneToken partialResultToken]\n end",
"def initialize(*args)\n old_initialize(*args)\n @ssl_context = OpenSSL::SSL::SSLContext.new\n @ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end",
"def initialize(input)\n @machine = self.class.machine\n @context =\n case (input)\n when Mua::State::Context\n input\n else\n self.class.context.new(\n input: input,\n state: @machine.initial_state\n )\n end\n\n yield(self) if (block_given?)\n end",
"def initialize(context, exp)\n @context = context\n @exp = exp\n\n @num_statements = 0\n @refs = AST::ObjectRefs.new\n end",
"def initialize(local, global, env)\n @local, @global, @env = local, global, env\n end",
"def initialize(name, context)\n @name = name\n @context = context\n end",
"def initialize(name, context)\n @name = name\n @context = context\n end",
"def initialize\n initialize_without_gc\n @gc_every_n_examples = 0\n end",
"def initialize (service_name, application_context)\n\n super()\n\n service_init service_name, application_context\n\n @paused_instances = {}\n\n @observers = {}\n\n @stopped = false\n\n engine_environment_id\n # makes sure it's called now\n end",
"def initialize\n # These require statements are intentionally placed here to initialize\n # the gRPC module only when it's required.\n # See https://github.com/googleapis/toolkit/issues/446\n require \"gapic/grpc\"\n require \"google/identity/accesscontextmanager/v1/access_context_manager_services_pb\"\n\n # Create the configuration object\n @config = Configuration.new Client.configure\n\n # Yield the configuration if needed\n yield @config if block_given?\n\n # Create credentials\n credentials = @config.credentials\n # Use self-signed JWT if the endpoint is unchanged from default,\n # but only if the default endpoint does not have a region prefix.\n enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&\n [email protected](\".\").first.include?(\"-\")\n credentials ||= Credentials.default scope: @config.scope,\n enable_self_signed_jwt: enable_self_signed_jwt\n if credentials.is_a?(::String) || credentials.is_a?(::Hash)\n credentials = Credentials.new credentials, scope: @config.scope\n end\n @quota_project_id = @config.quota_project\n @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id\n\n @operations_client = Operations.new do |config|\n config.credentials = credentials\n config.quota_project = @quota_project_id\n config.endpoint = @config.endpoint\n end\n\n @access_context_manager_stub = ::Gapic::ServiceStub.new(\n ::Google::Identity::AccessContextManager::V1::AccessContextManager::Stub,\n credentials: credentials,\n endpoint: @config.endpoint,\n channel_args: @config.channel_args,\n interceptors: @config.interceptors\n )\n end",
"def initialize(user, context)\n return unless context.respond_to?(:state_name)\n debug \"Initialize engine ...\"\n start_time = Time.now\n @user = user\n @context = context\n @conditions = parse_conditions\n @rule_set = RuleSet.new(@user, @context, @conditions)\n @rule_set.parse_dsl\n @rules = @rule_set.rules\n debug \"Done in #{ Time.now - start_time } s.\"\n @total_evaluation_time = 0\n end",
"def initialize\n # These require statements are intentionally placed here to initialize\n # the gRPC module only when it's required.\n # See https://github.com/googleapis/toolkit/issues/446\n require \"gapic/grpc\"\n require \"google/cloud/dataproc/v1beta2/jobs_services_pb\"\n\n # Create the configuration object\n @config = Configuration.new Client.configure\n\n # Yield the configuration if needed\n yield @config if block_given?\n\n # Create credentials\n credentials = @config.credentials\n # Use self-signed JWT if the endpoint is unchanged from default,\n # but only if the default endpoint does not have a region prefix.\n enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&\n [email protected](\".\").first.include?(\"-\")\n credentials ||= Credentials.default scope: @config.scope,\n enable_self_signed_jwt: enable_self_signed_jwt\n if credentials.is_a?(::String) || credentials.is_a?(::Hash)\n credentials = Credentials.new credentials, scope: @config.scope\n end\n @quota_project_id = @config.quota_project\n @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id\n\n @operations_client = Operations.new do |config|\n config.credentials = credentials\n config.endpoint = @config.endpoint\n end\n\n @job_controller_stub = ::Gapic::ServiceStub.new(\n ::Google::Cloud::Dataproc::V1beta2::JobController::Stub,\n credentials: credentials,\n endpoint: @config.endpoint,\n channel_args: @config.channel_args,\n interceptors: @config.interceptors\n )\n end",
"def thread_context\n Thread.current[:runshell_context] ||= Context.new(main_context.to_h)\n end",
"def context\n Thread.current[NAME] ||= Hash.new\n end",
"def set_context=(value)\n $log.debug(\"Setting context to #{value}\")\n @ssl_context ||= OpenSSL::SSL::SSLContext.new #Create a new context\n @ssl_context &&= OpenSSL::SSL::SSLContext.new(value)\n end",
"def converge_start(run_context)\n @run_context = run_context\n end",
"def initialize (service_name, application_context)\n\n super()\n service_init(service_name, application_context)\n\n @dm_repository =\n application_context[:expstorage_dm_repository] || :default\n\n DataMapper.repository(@dm_repository) {\n DmExpression.auto_upgrade!\n }\n\n observe_expool\n end",
"def initialize(ctx)\n @ctx = ctx\n @crashes = 0\n end",
"def initialize(*args)\n @options = args.extract_options!\n @passes = @failures = @errors = 0\n @current_context = \"\"\n end",
"def initialize(context = Context.new, options = {})\n if context.kind_of?(Hash) and options.empty?\n options, context = context, (context[:context] || context['context'])\n end\n options = Utility.symbolize_keys(options)\n self.context = context ? context.dup : Context.new\n self.tag_prefix = options[:tag_prefix] || 'radius'\n self.scanner = options[:scanner] || default_scanner\n end",
"def initialize\n # These require statements are intentionally placed here to initialize\n # the gRPC module only when it's required.\n # See https://github.com/googleapis/toolkit/issues/446\n require \"gapic/grpc\"\n require \"google/ads/google_ads/v3/services/mutate_job_service_services_pb\"\n\n # Create the configuration object\n @config = Configuration.new Client.configure\n\n # Yield the configuration if needed\n yield @config if block_given?\n\n # Create credentials\n credentials = @config.credentials\n credentials ||= Credentials.default scope: @config.scope\n if credentials.is_a?(String) || credentials.is_a?(Hash)\n credentials = Credentials.new credentials, scope: @config.scope\n end\n @quota_project_id = @config.quota_project\n @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id\n\n @operations_client = Operations.new do |config|\n config.credentials = credentials\n config.endpoint = @config.endpoint\n end\n\n @mutate_job_service_stub = ::Gapic::ServiceStub.new(\n ::Google::Ads::GoogleAds::V3::Services::MutateJobService::Stub,\n credentials: credentials,\n endpoint: @config.endpoint,\n channel_args: @config.channel_args,\n interceptors: @config.interceptors\n )\n end",
"def initialize(controller_context:)\n @cc = controller_context\n end",
"def initialize(context, next_middleware = nil, config = {})\n @_context = context\n @next_middleware = next_middleware\n @config = config\n end",
"def context\n unless @instance_context\n @instance_context = WorkersRealTimeStatisticsContext.new(@version , @params['workspace_sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = CompositionHookContext.new(@version, @params['sid'], )\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = TaskContext.new(@version , @params['workspace_sid'], @params['sid'])\n end\n @instance_context\n end",
"def testContextCreation\n _context = Context.new #Fresh instance \n assert_instance_of(Context, _context, \"Fresh instances should be Contexts indeed\" )\n assert_instance_of(FalseClass || TrueClass, _context.isActive, \"The context should be either active (true) or inactive (false)\")\n assert(!_context.isActive, \"A fresh context should be initially inactive\")\n end",
"def initialize(context, scope, options={})\n @context, @scope, @options = context, scope, options\n\n @restrictions = @scope.restrictions(context)\n @options[:eager_loaded] ||= {}\n end",
"def build_context(context: Context.current)\n builder = Builder.new(correlations_for(context).dup)\n yield builder\n context.set_value(CORRELATION_CONTEXT_KEY, builder.entries)\n end",
"def context\n @context ||= {}\n end",
"def context\n @context ||= {}\n end",
"def initialize(expression, scope, memoized = true)\n @expression = expression\n @scope = scope\n @memoized = !!memoized\n end",
"def get_or_create_context\n if !block_given?\n return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:getOrCreateContext, []).call(),::Vertx::Context)\n end\n raise ArgumentError, \"Invalid arguments when calling get_or_create_context()\"\n end",
"def initialize\n @referent = ContextObjectEntity.new\n @referrer = ContextObjectEntity.new\n @referringEntity = ContextObjectEntity.new\n @requestor = ContextObjectEntity.new\n @serviceType = []\n @resolver = []\n @foreign_keys = {}\n @openurl_ver = \"Z39.88-2004\"\n @admin = {\"ctx_ver\" => {\"label\" => \"version\", \"value\" => @openurl_ver}, \"ctx_tim\" => {\"label\" => \"timestamp\", \"value\" => DateTime.now.to_s}, \"ctx_id\" => {\"label\" => \"identifier\", \"value\" => \"\"}, \"ctx_enc\" => {\"label\" => \"encoding\", \"value\" => \"info:ofi/enc:UTF-8\"}}\n end",
"def initialize(msg, info = {}, execution_context: nil)\n super(msg)\n @info = info\n @execution_context = execution_context ? execution_context.dup : nil\n end",
"def initialize(context)\n super()\n @context = Hashie::Mash.new(context)\n @repository_info = @context.repository\n pull_request_info = @context.pull_request\n @event_created_at = pull_request_info.try(:created_at)\n @event_user_info = pull_request_info.try(:user)\n @commit_info = pull_request_info.try(:commits)\n end"
] |
[
"0.67508054",
"0.6748989",
"0.6230816",
"0.62093514",
"0.6085821",
"0.60184884",
"0.5963008",
"0.594317",
"0.59255344",
"0.5908465",
"0.5908465",
"0.58722246",
"0.58580136",
"0.58410996",
"0.5771573",
"0.57637465",
"0.57637465",
"0.5732501",
"0.57064855",
"0.5701131",
"0.56907487",
"0.5689076",
"0.5687848",
"0.56825453",
"0.56429887",
"0.5640646",
"0.5620345",
"0.5612091",
"0.5593349",
"0.55606925",
"0.55185235",
"0.54966646",
"0.5488541",
"0.5481894",
"0.5421321",
"0.54189354",
"0.5405333",
"0.5392649",
"0.5383869",
"0.53695196",
"0.53519195",
"0.53493124",
"0.5341026",
"0.532442",
"0.5318101",
"0.5305023",
"0.53014874",
"0.5278982",
"0.5265163",
"0.5263841",
"0.5253769",
"0.52335846",
"0.5229252",
"0.5229252",
"0.52259994",
"0.52240777",
"0.5223853",
"0.5223381",
"0.52199936",
"0.52158463",
"0.5209207",
"0.5198103",
"0.51895136",
"0.5180402",
"0.51797056",
"0.5168491",
"0.5167916",
"0.51631445",
"0.5151922",
"0.5151505",
"0.5151505",
"0.5148682",
"0.51465964",
"0.5116676",
"0.51129264",
"0.5111966",
"0.5108077",
"0.5099889",
"0.5082924",
"0.5082842",
"0.50800806",
"0.5073778",
"0.50569654",
"0.505671",
"0.5055658",
"0.5042726",
"0.5034566",
"0.5033704",
"0.50264156",
"0.5015469",
"0.5011351",
"0.49932262",
"0.49896336",
"0.498433",
"0.498433",
"0.49832824",
"0.49776876",
"0.49759454",
"0.49757278",
"0.49748647"
] |
0.6336505
|
2
|
Produce a record on `stream` with `key` and `value`
|
def produce_record(stream, key, value)
r = ::Concord::Thrift::Record.new
r.meta = ::Concord::Thrift::RecordMetadata.new
r.key = key
r.data = value
r.userStream = stream
transaction.records.push(r)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def put_record(stream, key, value)\n raise NotImplementedError\n end",
"def pipe_to(stream)\n message = ''\n create_stream() unless stream_exists?(stream)\n message = yield if block_given?\n body = update_message_body(message)\n resp = kinesis.put_record pipe_message_body(stream_name: stream, data: body.to_json)\n # TODO: implement retry logic for failed request\n @last_sequence_number = resp.sequence_number\n end",
"def get_stream(stream)\n @store[stream]\n end",
"def publish\n create_stream unless stream_exists?\n\n kinesis.put_record({\n stream_name: stream_name,\n data: \"Some data with a random number #{rand(100)}\",\n partition_key: \"#{rand(100000)}\",\n })\n end",
"def produce(topic, key, value)\n producer = init_producer\n key = serialize(key, @config.properties['key.serializer'])\n value = serialize(value, @config.properties['value.serializer'])\n\n producer.send(ProducerRecord.new(topic, key, value))\n end",
"def stream\n $stdin.each do |line|\n record = recordize(line.chomp)\n next unless record\n process(*record) do |output_record|\n emit output_record\n end\n end\n end",
"def map_record(record)\n context = Context.new(:source_record => record, :settings => settings)\n map_to_context!(context)\n return context.output_hash\n end",
"def map_record(record)\n context = Context.new(:source_record => record, :settings => settings)\n map_to_context!(context)\n return context.output_hash\n end",
"def format_stream(tag, es)\n # es is a Fluent::OneEventStream or Fluent::MultiEventStream.\n # Each event item gets serialised as a [timestamp, record] array.\n [tag, es.to_msgpack_stream].to_msgpack\n end",
"def create_record(line, line_number = -1) #:nodoc:\n h = Hash.new\n\n pack_format = self.class.get_subclass_variable 'pack_format'\n fields = self.class.get_subclass_variable 'fields'\n\n f = line.unpack(pack_format)\n (0..(fields.size-1)).map do |index|\n unless fields[index].is_padding?\n h.store fields[index].name, fields[index].pass_through_filters(f[index])\n end\n end\n Record.new(self.class, h, line_number)\n end",
"def <<(value)\n connection.rpush key_label, value\n end",
"def get_record(key)\n fields = get(key)[:record]\n MemoryRecord.new.init(key,fields) if fields\n end",
"def addRecord(rec); @records[rec.key] = rec end",
"def retrieve_key_string_from_stream(stream)\n return stream.read if stream.respond_to?(:read)\n return File.read(stream) if stream.to_s !~ /^-+BEGIN .* KEY-+$/\n stream\n end",
"def each\r\n record = @head\r\n while record\r\n yield record[:key], record[:value]\r\n record = record[:next]\r\n end\r\n end",
"def write_pair(field, value)\n key = (field.tag << 3) | field.wire_type\n stream << ::Protobuf::Field::VarintField.encode(key)\n stream << field.encode(value)\n end",
"def record(path, parameters={})\n result = request(path, parameters)\n (result && !result.empty?) ? Record.new(result.keys.first, result.values.first) : nil\n end",
"def record(path, parameters={})\n result = request(path, parameters)\n (result && !result.empty?) ? Record.new(result.keys.first, result.values.first) : nil\n end",
"def [](key)\r\n if record = touch(key)\r\n trail(record)\r\n record[:value]\r\n end\r\n end",
"def stream(key)\n object = object_for(key)\n\n chunk_size = 5.megabytes\n offset = 0\n\n raise ActiveStorage::FileNotFoundError unless object.exists?\n\n while offset < object.content_length\n yield object.get(range: \"bytes=#{offset}-#{offset + chunk_size - 1}\").body.string.force_encoding(Encoding::BINARY)\n offset += chunk_size\n end\n end",
"def parse_record(key, op_count, generation, expiration)\n bins = op_count > 0 ? {} : nil\n i = 0\n while i < op_count\n raise Aerospike::Exceptions::QueryTerminated.new unless valid?\n\n read_bytes(8)\n\n op_size = @data_buffer.read_int32(0).ord\n particle_type = @data_buffer.read(5).ord\n name_size = @data_buffer.read(7).ord\n\n read_bytes(name_size)\n name = @data_buffer.read(0, name_size).force_encoding('utf-8')\n\n particle_bytes_size = op_size - (4 + name_size)\n read_bytes(particle_bytes_size)\n value = Aerospike.bytes_to_particle(particle_type, @data_buffer, 0, particle_bytes_size)\n\n bins[name] = value\n\n i = i.succ\n end\n\n Record.new(@node, key, bins, generation, expiration)\n end",
"def create_metric_stream(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'CreateMetricStream'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :metric_stream\n\t\t\targs[:body]['MetricStream'] = optional[:metric_stream]\n\t\tend\n\t\tif optional.key? :project_name\n\t\t\targs[:query]['ProjectName'] = optional[:project_name]\n\t\tend\n\t\tself.run(args)\n\tend",
"def value(options = {}, &block)\n if options.is_a?(Hash)\n reload = !options.empty?\n else\n reload = options\n options = {}\n end\n expirable_memoize(reload) do\n self.class.stream(key, bucket.name, options, &block)\n end\n end",
"def flow_to_pipe(stream)\n throw NotImplementedError\n create_stream(stream) unless stream_exists? stream\n records = yield if block_given?\n body = message_body_collection(records)\n puts body\n # TODO: this isn't working yet. figure out retry logic\n # resp = kinesis.put_records(body)\n # retry(lambda { stream_exists? stream }) flow_to(stream)\n @last_sequence_number = resp.records.map(&:sequence_number).sort.last\n # TODO: what to return? true?\n end",
"def record(path, parameters={})\n result = request(path, parameters)\n (result && !result.empty?) ? Record.new(result.keys.first, result.values.first) : nil\n end",
"def build_stream(name:, client: kinesis, **config)\n stream_resource = Smash::CloudPowers::Synapse::Pipe::Stream.build(\n name: name, client: client, **config\n )\n\n self.attr_map(stream_resource.call_name => stream_resource) do |attribute, resource|\n instance_attr_accessor attribute\n resource\n end\n\n stream_resource\n end",
"def record(path, parameters={})\n @result = request(path, parameters)\n (@result && [email protected]?) ? Record.new(@result.keys.first, @result.values.first) : nil\n end",
"def encode_pair(buffer, value)\n buffer.write_varint(key).write_string(value)\n end",
"def append(stream, *events)\n @store[stream]\n events.each { |event| @store[stream] << event }\n puts '+' * 80\n end",
"def write_value_using_serializer_strategy(writer, key)\n writer.push_value(send(key), key)\n end",
"def process(record, &emit)\n yield record\n end",
"def publish(stream, message)\n @logger.tagged('publisher') do\n @redis_pool.with do |redis|\n redis.xadd(stream, payload: @serializer.serialize(message, stream))\n end\n @logger.debug { \"published to stream #{stream}: #{message.inspect}\" }\n end\n end",
"def link!(record)\n event = event_store.read.stream(record.stream_name).forward.first\n\n event_store.link(\n event.event_id,\n stream_name: stream_name\n )\n end",
"def key()\n begin\n @stream.peek\n rescue StopIteration\n nil\n end\n end",
"def emit record\n puts record.to_flat.join(\"\\t\")\n end",
"def [](name)\n case @hash[name]\n when Hash then\n @hash[name] = (@hash[name].keys.length == 1 && Array === @hash[name].values.first) ? @hash[name].values.first.map { |v| Record.new(@hash[name].keys.first, v) } : Record.new(name, @hash[name])\n else\n @hash[name]\n end\n end",
"def push_leaderboard(stream, hash)\n leaderboard = hash.inject([]) do |array, (key, value)|\n array << {'name' => key, 'value' => value}\n end\n post stream, 'leaderboard' => leaderboard\n end",
"def each_record\n keys.sort.each {|key| yield @records[key]}\n end",
"def format_stream(tag, es)\n out = ''\n es.each {|time,record|\n tag_temp = String.new(tag)\n filter_record(tag_temp, time, record)\n out << format(tag_temp, time, record)\n }\n out\n end",
"def store( key, value )\n key = key.to_s.strip unless key.nil?\n raise \"Invalid key\" if key.nil? or key == ''\n \n @db.execute( %Q{\n INSERT INTO #{TABLE_NAME}\n (key,value,created_at)\n VALUES (?,?,?)\n },\n key,\n value.to_yaml,\n Time.now.to_i\n )\n \n return value\n end",
"def write_log_to_kinesis(uuid, text)\n # this assumes that you have already configured your AWS SDK gem\n client = Aws::Kinesis::Client.new\n client.put_record(\n stream_name: $output_stream,\n data: text,\n partition_key: \"PartitionKey\"\n )\nend",
"def create(key, contents)\n store.write do |data| \n \n data[:columns][column][key] = contents \n\n Record.new(column, key, contents)\n end\n end",
"def stream_value(stream, range = nil)\n return 0 unless depth == 0\n raise ArgumentError,\n \"Stream passed in must provide a write method\" unless\n stream.respond_to? :write\n\n if range.nil?\n @structure.stream_value(stream)\n else\n @structure.stream_value(stream, range)\n end\n end",
"def record(lsn_no)\n reader.seek(lsn_no).record\n end",
"def stream_node(bt, reds, pointer_info, acc, dir, start_key = nil, &fun)\n # pp :stream_node => {:bt => bt, :reds => reds, :pointer_info => pointer_info, :start_key => start_key, :dir => dir, :acc => acc}\n pointer, _reds = *pointer_info\n # p :stream_node => { :_reds => _reds, :pointer => pointer }\n\n return :ok, acc if pointer_info.nil?\n\n node_type, node_list = get_node(bt, pointer)\n # p :node_type => node_type, :node_list => node_list\n adjusted_list = adjust_dir(dir, node_list)\n # p :adjusted_list => adjusted_list\n\n if start_key\n case node_type\n when :kp_node; stream_kp_node(bt, reds, adjusted_list, acc, dir, start_key, &fun)\n when :kv_node; stream_kv_node(bt, reds, adjusted_list, acc, dir, start_key, &fun)\n else\n raise \"invalid start_key: %p\" % [start_key]\n end\n else\n case node_type\n when :kp_node; stream_kp_node(bt, reds, adjusted_list, acc, dir, &fun)\n when :kv_node; stream_kv_node2(bt, reds, [], adjusted_list, acc, dir, &fun)\n else\n raise \"No such node_type\"\n end\n end\n end",
"def create\n repository.add_datastream to_api_params.merge({ :pid => pid, :dsid => dsid })\n reset_profile_attributes\n Datastream.new(digital_object, dsid)\n end",
"def create\n @stream = Stream.create!(stream_params)\n json_response(@stream, :created)\n end",
"def each\n store.each { |(key, value)| yield key, value }\n end",
"def test_record_activity_with_activity_appended_to_loaded_stream\n @stream.write(\"2012-01-31 10:52: Arrived\\n\" <<\n \"2012-01-31 10:59: Writing a test\\n\" <<\n \"\\n\" <<\n \"2012-02-01 11:12: Arrived\\n\")\n @stream.rewind\n now = Time.new(2012, 2, 1, 12, 37)\n timelog = Timelog.load_stream(@stream)\n timelog.record_activity(\"Reading mail\", now)\n assert_equal([{:start_time => Time.new(2012, 1, 31, 10, 52),\n :end_time => Time.new(2012, 1, 31, 10, 59),\n :description => 'Writing a test'},\n {:start_time => Time.new(2012, 2, 1, 11, 12),\n :end_time => Time.new(2012, 2, 1, 12, 37),\n :description => 'Reading mail'}],\n timelog.activities)\n @stream.rewind\n assert_equal(\"2012-01-31 10:52: Arrived\\n\" <<\n \"2012-01-31 10:59: Writing a test\\n\" <<\n \"\\n\" <<\n \"2012-02-01 11:12: Arrived\\n\" <<\n \"2012-02-01 12:37: Reading mail\\n\",\n @stream.read)\n end",
"def [](key)\n buffer.fields[key]\n end",
"def test_record_activity_with_starting_activity_appended_to_loaded_stream\n @stream.write(\"2012-01-31 10:52: Arrived\\n\" <<\n \"2012-01-31 10:59: Writing a test\\n\")\n @stream.rewind\n now = Time.new(2012, 2, 1, 11, 12)\n timelog = Timelog.load_stream(@stream)\n timelog.record_activity(\"Arrived\", now)\n assert_equal([{:start_time => Time.new(2012, 1, 31, 10, 52),\n :end_time => Time.new(2012, 1, 31, 10, 59),\n :description => 'Writing a test'}],\n timelog.activities)\n @stream.rewind\n assert_equal(\"2012-01-31 10:52: Arrived\\n\" <<\n \"2012-01-31 10:59: Writing a test\\n\" <<\n \"\\n\" <<\n \"2012-02-01 11:12: Arrived\\n\",\n @stream.read)\n end",
"def each\n return if empty?\n\n @record_index = -1\n with_record_stream do |stream|\n mapper = org.codehaus.jackson.map.ObjectMapper.new\n parser = mapper.getJsonFactory.createJsonParser(stream)\n\n while parser.nextToken\n @record_index += 1\n\n if @deleted_entries.get(@record_index)\n # Skip this entry\n parser.skipChildren\n else\n result = parser.readValueAs(java.util.Map.java_class)\n yield result\n end\n\n skip_comma(parser)\n end\n\n unless @count\n @count = @record_index + 1\n end\n end\n end",
"def emit record\n $stdout.puts(record.to_s)\n end",
"def pushStream(hash={})\n\t\t$room_count += 1 if hash['id'] == 'room'\n\t\t@@streams.push(hash['id'])\n\tend",
"def write(*args, &block)\n value = block_given? ? yield : args.pop\n last = args.pop\n prev_memo = prev_key = nil\n chain = args.inject(self) do |memo, key|\n unless valid_container?(memo, key)\n prev_memo[prev_key] = {}\n memo = prev_memo[prev_key]\n end\n prev_memo = memo\n prev_key = key\n memo[key]\n end\n unless valid_container?(chain, last)\n prev_memo[prev_key] = {}\n chain = prev_memo[prev_key]\n end\n chain[last] = value\n end",
"def build\n fail \"Please provide a value for key, currently: #{key}\" if key.nil?\n\n if in_key\n { in_key.to_sym => { key => data } }\n else\n process_data\n transform_to_hash\n end\n end",
"def write_to(stream)\n end",
"def next()\n @stream.next\n end",
"def value(key, value)\n factory(key, -> { value })\n end",
"def stream\n @__stream ||=\n Stream.new do |g|\n each do |item|\n g.append item\n end\n end\n end",
"def process(record)\n this_key = get_key(record)\n if this_key != self.key\n finalize { |record| yield record } unless self.key == :__first_group__\n self.key = this_key\n start record\n end\n accumulate(record)\n end",
"def store_value(timestamp, key, value)\n # Prepend the timestamp so we always have unique values\n @redis.zadd(key, timestamp, \"#{timestamp}:#{value}\")\n end",
"def stream(&block)\n attributes[:streams] << API::Stream.build(&block)\n end",
"def stream(key)\n file = file_for(key, skip_lookup: false)\n\n chunk_size = 5.megabytes\n offset = 0\n\n raise ActiveStorage::FileNotFoundError unless file.present?\n\n while offset < file.size\n yield file.download(range: offset..(offset + chunk_size - 1)).string\n offset += chunk_size\n end\n end",
"def each\r\n\t record = @head\r\n\t while record.next && record.next != @tail\r\n\t\t record = record.next\n\t\t record.values.each{|value| yield record.key, value }\r\n\t end\r\n end",
"def format(tag, time, record)\n partition_keys = []\n row_keys = []\n record.each_pair do |name, val|\n if @partition_key_array && @partition_key_array.include?(name)\n partition_keys << val\n record.delete(name)\n elsif @row_key_array && @row_key_array.include?(name)\n row_keys << val\n record.delete(name)\n end\n end\n if @add_time_to_partition_key\n partition_keys << Time.now.strftime(\"%Y%m%d\")\n end\n if @add_time_to_row_key\n row_keys << Time.now.getutc.to_i\n end\n if @add_uuid_to_row_key\n row_keys << SecureRandom.uuid\n end\n\n entity = Hash.new\n entity['partition_key'] = partition_keys.join(@key_delimiter)\n entity['row_key'] = row_keys.join(@key_delimiter)\n entity['entity_values'] = record\n entity.to_msgpack\n end",
"def read_data stream=STDIN\n\tdata = {}\n\tstream.each do |line|\n\t\tline =~ /^([0-9]*)\\|(.*)/;\n\t\tid, name_addr = $1.to_i, $2\n\t\traise \"duplicate id #{id}?\" if data[id]\n\t\tdata[id] = name_addr\n\tend\n\tdata\nend",
"def write(key, value)\n perform_update(:write, key, value.to_s)\n end",
"def stream; end",
"def stream; end",
"def stream; end",
"def stream; end",
"def parse_key_value\n to_transaction { to_h }\n end",
"def record(lsn_no)\n reader.seek(lsn_no).record\n end",
"def in(stream_name)\n AggregatedRecord::Proxy.new(stream_name, self)\n end",
"def write(record)\n @fh.puts(encode(record))\n self\n end",
"def stream_params\n params.require(:stream).permit(:keyword, :user_id)\n end",
"def value(key = :value)\n @record.send key\n end",
"def encode_pair(buffer, value)\n buffer.write_varint(key).write_float(value)\n end",
"def hash_record_low_mem! set, rec, duplicate_type\n key = make_key rec, duplicate_type\n\n set << key\nend",
"def inspect\n \"\\#<Stream #{ to_h }>\"\n end",
"def stream(value = nil)\n if value.nil?\n @stream\n else\n @stream = value\n end\n end",
"def log_kv(timestamp: Time.now, **fields)\n @logs << fields.merge(timestamp: timestamp)\n nil\n end",
"def output\n MappedRecord.new(self.to_hash)\n end",
"def capture(stream)\n begin\n stream = stream.to_s\n eval \"$#{stream} = StringIO.new\"\n yield\n result = eval(\"$#{stream}\").string\n ensure\n eval(\"$#{stream} = #{stream.upcase}\")\n end\n\n result\nend",
"def capture(stream)\n begin\n stream = stream.to_s\n eval \"$#{stream} = StringIO.new\"\n yield\n result = eval(\"$#{stream}\").string\n ensure\n eval(\"$#{stream} = #{stream.upcase}\")\n end\n\n result\nend",
"def capture(stream)\n begin\n stream = stream.to_s\n eval \"$#{stream} = StringIO.new\"\n yield\n result = eval(\"$#{stream}\").string\n ensure\n eval(\"$#{stream} = #{stream.upcase}\")\n end\n\n result\nend",
"def process(record)\n @output << record\n end",
"def for(stream)\n # noinspection RubyMismatchedReturnType\n where(%Q(#{stream_name} = '#{stream}'))\n end",
"def process record\n yield get(self.part, record)\n end",
"def capture(stream)\n begin\n stream = stream.to_s\n eval \"$#{stream} = StringIO.new\"\n yield\n result = eval(\"$#{stream}\").string\n ensure\n eval(\"$#{stream} = #{stream.upcase}\")\n end\n result\nend",
"def create(key, value)\n redis_key = prefix(key)\n value = Marshal.dump(value)\n @redis.setnx(redis_key, value)\n end",
"def log_kv(timestamp: Time.now, **fields)\n # Using Thrift::Log to avoid unnecessary memory allocations\n @logs << ThriftLogBuilder.build(timestamp, fields)\n nil\n end",
"def process(record)\n $stdout.puts record\n end",
"def chunk_signed_stream req, key\n args = []\n args << req.body_stream\n args << req.headers['x-amz-decoded-content-length'].to_i\n args << key\n args << key_path(req.headers['x-amz-date'])\n args << req.headers['x-amz-date']\n args << req.headers['authorization'].split('Signature=')[1]\n ChunkSignedStream.new(*args)\n end",
"def test_supports_key_value_with_timestamp_on_statsite\n @backend.implementation = :statsite\n @backend.expects(:write_packet).with(\"fooy:42|kv|@123456\\n\")\n StatsD.key_value('fooy', 42, 123456)\n end",
"def capture(stream)\n begin\n stream = stream.to_s\n eval \"$#{stream} = StringIO.new\"\n yield\n result = eval(\"$#{stream}\").string\n ensure\n eval(\"$#{stream} = #{stream.upcase}\")\n end\n\n result\n end",
"def capture(stream)\n begin\n stream = stream.to_s\n eval \"$#{stream} = StringIO.new\"\n yield\n result = eval(\"$#{stream}\").string\n ensure\n eval(\"$#{stream} = #{stream.upcase}\")\n end\n\n result\n end",
"def stream=(_arg0); end",
"def stream=(_arg0); end"
] |
[
"0.7422537",
"0.5717523",
"0.5650316",
"0.5506762",
"0.5304431",
"0.523678",
"0.5233242",
"0.5233242",
"0.51531154",
"0.51312",
"0.5099948",
"0.50368774",
"0.5036391",
"0.49827924",
"0.4939345",
"0.49281946",
"0.4886866",
"0.4886866",
"0.48497495",
"0.48435447",
"0.4841184",
"0.48245746",
"0.47844166",
"0.4776988",
"0.4772556",
"0.47713032",
"0.47598016",
"0.47543737",
"0.4750559",
"0.47453788",
"0.47411194",
"0.47317708",
"0.46994013",
"0.468346",
"0.46803248",
"0.46743163",
"0.4673496",
"0.4666522",
"0.46368375",
"0.46347234",
"0.46166992",
"0.46154362",
"0.4613359",
"0.4613104",
"0.46072185",
"0.4604528",
"0.4604324",
"0.46036172",
"0.46022648",
"0.45954922",
"0.45918164",
"0.45520622",
"0.45437303",
"0.45321912",
"0.4529954",
"0.4524912",
"0.45241287",
"0.4520896",
"0.45206612",
"0.45147574",
"0.450749",
"0.45023632",
"0.4502324",
"0.44952217",
"0.44937578",
"0.44901794",
"0.44890288",
"0.44872615",
"0.44859022",
"0.44859022",
"0.44859022",
"0.44859022",
"0.44856095",
"0.4479083",
"0.44781253",
"0.44772738",
"0.4472803",
"0.44718575",
"0.44689935",
"0.44646946",
"0.44612443",
"0.44609505",
"0.444992",
"0.44455823",
"0.44401586",
"0.44401586",
"0.44401586",
"0.44393617",
"0.44329333",
"0.44264072",
"0.44231215",
"0.44109967",
"0.44101056",
"0.43913424",
"0.43906978",
"0.43901622",
"0.4389415",
"0.4389415",
"0.43797028",
"0.43797028"
] |
0.7958232
|
0
|
Set a timer to trigger a callback in the future
|
def set_timer(key, time)
transaction.timers[key] = time
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def timer(milliseconds, &callback)\n # Implement in subclass\n end",
"def schedule(time, callback); end",
"def timer(timeout,options={},&callback)\n bot.timer.add_timer(:timestamp=>Time.now+timeout.to_i, :requestor=>options[:requestor]||name,&callback)\n end",
"def timer(callback = nil, &blk)\n Timer.new(@loop, callback || blk)\n end",
"def fire(time)\n if @callback\n @callback.call(time)\n end\n end",
"def initialize(interval, callback=nil, &blk)\n fire = proc {\n (callback || blk).call\n trigger(:fired)\n }\n @timer = NSTimer.scheduledTimerWithTimeInterval(interval,target: fire, selector: 'call:', userInfo: nil, repeats: false)\n end",
"def fire(time)\n if @callback\n @callback.call(time)\n end\n end",
"def run\n @lock.synchronize do\n until stopped?\n if run?\n begin\n @callback.call\n rescue => ex\n logger.warn \"[Neptune] Failed to run timer: #{ex.message}\"\n ensure\n # Always reset, regardless of whether it failed\n reset\n end\n else\n # Wait until enough time has passed for the next invocation\n @notifier.wait(@lock, seconds_left)\n end\n end\n end\n end",
"def run_after(delay, &block)\n NSTimer.scheduledTimerWithTimeInterval( delay,\n target: block,\n selector: \"call:\",\n userInfo: nil,\n repeats: false)\n end",
"def fire(time)\n\t\t\t\[email protected](time) if @callback\n\t\t\tend",
"def timer=(_arg0); end",
"def timer=(_arg0); end",
"def timer=(_arg0); end",
"def timer=(_arg0); end",
"def on_timeout\n trigger\n reset\n end",
"def timer\n handle = Timer.new(@reactor)\n handle.progress &Proc.new if block_given?\n handle\n end",
"def timer; end",
"def timer; end",
"def timer; end",
"def timer; end",
"def on_timeout=(callback)\n @timeout_callback = callback\n end",
"def on_timeout\n trigger\n reset\n end",
"def initialize(time, &callback)\n @time = time\n @callback = callback\n @start_time = Float::INFINITY\n end",
"def add_oneshot(delay:, callback:)\n Logger.debug(klass: self.class, name: :add_oneshot, message: \"delay: #{delay}\")\n return nil unless callback\n\n timer = Timer.new(timers: self, delay: delay, callback: callback)\n add timer\n timer\n end",
"def timer\n rescuer do\n Timeout.timeout(ttl) { yield }\n end\n end",
"def set_timer(delay=nil)\n if delay.class == Fixnum && block_given?\n return @j_del.java_method(:setTimer, [Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(delay,(Proc.new { |event| yield(event) }))\n end\n raise ArgumentError, \"Invalid arguments when calling set_timer(delay)\"\n end",
"def timer_on (opts={})\n @timer.cancel unless @timer.nil?\n length = @timeout + (opts[:with_interval] ? @interval : 0)\n @timer = EventMachine::Timer.new(length) {\n scrap = @buf ? \" - #{@buf.flush}\" : ''\n @handler.logger.error \"timeout on #{@handler.name}\" + scrap\n @handler.logger.debug {\"pid #{get_pid}\"}\n close_connection()\n }\n end",
"def trigger\n @timed_out = false\n @expires = Time.now + @period\n unless @thread\n @thread = Thread.new do\n begin\n begin\n sleepytime = @expires - Time.now\n while sleepytime > 0.0\n sleep(sleepytime)\n sleepytime = @expires - Time.now\n end\n @timed_out = true\n @expires += @period if @repeats\n @block.call if @block\n end while @repeats\n rescue StopTimerException\n @expires=nil\n ensure\n @thread = nil\n end\n end\n end\n end",
"def periodically(timing, event_callback)\n callback = proc { self.dispatch event_callback.to_sym }\n EventMachine::add_periodic_timer(timing, &callback)\n end",
"def periodically(timing, event_callback)\n EventMachine.add_periodic_timer(timing) do\n dispatch(event_callback.to_sym)\n end\n end",
"def on_timeout(options = {})\n timeout = options[:timeout] || 0.5\n\n sleep timeout\n\n yield\n end",
"def timeout_after(time); end",
"def initialize(timers:, delay:, callback:)\n @timers = timers\n @delay = delay\n @callback = callback\n reschedule\n end",
"def setTimeout(seconds = 0, *args, id: nextTimerID__, &block)\n return unless block\n setTimeout__ id, Time.now.to_f + seconds, args, &block\n end",
"def add_oneshot delay, timer_proc\n return nil unless timer_proc\n\n timer = Timer.new :timers => self, :delay => delay, :periodical => false, :timer_proc => timer_proc\n add timer\n timer\n end",
"def timer(*args, &b); \n if block_given?\n \tForce::Timer.timer(*args, &b)\n else\n Force::Timer.timer args[0] do\n send(args.shift, *args)\n end\n end\n end",
"def setTriggerTimeout _obj, _args\n \"_obj setTriggerTimeout _args;\" \n end",
"def set_timeout(seconds, block)\n listener = { seconds: seconds, block: block, time: @time, target: @time + seconds }\n @timeout_listeners.push listener\n listener\n end",
"def start_timer\n stop_timer\n @timer = EventMachine::PeriodicTimer.new(1) do\n #puts \"TIMER PROCESS ITERATE\"\n do_timer\n end\n end",
"def timeout=(_arg0); end",
"def fire\n schedule_firing_time if @periodical\n @timer_proc.call\n end",
"def set_timeout_source\n %Q|\n var setTimeout = function(cb, delay) {\n var timer = Components.classes[\"@mozilla.org/timer;1\"].createInstance(Components.interfaces.nsITimer);\n timer.initWithCallback({notify:cb}, delay, Components.interfaces.nsITimer.TYPE_ONE_SHOT);\n return timer;\n };\n |\n end",
"def schedule_timer(timeout)\n @scheduler.schedule_timer(timeout)\n end",
"def triggerTimeout _args\n \"triggerTimeout _args;\" \n end",
"def on_timeout\n trigger\n @active = false\n end",
"def schedule(time, callback)\n\t\t\tflush!\n\t\t\t\n\t\t\thandle = Handle.new(time.to_f, callback)\n\t\t\t\n\t\t\t@queue << handle\n\t\t\t\n\t\t\treturn handle\n\t\tend",
"def setup_heartbeat_timer; end",
"def timeout!; end",
"def delay(seconds); end",
"def delay(seconds); end",
"def start_periodic_timers; end",
"def start_periodic_timers; end",
"def add_timeout(interval, &block)\n @timer.add(interval, &block)\n end",
"def set_timeout timeout\r\n command 'setTimeout', timeout\r\n end",
"def set_timeout timeout\r\n command 'setTimeout', timeout\r\n end",
"def timeouts_set=(_arg0); end",
"def fire_on_lock_timeout(li, dt)\n return true unless @lock_timeout_callback\n @lock_timeout_callback.call(li, dt)\n end",
"def implicit_wait=(seconds); end",
"def start_timer start_to_fire_timeout, options = {}\n options[:timer_id] ||= SecureRandom.uuid\n options[:start_to_fire_timeout] = start_to_fire_timeout\n duration_opts(options, :start_to_fire_timeout)\n add_decision :start_timer, options\n options[:timer_id]\n end",
"def reset_timer; end",
"def reset_timer; end",
"def on_timer_timeout\n #puts \"#on_timer_minute #{@timer_minute} #{@timer_minute_limit}\"\n @timer_minute += 1\n if @timer_minute > @timer_minute_limit\n change_wallpaper\n\n # Restart timer\n reset_timer_minute\n end\n end",
"def current_timer=(_arg0); end",
"def delay; end",
"def delay; end",
"def delay; end",
"def fire\n @callback.call\n end",
"def sleep(dur=0) end",
"def start_callback\n lambda {\n self.start\n }\n end",
"def add_oneshot_at exact_time, timer_proc\n return nil unless timer_proc\n\n timer = Timer.new :timers => self, :exact_time => exact_time, :periodical => false, :timer_proc => timer_proc\n add timer\n timer\n end",
"def schedule_callback tick_count, &callback\n raise \"Callback has already been scheduled for tick #{tick_count}. If you meant to do this, execute $gtk.scheduled_callbacks.clear first.\" if @scheduled_callbacks[tick_count]\n @scheduled_callbacks[tick_count] = callback\n end",
"def action_callback(options)\n # Wait until the calling thread goes to sleep.\n while options[:thread].status == \"run\"\n sleep 0.1\n end\n\n # Run the block.\n if options[:thread].status == \"sleep\"\n # Call the callback.\n options[:block].call\n end\n rescue => e\n Log.exception(e)\n ensure\n # Wake up the thread.\n if options[:thread].status == \"sleep\"\n options[:thread].run\n end\n end",
"def after(interval, &block); end",
"def setTimer\n return NSTimer.timerWithTimeInterval( 1.0,\n target: self,\n selector: 'updateCountdown:',\n userInfo: nil,\n repeats: true )\n .tap do |timer|\n @countdown = @delayTime\n @timerField.stringValue = @countdown.to_int.to_s\n end if @delayTime > 1\n nil\n end",
"def fire(time); end",
"def fire(time); end",
"def with_timeout(time, &block)\n Timeout.timeout(time) do\n block.call(self)\n end\n end",
"def on_start=(callback)\n weak = WeakRef.new(self)\n\n Dispatch::Queue.main.async do\n if weak\n callback.call unless weak.isCancelled\n end\n end\n end",
"def timeouts_set; end",
"def start_timer\n @timer ||= EventMachine::PeriodicTimer.new(1) { cleanup }\n end",
"def after(interval, &block)\n Timer.new(self, interval, false, block)\n end",
"def add_timer(interval, callback=nil, &blk)\n @timers ||= {}\n timer = Timer.new(interval,callback,&blk)\n timer.on(:fired) do\n @timers.delete(timer.object_id)\n end\n timer.on(:cancelled) do\n @timers.delete(timer.object_id)\n end\n @timers[timer.object_id] = timer\n timer.object_id\n end",
"def ping()\n Timer.renew(@name, @timeout)\n end",
"def on_timer(value=1000)\n Thread.new() {\n begin\n nbtick=(value/TICK)+1\n loop do\n i=0\n sleep(TICK/1000.0) while self.connected?() && (i+=1)<nbtick\n self.connected?() ? yield() : break\n end\n rescue Exception => e\n $stdout.puts \"#{e} :\\n #{e.backtrace.join(\"\\n \")}\"\n end\n }\n end",
"def cb_schedule(async: true, **opt)\n async = false # TODO: remove when implementing async jobs\n opt[:callback] = callback if callback.present?\n async ? cb_perform_later(**opt) : cb_perform_now(**opt)\n end",
"def trigger_timer(timer)\n\n r = nil\n\n transync do\n\n# TODO: cron/every stop conditions maybe?\n\n if timer.type != 'at' && timer.type != 'in'\n\n @db[:flor_timers]\n .where(id: timer.id)\n .update(\n count: timer.count + 1,\n ntime: compute_next_time(timer.type, timer.schedule),\n mtime: Flor.tstamp)\n r = timers[timer.id]\n\n elsif @archive\n\n @db[:flor_timers]\n .where(id: timer.id)\n .update(\n count: timer.count + 1,\n status: 'triggered',\n mtime: Flor.tstamp)\n\n else\n\n @db[:flor_timers]\n .where(id: timer.id)\n .delete\n end\n\n put_messages([ timer.to_trigger_message ], false)\n end\n\n r\n\n rescue => err\n\n Thread.current[:sto_errored_items] = [ timer ]\n raise err\n end",
"def setCB(callback)\n @callbackfn = callback\n end",
"def start_timer\n @start_time = Time.now\n end",
"def watch_interval=(_arg0); end",
"def first_data_timeout(seconds); end",
"def schedule(&blk)\n @reactor.next_tick(blk)\n end",
"def add_timeout(seconds, &block)\n raise_not_implemented\n end",
"def start_timer\n @timing = $app.animate(1) do\n @time_remaining -= 1\n end\n end",
"def finish\n @time = 0.0\n @trigger.()\n end",
"def start_timer\n view.start_timer self\n end",
"def with_timer(name, &block)\n start = Time.now\n block.call\n duration = Time.now - start\n # report in ms\n self.add_field(name, duration * 1000)\n self\n end",
"def on_for(seconds=1)\n on\n sleep seconds\n off\n end",
"def timeout; end",
"def timeout; end",
"def timeout; end"
] |
[
"0.72811586",
"0.71235293",
"0.7055587",
"0.7055117",
"0.6755316",
"0.6696654",
"0.66893315",
"0.65120184",
"0.6504822",
"0.64899915",
"0.6413648",
"0.6413648",
"0.6413648",
"0.6413648",
"0.6391655",
"0.63417935",
"0.6336033",
"0.6336033",
"0.6336033",
"0.6336033",
"0.6327021",
"0.63196415",
"0.62801653",
"0.6231148",
"0.62169147",
"0.62106985",
"0.61946654",
"0.6172099",
"0.61435604",
"0.61377335",
"0.6126909",
"0.6114351",
"0.6096874",
"0.60850745",
"0.60379225",
"0.60018545",
"0.59571207",
"0.5944536",
"0.59022397",
"0.5898381",
"0.589477",
"0.58911854",
"0.5887775",
"0.586664",
"0.5825988",
"0.58220685",
"0.58192223",
"0.5807325",
"0.5792741",
"0.5792741",
"0.5779765",
"0.5779765",
"0.577215",
"0.57459104",
"0.57459104",
"0.5726514",
"0.57115054",
"0.5689222",
"0.56865114",
"0.56813335",
"0.56813335",
"0.5676924",
"0.5673167",
"0.5660266",
"0.5660266",
"0.5660266",
"0.5658304",
"0.5645607",
"0.56419486",
"0.5641068",
"0.56388485",
"0.56161785",
"0.56095773",
"0.56018466",
"0.5579519",
"0.5579519",
"0.556648",
"0.5560009",
"0.5559876",
"0.55515206",
"0.554755",
"0.5545157",
"0.5537595",
"0.5534711",
"0.55307317",
"0.55246264",
"0.550142",
"0.5497067",
"0.54934704",
"0.54868037",
"0.5479406",
"0.54780495",
"0.5473611",
"0.5471435",
"0.547129",
"0.5468133",
"0.5460695",
"0.54590374",
"0.54590374",
"0.54590374"
] |
0.58679426
|
43
|
Retrieve a binary blob stored in the proxy state
|
def get_state(key)
computation.get_state(key)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def save2blob()\n url = URI.parse(getUrl)\n h = Net::HTTP.start(url.host, url.port) do |http|\n resp, data = http.get(url.path + '?' + url.query)\n return data\n end\n end",
"def blob\n generate\n storage.get(path).body\n end",
"def blob; end",
"def blob; end",
"def to_blob\n @blob\n end",
"def blob\n dbf.blob\n end",
"def blob\n @blob ||= image.to_blob\n end",
"def value\r\n @value ||= self.class.service_instance.get_blob(path)\r\n end",
"def download\n self.rqrcode.to_blob\n end",
"def to_blob; end",
"def to_blob; end",
"def to_blob; end",
"def to_blob; end",
"def to_blob; end",
"def to_blob; end",
"def to_blob\n File.binread(path)\n end",
"def get_binary\n # the base uri for api requests\n _query_builder = Configuration.base_uri.dup\n\n # prepare query string for API call\n _query_builder << '/response/binary'\n\n # validate and preprocess url\n _query_url = APIHelper.clean_url _query_builder\n\n # prepare headers\n _headers = {\n 'user-agent' => 'Stamplay SDK'\n }\n\n # Create the HttpRequest object for the call\n _http_request = @http_client.get _query_url, headers: _headers\n \n # Call the on_before_request callback\n @http_call_back.on_before_request(_http_request) if @http_call_back\n\n # Invoke the API call and get the binary response\n _response = @http_client.execute_as_binary(_http_request)\n\n # Call the on_after_response callback\n @http_call_back.on_after_response(_response) if @http_call_back\n\n # Endpoint error handling using HTTP status codes.\n if _response.status_code == 404\n return nil\n end\n\n # Global error handling using HTTP status codes.\n validate_response(_response)\n\n # Return appropriate response type\n return _response.raw_body\n end",
"def blob\n @blob ||= ($repo.gblob(@rev + ':' + @name))\n end",
"def get_b\n n = self.get_i32\n OSC::Blob.new(self.get_data(n))\n end",
"def raw_bytes\n @raw_bytes ||= read_raw_bytes\n end",
"def data; Marshal.load(Base64.decode64(read_attribute(:data))); end",
"def data\n read_attribute(binary ? :binary_data : :data)\n end",
"def get_binary\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/response/binary'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.get(\n _query_url\n )\n _response = execute_request(_request, binary: true)\n\n # Validate response against endpoint and global error codes.\n return nil if _response.status_code == 404\n validate_response(_response)\n\n # Return appropriate response type.\n _response.raw_body\n end",
"def blob\n nil\n end",
"def blob(id)\n head \"/blobs/#{id}\"\n end",
"def bytes\n self\n end",
"def raw\n @buffer\n end",
"def get_raw_buffer\n @buffer\n end",
"def io\n @io ||= StringIO.new(blob, 'r+b')\n end",
"def raw_body\n if @rev\n @raw_body ||= blob.contents\n else\n @raw_body ||= File.exists?(@filename) ? File.read(@filename) : ''\n end\n end",
"def bytes\n contents.bytes\n end",
"def bytes\n contents.bytes\n end",
"def base64\n self[:data]\n end",
"def read\n object = uy_connection.get(@path)\n object.data\n end",
"def take_snapshot\n json_string = self.snapshot_model.to_json\n Crypto::Bytes.from_string(json_string)\n end",
"def read\n client[\"/vaults/#{vault_id}/blobs/#{blob_id}\"].get\n end",
"def blob_response(key, query, *args)\n url = File.join(properties.primary_endpoints.blob, *args) + \"?#{query}\"\n headers = build_headers(url, key, 'blob')\n\n ArmrestService.send(\n :rest_get,\n :url => url,\n :headers => headers,\n :proxy => proxy,\n :ssl_version => ssl_version,\n :ssl_verify => ssl_verify,\n )\n end",
"def read\n object.content\n end",
"def picdata\n object.imgdata\n end",
"def download_blob_to_tempfile(&block); end",
"def download_blob_to_tempfile(&block); end",
"def to_blob\n f = File.new @path\n f.binmode\n f.read\n ensure\n f.close if f\n end",
"def data\n if @path\n File.open(@path, \"rb\"){|f| f.read} rescue nil\n else\n @memory_io.string.clone\n end\n end",
"def read_binary\n raise NotImplementedError\n end",
"def ref\n @bin\n end",
"def store_blob(blob)\n super #=> returns blob[:tempfile]\n end",
"def blob(oid, destination)\n begin\n res = barerepo.blob_at oid, destination\n rescue\n return nil\n end\n res\n end",
"def blob(oid, destination)\n begin\n res = barerepo.blob_at oid, destination\n rescue\n return nil\n end\n res\n end",
"def bytes\n @lmdb.transaction do\n if ret = @dbs[:control]['bytes']\n ret.unpack1 'Q>'\n end\n end\n end",
"def get(filename)\n @ftp.getbinaryfile(filename, nil)\n end",
"def getbyte()\n #This is a stub, used for indexing\n end",
"def raw\n @xbrl_content\n end",
"def snapshot\r\n date = self.class.service_instance.snapshot_blob(self.path)\r\n properties = self.class.service_instance.get_blob_properties(self.path)\r\n return BlobObject.new(:name => self.name, \r\n :url => self.class.service_instance.generate_request_uri(self.path) + \"?snapshot=#{date}\",\r\n :content_type => properties[:content_type],\r\n :snapshot_date => date)\r\n end",
"def raw_data\n @raw_data ||= api_url.open.read\n end",
"def data\n @buffer.string\n end",
"def get_bytes()\n @value\n end",
"def read\n read_object(read_byte)\n end",
"def read_blob(ref, filename)\n blob = repository&.blob_at(ref, filename)\n\n raise 'Blob not found' unless blob\n raise 'File is not readable' unless blob.readable_text?\n\n blob\n end",
"def file_data\n @client.get_file @file_url\n end",
"def blob\n read_repo\n if @branches.count < 1\n render :template => 'repositories/newrepo'\n return\n end\n\n params[:action] = \"blob\"\n\n @blob = @repository.get_blob(@branch, @path)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repository }\n end\n end",
"def value\n \"LOAD_FILE(\\\"#{@blob_file}\\\")\"\n end",
"def store_blob(object,field_name,blob)\n super #=> returns blob[:tempfile]\n end",
"def bytes\n Base64.decode64(data)\n end",
"def blob?\n @blob\n end",
"def bytes; end",
"def getBlobById(blob_id)\n b = @repo.blob(blob_id).data\n if b == \"\"\n # either the blob doesn't exist or it does but the data is empty\n return false\n end\n return b\n end",
"def contents\n if persisted?\n f=Photo.mongo_client.database.fs.find_one(:_id=>BSON::ObjectId.from_string(@id))\n if f \n buffer = \"\"\n f.chunks.reduce([]) do |x,chunk| \n buffer << chunk.data.data \n end\n return buffer\n end \n end\n end",
"def download\n \n @tmpfile = fetch_remote(location)\n \n @fetched_at = Time.new\n \n return @tmpfile\n \n end",
"def get_image_bytes(url)\n URI.open(url).read\nend",
"def data\n FFI::MemoryPointer.new(:size_t) do |size|\n data = Spotify.image_data(@pointer, size)\n return data.read_bytes(size.read_size_t)\n end\n end",
"def data\n return @content.data\n end",
"def object_data(path)\n blob = path_to_object(path)\n return nil if (not blob) || (blob.kind_of? Grit::Tree)\n blob.kind_of?(Grit::Blob) ? blob.data : blob\n end",
"def data_as_bytes\n raise \"subclass responsibility\"\n end",
"def actual_buffer(offset=0)\n @transfer[:buffer].get_bytes(offset, @transfer[:actual_length])\n end",
"def blob(arg)\r\n file MojoMagick::tempfile(arg)\r\n end",
"def data= blob\n $postgres.exec_prepared('wsfile_update', [self.id, {value: blob, format: 1}])\n end",
"def get_object(id)\n return nil unless (blob = find_blob(id)) && (obj = blob.read_object(id))\n deserialize(obj)\n end",
"def blob(repo, digest, file)\n doreq('get', \"/v2/#{repo}/blobs/#{digest}\", file)\n end",
"def as_received\n raw_data\n end",
"def body\n downloader.content\n end",
"def credential_blob\n size = @cred_struct[:credential_blob_size]\n return nil unless size > 0\n\n @cred_struct[:credential_blob].read_bytes(size)\n end",
"def buffer\n @transfer[:buffer].read_string(@transfer[:length])\n end",
"def bytes()\n #This is a stub, used for indexing\n end",
"def get_bin(id)\n File.read(File.join(File.expand_path(File.dirname(__FILE__)),'data',id.to_s),mode: 'rb')\n end",
"def meta\n blob = ActiveStorage::Blob.find_signed(params[:id])\n\n render json: { blob: blob, url: rails_blob_url(blob) }\n end",
"def load(blob)\n internal = decrypt(blob)\n ::Riak::Serializers.deserialize(content_type, internal)\n end",
"def to_buffer\n validate_binary_operations\n @request.perform(binary: true)\n end",
"def base64\n content = storage.read(id)\n base64 = Base64.encode64(content)\n base64.chomp\n end",
"def to_blob\n stream = StringIO.new\n @surface.write_to_png(stream)\n stream.string\n end",
"def read\n connection.open(full_remote_path).read\n end",
"def as_bytes\n raise NotImplementedError\n end",
"def data\n Base64::decode64(@data)\n end",
"def metadata\r\n self.class.service_instance.get_blob_properties(path)\r\n end",
"def raw_response\n Net::HTTP.get(endpoint)\n end",
"def data\n return nil if photo_data.nil?\n return photo_data.data\n end",
"def blob(repo)\n @blob ||= Grit::Blob.create(repo,\n :id => @sha, :name => name, :size => @size)\n end",
"def read_keyblob(type); end",
"def file_download\n blob_cache(:file_download) do\n raw_download = tiddlywiki_file.download\n is_compressed? ? SiteCommon.decompress_html(raw_download) : raw_download\n end\n end",
"def find_blob_data(sha, path)\n commit = barerepo.lookup sha\n tree = barerepo.lookup commit.tree_id\n blob = tree.path path\n blobdata = barerepo.read(blob[:oid]).data\n image = {\n name: blob[:name],\n data: blobdata\n }\n [image , commit]\n end",
"def demarshal_object(blob)\n Marshal.load(blob)\n end",
"def data_as_bytes\n data = []\n data << @status\n data << @meta_type\n data << 4\n data << @data[0]\n data << @data[1]\n data << @data[2]\n data << @data[3]\n end"
] |
[
"0.6810621",
"0.6716295",
"0.65735465",
"0.65735465",
"0.6542191",
"0.6491445",
"0.64849716",
"0.64771134",
"0.63948447",
"0.6391976",
"0.6391976",
"0.6391976",
"0.6391976",
"0.6391976",
"0.6391976",
"0.6376434",
"0.6330468",
"0.6316375",
"0.62938255",
"0.6266625",
"0.62496614",
"0.62428075",
"0.62347037",
"0.62231135",
"0.6181908",
"0.61425316",
"0.6101521",
"0.6047331",
"0.60318387",
"0.60245395",
"0.58861655",
"0.58861655",
"0.58673024",
"0.58562005",
"0.58461344",
"0.5837113",
"0.5825128",
"0.58055437",
"0.57959116",
"0.579269",
"0.579269",
"0.57890165",
"0.5786655",
"0.5776776",
"0.5763302",
"0.57558143",
"0.57245815",
"0.57245815",
"0.568416",
"0.5674618",
"0.5670993",
"0.5661408",
"0.5645634",
"0.5642949",
"0.56281316",
"0.5626891",
"0.56233335",
"0.5622059",
"0.55738705",
"0.5571516",
"0.55715144",
"0.5550652",
"0.55462104",
"0.55269223",
"0.5523937",
"0.5521153",
"0.5499015",
"0.54988897",
"0.5498503",
"0.54961175",
"0.54892194",
"0.54630905",
"0.5459291",
"0.54460895",
"0.5441173",
"0.54390514",
"0.5439049",
"0.5427669",
"0.5404667",
"0.54034626",
"0.5399921",
"0.5398371",
"0.53969204",
"0.5392247",
"0.53916097",
"0.53890747",
"0.53807217",
"0.53790444",
"0.53711164",
"0.53708714",
"0.536653",
"0.5362194",
"0.5359943",
"0.53502333",
"0.53488207",
"0.5341305",
"0.53367007",
"0.5332366",
"0.5328568",
"0.53280437",
"0.5320995"
] |
0.0
|
-1
|
Store a binary blob, identified by a key, in the proxy state
|
def set_state(key, value)
computation.set_state(key, value)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def write(key, value)\n key.freeze if key.is_a? String\n\n @memory_store[key] = value\n @file_store.transaction do\n @file_store[key] = value\n end\n end",
"def storeSerialised( handle, key, klass )\n s = Marshal.dump( klass )\n handle[ key ] = s;\nend",
"def persist(key); end",
"def persist(key); end",
"def save(key, value)\n storage.transaction {storage[key] = value}\n end",
"def store(type, key, file)\n raise Dis::Errors::ReadOnlyError if readonly?\n\n store!(type, key, file)\n end",
"def store(key, data)\n store = Storage.new\n store.data = data\n\n if store.save \n session[key] = store.id\n cookies[key] = store.id\n end\n end",
"def set(data)\n data = data.to_json\n cache_key = Digest::SHA1.hexdigest(data)\n\n log(\"insert :Cache, #{cache_key} -> {'blob' => #{data.inspect}}\")\n connection.insert(:Cache, cache_key, { \"blob\" => data })\n cache_key\n end",
"def store(calling_node, key, value)\n @router.touch(calling_node)\n return false unless key.class == DataKey\n @values[key.to_bin] = value\n return true\n end",
"def store_blob(object,field_name,blob)\n super #=> returns blob[:tempfile]\n end",
"def store_blob(blob)\n super #=> returns blob[:tempfile]\n end",
"def store_data key, value\n init_data\n\n Bot::DB[my_name][key] = value\n end",
"def store_data key, value\n init_data\n\n Bot::DB[my_name][key] = value\n end",
"def store(key, value)\n #open!(key)\n super(key, value)\n end",
"def load_buffer_data(key)\n @buffers[@active_buffer].set_buffer_data(key,read_file(key))\n end",
"def store(new_file)\n res = client[\"/vaults/#{vault_id}/blobs\"].post file: new_file.to_file\n json = JSON.parse(res)\n self.blob_id = json['blob_id']\n true\n end",
"def []=(key, value)\n object = @bucket.get_or_new sanitize_key(key)\n object.raw_data = Marshal.dump(value)\n object.content_type = \"application/x-ruby-marshal\"\n object.store\n value\n end",
"def save(key, maybe_param, blob, etag)\n $logger.debug(\"Cache write: #{key},#{maybe_param}\")\n filename = args_to_filename(key, maybe_param)\n FileUtils.mkdir_p(File.dirname(filename))\n IO::write(filename, blob)\n IO::write(\"#{filename}.etag\", etag)\n end",
"def set(key, flags, expiration, length, data)\n storage[key] = {\n expiration: expiration,\n flags: flags,\n value: data\n }\n\n 'STORED'\n end",
"def store(key, data, opts={})\n if data.respond_to?(:read)\n multipart_store(key, data, opts)\n else\n singlepart_store(key, data, opts)\n end\n end",
"def store_cache(key, name)\n checksum = Digest::MD5.hexdigest(key)\n node.default['data-bag-cache']['__checksums__'][checksum] = name\n end",
"def unsafe_save(namespace, key, data)\n path = make_path(namespace, key)\n tmp = Tempfile.new('abbey') \n size = tmp.write(MultiJson.encode(data))\n tmp.close\n FileUtils.mv(tmp.path, path)\n settings.logger.info(\"Written #{make_key(namespace, key)} (size: #{size})\")\n tmp.unlink\n end",
"def store(key, value)\n\t\t\tused_key = key \n\t\t\twhile File.exists?(key_to_path(used_key))\n\t\t\t\tif fetch(used_key) == value\n\t\t\t\t\tFileUtils.touch(key_to_path(used_key))\n\t\t\t\t\treturn used_key # Already exists. Do not store again.\n\t\t\t\tend\n\t\t\t\tused_key = Soil.digest_class.digest(key)\n\t\t\tend\n\t\t\tfile_path = key_to_path(used_key)\n\n\t\t\tFileUtils.mkpath(file_path.dirname)\n\t\t\tFile.open(file_path, 'w') do |f|\n\t\t\t\tf.write(Zlib::Deflate.deflate value)\n\t\t\tend\n\t\t\treturn used_key\n\t\tend",
"def put key, value\n # append value to open file\n # write new keydict value\n @keydict[key] = write_data_entry key, value\n\n # sync\n\n if @data_file.size > MAX_FILE_SIZE\n fname = @data_file.path\n @data_file.close\n @data_file = open_new_data_file\n @old_data_files[fname] = File.open(fname, \"rb\")\n end\n end",
"def set_blob\n @blob = Blob.find(params[:id])\n end",
"def set_blob\n @blob = Blob.find(params[:id])\n end",
"def set key, data\n\t\t@data_base[ key ] = data\n\t\tupdate_database\n\tend",
"def write(key, content)\n set(key.to_s, content.to_json)\n end",
"def set(key, value)\n filename = filename_from_url(key)\n mkpath(filename)\n\n # Save metadata in a parallel file\n if value.respond_to?(:meta)\n filename_meta = \"#{filename}.meta\"\n meta = value.meta\n meta[:status] = value.status if value.respond_to?(:status)\n meta[:content_type] = value.content_type if value.respond_to?(:content_type)\n meta[:base_uri] = value.base_uri if value.respond_to?(:base_uri)\n File.open(filename_meta, 'wb') {|f| YAML::dump(meta, f)}\n end\n\n # Save file contents\n File.open(filename, 'wb'){|f| f.write value.read }\n value.rewind\n value\n end",
"def set(key, value)\n @content[key] = ActiveSupport::SafeBuffer.new(value.to_s)\n end",
"def blob; end",
"def blob; end",
"def stored_key(key)\n h(key)\n end",
"def save(key, data)\n self.ready\n \n unless @validId.nil?\n\t\t\t\traise SwapDmi::CacheSaveError.new(key) unless self.instance_exec(key, &@validId)\n end\n \n self.evict(key) if @evictWhen[:save]\n self.instance_exec(key, data, &@save)\n self\n end",
"def store(key, data, bucket = nil, options = {})\n validate_key!(key)\n # Must build path before infering content type in case bucket is being used for options\n path = path!(bucket, key, options)\n infer_content_type!(key, options)\n \n put(path, options, data) # Don't call .success? on response. We want to get the etag.\n end",
"def store(key, value)\n filename = File.join(dir, key)\n File.write(filename, value)\n filename\n end",
"def store(hash)\n store_for_id(@id, hash)\n end",
"def store(key_store_file, password)\n\n end",
"def put_object(obj, id)\n find_blob(id, true).write_object(id, serialize(obj))\n end",
"def store(id, data)\n storage[id] = data\n end",
"def read_keyblob(type); end",
"def restoreSerialised( handle, key )\n obj = nil\n data = handle[ key ];\n obj = Marshal.load( data )\n return obj\nend",
"def add_write(key, value, binary = false)\n if (@is_commit)\n raise RuntimeError.new('No further request supported after a commit!')\n end\n @requests << {'write' => {key => JSONConnection.encode_value(value, binary)}}\n self\n end",
"def read(key)\n key.freeze if key.is_a? String\n\n if @memory_store.has_key? key\n @memory_store[key]\n else\n @file_store.transaction do\n @memory_store[key] = @file_store[key]\n end\n @memory_store[key]\n end\n end",
"def set_state(key, value)\n proxy.setState(key, value)\n end",
"def store_buffer\n return unless buffer?\n @buffer.binmode\n @buffer.pos = 0 # TODO: なんか頭が落ちるので!\n File.open(stored_file_path, \"wb\") do |f|\n f.write(@buffer.read)\n end\n end",
"def set(key, value)\n self.data ||= {}\n self.data[key.to_s] = value\n self.save!\n end",
"def record_write bytes\n @reader.record_write bytes, @state\n end",
"def []=(key, content)\n temp_file = File.join(root, ['tmp', $$, Thread.current.object_id].join('-'))\n File.open(temp_file, 'wb') do |dest|\n if content.respond_to? :to_str\n dest.write(content.to_str)\n else\n content.each {|s| dest.write(s) }\n end\n end\n\n path = cache_path(key)\n File.unlink path if File.exist?(path)\n FileUtils.mkdir_p File.dirname(path), :mode => 0755\n FileUtils.mv temp_file, path\n rescue\n File.unlink temp_file rescue nil\n ensure\n content\n end",
"def store(keyname, value)\n @keystore.store(key: keyname, value: value)\n end",
"def set_checkpoint_key(value)\n @redis.write(@checkpoint_key, value)\n end",
"def store(key, contents)\n raise NotImplementedError.new 'Implement store(key, contents) in your CacheManager'\n end",
"def store_content(key, klass, content)\n raise MogileFS::ReadOnlyError if readonly?\n\n new_file key, klass do |mfp|\n if content.is_a?(MogileFS::Util::StoreContent)\n mfp.streaming_io = content\n else\n mfp << content\n end\n end\n\n content.length\n end",
"def write(key, value, opts = {})\n _key = Digest::SHA1.hexdigest key\n ttl = opts[:ttl] || @default_ttl\n \n # We don't want to cache errors\n return if value.is_a?(Faraday::Response) && !value.success?\n\n if (value.is_a?(Faraday::Response) && !value.headers['expires'].nil?)\n resp_ttl = DateTime.parse(value.headers['expires']).to_time.to_i - Time.now.to_i\n ttl = resp_ttl if resp_ttl > 0\n end\n\n _value = Marshal.dump value\n\n @memory_store[_key] = value\n $LOG.debug \"Writing to JDG cache hashed #{_key} for #{key}\"\n @conn.put do |req|\n req.url \"/rest/jbossdeveloper/#{@profile}_#{_key}\"\n req.headers['Content-Type'] = opts[:content_type] || 'application/ruby+object'\n req.headers['timeToLiveSeconds'] = ttl.to_s # need to see if we're actually a request and full from that\n req.body = _value\n end\n end",
"def save\n raise 'Blob is empty' if !data\n repository.put(self) if modified?\n id\n end",
"def put_raw_object(raw, id)\n find_blob(id, true).write_object(id, raw)\n end",
"def set key, value, expiration\n backend.set key.to_s, serialize(value), expiration rescue nil\n end",
"def store_object(robject, options = {})\n raw_data = begin; robject.raw_data.dup; rescue TypeError; robject.raw_data; end\n\n bucket_data(robject.bucket, options[:type])[:keys][robject.key] = {\n :value => raw_data,\n :content_type => robject.content_type.dup,\n :links => robject.links.dup,\n :indexes => robject.indexes.dup,\n :meta => robject.meta.dup,\n :etag => Digest::MD5.hexdigest(raw_data.to_s),\n :last_modified => Time.now.gmtime,\n :vclock => Base64.encode64(Time.now.to_f.to_s).chomp\n }\n end",
"def save!(private_key)\n bitcoin.sendrawtransaction to_signed_tx(private_key)\n end",
"def hash_end(_key)\n save_batch\n end",
"def key_data; end",
"def key_data; end",
"def add_blob\n repository.add(blob_path)\n end",
"def invoke_write_key(key)\n write_key(key)\n end",
"def set(key, value)\n @store[key] = value\n end",
"def image(key)\n return @data[key].clone\n end",
"def []=(key, value)\n @storage[key] = value\n end",
"def store_archive(hash)\n raise NotImplementedError\n end",
"def write(key, value)\n filepath = realpath(key)\n FileUtils.mkdir_p(File.dirname(filepath))\n IO.binwrite(filepath, Marshal.dump(value))\n true\n end",
"def store(path, record)\n # Sanitize path\n path = \"#{Paths::VFS}/#{path}\" unless path.start_with?(Paths::VFS)\n path = sanitize_path(path)\n\n @api.post(path, :body => record)\n end",
"def []=(key, val)\n @write_lock ||= true\n @data ||= restore\n @data[key] = val\n end",
"def put_record(stream, key, value)\n raise NotImplementedError\n end",
"def save(key, value)\n s3_write key, value\n end",
"def read(key)\n _key = Digest::SHA1.hexdigest key\n\n unless @memory_store.has_key? _key\n response = @conn.get \"/rest/jbossdeveloper/#{@profile}_#{_key}\"\n if response.success?\n @memory_store[_key] = Marshal.load(response.body)\n end\n end\n @memory_store[_key]\n end",
"def store identifier, object\n @storage.shift if @storage.size >= @size_limit\n @storage[identifier] = object\n end",
"def add_key_data(key_data_); end",
"def store(sender)\n raise ShadowHashError.new(ShadowHashError::UNSUPPORTED_OBJECT_ERR) unless sender.is_a? MacAdmin::User\n @data = { @label => convert_to_blob(@hash) }.to_plist\n sender['ShadowHashData'] = [@data]\n end",
"def add(host, key)\n File.open(source, \"a\") do |file|\n blob = [Net::SSH::Buffer.from(:key, key).to_s].pack(\"m*\").gsub(/\\s/, \"\")\n file.puts \"#{host} #{key.ssh_type} #{blob}\"\n end\n end",
"def persist(key)\n node_for(key).persist(key)\n end",
"def []=(key,value)\n doozer_pool.with_connection do |doozer|\n doozer[full_key(key)] = @serializer.serialize(value)\n end\n end",
"def []=(key, value)\n @data[key] = value\n\n save if autosave?\n end",
"def store(key, value)\n value = apply_store_hook(key, value)\n key = aliases[key] || key\n super(key, value) unless @frozen_keys.include?(key)\n end",
"def persist(key)\n send_command([:persist, key], &Boolify)\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 add(key)\n @internal_hash[key] = true\n end",
"def import_by_using_cached_keys\n CommitKeyCreator.update_key_associations @blob.keys.to_a, @commit\n end",
"def save(data)\n\t\t\tredis.sadd(key, data)\n\t\tend",
"def load(key)\n #Open the persistent store read-only, and return the value under the given key.\n value = nil\n storage.transaction(true) {value = storage[key]}\n fail \"'#{key}' not found in storage.\" if value == nil\n value\n end",
"def write_key(*key); end",
"def redis_save(src, dst, eta)\n @redis.set redis_key(src, dst), eta\n end",
"def write(key, content)\n temp_file = File.join(root, ['tmp', $$, Thread.current.unique_id].join('-'))\n File.open(temp_file, 'wb') do |dest|\n if content.respond_to? :to_str\n dest.write(content.to_str)\n else\n content.each {|s| dest.write(s) }\n end\n end\n\n path = cache_path(key)\n if File.exist?(path)\n File.unlink temp_file\n else\n FileUtils.mkdir_p File.dirname(path), :mode => 0755\n FileUtils.mv temp_file, path\n end\n true\n rescue\n File.unlink temp_file rescue false\n false\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 save( oid, metadata )\n\t\toid = normalize_oid( oid )\n\t\t@storage[ oid ] = metadata.dup\n\tend",
"def write(key, content)\n bucket.objects[key].write(content)\n end",
"def []=(key, value)\n @store[key] = value\n end",
"def []=(key, value)\n @lock.synchronize { @store[key] = value }\n end",
"def save_hashes_for_write\n \n end",
"def buffer=(buffer)\n @buffer = buffer\n return unless buffer?\n self.name = buffer.original_filename\n self.unique_key = genkey()\n end",
"def save\n return if @blob.data == content\n repository.store(self, commit_message)\n end",
"def set(key, value)\n path = File.join(@root, \"#{key}.cache\")\n\n # Ensure directory exists\n FileUtils.mkdir_p File.dirname(path)\n\n # Check if cache exists before writing\n exists = File.exist?(path)\n\n # Serialize value\n marshaled = Marshal.dump(value)\n\n # Compress if larger than 4KB\n if marshaled.bytesize > 4 * 1024\n deflater = Zlib::Deflate.new(\n Zlib::BEST_COMPRESSION,\n Zlib::MAX_WBITS,\n Zlib::MAX_MEM_LEVEL,\n Zlib::DEFAULT_STRATEGY\n )\n deflater << marshaled\n raw = deflater.finish\n else\n raw = marshaled\n end\n\n # Write data\n PathUtils.atomic_write(path) do |f|\n f.write(raw)\n @size = size + f.size unless exists\n end\n\n # GC if necessary\n gc! if size > @max_size\n\n value\n end",
"def save(attrs)\n sha = git.set(:blob, JSON.generate(attrs))\n cache[sha] = attrs\n sha\n end"
] |
[
"0.6259867",
"0.61232007",
"0.61055636",
"0.61055636",
"0.61033887",
"0.60126525",
"0.5987791",
"0.5929911",
"0.5909976",
"0.58571386",
"0.58549505",
"0.5834682",
"0.5834682",
"0.570967",
"0.5664677",
"0.5619842",
"0.5606173",
"0.55977577",
"0.559244",
"0.5567842",
"0.5550051",
"0.5547017",
"0.5538463",
"0.55238837",
"0.5482425",
"0.5482236",
"0.54689467",
"0.5464355",
"0.5462511",
"0.54581034",
"0.5452329",
"0.5452329",
"0.5426135",
"0.5423699",
"0.5423517",
"0.5414325",
"0.5404002",
"0.5399019",
"0.5396163",
"0.5370217",
"0.53673524",
"0.5353345",
"0.53515995",
"0.5344942",
"0.5333471",
"0.53332967",
"0.5327032",
"0.532484",
"0.5316226",
"0.5313721",
"0.5301056",
"0.5294339",
"0.5285719",
"0.52853596",
"0.5284836",
"0.5273662",
"0.527285",
"0.52699566",
"0.5244462",
"0.52419764",
"0.5241212",
"0.5241212",
"0.52376544",
"0.5226434",
"0.5225422",
"0.5218875",
"0.52178484",
"0.52069354",
"0.52038366",
"0.5198456",
"0.519749",
"0.5190154",
"0.51568943",
"0.5145569",
"0.51418364",
"0.5141667",
"0.5130253",
"0.5125277",
"0.5123511",
"0.51214355",
"0.5121343",
"0.511714",
"0.510861",
"0.510542",
"0.51027447",
"0.5092427",
"0.50902706",
"0.50901145",
"0.5085711",
"0.5079469",
"0.5075441",
"0.5069632",
"0.50693375",
"0.5067204",
"0.50658154",
"0.5062869",
"0.50594544",
"0.5054612",
"0.5052676",
"0.5051814",
"0.5047487"
] |
0.0
|
-1
|
Initialize a new `Computation` and register it with the proxy
|
def initialize(handler: nil, proxy_host: nil, proxy_port: nil)
self.handler = handler
self.proxy_host = proxy_host
self.proxy_port = proxy_port
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new(*constructor_args)\n @proxy.new do |*call_args|\n @worker.new(constructor_args, @job, &@block).call(call_args, @context)\n end\n end",
"def initialize(computation)\n self.computation = computation\n self.transaction = ::Concord::Thrift::ComputationTx.new\n self.transaction.records = []\n self.transaction.timers = {}\n end",
"def future(&computation)\n Lazy::Future.new(&computation)\n end",
"def when_ready(trace_name = nil, &block)\n result_proxy = AsyncProxy::ComputedProxy.new(self, block, trace_name)\n register_callback {result_proxy.launch_computation}\n result_proxy\n end",
"def initialize\n @conf = BeEF::Core::Configuration.instance\n @proxy_server = TCPServer.new(@conf.get('beef.extension.proxy.address'), @conf.get('beef.extension.proxy.port'))\n\n loop do\n proxy = @proxy_server.accept\n Thread.new proxy, &method(:handle_request)\n end\n end",
"def initialize(executor = nil)\n @state = PENDING\n @subscribers = []\n @value = nil\n\n executor.call(method(:fulfill), method(:reject)) if executor\n end",
"def initialize\n # delegates effect instances.\n @eff = OpenStruct.new(\n async: Ruff.instance,\n yield: Ruff.instance,\n await: Ruff.instance\n )\n\n # is a proc queue.\n @q = Util::FnStack.new\n end",
"def start\n super\n start_proxy\n end",
"def initialize(*args, &block)\n @observing_procs = {}\n super(*args, &block)\n end",
"def register!(container, realtime_calls_adapter: nil)\n instance = self.new(container)\n container.register(:dependency_graph, instance)\n end",
"def initialize(*)\n super\n @predicate = Function.optimize_operand(operation.predicate)\n end",
"def operation\n @op_notifier = Notifier.new\n Operation.new(self)\n end",
"def proxy\n @proxy ||= Proxy.new self\n end",
"def register(*args)\n worker = attempt(*args)\n @initial << [args, worker]\n end",
"def proxy; self end",
"def compute!\n @invalidated = false\n\n unless @stopped\n\n @computing = true\n run_in do\n if @computation.arity > 0\n # Pass in the Computation so it can be canceled from within\n @computation.call(self)\n else\n @computation.call\n end\n end\n @computing = false\n end\n end",
"def circuit_proxy(storage, options)\n CircuitProxy.new(storage, circuit: options.circuit, notifier: options.notifier)\n end",
"def initialize\n @worker = Fetcher::Worker.new\n end",
"def initialize\n @worker = Fetcher::Worker.new\n end",
"def initialize(service, connection, protocol)\n @service = service\n @connection = connection\n @protocol = protocol\n # define RPC proxy methods on this instance\n extract_rpcs(service).each do |rpc|\n define_singleton_method(rpc) { |*rpc_args| post_rpc(rpc, *rpc_args) }\n end\n end",
"def deferred(name, &impl) # :yields:\n impl_name = Container.impl_method_name(name)\n define_implementation(impl_name, impl)\n \n proxy_name = Container.impl_method_name(\"#{name}_proxy\")\n\n ivname = Container.iv(name)\n proxy_ivname = Container.iv(\"#{name}_proxy\")\n \n define_method(name) do\n instance_variable_get(ivname) || send(proxy_name)\n end\n \n define_method(proxy_name) do\n proxy = instance_variable_get(proxy_ivname)\n \n unless proxy\n proxy = proc {instance_variable_set(ivname, send(impl_name))}\n def proxy.method_missing(*args, &block)\n call.__send__(*args, &block)\n end\n instance_variable_set(proxy_ivname, proxy)\n class << proxy; self; end.class_eval do\n (proxy.methods - PROXY_METHODS).each do |m|\n undef_method m\n end\n end\n end\n\n proxy\n end\n end",
"def initialize(callable)\n @callable = callable\n freeze\n end",
"def [](object)\n if running?\n load_features\n MethodProxy.new object, @proxy\n else\n raise NotRunning\n end\n 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 initialize(*)\n super\n @operand = optimize_operand\n end",
"def use(proxy, options = {}, &block)\n proxy = Moneta.const_get(proxy) if Symbol === proxy\n raise ArgumentError, 'You must give a Class or a Symbol' unless Class === proxy\n @proxies.unshift [proxy, options, block]\n nil\n end",
"def use(proxy, options = {}, &block)\n proxy = Moneta.const_get(proxy) if Symbol === proxy\n raise ArgumentError, 'You must give a Class or a Symbol' unless Class === proxy\n @proxies.unshift [proxy, options, block]\n nil\n end",
"def initialize(proxy_queue)\n @proxy_queue = proxy_queue\n @current_proxy_index = 0\n self.get_next\n end",
"def proxy; end",
"def proxy; end",
"def proxy; end",
"def perform(work, derivative_type)\n OnDemandDerivativeCreator.new(work, derivative_type: derivative_type).attach_derivative!\n end",
"def connect_through_proxy; end",
"def initialize\n @proxy_map = {}\n initialize_model\n end",
"def initialize(...)\n @metrics = {}\n register(...)\n end",
"def initialize(inputs, calculation, calculators: default_calculators)\n calculation.reset_messages\n self.inputs = inputs\n calculation.merge_inputs(inputs)\n self.calculation = calculation\n self.calculators = calculators\n end",
"def create_proxy ref\n proxy_class = @known_proxies[ref._remote_class_name]\n return ref unless proxy_class\n proxy_class.new(ReferenceCreationData.new(ref))\n end",
"def proxy meth\n Proxy.new self, meth\n end",
"def method_missing(method, *args, &block)\n self.class.define_proxy method\n send(method, *args, &block)\n end",
"def initialize(env)\n @env = env\n @params = _compute_params\n freeze\n end",
"def initialize(expression, scope, memoized = true)\n @expression = expression\n @scope = scope\n @memoized = !!memoized\n end",
"def proxy_start\n $proxy = Ritm::Proxy::Launcher.new\n $proxy.start\nend",
"def init\n ctx = ComputationContext.new(self)\n log_failure do\n handler.init(ctx)\n end\n ctx.transaction\n end",
"def lazy\n Fetcher.new(self).lazy\n end",
"def executor!\n @executor = true\n end",
"def executor!\n @executor = true\n end",
"def executor!\n @executor = true\n end",
"def initialize(env)\n @env = env\n super(_compute_params)\n # freeze\n end",
"def register_proxy(proxy)\n @proxy_map[proxy.name] = proxy\n proxy.on_register\n end",
"def new\n @eval = Eval.new\n respond_with(@eval)\n end",
"def proxy # :nodoc:\n return const_get('Proxy', false) if const_defined?('Proxy', false)\n\n const_set('Proxy', Module.new).tap { |proxy| prepend proxy }\n end",
"def initialize\n\t\t@calculator = []\n\tend",
"def initialize(cache)\n @cache = cache\n @connector = ServiceConnector.new\n @rule_poller = RulePoller.new cache: @cache, connector: @connector\n @rule_poller_elapsed = 0\n end",
"def initialize\n initialize_without_gc\n @gc_every_n_examples = 0\n end",
"def call(interpreter, arguments)\n instance = LoxInstance.new self\n initializer = find_method \"init\"\n\n unless initializer.nil?\n initializer.bind(instance).call(interpreter, arguments)\n end\n\n instance\n end",
"def initialize(*arguments)\n @arguments = arguments\n @operations = []\n end",
"def initialize(options={})\n # Ensure http_proxy env vars are used if no proxy explicitly supplied.\n @options = options\n @http_proxy =\n case @options[:http_proxy]\n when :no_proxy\n false\n when nil\n true\n else\n @options[:http_proxy].to_str\n end\n @fetcher_class = CachedFetcher\n end",
"def define_proxy_class\n @proxy_class = Class.new Assembler::ProxyBase\n target.const_set :Proxy, @proxy_class\n \n @proxy_class.const_set :Abi, @abi\n @proxy_class.const_set :Isa, @isa\n \n # Capture the ISA and ABI in the closure.\n isa = @isa\n proxy_defines = Proc.new do\n isa.instance_methods.each do |method|\n if method[0, 5] == 'emit_'\n isa_method_msg = method.to_sym\n proxy_method_name = method[5, method.length].to_sym\n define_method proxy_method_name do |*args|\n emit_data = isa.send isa_method_msg, *args\n @assembler.emit_bytes proxy_method_name, emit_data\n end\n end\n end\n end\n @proxy_class.class_eval(&proxy_defines)\n (class << @proxy_class; self; end).module_eval(&proxy_defines) \n end",
"def method_missing(meth, *args)\n if @target.respond_to? meth, true # The second `true` argument checks private methods.\n # Create an instance of the job through the proxy and \n # configure it with the options given to the proxy.\n @block.call configure @target.build_job(meth, *args)\n else\n super\n end\n end",
"def setup_proxy(object, transaction)\n\t super(object, transaction)\n\n @poll_handlers.clear\n @execute_handlers.clear\n\n\t @arguments = Roby::TaskArguments.new(self)\n\t object.arguments.each do |key, value|\n\t\tif value.kind_of?(Roby::PlanObject)\n\t\t arguments.update!(key, transaction[value])\n\t\telse\n\t\t arguments.update!(key, value)\n\t\tend\n\t end\n\n each_event do |ev|\n transaction.setup_and_register_proxy(ev, object.event(ev.symbol))\n end\n\tend",
"def proxy\n manager_instance(ProxyManager)\n end",
"def initialize(getter, setter=nil, scope=nil)\n @reactive_manager = ::ReactiveManager.new(getter, setter, scope)\n end",
"def perform(*args)\n new(*args).call\n end",
"def compile\n @instance ||= new\n end",
"def execution_context\n initialize_context!(Object.new)\n end",
"def _initialize(p)\n @store = p.store\n @_id = p.id\n @store._register_in_memory(self, @_id)\n ObjectSpace.define_finalizer(\n self, ObjectBase._finalize(@store, @_id, object_id))\n @_stash_map = nil\n # Allocate a proxy object for this object. User code should only operate\n # on this proxy, never on self.\n @myself = POXReference.new(@store, @_id)\n end",
"def register(&prc)\n @eff.perform prc\n end",
"def method_missing (method, *args, &block)\n __proxy_result__.send(method, *args, &block)\n end",
"def initialize\n # These require statements are intentionally placed here to initialize\n # the gRPC module only when it's required.\n # See https://github.com/googleapis/toolkit/issues/446\n require \"gapic/grpc\"\n require \"google/ads/google_ads/v3/services/mutate_job_service_services_pb\"\n\n # Create the configuration object\n @config = Configuration.new Client.configure\n\n # Yield the configuration if needed\n yield @config if block_given?\n\n # Create credentials\n credentials = @config.credentials\n credentials ||= Credentials.default scope: @config.scope\n if credentials.is_a?(String) || credentials.is_a?(Hash)\n credentials = Credentials.new credentials, scope: @config.scope\n end\n @quota_project_id = @config.quota_project\n @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id\n\n @operations_client = Operations.new do |config|\n config.credentials = credentials\n config.endpoint = @config.endpoint\n end\n\n @mutate_job_service_stub = ::Gapic::ServiceStub.new(\n ::Google::Ads::GoogleAds::V3::Services::MutateJobService::Stub,\n credentials: credentials,\n endpoint: @config.endpoint,\n channel_args: @config.channel_args,\n interceptors: @config.interceptors\n )\n end",
"def proxy real_cls, constructor_args\n @real_cls = real_cls\n @constructor_args = constructor_args\n end",
"def initialize(generator)\n @generator = Fiber.new { generator.call; nil }\n end",
"def initialize(proxy_addr, proxy_port)\n timeout = ProxyFetcher.config.proxy_validation_timeout\n\n @http = HTTP.follow.via(proxy_addr, proxy_port.to_i).timeout(connect: timeout, read: timeout)\n end",
"def fetch\n requests = instantiate_modules.select(&:fetch?).map(&:requests).flatten\n\n total, done = requests.size, 0\n update_progress(total, done)\n\n before_fetch\n\n backend.new(requests).run do\n update_progress(total, done += 1)\n end\n\n after_fetch\n\n true\n rescue => e\n error(e)\n raise e\n end",
"def initialize(change)\n @change = change\n @steps = []\n @notifications = []\n initialize_persistent_state(change.workflow_cache)\n @proxy = WorkflowProxy.new(self)\n\n # We're using pessimistic locking here, so this will block until an\n # exclusive lock can be obtained on the change.\n @change.with_lock do\n catch :exit do\n if @entry_points.empty?\n send(:__start_workflow)\n else\n # TODO: This should fail silently if an entry point is no longer\n # defined, this will allow for modification of the workflows with\n # existing changes in the DB.\n @entry_points.each { |ep| send(ep) }\n end\n end\n persist_state!\n end\n end",
"def proxy\n @proxy\n end",
"def initialize(worker)\n @worker = worker\n end",
"def initialize(dependency, requester)\n @dependency = dependency\n @requester = requester\n end",
"def pre_run_initialize\n @evaluator = @evaluator_class.new(self) if @evaluator.nil?\n @evolver = @evolver_class.new(self) if @evolver.nil?\n end",
"def initialize\n @tasks = []\n @futures = nil\n end",
"def call\n __proxied_call\n end",
"def http_proxy=(_arg0); end",
"def method_missing(method, *args, &block)\n __proxy_result__.send(method, *args, &block)\n end",
"def map_proxy_state\n super\n end",
"def initialize(spec)\n super()\n\n @spec = spec\n\n @checkout_timeout = ( spec.config[:checkout_timeout] ||\n spec.config[:wait_timeout] || 5.0 ).to_f # <= 3.2 supports wait_timeout\n @reaper = Reaper.new self, spec.config[:reaping_frequency]\n @reaping = !! @reaper.run\n\n # default max pool size to 5\n if spec.config[:pool]\n @size = spec.config[:pool].to_i\n else\n if defined? Rails.env && ( (! Rails.env.development? && ! Rails.env.test?) rescue nil )\n logger && logger.debug(\"pool: option not set, using default size: 5\")\n end\n @size = 5\n end\n\n # The cache of reserved connections mapped to threads\n @reserved_connections = ThreadSafe::Map.new(:initial_capacity => @size)\n\n @connections = []\n @automatic_reconnect = true\n\n @available = Queue.new self\n\n initial_size = spec.config[:pool_initial] || 0\n initial_size = @size if initial_size == true\n initial_size = (@size * initial_size).to_i if initial_size <= 1.0\n # NOTE: warn on onitial_size > size !\n prefill_initial_connections if ( @initial_size = initial_size.to_i ) > 0\n\n if frequency = spec.config[:validate_frequency]\n require 'active_record/bogacs/validator' unless self.class.const_defined?(:Validator)\n @validator = Validator.new self, frequency, spec.config[:validate_timeout]\n if @validator.run && @reaping\n logger && logger.info(\"pool: validator configured alongside with reaper\")\n end\n end\n end",
"def initialize\n @_calls = []\n end",
"def set_calculator\n Rails.logger.info \"set_calculator\"\n @calculator = Calculator.new(calculator_params)\n end",
"def initialize(url, path)\n memoize [:fetch]\n @store ||= fetch(url, path)\n end",
"def using_proxy?; end",
"def build_wrapper\n @impl\n end",
"def __proxy_result__\n @proxy_result = @method_call.call unless defined?(@proxy_result)\n @proxy_result\n end",
"def initialize check_performance: false\n @instructions = []\n @labels = {}\n @check_performance = check_performance\n @performance_warnings = []\n # A set of temp registers recorded as we see them (not at allocation time)\n @temp_registers = Set.new\n yield self if block_given?\n end",
"def initialize(jump_proxies)\n @jump_proxies = jump_proxies\n end",
"def initialize\n # These require statements are intentionally placed here to initialize\n # the gRPC module only when it's required.\n # See https://github.com/googleapis/toolkit/issues/446\n require \"gapic/grpc\"\n require \"google/cloud/dataproc/v1beta2/jobs_services_pb\"\n\n # Create the configuration object\n @config = Configuration.new Client.configure\n\n # Yield the configuration if needed\n yield @config if block_given?\n\n # Create credentials\n credentials = @config.credentials\n # Use self-signed JWT if the endpoint is unchanged from default,\n # but only if the default endpoint does not have a region prefix.\n enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&\n [email protected](\".\").first.include?(\"-\")\n credentials ||= Credentials.default scope: @config.scope,\n enable_self_signed_jwt: enable_self_signed_jwt\n if credentials.is_a?(::String) || credentials.is_a?(::Hash)\n credentials = Credentials.new credentials, scope: @config.scope\n end\n @quota_project_id = @config.quota_project\n @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id\n\n @operations_client = Operations.new do |config|\n config.credentials = credentials\n config.endpoint = @config.endpoint\n end\n\n @job_controller_stub = ::Gapic::ServiceStub.new(\n ::Google::Cloud::Dataproc::V1beta2::JobController::Stub,\n credentials: credentials,\n endpoint: @config.endpoint,\n channel_args: @config.channel_args,\n interceptors: @config.interceptors\n )\n end",
"def initialize(ip, secret)\n @ip = ip\n @secret = secret\n \n @conn = SOAP::RPC::Driver.new(\"https://#{@ip}:17443\")\n @conn.add_method(\"neptune_start_job\", \"job_data\", \"secret\")\n @conn.add_method(\"neptune_put_input\", \"job_data\", \"secret\")\n @conn.add_method(\"neptune_get_output\", \"job_data\", \"secret\")\n @conn.add_method(\"neptune_get_acl\", \"job_data\", \"secret\")\n @conn.add_method(\"neptune_set_acl\", \"job_data\", \"secret\")\n @conn.add_method(\"neptune_compile_code\", \"job_data\", \"secret\")\n end",
"def register!(container)\n instance = self.new(container)\n container.register(:dependency_graph, instance)\n end",
"def exec_in_proxy_context(dsl, proxy_type, *args, **_arg3, &block); end",
"def init_counters\n calculate_ratio_sum\n calculate_proxies_needed\n end",
"def initialize\n @connector=ConnectionManager.instance\n @connector.add_observer(self)\n end",
"def initialize(prefork:)\n @prefork = prefork\n @workers = {}\n @reapers = 0\n @reexec = false\n end",
"def call!(*args)\n new(*args).call!\n end",
"def run_in\n previous = Computation.current\n Computation.current = self\n begin\n yield\n ensure\n Computation.current = previous\n end\n\n self\n end"
] |
[
"0.612914",
"0.6006112",
"0.58804315",
"0.55033314",
"0.53794134",
"0.5330355",
"0.52628416",
"0.5190672",
"0.5173242",
"0.51452124",
"0.5121439",
"0.5121163",
"0.51166016",
"0.5113001",
"0.51019245",
"0.50968313",
"0.50710595",
"0.5068734",
"0.5068734",
"0.506155",
"0.5055277",
"0.50343096",
"0.50063497",
"0.50019866",
"0.4990009",
"0.49573487",
"0.49573487",
"0.49453872",
"0.49205485",
"0.49205485",
"0.49205485",
"0.49135953",
"0.49103445",
"0.4898896",
"0.48927322",
"0.4892606",
"0.4892165",
"0.48908335",
"0.48907125",
"0.4884153",
"0.48793757",
"0.48631692",
"0.48461062",
"0.48388174",
"0.48370844",
"0.48370844",
"0.48370844",
"0.48335394",
"0.48327312",
"0.48310983",
"0.48063445",
"0.47890356",
"0.47883946",
"0.47878882",
"0.47820464",
"0.47810128",
"0.47808278",
"0.47570124",
"0.4755364",
"0.47551724",
"0.47547257",
"0.47527963",
"0.47524545",
"0.4752035",
"0.47461563",
"0.4745357",
"0.4744715",
"0.4737712",
"0.47339192",
"0.47255006",
"0.47220165",
"0.47214922",
"0.47174528",
"0.47158638",
"0.47154295",
"0.4706725",
"0.47056404",
"0.47039327",
"0.4703548",
"0.46986064",
"0.46944103",
"0.4692018",
"0.46902105",
"0.46879143",
"0.46745262",
"0.46701184",
"0.46697882",
"0.46623093",
"0.46616507",
"0.4656938",
"0.4655702",
"0.4655499",
"0.4650924",
"0.4644896",
"0.46421295",
"0.46306902",
"0.46268833",
"0.46167663",
"0.4616034",
"0.46137345",
"0.46127456"
] |
0.0
|
-1
|
Process records from upstream. Wraps the user method in transactions, which are returned to the proxy upon completion.
|
def boltProcessRecords(records)
txs = []
records.each do |record|
ctx = ComputationContext.new(self)
log_failure do
handler.process_record(ctx, record)
end
txs.push(ctx.transaction)
end
txs
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def process *args, &block\n raise \"override the process method in your implementation: it should process each record.\"\n end",
"def process_with_payu\n process_purchase\n end",
"def process_transaction(trans, volume = trans.volume)\n # Fetch Portfolio of involved parties (buyer and seller)\n return false if !transaction_arg_check(trans.transaction_type, trans.stock.code, volume, trans.price) || !oddlot?(volume, trans)\n\n # Check if User-Stock relation already exist, create it it does not yet exists\n stocks << trans.stock unless BuyersStock.exists?(id, trans.stock.id)\n seller_stock = BuyersStock.exists?(trans.user.id, trans.stock.id) ? BuyersStock.find_entry(id, trans.stock.id) : BuyersStock.create(user_id: trans.user.id, stock_id: trans.stock.id, volume: 0, alloted_volume: 0)\n buyer_stock = BuyersStock.find_entry(id, trans.stock.id)\n # Actual Process transaction\n return false unless process(volume, trans, buyer_stock, seller_stock)\n\n # Set fulfilled original transaction\n trans.fulfilled = true\n # Save and check if there is an error in updating the involved models (buyer,seller, and respective user-stock relationship)\n if save\n ActiveRecord::Base.transaction do\n buyer_stock.save\n trans.user.save\n seller_stock.save\n trans.save\n Transaction.create(user_id: id, stock_id: trans.stock_id, volume: volume, transaction_type: trans.opposite_type, fulfilled: true, price: trans.price)\n logger.info 'Successful Transaction'\n return true\n end\n else\n logger.info 'Something went wrong'\n false\n end\n end",
"def process_batch(records)\n benchmarks[:processing] << Benchmark.realtime do\n records.each do |record|\n next if skip_before_transform?(record)\n invoke_callback(:before_each, record)\n attrs = transformer.run(record)\n next unless attrs # skip if transformation failed\n invoke_callback(:each_before_save, attrs, record)\n next if invoke_callback(:reject_after_transform_if, attrs)\n invoke_callback(:after_each, record, attrs)\n attrs = data_scrubber.scrub!(attrs)\n \n if update?(record, attrs)\n update_attrs << attrs\n elsif create_new_records\n new_rows << attrs.values\n end\n end\n end\n end",
"def process_payments!\n ret = payments.each(&:process!)\n end",
"def call\n db.transaction do\n _call_in_transaction\n end\n end",
"def process_transaction(client)\n \n # for data analysis, we track the start time of this transaction\n start_time = Time.now()\n\n request = form_request(client)\n if request.nil?\n MixPanel.track(\"Request Unsupported\", properties = {\n \"token\"=>$MIXPANEL_API_TOKEN,\n \"Event Time\"=>Time.now\n })\n client.print(\"I'm sorry, this proxy does not support that request type.\\n\") \n return 0\n end\n\n # make the request and store response\n # If the request is a GET request, we will search and update the cache.\n if request.request_type.eql?(\"GET\") && cached_entry = $CACHE.retrieve(request.url)\n response = cached_entry\n client.print(response)\n\n end_time = Time.now()\n MixPanel.track(\"Cached Request Processed\", properties = {\n \"token\"=>$MIXPANEL_API_TOKEN, \n \"Event Time\"=>Time.now, \n \"Url\"=>request.url, \n \"Process Time\"=>start_time - end_time, \n \"Request Type\"=>request.request_type\n })\n else\n response = make_request_and_respond(request, client)\n $CACHE.update(request.url, response, Time.now()) if request.request_type.eql?(\"GET\")\n \n end_time = Time.now()\n MixPanel.track(\"Uncached Request Processed\", properties = {\n \"token\"=>$MIXPANEL_API_TOKEN, \n \"Event Time\"=>Time.now, \n \"Url\"=>request.url, \n \"Process Time\"=>start_time - end_time, \n \"Request Type\"=>request.request_type\n })\n end\nend",
"def perform!\n run_callbacks(:before_perform, self)\n self.class.upcoming_mailings\n .in_batches(of: self.class.batch_size)\n .each do |batch|\n run_callbacks(:on_perform, self, batch)\n batch.each(&:process!)\n end\n run_callbacks(:after_perform, self)\n nil\n end",
"def process\n save_as(:processing)\n perform_checks\n initiate_delivery\n capture_payment\n save_as(:processed)\n end",
"def processTransaction\t\t\n\t\t# retrieve the requests with data in form\n\t\ttransaction_request = @request[:transaction] \t\t\n\t\t# store transaction num, we'll use it later to see if there was a transaction or not\n\t\ttransaction_num = transaction_request[:transactionNum]\n\t\t# fetch the operations\n\t\toperations = transaction_request[:operations]\n\t\t\n\t\t# response list\n\t\tres_list = Array.new\t\t\t\n\t\t# transaction progress\n\t\[email protected] do \t\t\t\t\t\t\t\t\t\n\t\t\tbegin\t\t\t\t\n\t\t\t\toperations.each do |op|\t \n\t\t\t\t\t# parase advanced criterias, if any\n\t\t\t\t\tadvanced_criteria = parse_advanced_criterias(op)\n\t\t\t\t\t \n\t\t\t\t\treq = DSRequest.new(op, @model) \t\t\t\t\t\n\t\t\t\t\tunless advanced_criteria == nil\n\t\t\t\t\t\treq.advancedCriteria = advanced_criteria\n\t\t\t\t\tend \n\t\t\t\t\t# execute the request and get the response\n\t\t\t\t\tres = req.execute\t\t\t\t\t\t\t \n\t\t\t\t\tif res == nil\n\t\t\t\t\t\tres = DSResponse.new\n\t\t\t\t\t\tres.status = -1\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t# store the response for later\n\t\t\t\t\tres_list << res\t \t\t\t\t\t\n\t\t\t\tend\t\t\t\n\t\t\trescue ActiveRecord::RecordInvalid\n\t\t\t\t# if it occurs exception\n\t\t\t\traise ActiveRecord::Rollback\n\t\t\tend\n\t\tend\n\t\t\n\t\t# if we have only one object, send directly the DSResponse\n\t\tif transaction_num == -1\n\t\t\tresponse = DSResponse.new\n\t\t\tresponse.data = res_list[0].data\n\t\t\tresponse.startRow = res_list[0].startRow\n\t\t\tresponse.endRow = res_list[0].endRow\n\t\t\tresponse.totalRow = res_list[0].totalRow\n\t\t\tresponse.status = res_list[0].status\n\t\t\t\n\t\t\treturn response\n\t\tend\n\t\t\n\t\t# iterate over the responses and create a instance of an anonymous class which mimics the required json\n\t\tresponses = Array.new\n\t\t\n\t\tres_list.each do | response |\t\t\t\n\t\t\tres = DSResponse.new\n\t\t\tres.data = response.data\t\t\t\n\t\t\tres.startRow = response.startRow\n\t\t\tres.endRow = response.endRow\n\t\t\tres.totalRow = response.totalRow\n\t\t\tres.status = response.status\t\t\t\n\t\t\tresponses << res\n\t\tend \n\t\treturn responses\n\tend",
"def delegate( txn, chain, *args )\n\t\tyield( chain )\n\tend",
"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 commit_transaction\n\t super\n\t \n\t # Update the task arguments. The original\n\t # Roby::Task#commit_transaction has already translated the proxy\n\t # objects into real objects\n\t arguments.each do |key, value|\n\t\t__getobj__.arguments.update!(key, value)\n\t end\n\n execute_handlers.each do |h|\n __getobj__.execute(h.as_options, &h.block)\n end\n poll_handlers.each do |h|\n __getobj__.poll(h.as_options, &h.block)\n end\n\n __getobj__.abstract = self.abstract?\n if @fullfilled_model\n __getobj__.fullfilled_model = @fullfilled_model.dup\n end\n __getobj__.do_not_reuse if !@reusable\n\tend",
"def process record\n yield get(self.part, record)\n end",
"def process_transactions\n @transactions.each do |transaction|\n transaction[:events_data].each do |event|\n\n r = validate_event(event)\n next unless r.success?\n\n contract_event_obj = create_contract_event(transaction[:transaction_hash], event)\n next if contract_event_obj.status != GlobalConstant::ContractEvent.recorded_status\n\n process_event(contract_event_obj)\n\n end\n\n end\n\n end",
"def process_on_mangopay\n case self.transaction_type.to_sym\n when :preauth\n do_preauth\n # dont quite finish, as requires some refreshes until we know that it went through. (all the way to validated)\n when :payin\n do_payin\n when :transfer\n do_transfer\n when :payout\n do_payout\n # dont quite finish, as requires some refreshes until we know that it went through. (all the way to finished)\n when :payin_refund\n # this should create a refund for a specific financial_transaction of transaction_type payin\n do_payin_refund\n else\n LOG.error message: \"Could not handle transaction. Unprocessable transaction_type\", financial_transaction_id: self.id\n self.fail!\n end\n end",
"def _call_in_transaction\n aliquot_updater = UpdateAliquotsHandler.new(db, bus, log, metadata, s2_resource, settings)\n\n begin \n s2_resource[:plates].each do |plate|\n aliquot_updater.send(:update_aliquots, plate) if plate[:plate].size == SupportedPlateSize\n end\n\n db.transaction(:savepoint => true) do\n begin\n date = s2_resource[:plates].first[:date]\n add_asset_links(s2_resource[:transfer_map], date)\n set_transfer_requests(s2_resource[:transfer_map], date)\n rescue PlateNotFoundInSequencescape => e\n log.info(\"The asset_link and the transfer request has not been set: #{e.message}\")\n end\n end\n rescue Sequel::Rollback, PlateNotFoundInSequencescape, UnknownSample => e\n metadata.reject(:requeue => true)\n log.info(\"Error updating plate aliquots in Sequencescape: #{e}\")\n raise Sequel::Rollback\n else\n metadata.ack\n log.info(\"Plate transfer message processed and acknowledged\")\n end\n end",
"def transaction\n start_transaction\n\n yield\n ensure\n end_transaction if transaction_started?\n end",
"def process(record, &emit)\n yield record\n end",
"def process_receipts(_)\n Forwarder::process_receipts!\nend",
"def perform( &block )\r\n @transaction_strategy.perform( &block )\r\n end",
"def transaction(&block); end",
"def call(*args, **kwargs, &block)\n forward(*args, **kwargs, &block)\n end",
"def transaction_import_process(send_transaction)\n readcsv\n check\n save\n send_to_acx if send_transaction\n end",
"def _postprocess(raw_results,callback)\n if raw_results.is_a?(Redis::Future)\n #\n # Redis::Future have a built-in mechanism for calling a\n # transformation on the raw results.\n #\n # Here, we monkey-patch not the Redis::Future class, but just\n # this one raw_results object. We give ourselves a door to\n # set the post-processing transformation.\n #\n # The transformation will be called only once when the real\n # results are materialized.\n #\n class << raw_results\n def transformation=(transformation)\n raise \"transformation collision\" if @transformation\n @transformation = transformation\n end\n end\n raw_results.transformation = callback\n raw_results\n else\n #\n # If not Redis::Future, we invoke the callback immediately.\n #\n callback.call(raw_results)\n end\n end",
"def process(members=@members)\n print_log \"Processing #{members.size} records\"\n members.each { |member|\n print_log \"Enqueueing #{member.name} (#{member.id})\"\n member.enqueue\n }\n end",
"def transaction(&block)\n yield\n end",
"def transaction(&block)\n yield\n end",
"def hook_into_callback_chain(env, aroundware)\n async_callback = env['async.callback']\n\n # The response from the downstream app is accepted by the aroundware...\n downstream_callback = Proc.new do |resp|\n safely(env){ aroundware.call(resp) }\n end\n\n # .. but the upstream chain is only invoked when the aroundware completes\n invoke_upstream_chain = Proc.new do\n new_resp = safely(env){ aroundware.post_process }\n async_callback.call(new_resp)\n end\n\n env['async.callback'] = downstream_callback\n aroundware.callback(&invoke_upstream_chain)\n aroundware.errback(&invoke_upstream_chain)\n end",
"def transaction(model_class)\n raise \"you must override #transaction in an adapter subclass, it must yield\"\n end",
"def within_transaction; end",
"def within_transaction; end",
"def in_transaction(opts = {})\n yield\n end",
"def call\n run_callbacks :after_fetched do\n process\n end\n end",
"def run_upwards\n result = request\n\n bond.applying_migrations.each do |migration|\n result = migration.up(result)\n end\n\n result\n end",
"def perform_transaction()\n transaction_record = {\n 'transaction_id' => transaction_id,\n 'record_code' => '400',\n 'subrecord_code' => '00',\n 'record_sequence_number' => '00',\n 'update_type' => '2',\n 'goods_nomenclature' => {\n 'goods_nomenclature_sid' => '96196',\n 'goods_nomenclature_item_id' => '0305720040',\n 'producline_suffix' => '80',\n 'validity_start_date' => '2012-01-01',\n 'statistical_indicator' => '0'\n }\n }\n\n TaricImporter::RecordProcessor.new(transaction_record, operation_date).process!\n end",
"def perform(record)\n run(record, false)\n end",
"def transaction(&blk)\n tap(&blk)\n end",
"def perform_inner_commit\n @provider.push self\n\n begin\n perform_commit\n rescue => cause\n perform_rollback cause\n end\n\n clear\n stop\n end",
"def delegate( txn, chain, *args )\n\t\t\tself.log.debug \"Delegating to chain: %p\" % [ chain ]\n\n\t\t\twith_authorization( txn, chain ) do\n\t\t\t\tyield( chain )\n\t\t\tend\n\t\tend",
"def transform\n entries.each { |entry| entry.transform user }\n @state = :transformed\n @account_id = nil\n true\n end",
"def call!\n rows.map.with_index do |row, row_num|\n process_entities(row, row_num, &:call!)\n end\n end",
"def perform_transaction()\n transaction_record = {\n 'transaction_id' => transaction_id,\n 'record_code' => '400',\n 'subrecord_code' => '00',\n 'record_sequence_number' => '199',\n 'update_type' => '1',\n 'goods_nomenclature' => {\n 'goods_nomenclature_sid' => '70180',\n 'goods_nomenclature_item_id' => '1604141620',\n 'producline_suffix' => '80',\n 'validity_start_date' => '1998-07-14',\n 'validity_end_date' => '2011-12-31',\n 'statistical_indicator' => '0'\n }\n\n }\n\n TaricImporter::RecordProcessor.new(transaction_record, operation_date).process!\n end",
"def process!\n if valid?\n # get the csv rows as an array of hashes\n setup_data\n raw_csv_data = compute_csv_data\n # remove duplicate rows in the csv file (by email or name)\n prefilterted_csv_data = prefilter_csv_data raw_csv_data\n # remove the rows that match emails in the database\n new_data = filter_data_through_db prefilterted_csv_data\n\n # crate a new users\n resolved_data = create_new_user_records new_data\n end\n @rejected_user_data\n end",
"def do_payin_refresh\n #sanity check\n unless self.payin? &&\n self.processing?\n\n raise \"can not process this transaction with this method from this state\"\n end\n\n begin\n # https://docs.mangopay.com/api-references/pay-out-bank-wire/\n # https://github.com/Mangopay/mangopay2-ruby-sdk/blob/master/lib/mangopay/pay_out.rb\n payin = MangoPay::PayIn.fetch( self.transaction_vid )\n self.update(\n result_code: payin['ResultCode'],\n result_message: payin['ResultMessage'],\n response_body: payin,\n )\n # consider adding more sanity checking, and raise exception if local data does not match with remote?\n\n # update transaction status from mangopay result: (one of: CREATED, SUCCEEDED, FAILED)\n aasm_change_on_status payin['Status']\n rescue => e\n LOG.error message: \"Exception e:#{e} processing transaction\", financial_transaction_id: self.id, mangopay_result: payin\n end\n end",
"def process_upload!\n init_error_report\n\n if fail_on_error?\n handle_save_nothing_on_error\n else\n handle_save_clean_orders\n end\n\n store_error_report if result.failed?\n self.processed_at = Time.zone.now\n save!\n end",
"def execute!\n stack = InternalMiddleware.batch_stack(self)\n format_response(stack.call(middleware_env))\n end",
"def invoke(source, &block)\n if source.parent\n block.()\n else\n ActiveRecord::Base.transaction(&block)\n end\n end",
"def apply_to_transaction(transaction)\n transaction.apply_pattern(self)\n end",
"def execute\n return unless active\n process_outbound_messages\n end",
"def process(record)\n @output << record\n end",
"def transaction\n use do |connection|\n connection.transaction do |conn|\n begin\n yield conn\n rescue Rollback\n return\n end\n end\n end\n end",
"def transaction(&block)\n block.call\n end",
"def process\n if recipient_ids == :all_users\n process_for_all_users\n else\n process_by_recipient_ids\n end\n end",
"def perform!\n super\n transfer!\n cycle!\n end",
"def process\r\n\t\t\tif !@peers_add_queue.empty?\t\t\t \r\n\t\t\t\tpeer = @peers_add_queue.pop\r\n\t\t\t\tswdebug \"Add Peer #{peer.host_id}\"\r\n\t\t\t\tpeers_add(peer)\r\n\t\t\tend\r\n\r\n\t\t\t# Send a message if there is a message in the @outbound queue\r\n\t\t\tobcnt = process_outbound\r\n\r\n\t\t\t# Receive a message if there is a message in the @inbound queue\r\n\t\t\tibcnt = process_inbound\r\n\r\n\t\t\t#@todo - rectify storage versus just knowing the uuid in hive\r\n\r\n\t\t\t# Prune the seen list to max cache amount\r\n\t\t\t# @todo hive.prune_seen\r\n\t\t\t#if @inbound_seen.size > MAX_SEEN\r\n\t\t\t#\t@inbound_seen.shift(@inbound_seen.count - MAX_SEEN)\r\n\t\t\t#end\r\n\r\n\t\t\t# Prune the processed list to max cache amount\r\n\t\t\t# @todo hive.prune_processed\r\n\t\t\t#if @inbound_processed.size > MAX_PROCESSED\r\n\t\t\t#\t@inbound_processed.shift(@inbound_processed.count - MAX_PROCESSED)\r\n\t\t\t#end\r\n\r\n\t\t\treturn (obcnt + ibcnt)\r\n\t\tend",
"def use_transactions; end",
"def use_transactions; end",
"def perform_top_level\n @propagate_exceptions = true\n rv = true\n\n begin\n xact = self\n database.batch do\n xact.instance_eval(&xact.block)\n end\n\n commit\n @database.notify\n rescue Exception => e\n raise e if (not e.kind_of? TransactionRollback) && @propagate_exceptions\n rv = false\n end\n\n rv\n end",
"def txn\n # Do a hard reset on the repository to ensure a clean slate.\n @repo.reset_hard\n # The caller should make changes and commit them.\n yield\n begin\n # Attempt to push to the origin. If an error occurs,\n # pull from the origin and rebase our local changes.\n # Then try to push again.\n @repo.push\n log << \"Database pushed\"\n rescue Config::Core::GitRepo::PushError => e\n @repo.pull_rebase\n log << \"Database pulled to resolve remote changes. Now at: #{version}\"\n # NOTE: We should determine if retries should be slower\n # or if a backoff strategy should be designed.\n retry\n end\n end",
"def call\n rows.map.with_index do |row, row_num|\n process_entities(row, row_num, &:call)\n end\n end",
"def process!\n raise ArgumentError, \"No family assigned\" unless family\n save! if new_record? || changed?\n\n before_num = family.bank_transactions.count\n accounts.each do |account|\n bank_account = bank_account_of(account)\n raise \"Could not find account with #{account.inspect}\" if bank_account.nil?\n account.transactions.each do |txn|\n bank_transaction = family.bank_transactions.find_or_initialize_by_fitid(txn.number)\n bank_transaction.update_attributes!(:bank_account => bank_account,\n :amount => txn.amount.to_s,\n :name => txn.name,\n :memo => txn.memo,\n :import => self,\n :posted_on => txn.timestamp) if bank_transaction.new_record?\n end\n end\n \n family.bank_transactions.count - before_num\n end",
"def transaction\n start_transaction!\n\n result = yield\n\n query 'COMMIT'\n\n result\n rescue\n query 'ROLLBACK'\n raise\n\n ensure\n end_transaction!\n end",
"def commit_transaction\n\t super\n\n\t arguments.dup.each do |key, value|\n if value.respond_to?(:transaction_proxy?) && value.transaction_proxy?\n\t\t arguments.update!(key, value.__getobj__)\n\t\tend\n\t end\n\tend",
"def execute_middleware_chain\n self.process_started_at = Time.now\n\n Cloudenvoy.config.subscriber_middleware.invoke(self) do\n begin\n process(message)\n rescue StandardError => e\n logger.error([e, e.backtrace.join(\"\\n\")].join(\"\\n\"))\n try(:on_error, e)\n raise(e)\n end\n end\n ensure\n self.process_ended_at = Time.now\n end",
"def <<(*records)\n save_records = proxy_owner.persisted?\n\n if records.flatten.all? &:valid?\n records.flatten.each do |record|\n unless include? record\n raise_if_type_mismatch(record)\n add_foreign_key_in_proxy_owner(record.id)\n proxy_target << record\n record.save if save_records\n end\n end\n\n proxy_owner.save if save_records\n\n self\n end\n end",
"def process_updates(table_name, field, rows)\n ActiveRecord::Base.transaction do\n mass_import(rows)\n mass_update(table_name, field)\n end\n end",
"def process\n\t\t\tOrderTicketStatusTracking.transaction do\n\t\t\t\tpreorder= OrderHeader.where(member_id: @member_id).first\n\t\t\t\tif(preorder==nil)\n\t\t\t\t\torder_header=OrderHeader.new\n\t\t\t\t\[email protected]_id\n\t\t\t\t\[email protected]_id\n\t\t\t\t\torder_header.order_date=Time.now\n\t\t\t\t\torder_header.order_time=Time.now.strftime(\"%I:%M:%S\")\n\t\t\t\t\torder_header.table_number=@table_number\n\n\t\t\t\t\torder_header.member_id=@member_id\n\t\t\t\t\torder_header.steward=@steward\n\t\t\t\t\torder_header.waitor=@waitor\n\t\t\t\t\torder_header.facility_code=@facility_code\n\t\t\t\t\torder_header.order_status='O'\n\t\t\t\t\torder_header.save!\n\t\t\t\t\tpreorder=order_header\n\t\t\t\tend\n\t\t\t\tSaveOrderDetail.call(@context,params:@params)\n\t\t\t\tsuccess_obj = Core::ServiceSuccess.new\n\t\t\t\tsuccess_obj.status(200)\n\t\t\t\tsuccess_obj.data({\"msg\": \"Order Inserted\"})\n\t\t\t\tsuccess_obj\n\t\t\tend\n\t\tend",
"def process_gateway_return\n #TODO support multiple gateways - maybe store payment_method_id in session?\n gateway = PaymentMethod.find_by_id_and_type(IdealLite.parse_custom_data(params)[\"payment_method_id\"], \"IdealLite\")\n @order, payment_made = gateway.process_response(params)\n\n if @order && payment_made\n #Payment successfully processed\n @order.payments.clear\n payment = @order.payments.create\n payment.started_processing\n payment.amount = params[:amount] || @order.total\n payment.payment_method = gateway\n payment.complete\n @order.save\n\n #The admin interface for creating an order doesn't actually step through all the different states - it remains\n #on 'cart'. In order to complete, we just need to step through the states (firing events, etc along the way) until\n #the order is \"complete\"\n until @order.completed?\n @order.next!\n end\n\n if @order.state == \"complete\" or @order.completed?\n flash[:notice] = I18n.t(:order_processed_successfully)\n redirect_to admin_order_url(@order)\n else\n redirect_to new_admin_order_payment_path\n end\n elsif @order.nil?\n #Order not passed through correctly\n flash[:error] = I18n.t('external_gateway.gateway_response.admin_order_missing')\n redirect_to new_admin_order_payment_path\n else\n #Error processing payment\n flash[:error] = I18n.t(:payment_processing_failed)\n redirect_to new_admin_order_payment_path and return\n end\n end",
"def perform\n if user = User.for_receipt(receipt)\n receipt.process! && perform_for_user(user)\n else\n receipt.reject!\n end\n\n true\n end",
"def perform\n\n _perform do\n\n sanitize_event_data\n\n create_purchase_log_entry\n\n get_user_from_ethereum\n\n update_purchase_attribute_in_pepo_campaigns\n\n send_purchase_confirmation_email\n\n end\n\n end",
"def with_process_log(record)\n process_log(record.merge(transition: \"start\"))\n result = yield\n process_log(record.merge(transition: \"complete\"))\n return result\n rescue DRb::DRbConnError\n yield\n end",
"def process_payments!\n if group_buy\n process_payments_with(:authorize!)\n else\n process_payments_with(:purchase!)\n end\n end",
"def finish_request\n if transactional?\n if response.code < 400\n @connection.commit_db_transaction\n else\n @connection.rollback_db_transaction\n end\n ActiveRecord::Base.clear_active_connections!\n end\n super\n end",
"def forward; end",
"def forward; end",
"def within_transaction(object); end",
"def perform\n\n begin\n\n while true\n set_data_for_current_iteration\n\n get_block_transactions\n\n r = validate_response\n return r unless r.success?\n\n if blocks_trail_count >= MIN_BLOCK_DIFFERENCE\n\n process_transactions\n\n update_last_processed_block_number\n\n verify_token_count if blocks_trail_count == MIN_BLOCK_DIFFERENCE\n\n end\n\n return if blocks_trail_count <= MIN_BLOCK_DIFFERENCE\n return if GlobalConstant::SignalHandling.sigint_received?\n end\n\n rescue StandardError => e\n puts e.inspect\n Rails.logger.error(e)\n return\n end\n\n end",
"def capture\n begin \n Order.transaction do\n # lock order\n Order.find_by_id(self.id, :lock => true)\n # go through all order_payments\n order_payments = self.order_payments\n if order_payments.size == 0\n p \"No order_payments to process.\"\n raise PaymentError, \"No order_payments to process.\"\n end\n for order_payment in order_payments\n order_payment.capture!\n end\n self.upgrade_coupons!\n # update order\n self.update_attributes!(:state => Order::PAID, :paid_at => Time.zone.now)\n end\n # send confirmation email\n user = User.find_by_id(self.user_id)\n if user and user.send_confirmation(self.deal_id)\n return true\n else\n logger.error \"Order.capture: Confirmation email failed to send: #{self.inspect}\"\n return false\n end\n rescue PaymentError => pe\n p \"Order.capture: Failed for Order #{self.inspect} #{pe}\"\n logger.error \"Order.capture: Failed for Order #{self.inspect} #{pe}\"\n rescue ActiveRecord::RecordInvalid => invalid\n p \"Order.capture: Failed for Order #{self.inspect} #{invalid}\"\n logger.error \"Order.capture: Failed for Order #{self.inspect} #{invalid}\"\n end\n return false\n end",
"def run\n start_time = Time.now\n\n setup\n\n importer_run.update_attributes( started_at: start_time,\n source_model: source_model.name,\n destination_model: destination_model.name,\n importer_version: VERSION )\n\n # get a total count of records to process, bail out if none are found\n count = base_query(false).count\n\n logger.info \"\"\n if count == 0\n logger.info \"no #{source_model.name.pluralize} to import, exiting\"\n return\n end\n\n logger.info \"Starting import from #{source_model.table_name} into #{destination_model.name}...\"\n\n # step through the records in batches\n (0..count).step(batch_size) do |offset|\n thread_pool.schedule do\n with_connections do\n batch_elapsed_time = Benchmark.realtime do\n logger.info \"Importing from #{source_model.table_name} into #{destination_model.name} (#{offset / batch_size + 1}/#{count / batch_size + 1})\"\n\n # wipe the slate from the last batch\n prepare_for_new_batch\n\n benchmarks[:source_db] << Benchmark.realtime do\n # grab this batch of records from source\n fetch_records(offset)\n end\n\n # bail if there aren't any\n next if records.empty?\n\n logger.info \" #{records.count} source records fetched in #{benchmarks[:source_db].last}s\"\n if source_order_by\n logger.info \" #{source_order_by}: from #{records.first.read_attribute(source_order_by)} to #{records.last.read_attribute(source_order_by)}\"\n end\n\n # process this batch of records\n process_batch(records)\n\n logger.info \" #{records.count} records processed in #{benchmarks[:processing].last}s\"\n\n insert_and_update_batch\n end\n logger.info \" batch processed in #{batch_elapsed_time}s\"\n end\n end\n end\n thread_pool.shutdown\n \n print_validation_errors\n\n logger.info \"-------------------------------------------------\"\n logger.info \"Processing: #{benchmarks[:processing].sum}s total, #{benchmarks[:processing].sum / count}s per record\"\n logger.info \"source Database: #{benchmarks[:source_db].sum}s total, #{benchmarks[:source_db].sum / count}s per record\"\n logger.info \"dest Database: #{benchmarks[:destination_db].sum}s total, #{benchmarks[:destination_db].sum / count}s per record\"\n logger.info \"Total: #{Time.now - start_time}s elapsed\"\n importer_run.update_attributes( completed_at: Time.now )\n rescue Exception => e\n importer_run.update_attributes( error_trace: \"#{e.class} - #{e.message}\\n#{e.backtrace.join(\"\\n\")}\" )\n raise e\n ensure\n importer_run.update_attributes( records_created: records_created,\n records_updated: records_updated,\n duration: ((Time.now - start_time) * 1000).round,\n validation_errors: validation_errors )\n end",
"def process_postponed_queries\n Array(@postponed_queries).each do |arguments, block|\n connection.add_index(*arguments, &block)\n end\n\n clear_queue\n\n self\n end",
"def process_upload\n return if @upload_processed\n @file.file.process!\n @upload_processed = true\n end",
"def post_process; end",
"def process_transaction(tx, raise_errors=false)\n accepted = false\n Toshi::Utils.synchronized(Toshi::Lock::PROCESS_TRANSACTION) do\n @output_cache.flush\n missing_inputs_exception = nil\n\n @storage.transaction do\n begin\n accepted = self.accept_to_memory_pool(tx, false, raise_errors)\n rescue TxMissingInputsError => missing_inputs_exception\n # we don't want these to cause us to abort the db transaction\n @mempool.add_orphan_tx(tx)\n end\n end\n\n if accepted\n # Recursively process any orphan transactions that depended on this one\n relay_transaction_to_peers(tx)\n work_queue = [ tx.hash ]\n i = 0\n while i < work_queue.length do\n @mempool.get_orphan_txs_by_prev_hash(work_queue[i]).each do |orphan_tx|\n orphan_accepted = false\n @storage.transaction do\n begin\n orphan_accepted = self.accept_to_memory_pool(orphan_tx, false, false)\n rescue TxMissingInputsError\n # don't care about orphans still being orphans.\n rescue ValidationError => ex\n logger.warn{ \"orphan tx #{orphan_tx.hash} failed validation: #{ex.message}\" }\n @storage.remove_orphan_tx(orphan_tx.hash)\n end\n end\n if orphan_accepted\n # orphan is no longer an orphan, see if it's a parent\n work_queue << orphan_tx.hash\n relay_transaction_to_peers(orphan_tx)\n end\n end\n i += 1\n end\n end\n\n @output_cache.flush\n raise missing_inputs_exception if missing_inputs_exception && raise_errors\n\n end # synchronized\n return accepted\n rescue ValidationError, TxValidationError => e\n raise if raise_errors\n accepted\n end",
"def createTransaction\n results1 = checkUser(params[:userid]) #userid user to give the money\n money1 = checkMoneyUser(@current_user[\"id\"]) # check if the user id that sends the money have the amount\n moneyusergiving = money1.parsed_response\n if (moneyusergiving[\"money\"]).to_f > 0 && (moneyusergiving[\"money\"]).to_f >= (params[:amount]).to_f\n if results1.code == 200\n results2 = postTransaction(@current_user[\"id\"], params[:userid], params[:amount]) # create initial state\n transact = results2.parsed_response # transact object to get the id in the rest of the process\n if results2.code == 201\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], transact[\"state\"], 0)\n newMoneyGiving = (moneyusergiving[\"money\"]).to_f - (params[:amount]).to_f\n results3 = updateMoney(newMoneyGiving, @current_user[\"id\"]) #subtract money from useridgiving\n if results3.code == 204\n logUpdateMoney(@current_user[\"id\"], newMoneyGiving, 0)\n results4 = updateTransaction(\"pending\", transact[\"id\"])# put pending state\n if results4.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"pending\", 0)\n money2 = checkMoneyUser(params[:userid]) # check if the user id that sends the money have the amount\n moneyuserreceiving= money2.parsed_response\n newMoneyReceiving = (moneyuserreceiving[\"money\"]).to_f + (params[:amount]).to_f\n results5 = updateMoney(newMoneyReceiving, params[:userid])#add money from useridreceiving\n if results5.code == 204\n logUpdateMoney(params[:userid], (moneyuserreceiving[\"money\"]).to_f + (params[:amount]).to_f, 0)\n results6 = updateTransaction(\"complete\", transact[\"id\"])# put complete state\n if results6.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"complete\", 0)\n subject = \"Transacción\"\n content = \"Has recibido una transacción del usuario \" + formato(@current_user[\"id\"]) + \" por valor de $\" + (params[:amount]).to_s\n notification_key = get_group_key(params[:userid])\n createNotification(params[:userid],subject, content, notification_key)\n head 201 # transaction created and state #####COMPLETE#######\n else\n ##########ERROR EN UPDATE A TRANSACCION (complete)###### Si ya se le resto el dinero se le devuelve y al otro usuario si se le sumo se le resta.\n #devuelve el dinero al que envia\n undoUpdateMoney(@current_user[\"id\"], newMoneyGiving.to_f , newMoneyGiving.to_f + (params[:amount]).to_f)\n #le quita al que recibe\n undoUpdateMoney(params[:userid], newMoneyReceiving.to_f , newMoneyReceiving.to_f - (params[:amount]).to_f)\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"incomplete\", 1)\n end\n render json: results6.parsed_response, status: results6.code\n ##########ERROR EN UPDATE A TRANSACCION (complete)###### Si ya se le resto el dinero se le devuelve y al otro usuario si se le sumo se le resta.\n end\n else\n ##########ERROR EN SUMAR DINERO AL DESTINATARIO###### Si ya se le resto el dinero se le devuelve y al otro usuario si se le sumo se le resta.\n #devuelve el dinero al que envia\n undoUpdateMoney(@current_user[\"id\"], newMoneyGiving.to_f , newMoneyGiving.to_f + (params[:amount]).to_f)\n #le quita al que recibe\n undoUpdateMoney(params[:userid], newMoneyReceiving.to_f , newMoneyReceiving.to_f - (params[:amount]).to_f)\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"incomplete\", 1)\n end\n render json: results5.parsed_response, status: results5.code\n ##########ERROR EN SUMAR DINERO AL DESTINATARIO###### Si ya se le resto el dinero se le devuelve y si se le sumo se le resta.\n end\n else\n ##########ERROR EN UPDATE A TRANSACCION (pending)###### Si ya se le resto el dinero se le devuelve y si se le sumo se le resta.\n undoUpdateMoney(@current_user[\"id\"], newMoneyGiving.to_f , newMoneyGiving.to_f + (params[:amount]).to_f)\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"incomplete\", 1)\n end\n render json: results4.parsed_response, status: results4.code\n ##########ERROR EN UPDATE A TRANSACCION (pending)###### Si ya se le resto el dinero se le devuelve y si se le sumo se le resta.\n end\n else\n ##########ERROR EN RESTAR DINERO AL USUARIO QUE ENVIA###### Si ya se le resto el dinero se le devuelve y se deja la transaccion como incomplete\n undoUpdateMoney(@current_user[\"id\"], newMoneyGiving.to_f , newMoneyGiving.to_f + (params[:amount]).to_f)\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"incomplete\", 1)\n end\n render json: results3.parsed_response, status: results3.code\n ##########ERROR EN RESTAR DINERO AL USUARIO QUE ENVIA###### Si ya se le resto el dinero se le devuelve y se deja la transaccion como incomplete\n end\n else\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"incomplete\", 1)\n end\n render json: results2.parsed_response, status: results2.code\n end\n elsif results1.code == 404\n renderError(\"Not Found\", 404, \"The resource does not exist\")\n end\n else\n renderError(\"Bad Request\", 400, \"The user do not have enough money\")\n return -1\n end\n end",
"def _call_in_transaction\n begin\n update_aliquots(s2_resource)\n rescue Sequel::Rollback, PlateNotFoundInSequencescape, UnknownSample => e\n metadata.reject(:requeue => true)\n log.info(\"Error updating plate aliquots in Sequencescape: #{e}\")\n raise Sequel::Rollback\n rescue TransferRequestNotFound => e\n metadata.ack\n log.info(\"Plate update message processed and acknowledged with the warning: #{e}\")\n else\n metadata.ack\n log.info(\"Plate update message processed and acknowledged\")\n end\n end",
"def within_transaction\n if use_transaction\n first.within_transaction do\n yield\n success?\n end\n else\n yield\n end\n end",
"def add_to_transaction(*)\n @connection.add_transaction_record(self)\n end",
"def process\n raise NotImplementedError(\"The instance method '#process' must be implemented for the operation\")\n end",
"def batch\n mon_synchronize do\n begin\n original, @client = @client, SSDB::Batch.new\n yield(self)\n @client.values = original.perform(@client)\n ensure\n @client = original\n end\n end\n end",
"def batch\n mon_synchronize do\n begin\n original, @client = @client, SSDB::Batch.new\n yield(self)\n @client.values = original.perform(@client)\n ensure\n @client = original\n end\n end\n end",
"def after_process_record (row: , result: , batch_id: )\n get_batch_params batch_id\n REDIS_BATCHES.rpush(@batch_success, row.to_json) if result == 'success'\n REDIS_BATCHES.rpush(@batch_error, row.to_json) if result == 'error'\n REDIS_BATCHES.decr(@batch_counter)\n after_complete_batch unless REDIS_BATCHES.get(@batch_counter).to_i > 0\n rescue => e\n Rails.logger.error \"#{self.name}.#{__method__} - #{e}\"\n end",
"def transactions\n @connection.savepoint\n end",
"def process(result)\n # :nocov:\n raise NotImplementedError\n # :nocov:\n end",
"def process\n if threaded?\n @request.threaded = true\n EventMachine.defer { post_process(pre_process) }\n else\n @request.threaded = false\n post_process(pre_process)\n end\n end",
"def hook_into_callback_chain(env, *args)\n async_callback = env['async.callback']\n\n # The response from the downstream app is sent to post_process\n # and then directly up the callback chain\n downstream_callback = Proc.new do |status, headers, body|\n new_resp = safely(env){ post_process(env, status, headers, body, *args) }\n async_callback.call(new_resp)\n end\n\n env['async.callback'] = downstream_callback\n end",
"def bulk(records)\n records_array = Array(records)\n\n bulk_delay(records_array)\n\n yield\n\n bulk_queue(records_array)\n end",
"def run\n master_connection = acquire_connection\n worker_connection = acquire_connection\n\n run_cursor_loop(master_connection) do |row|\n process_method.call(worker_connection, row)\n end\n\n release_connection(master_connection)\n release_connection(worker_connection)\n end",
"def transaction; end",
"def transaction; end"
] |
[
"0.58849883",
"0.57768244",
"0.54928666",
"0.5474429",
"0.5464763",
"0.54029953",
"0.5368554",
"0.5363739",
"0.5359235",
"0.5335334",
"0.52973145",
"0.5286358",
"0.52395815",
"0.5234661",
"0.5228884",
"0.5219611",
"0.5217118",
"0.51980644",
"0.51750386",
"0.51679695",
"0.5163535",
"0.51321983",
"0.5117992",
"0.5112547",
"0.5074265",
"0.5073402",
"0.5055979",
"0.5055979",
"0.5038589",
"0.50355446",
"0.50347936",
"0.50347936",
"0.50242144",
"0.5023674",
"0.50189924",
"0.49936554",
"0.4992299",
"0.4970061",
"0.49555194",
"0.49395204",
"0.4936892",
"0.49353215",
"0.4933586",
"0.4926122",
"0.49240226",
"0.49083996",
"0.4896089",
"0.48899767",
"0.48894903",
"0.48869598",
"0.48828936",
"0.48804355",
"0.48792753",
"0.48735073",
"0.48482758",
"0.48421696",
"0.4819662",
"0.4819662",
"0.48139372",
"0.4809527",
"0.48075858",
"0.48034367",
"0.48010942",
"0.47943413",
"0.4790804",
"0.47905508",
"0.47901145",
"0.47863236",
"0.47850546",
"0.47696522",
"0.47674298",
"0.47572267",
"0.47526583",
"0.4751389",
"0.474057",
"0.474057",
"0.4738265",
"0.47358388",
"0.47341865",
"0.47326013",
"0.47310823",
"0.4729368",
"0.47290605",
"0.47277802",
"0.47268808",
"0.47253713",
"0.4723125",
"0.47225395",
"0.472174",
"0.472",
"0.472",
"0.47179717",
"0.47176445",
"0.47147277",
"0.47120488",
"0.47069535",
"0.47057214",
"0.4697632",
"0.46870676",
"0.46870676"
] |
0.5456627
|
5
|
Process a timer callback from the proxy. Wraps the user method in a transaction, which is returned to the proxy upon completion.
|
def boltProcessTimer(key, time)
ctx = ComputationContext.new(self)
log_failure do
handler.process_timer(ctx, key, time)
end
ctx.transaction
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def timer(timeout,options={},&callback)\n bot.timer.add_timer(:timestamp=>Time.now+timeout.to_i, :requestor=>options[:requestor]||name,&callback)\n end",
"def finalized_plan_event(transaction, proxy); end",
"def timer\n rescuer do\n Timeout.timeout(ttl) { yield }\n end\n end",
"def timer(milliseconds, &callback)\n # Implement in subclass\n end",
"def finalized_plan_task(transaction, proxy); end",
"def timer(*args, &b); \n if block_given?\n \tForce::Timer.timer(*args, &b)\n else\n Force::Timer.timer args[0] do\n send(args.shift, *args)\n end\n end\n end",
"def process_transaction(client)\n \n # for data analysis, we track the start time of this transaction\n start_time = Time.now()\n\n request = form_request(client)\n if request.nil?\n MixPanel.track(\"Request Unsupported\", properties = {\n \"token\"=>$MIXPANEL_API_TOKEN,\n \"Event Time\"=>Time.now\n })\n client.print(\"I'm sorry, this proxy does not support that request type.\\n\") \n return 0\n end\n\n # make the request and store response\n # If the request is a GET request, we will search and update the cache.\n if request.request_type.eql?(\"GET\") && cached_entry = $CACHE.retrieve(request.url)\n response = cached_entry\n client.print(response)\n\n end_time = Time.now()\n MixPanel.track(\"Cached Request Processed\", properties = {\n \"token\"=>$MIXPANEL_API_TOKEN, \n \"Event Time\"=>Time.now, \n \"Url\"=>request.url, \n \"Process Time\"=>start_time - end_time, \n \"Request Type\"=>request.request_type\n })\n else\n response = make_request_and_respond(request, client)\n $CACHE.update(request.url, response, Time.now()) if request.request_type.eql?(\"GET\")\n \n end_time = Time.now()\n MixPanel.track(\"Uncached Request Processed\", properties = {\n \"token\"=>$MIXPANEL_API_TOKEN, \n \"Event Time\"=>Time.now, \n \"Url\"=>request.url, \n \"Process Time\"=>start_time - end_time, \n \"Request Type\"=>request.request_type\n })\n end\nend",
"def run(context)\n\t\tcontext.onTimerFinished\n\tend",
"def run\n @lock.synchronize do\n until stopped?\n if run?\n begin\n @callback.call\n rescue => ex\n logger.warn \"[Neptune] Failed to run timer: #{ex.message}\"\n ensure\n # Always reset, regardless of whether it failed\n reset\n end\n else\n # Wait until enough time has passed for the next invocation\n @notifier.wait(@lock, seconds_left)\n end\n end\n end\n end",
"def around_perform_stats(*args)\n start = Time.now\n yield\n time_taken = Time.now - start\n statsd.timing(\"duration:#{self}\", time_taken)\n statsd.increment(\"total_successful:#{self}\")\n statsd.increment(\"total_successful\")\n run_hooks(:duration, :duration, args) {|key| statsd.timing(key, time_taken)}\n end",
"def delegate( txn, chain, *args )\n\t\tyield( chain )\n\tend",
"def exec\n # synchronized so that both timestamp is set and being_executed\n # set to true before the possiblity of a timeout management\n # check (see handle_timeout! below)\n @pool_lock.synchronize{\n @thread = Thread.current\n @being_executed = true\n @timestamp = Time.now\n }\n\n @handler.call *@params\n\n # synchronized so as to ensure that a timeout check does not\n # occur until before (in which case thread is killed during\n # the check as one atomic operation) or after (in which case\n # job is marked as completed, and thread is not killed / goes\n # onto pull anther job)\n @pool_lock.synchronize{\n @being_executed = false\n }\n end",
"def execute(callback)\n unlock(:server)\n\n runtime_lock.execute(callback) do\n yield\n end\n end",
"def later(symbol,*args)\n service(symbol).later self,*args\n end",
"def timer=(_arg0); end",
"def timer=(_arg0); end",
"def timer=(_arg0); end",
"def timer=(_arg0); end",
"def set_current_timing_method(method)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n Native.Timer_set_current_timing_method(@handle.ptr, method)\n end",
"def timer_on (opts={})\n @timer.cancel unless @timer.nil?\n length = @timeout + (opts[:with_interval] ? @interval : 0)\n @timer = EventMachine::Timer.new(length) {\n scrap = @buf ? \" - #{@buf.flush}\" : ''\n @handler.logger.error \"timeout on #{@handler.name}\" + scrap\n @handler.logger.debug {\"pid #{get_pid}\"}\n close_connection()\n }\n end",
"def finished_transaction transaction, result\n if @finished_transaction_handler\n @finished_transaction_handler[transaction, result]\n end\n end",
"def timer\n handle = Timer.new(@reactor)\n handle.progress &Proc.new if block_given?\n handle\n end",
"def on_invocation(sender, signature, meth, *args)\n Fiber.new do\n result = self.__send__(meth, *args)\n sender.finish_invocation(signature, result)\n end.resume\n end",
"def on_invocation(sender, signature, meth, *args)\n Fiber.new do\n result = self.__send__(meth, *args)\n sender.finish_invocation(signature, result)\n end.resume\n end",
"def transaction_with_timeout\n db.transaction do\n begin\n db.run(\"SET statement_timeout TO #{statement_timeout}\") if statement_timeout\n yield db\n db.run('SET statement_timeout TO DEFAULT')\n end\n end\n end",
"def execute\n lock do\n yield\n unlock_with_callback\n callback_safely\n item[JID]\n end\n end",
"def timer\n # 2. start executing the method\n start_time = Time.now\n yield # 3. jump out of 'timer', start execuding the block\n\n # 6. continue executing the method as per usual\n end_time = Time.now\n\n puts \"Elapsed time: #{end_time - start_time} s\"\nend",
"def timer(method=nil, *args)\n start_time = Time.now\n if block_given?\n yield\n else\n send(method, args)\n end\n end_time = Time.now\n puts \"Time elapsed #{(end_time - start_time)} seconds\"\nend",
"def execute(callback)\n callback.call if unlock(:server)\n yield\n end",
"def callback\n\n end",
"def cb_perform_later(**opt)\n __debug { \"#{__method__} | opt = #{opt.inspect}\" } # TODO: remove\n receiver.job_class.perform_later(receiver, meth, **opt).present?\n end",
"def commit_transaction\n\t super\n\t \n\t # Update the task arguments. The original\n\t # Roby::Task#commit_transaction has already translated the proxy\n\t # objects into real objects\n\t arguments.each do |key, value|\n\t\t__getobj__.arguments.update!(key, value)\n\t end\n\n execute_handlers.each do |h|\n __getobj__.execute(h.as_options, &h.block)\n end\n poll_handlers.each do |h|\n __getobj__.poll(h.as_options, &h.block)\n end\n\n __getobj__.abstract = self.abstract?\n if @fullfilled_model\n __getobj__.fullfilled_model = @fullfilled_model.dup\n end\n __getobj__.do_not_reuse if !@reusable\n\tend",
"def check_for_timer_events\n super\n return if @worker_method_triggers.nil? or @worker_method_triggers.empty?\n @worker_method_triggers.delete_if { |key,value| value[:trigger].respond_to?(:end_time) && value[:trigger].end_time <= Time.now }\n\n @worker_method_triggers.each do |key,value|\n time_now = Time.now.to_i\n if value[:runtime] < time_now\n check_db_connection\n invoke_user_method(key,value[:data])\n t_time = value[:trigger].fire_after_time(Time.now)\n value[:runtime] = t_time.to_i\n end\n end\n end",
"def within_transaction; end",
"def within_transaction; end",
"def _add_timeout_arg(a_func, timeout)\n proc do |request, **kwargs|\n kwargs[:timeout] = timeout\n a_func.call(request, **kwargs)\n end\n end",
"def install_completion_callback( request, t0, segment, wrapped_request, wrapped_response )\n original_callback = request.on_complete\n request._ty_original_on_complete = original_callback\n request.on_complete do |finished_request|\n begin\n TingYun::Agent::CrossAppTracing.finish_trace(TingYun::Agent::TransactionState.tl_get,t0, segment, wrapped_request, wrapped_response )\n ensure\n # Make sure the existing completion callback is run, and restore the\n # on_complete callback to how it was before.\n original_callback.call( finished_request ) if original_callback\n remove_instrumentation_callbacks( request )\n end\n end\n end",
"def timer(callback = nil, &blk)\n Timer.new(@loop, callback || blk)\n end",
"def set_timeout_source\n %Q|\n var setTimeout = function(cb, delay) {\n var timer = Components.classes[\"@mozilla.org/timer;1\"].createInstance(Components.interfaces.nsITimer);\n timer.initWithCallback({notify:cb}, delay, Components.interfaces.nsITimer.TYPE_ONE_SHOT);\n return timer;\n };\n |\n end",
"def call(timeout)\n @time_out_at = read_clock + timeout\n\n yield\n end",
"def callback\n end",
"def timer; end",
"def timer; end",
"def timer; end",
"def timer; end",
"def exec(lock)\n lock.synchronize {\n @thread = Thread.current\n @time_started = Time.now\n }\n\n @handler.call *@params\n\n # ensure we do not switch to another job\n # before atomic check expiration / terminate\n # expired threads happens below\n lock.synchronize {\n @time_completed = Time.now\n @thread = nil\n }\n end",
"def on_timeout=(callback)\n @timeout_callback = callback\n end",
"def add_timeout(seconds, &block)\n raise_not_implemented\n end",
"def finish_invocation(signature, result)\n @invocation_callbacks.delete(signature).transfer(result) if @invocation_callbacks.has_key?(signature)\n end",
"def finish_invocation(signature, result)\n @invocation_callbacks.delete(signature).transfer(result) if @invocation_callbacks.has_key?(signature)\n end",
"def cb_perform_now(**opt)\n __debug { \"#{__method__} | opt = #{opt.inspect}\" } # TODO: remove\n receiver.job_class.perform_now(receiver, meth, **opt)\n true # TODO: return from #perform ???\n end",
"def with_method_transaction\n temp_name = \"__pry_#{method.original_name}__\"\n method = self.method\n method.owner.class_eval do\n alias_method temp_name, method.original_name\n yield\n alias_method method.name, method.original_name\n alias_method method.original_name, temp_name\n end\n\n ensure\n method.send(:remove_method, temp_name) rescue nil\n end",
"def _postprocess(raw_results,callback)\n if raw_results.is_a?(Redis::Future)\n #\n # Redis::Future have a built-in mechanism for calling a\n # transformation on the raw results.\n #\n # Here, we monkey-patch not the Redis::Future class, but just\n # this one raw_results object. We give ourselves a door to\n # set the post-processing transformation.\n #\n # The transformation will be called only once when the real\n # results are materialized.\n #\n class << raw_results\n def transformation=(transformation)\n raise \"transformation collision\" if @transformation\n @transformation = transformation\n end\n end\n raw_results.transformation = callback\n raw_results\n else\n #\n # If not Redis::Future, we invoke the callback immediately.\n #\n callback.call(raw_results)\n end\n end",
"def with_timer(name, &block)\n start = Time.now\n block.call\n duration = Time.now - start\n # report in ms\n self.add_field(name, duration * 1000)\n self\n end",
"def instrument_method(klass,method_name,unbound_orig_method,inst_code) \n lambda do |*args|\n bound_method = unbound_orig_method.bind(self)\n# if ::DRuby::Profile::Interceptor.enabled then\n inst_code.call(bound_method,*args)\n# else\n# bound_method.call(*args)\n# end\n end\n end",
"def trigger_timer(timer)\n\n r = nil\n\n transync do\n\n# TODO: cron/every stop conditions maybe?\n\n if timer.type != 'at' && timer.type != 'in'\n\n @db[:flor_timers]\n .where(id: timer.id)\n .update(\n count: timer.count + 1,\n ntime: compute_next_time(timer.type, timer.schedule),\n mtime: Flor.tstamp)\n r = timers[timer.id]\n\n elsif @archive\n\n @db[:flor_timers]\n .where(id: timer.id)\n .update(\n count: timer.count + 1,\n status: 'triggered',\n mtime: Flor.tstamp)\n\n else\n\n @db[:flor_timers]\n .where(id: timer.id)\n .delete\n end\n\n put_messages([ timer.to_trigger_message ], false)\n end\n\n r\n\n rescue => err\n\n Thread.current[:sto_errored_items] = [ timer ]\n raise err\n end",
"def add_oneshot delay, timer_proc\n return nil unless timer_proc\n\n timer = Timer.new :timers => self, :delay => delay, :periodical => false, :timer_proc => timer_proc\n add timer\n timer\n end",
"def transaction(&blk)\n tap(&blk)\n end",
"def delegate( txn, chain, *args )\n\t\t\tself.log.debug \"Delegating to chain: %p\" % [ chain ]\n\n\t\t\twith_authorization( txn, chain ) do\n\t\t\t\tyield( chain )\n\t\t\tend\n\t\tend",
"def method_missing(*args)\n @real_txn.send(*args)\n end",
"def with_timer(name)\n start = Time.now\n yield\n duration = Time.now - start\n # report in ms\n add_field(name, duration * 1000)\n self\n end",
"def update(time_delta)\n @callbacks.clear\n @dead_timers.clear\n\n @timers.each do |name, timer_hash|\n timer_hash[:count] += time_delta\n if timer_hash[:count] > timer_hash[:interval_ms]\n timer_hash[:count] -= timer_hash[:interval_ms]\n @callbacks << timer_hash[:callback]\n @dead_timers << name unless timer_hash[:recurring]\n end\n end\n @dead_timers.each do |name|\n remove_timer name\n end\n @callbacks.each &:call\n end",
"def set_timer\n @timer = User.find(params[:user_id]).timers.find(params[:id])\n end",
"def commit_transaction\n\t super\n\n\t arguments.dup.each do |key, value|\n if value.respond_to?(:transaction_proxy?) && value.transaction_proxy?\n\t\t arguments.update!(key, value.__getobj__)\n\t\tend\n\t end\n\tend",
"def current_timing_method()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.Timer_current_timing_method(@handle.ptr)\n result\n end",
"def within_transaction(object); end",
"def current_timer=(_arg0); end",
"def transaction(&block); end",
"def timeout=(_arg0); end",
"def test_reply_with_timeout\n address = \"some-address\"\n\n id = EventBus.register_handler(address) do |msg|\n p msg\n end\n @tu.azzert id != nil\n EventBus.send address, {'message' => 'test'}, 10 do |msg|\n p msg\n end\n\n @tu.test_complete\nend",
"def after_complete(order, transition)\n Delayed::Job.enqueue DelayedSubscriberUpdate.new(Spree::Config.get(:exact_target_user), Spree::Config.get(:exact_target_password), order.number)\n end",
"def setup_proxy(object, transaction)\n\t super(object, transaction)\n\n @poll_handlers.clear\n @execute_handlers.clear\n\n\t @arguments = Roby::TaskArguments.new(self)\n\t object.arguments.each do |key, value|\n\t\tif value.kind_of?(Roby::PlanObject)\n\t\t arguments.update!(key, transaction[value])\n\t\telse\n\t\t arguments.update!(key, value)\n\t\tend\n\t end\n\n each_event do |ev|\n transaction.setup_and_register_proxy(ev, object.event(ev.symbol))\n end\n\tend",
"def spy_transaction!\n @within_transaction = nil\n allow(TestSqlCaller).to receive(:transaction).and_wrap_original do |meth, *args, &block|\n @within_transaction = true\n meth.call(*args, &block)\n ensure\n @within_transaction = false\n end\n end",
"def begin\n @timestamp = Time.now\n # NOTE: yield self is a bit of a smell to me, but I am okay with this\n # as the block is evaluated in the context of the caller and not of\n # the Transaction object.\n yield self if block_given?\n ensure\n finished\n end",
"def statement_timeout=(_arg0); end",
"def around_hook(hook)\n define_method hook do |&block|\n add_hook(hook, &block)\n end\n define_method \"run_#{hook}\" do |*args, &block|\n run_around_hook(hook, *args, &block)\n end\n end",
"def hook_pending_request(request) #THREAD_LOCAL_ACCESS\n wrapped_request, wrapped_response = wrap_request(request)\n state = TingYun::Agent::TransactionState.tl_get\n t0 = Time.now.to_f\n node = TingYun::Agent::CrossAppTracing.start_trace(state, t0, wrapped_request)\n\n unless request._ty_instrumented\n install_header_callback( request, wrapped_response )\n install_completion_callback( request, t0, node, wrapped_request, wrapped_response )\n request._ty_instrumented = true\n end\n rescue => err\n TingYun::Agent.logger.error(\"Untrapped exception\", err)\n end",
"def run(context)\n\t\tcontext.onTimerCreated\n\tend",
"def outer_around(call_signature, request, active_call, &_block)\n timed = Timer.time do\n yield\n end\n rc = RequestContext.new(\n service: service,\n request: request,\n response: timed.result,\n execution_time: timed.time,\n call_signature: call_signature,\n active_call: active_call\n )\n call(rc)\n raise rc.response unless rc.success?\n rc.response\n end",
"def queue(&callback)\n callback.call(cassandra_proxy)\n end",
"def callback\n\tend",
"def method_missing(*args, &block)\n transaction do |y|\n y.send(*args, &block)\n end\n end",
"def handle_timer_fired(event)\n timer_id = event.attributes[:timer_id]\n return if timer_id == DecisionHelper.force_immediate_decision_timer\n @decision_helper[timer_id].consume(:handle_completion_event)\n if @decision_helper[timer_id].done?\n open_request = @decision_helper.scheduled_timers.delete(timer_id)\n return if open_request.nil?\n open_request.blocking_promise.set(nil)\n open_request.completion_handle.complete\n end\n end",
"def schedule(time, callback); end",
"def handleTimeout\n\n return unless hastimer?\n\n @timer.keys.each do |timerType|\n\n # This is because @timer can be modified during an iteration\n next if (@timer[timerType].nil? || @timer[timerType].empty?)\n\n if Time.now > (@timer[timerType][\"Started\"] + ACTIONS[timerType][:TIMEOUT])\n\n writeLog(\"Reached timeout of type #{timerType}\")\n\n # close log File.\n if timerType.eql?(\"FINISH_LOG\")\n\n disableTimer(timerType)\n writeLog(\"Zipping log file.\")\n finishLogFile\n next\n end\n\n # we reached a timeout here. Must choose what to do\n # verify if limit has been exceeded\n if @timer[timerType][\"Tries\"] >= ACTIONS[timerType][:LIMIT]\n\n # Limit reached, finish transaction and generate an error. Insert this into LOG\n CFDP::CFDP_Indication(\"Transaction #{@ID} has detected an error. Error is: #{timerType}_LIMIT. Finishing transaction.\")\n writeLog(\"Transaction #{@ID} has detected an error. Error is: #{timerType}_LIMIT. Finishing transaction.\")\n CFDP::HKPacket.instance.updateVar(ACTIONS[timerType][:CONDITION])\n finish(\"FAILED\")\n else\n\n # Limit not reached, reset Timer, re-send things and update transaction\n resetTimer(timerType)\n\n # Verify action\n case timerType\n when \"EOF\", \"FINISHED\"\n\n # Must re-send PDU from that transaction and update limit counter.\n writeLog(\"#{timerType}_LIMIT reached, re-sending PDU\")\n CFDPEngine.instance.insertIntoBuffer(@pdus[timerType])\n @timer[timerType][\"Tries\"]+=1\n when \"NAK\"\n\n # check if my NAK has been responded\n nakPdu = verifyMissingPDU\n\n if nakPdu.nil?\n\n writeLog(\"NAK has been fully responded.\")\n disableTimer(\"NAK\")\n finish_downlink_transaction if haspdueof?\n next\n elsif nakPdu.pack == @pdus[\"NAK\"].pack\n\n writeLog(\"NAK_LIMIT reached, re-sending PDU\")\n @timer[timerType][\"Tries\"]+=1\n else\n\n writeLog(\"NAK partially responded. Generated new NAK #{nakPdu.pack.to_s}.\")\n writeLog(\"Overriding tries of type #{timerType} to 0.\")\n @pdus[\"NAK\"] = nakPdu\n @timer[timerType][\"Tries\"]=0\n end\n\n CFDPEngine.instance.insertIntoBuffer(nakPdu)\n end\n end\n end\n end\n end",
"def call\n SCC::Logger.info \"[TIMER] Starting timer for #{duration} seconds, with #{interval} second intervals.\"\n call_count.times do |n|\n yield\n\n SCC::Logger.info \"[TIMER] Finished #{n+1} of #{call_count} calls.\"\n\n if (n+1) != call_count\n SCC::Logger.info \"[TIMER] Waiting #{interval} seconds till next call.\"\n sleep interval\n end\n end\n end",
"def set_timer(key, time)\n transaction.timers[key] = time\n end",
"def handle_callback(hook, event, *data)\n to = machine.events_map.move_to(event.event_name, event.from, *data)\n trans_event = TransitionEvent.new(event.event_name, event.from, to)\n callable = create_callable(hook)\n\n if hook.is_a?(Async)\n defer(callable, trans_event, *data)\n else\n callable.(trans_event, *data)\n end\n end",
"def call_tax_svc_with_timeout(method, *args)\n Timeout.timeout(SpreeAvatax::Config.timeout, SpreeAvatax::AvataxTimeout) do\n tax_svc.public_send(method, *args)\n end\n end",
"def on_prepare_transaction_commit(unit, transaction); end",
"def replace_inner(timer)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n if timer.handle.ptr == nil\n raise \"timer is disposed\"\n end\n Native.SharedTimer_replace_inner(@handle.ptr, timer.handle.ptr)\n timer.handle.ptr = nil\n end",
"def fire(time)\n if @callback\n @callback.call(time)\n end\n end",
"def register_completion_callback(callback)\n @duty_completion_callback = callback\n end",
"def duration(proc)\n start = Time.now\n proc.call\n dur = Time.now - start\nend",
"def transaction_done\n puts \".........\" + self.class.name + \" has been notified\"\n end",
"def after_commit(unit); end",
"def asynchronous_block (&block)\n Proxy.new(nil, nil, nil, &block)\n end",
"def time_method(klass, method, item, type=\"instance\")\n item ||= \"#{klass}::#{method}\"\n SE::Aspect.define do\n if type == \"instance\"\n with_instance_of(klass).before(method.to_sym) {SE::Timer.start(item)}\n with_instance_of(klass).after(method.to_sym) {SE::Timer.end(item)}\n else\n with_class(klass).before(method.to_sym) {SE::Timer.start(item)}\n with_class(klass).after(method.to_sym) {SE::Timer.end(item)}\n end\n end\n end",
"def timeout_wrap(&block)\n ::Timeout.timeout(timeout, &block)\n rescue ::Timeout::Error\n failure(:RPC_FAILED, \"The server took longer than #{timeout} seconds to respond\")\n end",
"def reply (workitem)\n\n unschedule_timeout(workitem)\n\n super\n end"
] |
[
"0.5476667",
"0.5414996",
"0.5308264",
"0.5299317",
"0.51228255",
"0.51091546",
"0.50555134",
"0.5002299",
"0.4982722",
"0.498127",
"0.49794996",
"0.49671572",
"0.4945523",
"0.49429312",
"0.49390447",
"0.49390447",
"0.49390447",
"0.49390447",
"0.4881811",
"0.48604032",
"0.48569188",
"0.48556495",
"0.48553026",
"0.48553026",
"0.48414165",
"0.48363715",
"0.4831019",
"0.48216042",
"0.47776756",
"0.47729245",
"0.4767586",
"0.47629887",
"0.47612435",
"0.4760821",
"0.4760821",
"0.4729293",
"0.47240472",
"0.4721888",
"0.47205043",
"0.472002",
"0.4716903",
"0.4703561",
"0.4703561",
"0.4703561",
"0.4703561",
"0.46776548",
"0.4674183",
"0.4665592",
"0.46529388",
"0.46529388",
"0.46410453",
"0.46393505",
"0.46267968",
"0.46239",
"0.46233043",
"0.46193203",
"0.46139973",
"0.46084386",
"0.46076226",
"0.4605281",
"0.46023774",
"0.4600421",
"0.45983845",
"0.45962664",
"0.45912087",
"0.45863056",
"0.45861503",
"0.45845655",
"0.45591772",
"0.4555943",
"0.4547572",
"0.45469272",
"0.45371556",
"0.45358115",
"0.45327723",
"0.45316163",
"0.45249608",
"0.4522676",
"0.45223087",
"0.45195433",
"0.45157292",
"0.45118025",
"0.45115355",
"0.4509078",
"0.45084256",
"0.45039716",
"0.45032087",
"0.45003498",
"0.4496856",
"0.44914782",
"0.44897053",
"0.44871116",
"0.4484552",
"0.4484495",
"0.44815034",
"0.44784486",
"0.44759846",
"0.44749165",
"0.44712025",
"0.44588697"
] |
0.5548104
|
0
|
The initialization function, called when the framework is ready to start sending the computation records. Wraps the user method in a transaction, which is returned to the proxy upon completion.
|
def init
ctx = ComputationContext.new(self)
log_failure do
handler.init(ctx)
end
ctx.transaction
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize(computation)\n self.computation = computation\n self.transaction = ::Concord::Thrift::ComputationTx.new\n self.transaction.records = []\n self.transaction.timers = {}\n end",
"def setup\n set_par_price\n make_certificates_available\n create_transaction\n end",
"def init_monolithic_transactions!\n init_generic_transactions(monolithic_files, @monolithics)\n end",
"def initialize\n open_connection!\n @transaction_open = false\n end",
"def setup\n # suppress ActiveRecord logging\n ActiveRecord::Base.logger.level = Logger::WARN\n\n @importer_run = ImporterRun.new\n @transformer = Transformer.new(context: context, transformations: transformations, options: transformation_options)\n @thread_pool = ETL::ThreadPool.new(options.pool)\n @data_scrubber = ETL::DataScrubber.new(options.destination_model)\n invoke_callback(:before_run)\n end",
"def start(&block)\n transaction.start do\n run_callbacks(:transaction, &block)\n end\n end",
"def call\n db.transaction do\n _call_in_transaction\n end\n end",
"def setup_proxy(object, transaction)\n\t super(object, transaction)\n\n @poll_handlers.clear\n @execute_handlers.clear\n\n\t @arguments = Roby::TaskArguments.new(self)\n\t object.arguments.each do |key, value|\n\t\tif value.kind_of?(Roby::PlanObject)\n\t\t arguments.update!(key, transaction[value])\n\t\telse\n\t\t arguments.update!(key, value)\n\t\tend\n\t end\n\n each_event do |ev|\n transaction.setup_and_register_proxy(ev, object.event(ev.symbol))\n end\n\tend",
"def transaction(&block); end",
"def transaction\n start_transaction\n\n yield\n ensure\n end_transaction if transaction_started?\n end",
"def begin_db_transaction() end",
"def begin_db_transaction() end",
"def within_transaction; end",
"def within_transaction; end",
"def use_transactions; end",
"def use_transactions; end",
"def begin_transaction\n return System.begin_transaction\n end",
"def prepare; self; end",
"def transaction(&block)\n block.call\n end",
"def begin\n raise \"Illegal state for begin: #{@state}\" unless @state == :none\n each_adapter(:connect_adapter, [:log_fatal_transaction_breakage])\n each_adapter(:begin_adapter, [:rollback_and_close_adapter_if_begin, :close_adapter_if_none])\n @state = :begin\n end",
"def transaction; end",
"def transaction; end",
"def transaction; end",
"def initialize\n #puts \"in initialize of class #{self.class.to_s}\"\n\n @store = get_store\n ActiveRecord::Base.connection = @store\n end",
"def initialize(*things)\n @transaction_primitives = {}\n @state = :none\n @adapters = {}\n link(*things)\n commit { |*block_args| yield(*block_args) } if block_given?\n end",
"def transaction(&block)\n @fb_txns << Rubyfb::Transaction.new(@fb_cxn)\n super &block\n end",
"def user_init; end",
"def init_sequential_transactions!\n init_generic_transactions(sequential_files, @transactions)\n end",
"def on_prepare_transaction_commit(unit, transaction); end",
"def initialize(datastore, framework, user_output, opts = {}, &query_proc)\n raise ArgumentError, 'Missing the bloc that does the requests' unless block_given?\n raise ArgumentError, 'Positional arguments can\\'t be nil' if [datastore, framework, user_output].any?(&:nil?)\n\n check_opts(opts)\n @query_proc = query_proc\n @safe = opts[:safe]\n @concat_separator = opts[:concat_separator]\n @second_concat_separator = opts[:second_concat_separator] || ';'\n @null_replacement = opts[:null_replacement] || ''\n @truncation_length = opts[:truncation_length] if opts[:truncation_length] && opts[:truncation_length].is_a?(Integer) && opts[:truncation_length] > 0\n @hex_encode_strings = opts[:hex_encode_strings]\n @encoder = opts[:encoder]\n @datastore = datastore\n @framework = framework\n @user_output = user_output\n end",
"def transaction(&blk)\n tap(&blk)\n end",
"def setup &block\n if @setup_block\n setup_block = @setup_block\n exec_setup_block = method(:exec_setup_block)\n @setup_block = lambda do |attributes, options, backend_class|\n [setup_block, block].each do |blk|\n exec_setup_block.call(self, attributes, options, backend_class, &blk)\n end\n end\n else\n @setup_block = block\n end\n end",
"def ar_default_transaction_handler\n ar_model.transaction do\n yield\n end\n end",
"def commit_transaction\n\t super\n\t \n\t # Update the task arguments. The original\n\t # Roby::Task#commit_transaction has already translated the proxy\n\t # objects into real objects\n\t arguments.each do |key, value|\n\t\t__getobj__.arguments.update!(key, value)\n\t end\n\n execute_handlers.each do |h|\n __getobj__.execute(h.as_options, &h.block)\n end\n poll_handlers.each do |h|\n __getobj__.poll(h.as_options, &h.block)\n end\n\n __getobj__.abstract = self.abstract?\n if @fullfilled_model\n __getobj__.fullfilled_model = @fullfilled_model.dup\n end\n __getobj__.do_not_reuse if !@reusable\n\tend",
"def post_init\n send_message(MosesPG::Message::StartupMessage.new(@user, @dbname))\n\n # when we enter the ready state after connecting, send self to the\n # callback\n @result = FakeResult.new(self)\n self\n end",
"def initial_query; end",
"def delegate( txn, chain, *args )\n\t\tyield( chain )\n\tend",
"def setup\n super do |server_app, binder|\n binder.forward :concurrency\n\n yield(server_app, binder) if block_given?\n end\n end",
"def initialize (&block)\n instance_exec(&block)\n end",
"def transaction\n connect do |c|\n t = Txn.new(c, @log)\n yield t\n end\n end",
"def begin\n @timestamp = Time.now\n # NOTE: yield self is a bit of a smell to me, but I am okay with this\n # as the block is evaluated in the context of the caller and not of\n # the Transaction object.\n yield self if block_given?\n ensure\n finished\n end",
"def initialize\n @transaction_log = []\n end",
"def initialize(&block)\n instance_exec(&block) if block_given?\n end",
"def begin\n self.transaction_count += 1\n end",
"def start(&block)\n res = database.execute_request(\n :post,\n '/transaction/begin',\n headers: { content_type: 'text/plain' }\n ).body\n self.id = res\n @state = :started\n instance_eval(&block) if block_given?\n self\n end",
"def initialize(context, &run_block)\n @__context = context\n # Ruby cannot marshal procs or lambdas, so we need to define a method.\n # Binding to self allows us to intercept logging calls.\n define_singleton_method(:call, run_block.bind(self))\n end",
"def initialize(*args, &block)\n super(*args)\n instance_exec(_context, &block)\n end",
"def transaction(&block)\n yield\n end",
"def transaction(&block)\n yield\n end",
"def perform( &block )\r\n @transaction_strategy.perform( &block )\r\n end",
"def begin\n raise \"Nested transactions are not allowed\" if @state != :INITIALIZED\n begin\n case @isolation\n when Hash\n if @isolation[:timestamp]\n @grpc_transaction = @connection.session.create_snapshot timestamp: @isolation[:timestamp]\n elsif @isolation[:staleness]\n @grpc_transaction = @connection.session.create_snapshot staleness: @isolation[:staleness]\n elsif @isolation[:strong]\n @grpc_transaction = @connection.session.create_snapshot strong: true\n else\n raise \"Invalid snapshot argument: #{@isolation}\"\n end\n when :read_only\n @grpc_transaction = @connection.session.create_snapshot strong: true\n when :pdml\n @grpc_transaction = @connection.session.create_pdml\n else\n @begin_transaction_selector = Google::Cloud::Spanner::V1::TransactionSelector.new \\\n begin: Google::Cloud::Spanner::V1::TransactionOptions.new(\n read_write: Google::Cloud::Spanner::V1::TransactionOptions::ReadWrite.new\n )\n\n end\n @state = :STARTED\n rescue Google::Cloud::NotFoundError => e\n if @connection.session_not_found? e\n @connection.reset!\n retry\n end\n @state = :FAILED\n raise\n rescue StandardError\n @state = :FAILED\n raise\n end\n end",
"def initialize\n # complete\n end",
"def begin\n new_transaction = Transaction.new(@data)\n\n # Record nested transactions in teh parent transactions buffer\n if current_transaction\n current_transaction.add_nested_transaction(new_transaction)\n end\n\n @all_transactions << new_transaction\n end",
"def run\n\t\tsuper\n\t\t## todo, run msf stuff here\n\t\t\n\t\t## Set up xmlrpc?\n\t\t\n\t\t## Run module & Capture results\n\t\t\n\t\t## Modify the object?\n\t\t\n\t\[email protected]!\n\t\tnil\n\tend",
"def prepare!; end",
"def prepare!; end",
"def main\n log \" START: #{inspect}\"\n\n @coordinator.install\n\n begin\n unless @coordinator.cancelled?\n @result = @context.execute do |*args|\n @update_callback.call(*args) if @update_callback\n end\n end\n\n rescue Exception => e\n @exception = e\n\n if e.is_a?(TimeoutError)\n @timeout_callback.call if @timeout_callback\n end\n end\n\n @coordinator.uninstall\n\n log \"FINISH: #{inspect}\"\n end",
"def begin_db_transaction\n log('begin transaction', nil) do\n begin_isolated_db_transaction(default_transaction_isolation)\n end\n end",
"def call\n context.run(self) do\n #subject.run_setup(scope) if subject\n scope.instance_exec(*arguments, &procedure)\n #subject.run_teardown(scope) if subject\n end\n end",
"def init(init_exec)\n data = get_data_from_db(init_exec)\n data = prepare_data(data)\n yield(data)\n @params_list = get_params # todo : les params ont déjà été get avec les valeurs par défaut, regarder s'il ne serait pas possible de faire usage du tableau de structures plutot que d'en demander un autre\n end",
"def init\n @init.call if @init\n end",
"def initialize(&block)\n super(transport)\n\n @parameters = {}\n @query = {}\n @headers = Headers[HEADERS]\n @method = :get\n @asynchronous = true\n @binary = false\n @cacheable = true\n @opened = false\n @sent = false\n @completed = false\n @callbacks = Hash.new { |h, k| h[k] = [] }\n\n if block.arity == 0\n instance_exec(&block)\n else\n block.call(self)\n end if block\n end",
"def transaction(start_db_transaction=true)\n yield\n end",
"def prepare; end",
"def prepare; end",
"def prepare; end",
"def within_transaction(object); end",
"def initialize\n super\n @update_to_call = []\n Scheduler.start(:on_init, self.class)\n end",
"def init_processing \n # intentionally trigger creation of session if it didn't already exist\n # because we need to track session ID for caching. Can't find any\n # way to force session creation without setting a value in session,\n # so we do this weird one.\n session[nil] = nil\n\n\n\n # We have to clean the params of bad char encoding bytes, or it causes\n # no end of problems later. We can't just refuse to process, sources\n # do send us bad bytes, I'm afraid.\n params.values.each do |v|\n v.scrub! if v.respond_to?(:'scrub!')\n end\n # Create an UmlautRequest object.\n options = {}\n if ( @@no_create_request_actions.include?(params[:action]) )\n options[:allow_create] = false\n end\n @user_request ||= Request.find_or_create(params, session, request, options )\n # If we chose not to create a request and still don't have one, bale out.\n return unless @user_request\n @user_request.save!\n @collection = create_collection\n end",
"def post_init \n self.class.add_signal_traps\n setup_dataflow\n end",
"def transaction\n sanity_check\n raise InterfaceError, \"No block given\" unless block_given?\n\n commit\n begin\n yield self\n commit\n rescue Exception\n rollback\n raise\n end\n end",
"def begin_db_transaction() \n log('Opening boxcar', 'begin_db_transaction()')\n @command_boxcar = []\n end",
"def setup(opts_given = {})\n opts = {:stub_amqp => true, :use_transactional => true, :mock_soap => true}.merge(opts_given)\n if opts[:stub_amqp]\n @messages_sent = []\n AmqpListener.stubs(:send_to_exchange).returns(true).with do |arg1, arg2|\n # puts \"new message to #{arg1}\"\n @messages_sent << [arg1, arg2]\n true\n end\n AmqpListener.stubs(:send).returns(true).with do |arg1, arg2|\n # puts \"new message to #{arg1}\"\n @messages_sent << [arg1, arg2]\n true\n end\n end\n if opts[:use_transactional]\n CommitCallback.adapt_for_transactional_test!(ActiveRecord::Base.connection)\n else\n ActiveRecord::Base.connection.rollback_db_transaction\n ActiveRecord::Base.connection.decrement_open_transactions \n end\n \n Savon::Client.any_instance.stubs(:publish_case_manager_xml).yields(mock{stubs(:body=).returns(true)}).returns(\"a good response, since eai doesn't send anything else\")\n User.current_user= User.current_user || User.new(:username => \"tribute_test_user\", :user_number => 1337, :remote_roles => {})\n end",
"def init; end",
"def init; end",
"def init; end",
"def init; end",
"def begin\n db.transaction do\n yield\n end\n end",
"def initialize\n ensure_store_path\n #TODO set timer\n end",
"def work(&block)\n Celluloid::Logger.info \"Preparing work...\"\n self.working_code = block if block_given?\n end",
"def post_initialize\n # raise NotImplementedError\n end",
"def transaction(&block)\n self['AutoCommit'] = false\n self.do_transaction(&block)\n self['AutoCommit'] = true\n end",
"def initialize(trigger, procedure)\n super\n load_settings\n \n begin\n targz\n encrypt\n store\n record\n notify\n ensure\n remove_tmp_files\n end\n end",
"def post_init\n end",
"def setup &block\n block.try(:call, self)\n end",
"def transaction( &block )\n connect do | conn |\n conn.transaction do | conn |\n yield SqlRunner.new(SingleConnectionPool.new( conn ))\n end\n end\n end",
"def execution_context\n initialize_context!(Object.new)\n end",
"def init\n\n end",
"def start_transaction!\n fail DbMod::Exceptions::AlreadyInTransaction if @in_transaction\n @in_transaction = true\n\n query 'BEGIN'\n end",
"def init; end",
"def prepare()\n end",
"def initialize(events, after_forker = NewRelic::Agent)\n # We intentionally don't set our pid as started at this point.\n # Startup routines must call mark_started when they consider us set!\n @starting_pid = nil\n @after_forker = after_forker\n\n events&.subscribe(:start_transaction, &method(:on_transaction))\n end",
"def transaction\n begin\n if block_given?\n begin_db_transaction\n result = yield\n commit_db_transaction\n result\n end\n rescue Exception => database_transaction_rollback\n rollback_db_transaction\n raise\n end\n end",
"def main\n @coordinator.install\n\n begin\n unless @coordinator.cancelled?\n @result = @context.execute\n end\n\n rescue => e\n @exception = e\n end\n\n @coordinator.uninstall\n\n @context = nil\n end",
"def with_transaction(&block)\n base_model.transaction(&block)\n end",
"def setup\n @gateway = flexmock('gateway')\n @db = Catalog::Test::MetadataDatabase.new\n\n @handler_clazz = GetRecordsHandler\n @default_input = {:service => 'CSW', :version => '2.0.2', :typenames => 'csw:Record'}\n @default_args = [@gateway]\n end",
"def begin_db_transaction\n execute(\"BEGIN\")\n end",
"def begin_db_transaction\n execute(\"BEGIN\")\n end",
"def start_transaction\n NewRelic::Agent.instance.events.notify(:start_transaction)\n end",
"def initial_query=(_arg0); end"
] |
[
"0.6197945",
"0.61652875",
"0.61225367",
"0.60193354",
"0.5948263",
"0.58906764",
"0.58843607",
"0.58569413",
"0.5829021",
"0.5798062",
"0.5790211",
"0.5790211",
"0.5762776",
"0.5762776",
"0.5756683",
"0.5756683",
"0.57310486",
"0.5699439",
"0.56978106",
"0.56777555",
"0.5675726",
"0.5675726",
"0.5675726",
"0.5660008",
"0.5637393",
"0.56224984",
"0.5601293",
"0.5587505",
"0.55746245",
"0.557342",
"0.5472008",
"0.5469623",
"0.545488",
"0.5452013",
"0.5449132",
"0.54453737",
"0.5444046",
"0.54349506",
"0.5429511",
"0.5407706",
"0.54070866",
"0.53984946",
"0.53963697",
"0.538931",
"0.5371332",
"0.53482455",
"0.534254",
"0.53422534",
"0.53422534",
"0.53285176",
"0.53279865",
"0.5321814",
"0.5319717",
"0.531917",
"0.53185666",
"0.53185666",
"0.5315274",
"0.53067106",
"0.5285467",
"0.5280598",
"0.5280513",
"0.5267383",
"0.5263324",
"0.52369213",
"0.52369213",
"0.52369213",
"0.5221559",
"0.5217572",
"0.52100265",
"0.51997703",
"0.5198619",
"0.5186812",
"0.51856595",
"0.51824",
"0.51824",
"0.51824",
"0.51824",
"0.5178077",
"0.51747054",
"0.5168166",
"0.5163298",
"0.51603365",
"0.51575416",
"0.51377195",
"0.51289004",
"0.5124579",
"0.5123621",
"0.5120596",
"0.5117638",
"0.51165885",
"0.5114434",
"0.51106954",
"0.51063776",
"0.5101465",
"0.50911915",
"0.5088271",
"0.5086802",
"0.5086802",
"0.5084172",
"0.50835115"
] |
0.72102404
|
0
|
The class destructor, use this method to perform any cleanup before the proxy kills the process this instance resides in.
|
def destroy
log_failure do
handler.destroy
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def stop!\n self.class.cleanup!(:pid => @sudo_pid, :socket => @socket)\n @proxy = nil\n end",
"def teardown\n Process.kill('KILL',@pid)\n end",
"def shutdown\n shutdown_proxy\n exit_thread\n super\n end",
"def close!\n _close\n @clean_proc.call\n ObjectSpace.undefine_finalizer(self)\n end",
"def destroy\n return nil if destroyed?\n\n debug \"Destroying Ruby-process (#{caller}).\\n\" if @debug\n pid = @pid\n tries = 0\n\n destroy_proxy_objects\n\n #Make main kill it and make sure its dead...\n begin\n if @main && @pid\n tries += 1\n Process.kill(\"TERM\", pid) rescue Errno::ESRCH\n\n #Ensure subprocess is dead.\n begin\n Timeout.timeout(1) do\n sleep 0.01\n\n loop do\n begin\n Process.getpgid(pid)\n alive = true\n rescue Errno::ESRCH\n alive = false\n end\n\n break unless alive\n end\n end\n rescue Timeout::Error\n Process.kill(9, pid) rescue Errno::ESRCH\n retry\n end\n end\n rescue Errno::ESRCH\n #Process is already dead - ignore.\n ensure\n @pid = nil\n\n @io_out.close if @io_out && !@io_out.closed?\n @io_out = nil\n\n @io_in.close if @io_in && !@io_in.closed?\n @io_in = nil\n\n @io_err if @io_err && !@io_err.closed?\n @io_err = nil\n\n @main = nil\n end\n\n return nil\n end",
"def dealloc()\n\n\t\tself.disconnect();\n\n\t\t@mPortOptions = nil;\n\n\t\tnil;\n\n\tend",
"def finalize()\n # below function is not yet fully functional\n unlock_all_instances()\n end",
"def cleanup_meterpreter\n if self.pivot_session\n self.pivot_session.remove_pivot_session(self.session_guid)\n end\n\n self.pivot_sessions.keys.each do |k|\n pivot = self.pivot_sessions[k]\n pivot.pivoted_session.kill('Pivot closed')\n pivot.pivoted_session.shutdown_passive_dispatcher\n end\n\n unless self.skip_cleanup\n ext.aliases.each_value do | extension |\n extension.cleanup if extension.respond_to?( 'cleanup' )\n end\n end\n\n dispatcher_thread.kill if dispatcher_thread\n\n unless self.skip_cleanup\n core.shutdown rescue nil\n end\n\n shutdown_passive_dispatcher\n end",
"def cleanup\r\n\t\tsuper\r\n\t\tif self.service\r\n\t\t\tprint_status(\"Shutting down payload stager listener...\")\r\n\t\t\tbegin\r\n\t\t\t\tself.service.deref if self.service.kind_of?(Rex::Service)\r\n\t\t\t\tif self.service.kind_of?(Rex::Socket)\r\n\t\t\t\t\tself.service.close\r\n\t\t\t\t\tself.service.stop\r\n\t\t\t\tend\r\n\t\t\t\tself.service = nil\r\n\t\t\trescue ::Exception\r\n\t\t\tend\r\n\t\tend\r\n\tend",
"def cleanup; end",
"def cleanup; end",
"def cleanup; end",
"def cleanup; end",
"def cleanup!; end",
"def cleanup!; end",
"def close\n @proxy_socket.close\n @proxy_socket = nil\n end",
"def setup_finalizer\n ObjectSpace.define_finalizer(self, self.class.close_zloop(@zloop))\n end",
"def shut_down\n end",
"def destroy\n kill\n reset\n end",
"def finalize\n logger.info \"Finalizing\"\n if @monitor_thread\n @monitor_thread.kill\n @monitor_thread = nil\n end\n @doozer_pool.close if @doozer_pool\n @doozer_pool = nil\n end",
"def stop\n\t\t@dispatch_thread.kill if !@dispatch_thread.nil?\n\t\t@dispatch_thread = nil\n\n\t\[email protected] if [email protected]?\n\t\t@cpg = nil\n\t\t@cpg_members = nil\n\n\t\[email protected] if [email protected]?\n\t\t@quorum = nil\n\tend",
"def destroy(world)\n begin\n # Is it a spriteCloud proxy?\n if @is_scproxy\n # Request HAR data\n response = self.har_get\n if response[\"status\"] == true\n # Add it to the storage\n world.storage.set(\"har\", response[\"result\"])\n end\n end\n self.close\n rescue StandardError => err\n world.log.debug(\"Failed to close the proxy: #{err}\")\n end\n end",
"def tear_down; end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def teardown\n evicting_thread.kill\n end",
"def cleanup\r\n end",
"def teardown\n #commented this out because it is now unnecessary\n # @api = nil\n #GC.start\n @api.close_api\n # @server.close\n end",
"def cleanup\n\t\tcleanup_meterpreter\n\n\t\tsuper\n\tend",
"def cleanup\n super\n disconnect\n end",
"def cleanup\n end",
"def cleanup\n end",
"def tear_down\n self.instance.tear_down unless self.instance.nil?\n self.instance = nil\n end",
"def flexmock_teardown\n if ! detached?\n @methods_proxied.each do |method_name|\n remove_current_method(method_name)\n restore_original_definition(method_name)\n end\n @obj.instance_variable_set(\"@flexmock_proxy\", nil)\n @obj = nil\n end\n end",
"def flexmock_teardown\n if ! detached?\n @methods_proxied.each do |method_name|\n remove_current_method(method_name)\n restore_original_definition(method_name)\n end\n @obj.instance_variable_set(\"@flexmock_proxy\", nil)\n @obj = nil\n end\n end",
"def cleanup\n log.info(\"Shutting down\")\n @lifelines.each do |pid, lifeline|\n begin\n lifeline.close\n rescue IOError\n end\n end\n socket.close\n remove_pid_file\n end",
"def destroy_all\n proxy_target.each { |object| object.destroy }\n end",
"def terminate\n self.destroy\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def stop\n Vedeu.trigger(:_cleanup_)\n\n Vedeu::Runtime::MainLoop.stop!\n end",
"def cleanup!\n # This method may be left unimplemented if that is applicable\n end",
"def on_stop\n # close any open files, sockets, etc.\n end",
"def stop\n\t\treturn nil unless self.running?\n\t\tbegin\n\t\t\tProcess.kill 'TERM', @pid\n\t\t\tProcess.waitpid( @pid, 0 )\n\t\trescue SystemCallError => err\n\t\t\t$stderr.puts \"SystemCallError while stopping: #{err.message}\" if\n\t\t\t\t$DEBUG || $VERBOSE\n\t\tend\n\n\t\t@errlog = nil\n\t\t@custom_logs = {}\n\t\tObjectSpace.undefine_finalizer( self )\t\n\tend",
"def finalize(*args)\n FFI::Libvirt.virDomainFree(self)\n end",
"def kill\n\t\tframework.sessions.deregister(self)\n\tend",
"def kill\n\t\tframework.sessions.deregister(self)\n\tend",
"def cleanup_hook; end",
"def kill() end",
"def close()\n # If we don't have one we don't do anything\n return if !@is_scproxy or !self.has_session?\n\n # Send the call to the master\n response = self.proxy_close :port => @port, :master => true\n\n # Did we close it?\n if response[\"status\"] == true\n # Clear our session\n @port = nil\n else\n # Show an error\n raise response[\"message\"]\n end\n end",
"def kill\n signal(\"KILL\", scope: :all)\n cleanup\n end",
"def clean_up\n access_processes do |processes|\n processes.values.select(&:exited?).each do |process|\n process.io.stdout.path.unlink rescue nil\n end\n processes.delete_if { |_, process| process.exited? }\n # Do not leak @processes outside\n # We are using dRuby, keep input/output objects simple\n nil\n end\n end",
"def teardown\n response = Vanagon::Utilities.http_request(\n \"#{@pooler}/vm/#{@target}\",\n \"DELETE\",\n nil,\n { 'X-AUTH-TOKEN' => @token }\n )\n if response and response[\"ok\"]\n Vanagon::Driver.logger.info \"#{@target} has been destroyed\"\n $stderr.puts \"#{@target} has been destroyed\"\n else\n Vanagon::Driver.logger.info \"#{@target} could not be destroyed\"\n warn \"#{@target} could not be destroyed\"\n end\n rescue Vanagon::Error => e\n Vanagon::Driver.logger.info \"#{@target} could not be destroyed (#{e.message})\"\n warn \"#{@target} could not be destroyed (#{e.message})\"\n end",
"def teardown\n @mem.mem_clear\n end",
"def shutdown\n transition :shutdown\n kill_actors\n close_comm\n NodeCache.delete @id\n MailboxManager.delete Thread.mailbox\n instance_variables.each { |iv| remove_instance_variable iv }\n end",
"def cleanup!\n valid_proxies = ProxyListValidator.new(@proxies).validate\n @proxies &= valid_proxies\n end",
"def shutdown; end",
"def shutdown; end",
"def shutdown; end",
"def shutdown; end",
"def shutdown; end",
"def shutdown; end",
"def shutdown; end",
"def cleanup!\n valid_proxies = ProxyListValidator.new(@proxies).validate\n @proxies &= valid_proxies\n end",
"def clean!\n @pool_mutex.synchronize { _clean }\n end",
"def proxy_unbind\n close_connection_after_writing\n end",
"def cleanup\n self.image = nil\n GC.start\n end",
"def cleanup\n self.image = nil\n GC.start\n end",
"def finalize!; end",
"def setup_finalizer\n ObjectSpace.define_finalizer(self, self.class.close_zmsg(@zmsg))\n end",
"def cleanup\n # override and do something appropriate\n end",
"def destruct\n #puts \"Entering module ObjectBindings.destruct on item #{self} ...\"\n #puts \"about to destruct connections ...\"\n self.getConnections.each do |c| c.destruct end\n #puts \"about to destroyText ...\"\n self.destroyText\n #puts \"about to destroy self: #{self}\"\n self.destroy\n end",
"def close\n API.finalize( @vm )\n end",
"def destroy\n # Shutdown pool if active\n service.pool_action uuid, :destroy if active?\n # If this is a persistent domain we need to undefine it\n service.pool_action uuid, :undefine if persistent?\n end",
"def cleanUp\n if @running != nil\n info(\"Cleaning: Disconnect from the PubSub server\")\n RMCommunicator.instance.stop\n # info(\"Cleaning: Kill all previously started Applications\")\n # ExecApp.killAll ## NOTE: do we want to kill of the started RM on reset ???\n info(\"Cleaning: Exit\")\n info(\"\\n\\n------------ EXIT ------------\\n\")\n end\n end",
"def cleanup\n if (payload_instance and handler_enabled?)\n payload_instance.cleanup_handler\n end\n self.abort_sockets if self.respond_to?(:abort_sockets)\n end",
"def decommission_proxy(proxy)\n server = server_by_proxy proxy\n server.destroy\n Activity << \"Decommissioned proxy #{proxy.host} (#{server.name})\"\n end",
"def dispose\n call Memory.deAlloc(self)\n end",
"def dispose\n call Memory.deAlloc(self)\n end",
"def cleanup\n\tend",
"def cleanup\n\tend",
"def kill\n @alive = false\n end",
"def kill!() end",
"def cleanup\n super\n if(service)\n stop_service()\n print_status(\"Server stopped.\")\n end\n end",
"def destroy\n self.timelog_stop_tracking\n \n #Use quit-variable to avoid Gtk-warnings.\n Gtk.main_quit if @quit != true\n @quit = true\n end",
"def dealloc\n end",
"def cleanup\n @omicli_pgids.each do |pgid|\n `pkill -KILL -g #{pgid}`\n end\n @omicli_pgids.clear\n end",
"def shutdown\n @connection_manager.shutdown if @connection_manager\n @client = nil\n @connection_manager = nil\n end",
"def shutdown\n @container = nil\n end",
"def cleanup(machine, opts)\n end",
"def finalize\n nil\n end",
"def dealloc\n notification_center.removeObserver(self)\n close\n super\n end",
"def destroy\n Process.kill(9, pid)\n end",
"def stop!\n return unless started?\n return if @process.nil?\n\n SSHTunnel.logger.info \"Stopping tunnel : #{self}\"\n\n @process.terminate\n @process.wait\n @started = false\n @process = nil\n end",
"def release\n self.ip_address = nil\n end",
"def shutdown\n @running = false\n \n super\n \n end",
"def close\n Wrapper.Quit(@native_manager) if @native_manager\n ensure\n @native_manager = nil\n end",
"def cleanup \n # close the sockets \n @servers.each{ |server| server[:listner].stop }\n @monitor.close\n end"
] |
[
"0.7218145",
"0.7097898",
"0.6955957",
"0.67301124",
"0.67030853",
"0.66489",
"0.6558154",
"0.65223634",
"0.6521523",
"0.64924544",
"0.64924544",
"0.64924544",
"0.64924544",
"0.64438206",
"0.64438206",
"0.6423641",
"0.64176726",
"0.64139134",
"0.6410862",
"0.63859314",
"0.6375328",
"0.63600457",
"0.6353487",
"0.6340968",
"0.6340968",
"0.6340968",
"0.6340968",
"0.63405454",
"0.63402164",
"0.63369423",
"0.6336273",
"0.63354266",
"0.6318612",
"0.6318612",
"0.63125694",
"0.6283891",
"0.6283891",
"0.6283133",
"0.6280748",
"0.6269478",
"0.62549883",
"0.62549883",
"0.62549883",
"0.6219602",
"0.6208423",
"0.6202291",
"0.6188118",
"0.61782944",
"0.61746764",
"0.617311",
"0.6164586",
"0.6162338",
"0.61578435",
"0.61466587",
"0.6124694",
"0.6119345",
"0.6090623",
"0.6084347",
"0.6077399",
"0.60763943",
"0.60763943",
"0.60763943",
"0.60763943",
"0.60763943",
"0.60763943",
"0.60763943",
"0.6075723",
"0.607557",
"0.60642344",
"0.6021683",
"0.6021683",
"0.60128933",
"0.6011726",
"0.6007295",
"0.60070115",
"0.6004362",
"0.5996679",
"0.5987435",
"0.5983473",
"0.59778833",
"0.5963774",
"0.5963774",
"0.59543693",
"0.59543693",
"0.5954089",
"0.59513026",
"0.5950007",
"0.59439707",
"0.5942336",
"0.5935135",
"0.593309",
"0.59329087",
"0.5932435",
"0.5929077",
"0.59247065",
"0.59242475",
"0.5922304",
"0.59177095",
"0.591525",
"0.5906379",
"0.5901216"
] |
0.0
|
-1
|
Retrieve a binary blob stored in the proxy state
|
def get_state(key)
proxy.getState(key)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def save2blob()\n url = URI.parse(getUrl)\n h = Net::HTTP.start(url.host, url.port) do |http|\n resp, data = http.get(url.path + '?' + url.query)\n return data\n end\n end",
"def blob\n generate\n storage.get(path).body\n end",
"def blob; end",
"def blob; end",
"def to_blob\n @blob\n end",
"def blob\n dbf.blob\n end",
"def blob\n @blob ||= image.to_blob\n end",
"def value\r\n @value ||= self.class.service_instance.get_blob(path)\r\n end",
"def download\n self.rqrcode.to_blob\n end",
"def to_blob; end",
"def to_blob; end",
"def to_blob; end",
"def to_blob; end",
"def to_blob; end",
"def to_blob; end",
"def to_blob\n File.binread(path)\n end",
"def get_binary\n # the base uri for api requests\n _query_builder = Configuration.base_uri.dup\n\n # prepare query string for API call\n _query_builder << '/response/binary'\n\n # validate and preprocess url\n _query_url = APIHelper.clean_url _query_builder\n\n # prepare headers\n _headers = {\n 'user-agent' => 'Stamplay SDK'\n }\n\n # Create the HttpRequest object for the call\n _http_request = @http_client.get _query_url, headers: _headers\n \n # Call the on_before_request callback\n @http_call_back.on_before_request(_http_request) if @http_call_back\n\n # Invoke the API call and get the binary response\n _response = @http_client.execute_as_binary(_http_request)\n\n # Call the on_after_response callback\n @http_call_back.on_after_response(_response) if @http_call_back\n\n # Endpoint error handling using HTTP status codes.\n if _response.status_code == 404\n return nil\n end\n\n # Global error handling using HTTP status codes.\n validate_response(_response)\n\n # Return appropriate response type\n return _response.raw_body\n end",
"def blob\n @blob ||= ($repo.gblob(@rev + ':' + @name))\n end",
"def get_b\n n = self.get_i32\n OSC::Blob.new(self.get_data(n))\n end",
"def raw_bytes\n @raw_bytes ||= read_raw_bytes\n end",
"def data; Marshal.load(Base64.decode64(read_attribute(:data))); end",
"def data\n read_attribute(binary ? :binary_data : :data)\n end",
"def get_binary\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/response/binary'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.get(\n _query_url\n )\n _response = execute_request(_request, binary: true)\n\n # Validate response against endpoint and global error codes.\n return nil if _response.status_code == 404\n validate_response(_response)\n\n # Return appropriate response type.\n _response.raw_body\n end",
"def blob\n nil\n end",
"def blob(id)\n head \"/blobs/#{id}\"\n end",
"def bytes\n self\n end",
"def raw\n @buffer\n end",
"def get_raw_buffer\n @buffer\n end",
"def io\n @io ||= StringIO.new(blob, 'r+b')\n end",
"def raw_body\n if @rev\n @raw_body ||= blob.contents\n else\n @raw_body ||= File.exists?(@filename) ? File.read(@filename) : ''\n end\n end",
"def bytes\n contents.bytes\n end",
"def bytes\n contents.bytes\n end",
"def base64\n self[:data]\n end",
"def read\n object = uy_connection.get(@path)\n object.data\n end",
"def take_snapshot\n json_string = self.snapshot_model.to_json\n Crypto::Bytes.from_string(json_string)\n end",
"def read\n client[\"/vaults/#{vault_id}/blobs/#{blob_id}\"].get\n end",
"def blob_response(key, query, *args)\n url = File.join(properties.primary_endpoints.blob, *args) + \"?#{query}\"\n headers = build_headers(url, key, 'blob')\n\n ArmrestService.send(\n :rest_get,\n :url => url,\n :headers => headers,\n :proxy => proxy,\n :ssl_version => ssl_version,\n :ssl_verify => ssl_verify,\n )\n end",
"def read\n object.content\n end",
"def picdata\n object.imgdata\n end",
"def download_blob_to_tempfile(&block); end",
"def download_blob_to_tempfile(&block); end",
"def to_blob\n f = File.new @path\n f.binmode\n f.read\n ensure\n f.close if f\n end",
"def data\n if @path\n File.open(@path, \"rb\"){|f| f.read} rescue nil\n else\n @memory_io.string.clone\n end\n end",
"def read_binary\n raise NotImplementedError\n end",
"def ref\n @bin\n end",
"def store_blob(blob)\n super #=> returns blob[:tempfile]\n end",
"def blob(oid, destination)\n begin\n res = barerepo.blob_at oid, destination\n rescue\n return nil\n end\n res\n end",
"def blob(oid, destination)\n begin\n res = barerepo.blob_at oid, destination\n rescue\n return nil\n end\n res\n end",
"def bytes\n @lmdb.transaction do\n if ret = @dbs[:control]['bytes']\n ret.unpack1 'Q>'\n end\n end\n end",
"def get(filename)\n @ftp.getbinaryfile(filename, nil)\n end",
"def getbyte()\n #This is a stub, used for indexing\n end",
"def raw\n @xbrl_content\n end",
"def snapshot\r\n date = self.class.service_instance.snapshot_blob(self.path)\r\n properties = self.class.service_instance.get_blob_properties(self.path)\r\n return BlobObject.new(:name => self.name, \r\n :url => self.class.service_instance.generate_request_uri(self.path) + \"?snapshot=#{date}\",\r\n :content_type => properties[:content_type],\r\n :snapshot_date => date)\r\n end",
"def raw_data\n @raw_data ||= api_url.open.read\n end",
"def data\n @buffer.string\n end",
"def get_bytes()\n @value\n end",
"def read\n read_object(read_byte)\n end",
"def read_blob(ref, filename)\n blob = repository&.blob_at(ref, filename)\n\n raise 'Blob not found' unless blob\n raise 'File is not readable' unless blob.readable_text?\n\n blob\n end",
"def file_data\n @client.get_file @file_url\n end",
"def blob\n read_repo\n if @branches.count < 1\n render :template => 'repositories/newrepo'\n return\n end\n\n params[:action] = \"blob\"\n\n @blob = @repository.get_blob(@branch, @path)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repository }\n end\n end",
"def value\n \"LOAD_FILE(\\\"#{@blob_file}\\\")\"\n end",
"def store_blob(object,field_name,blob)\n super #=> returns blob[:tempfile]\n end",
"def bytes\n Base64.decode64(data)\n end",
"def blob?\n @blob\n end",
"def bytes; end",
"def getBlobById(blob_id)\n b = @repo.blob(blob_id).data\n if b == \"\"\n # either the blob doesn't exist or it does but the data is empty\n return false\n end\n return b\n end",
"def get_image_bytes(url)\n URI.open(url).read\nend",
"def download\n \n @tmpfile = fetch_remote(location)\n \n @fetched_at = Time.new\n \n return @tmpfile\n \n end",
"def contents\n if persisted?\n f=Photo.mongo_client.database.fs.find_one(:_id=>BSON::ObjectId.from_string(@id))\n if f \n buffer = \"\"\n f.chunks.reduce([]) do |x,chunk| \n buffer << chunk.data.data \n end\n return buffer\n end \n end\n end",
"def data\n FFI::MemoryPointer.new(:size_t) do |size|\n data = Spotify.image_data(@pointer, size)\n return data.read_bytes(size.read_size_t)\n end\n end",
"def data\n return @content.data\n end",
"def object_data(path)\n blob = path_to_object(path)\n return nil if (not blob) || (blob.kind_of? Grit::Tree)\n blob.kind_of?(Grit::Blob) ? blob.data : blob\n end",
"def data_as_bytes\n raise \"subclass responsibility\"\n end",
"def actual_buffer(offset=0)\n @transfer[:buffer].get_bytes(offset, @transfer[:actual_length])\n end",
"def blob(arg)\r\n file MojoMagick::tempfile(arg)\r\n end",
"def get_object(id)\n return nil unless (blob = find_blob(id)) && (obj = blob.read_object(id))\n deserialize(obj)\n end",
"def data= blob\n $postgres.exec_prepared('wsfile_update', [self.id, {value: blob, format: 1}])\n end",
"def blob(repo, digest, file)\n doreq('get', \"/v2/#{repo}/blobs/#{digest}\", file)\n end",
"def as_received\n raw_data\n end",
"def body\n downloader.content\n end",
"def credential_blob\n size = @cred_struct[:credential_blob_size]\n return nil unless size > 0\n\n @cred_struct[:credential_blob].read_bytes(size)\n end",
"def buffer\n @transfer[:buffer].read_string(@transfer[:length])\n end",
"def bytes()\n #This is a stub, used for indexing\n end",
"def meta\n blob = ActiveStorage::Blob.find_signed(params[:id])\n\n render json: { blob: blob, url: rails_blob_url(blob) }\n end",
"def get_bin(id)\n File.read(File.join(File.expand_path(File.dirname(__FILE__)),'data',id.to_s),mode: 'rb')\n end",
"def load(blob)\n internal = decrypt(blob)\n ::Riak::Serializers.deserialize(content_type, internal)\n end",
"def to_buffer\n validate_binary_operations\n @request.perform(binary: true)\n end",
"def base64\n content = storage.read(id)\n base64 = Base64.encode64(content)\n base64.chomp\n end",
"def read\n connection.open(full_remote_path).read\n end",
"def to_blob\n stream = StringIO.new\n @surface.write_to_png(stream)\n stream.string\n end",
"def as_bytes\n raise NotImplementedError\n end",
"def data\n Base64::decode64(@data)\n end",
"def metadata\r\n self.class.service_instance.get_blob_properties(path)\r\n end",
"def raw_response\n Net::HTTP.get(endpoint)\n end",
"def data\n return nil if photo_data.nil?\n return photo_data.data\n end",
"def blob(repo)\n @blob ||= Grit::Blob.create(repo,\n :id => @sha, :name => name, :size => @size)\n end",
"def read_keyblob(type); end",
"def file_download\n blob_cache(:file_download) do\n raw_download = tiddlywiki_file.download\n is_compressed? ? SiteCommon.decompress_html(raw_download) : raw_download\n end\n end",
"def find_blob_data(sha, path)\n commit = barerepo.lookup sha\n tree = barerepo.lookup commit.tree_id\n blob = tree.path path\n blobdata = barerepo.read(blob[:oid]).data\n image = {\n name: blob[:name],\n data: blobdata\n }\n [image , commit]\n end",
"def demarshal_object(blob)\n Marshal.load(blob)\n end",
"def data_as_bytes\n data = []\n data << @status\n data << @meta_type\n data << 4\n data << @data[0]\n data << @data[1]\n data << @data[2]\n data << @data[3]\n end"
] |
[
"0.6810824",
"0.67158085",
"0.65718204",
"0.65718204",
"0.65417856",
"0.6490886",
"0.648429",
"0.6477422",
"0.6394587",
"0.63911885",
"0.63911885",
"0.63911885",
"0.63911885",
"0.63911885",
"0.63911885",
"0.6375687",
"0.63331854",
"0.6315418",
"0.6293909",
"0.62672865",
"0.6248689",
"0.62423134",
"0.6237752",
"0.6222279",
"0.6181275",
"0.6142936",
"0.6102273",
"0.6048501",
"0.6031316",
"0.6024257",
"0.588667",
"0.588667",
"0.5867206",
"0.58570725",
"0.58448845",
"0.5837802",
"0.5826665",
"0.5805781",
"0.5795569",
"0.5791024",
"0.5791024",
"0.57880944",
"0.578632",
"0.57760215",
"0.57634956",
"0.57531756",
"0.572379",
"0.572379",
"0.56847894",
"0.56746215",
"0.5670904",
"0.5662258",
"0.56459284",
"0.5643866",
"0.5628096",
"0.562722",
"0.56226504",
"0.5621664",
"0.55749786",
"0.55705404",
"0.5570075",
"0.5548004",
"0.554641",
"0.5526004",
"0.5523441",
"0.5520191",
"0.54996896",
"0.5499367",
"0.5499013",
"0.5497244",
"0.5489977",
"0.54624814",
"0.5459032",
"0.54468596",
"0.5439577",
"0.54383475",
"0.5436993",
"0.5428254",
"0.54050404",
"0.5404002",
"0.54002213",
"0.53983474",
"0.539757",
"0.53913254",
"0.53907114",
"0.53872734",
"0.53814024",
"0.5378031",
"0.53721577",
"0.53710663",
"0.53671867",
"0.53616613",
"0.53605634",
"0.5353222",
"0.5349042",
"0.5340533",
"0.53350645",
"0.53320915",
"0.53275555",
"0.5326255",
"0.53212965"
] |
0.0
|
-1
|
Store a binary blob, identified by a key, in the proxy state
|
def set_state(key, value)
proxy.setState(key, value)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def write(key, value)\n key.freeze if key.is_a? String\n\n @memory_store[key] = value\n @file_store.transaction do\n @file_store[key] = value\n end\n end",
"def storeSerialised( handle, key, klass )\n s = Marshal.dump( klass )\n handle[ key ] = s;\nend",
"def persist(key); end",
"def persist(key); end",
"def save(key, value)\n storage.transaction {storage[key] = value}\n end",
"def store(type, key, file)\n raise Dis::Errors::ReadOnlyError if readonly?\n\n store!(type, key, file)\n end",
"def store(key, data)\n store = Storage.new\n store.data = data\n\n if store.save \n session[key] = store.id\n cookies[key] = store.id\n end\n end",
"def set(data)\n data = data.to_json\n cache_key = Digest::SHA1.hexdigest(data)\n\n log(\"insert :Cache, #{cache_key} -> {'blob' => #{data.inspect}}\")\n connection.insert(:Cache, cache_key, { \"blob\" => data })\n cache_key\n end",
"def store(calling_node, key, value)\n @router.touch(calling_node)\n return false unless key.class == DataKey\n @values[key.to_bin] = value\n return true\n end",
"def store_blob(object,field_name,blob)\n super #=> returns blob[:tempfile]\n end",
"def store_blob(blob)\n super #=> returns blob[:tempfile]\n end",
"def store_data key, value\n init_data\n\n Bot::DB[my_name][key] = value\n end",
"def store_data key, value\n init_data\n\n Bot::DB[my_name][key] = value\n end",
"def store(key, value)\n #open!(key)\n super(key, value)\n end",
"def load_buffer_data(key)\n @buffers[@active_buffer].set_buffer_data(key,read_file(key))\n end",
"def store(new_file)\n res = client[\"/vaults/#{vault_id}/blobs\"].post file: new_file.to_file\n json = JSON.parse(res)\n self.blob_id = json['blob_id']\n true\n end",
"def []=(key, value)\n object = @bucket.get_or_new sanitize_key(key)\n object.raw_data = Marshal.dump(value)\n object.content_type = \"application/x-ruby-marshal\"\n object.store\n value\n end",
"def save(key, maybe_param, blob, etag)\n $logger.debug(\"Cache write: #{key},#{maybe_param}\")\n filename = args_to_filename(key, maybe_param)\n FileUtils.mkdir_p(File.dirname(filename))\n IO::write(filename, blob)\n IO::write(\"#{filename}.etag\", etag)\n end",
"def set(key, flags, expiration, length, data)\n storage[key] = {\n expiration: expiration,\n flags: flags,\n value: data\n }\n\n 'STORED'\n end",
"def store(key, data, opts={})\n if data.respond_to?(:read)\n multipart_store(key, data, opts)\n else\n singlepart_store(key, data, opts)\n end\n end",
"def store_cache(key, name)\n checksum = Digest::MD5.hexdigest(key)\n node.default['data-bag-cache']['__checksums__'][checksum] = name\n end",
"def unsafe_save(namespace, key, data)\n path = make_path(namespace, key)\n tmp = Tempfile.new('abbey') \n size = tmp.write(MultiJson.encode(data))\n tmp.close\n FileUtils.mv(tmp.path, path)\n settings.logger.info(\"Written #{make_key(namespace, key)} (size: #{size})\")\n tmp.unlink\n end",
"def store(key, value)\n\t\t\tused_key = key \n\t\t\twhile File.exists?(key_to_path(used_key))\n\t\t\t\tif fetch(used_key) == value\n\t\t\t\t\tFileUtils.touch(key_to_path(used_key))\n\t\t\t\t\treturn used_key # Already exists. Do not store again.\n\t\t\t\tend\n\t\t\t\tused_key = Soil.digest_class.digest(key)\n\t\t\tend\n\t\t\tfile_path = key_to_path(used_key)\n\n\t\t\tFileUtils.mkpath(file_path.dirname)\n\t\t\tFile.open(file_path, 'w') do |f|\n\t\t\t\tf.write(Zlib::Deflate.deflate value)\n\t\t\tend\n\t\t\treturn used_key\n\t\tend",
"def put key, value\n # append value to open file\n # write new keydict value\n @keydict[key] = write_data_entry key, value\n\n # sync\n\n if @data_file.size > MAX_FILE_SIZE\n fname = @data_file.path\n @data_file.close\n @data_file = open_new_data_file\n @old_data_files[fname] = File.open(fname, \"rb\")\n end\n end",
"def set_blob\n @blob = Blob.find(params[:id])\n end",
"def set_blob\n @blob = Blob.find(params[:id])\n end",
"def set key, data\n\t\t@data_base[ key ] = data\n\t\tupdate_database\n\tend",
"def write(key, content)\n set(key.to_s, content.to_json)\n end",
"def set(key, value)\n filename = filename_from_url(key)\n mkpath(filename)\n\n # Save metadata in a parallel file\n if value.respond_to?(:meta)\n filename_meta = \"#{filename}.meta\"\n meta = value.meta\n meta[:status] = value.status if value.respond_to?(:status)\n meta[:content_type] = value.content_type if value.respond_to?(:content_type)\n meta[:base_uri] = value.base_uri if value.respond_to?(:base_uri)\n File.open(filename_meta, 'wb') {|f| YAML::dump(meta, f)}\n end\n\n # Save file contents\n File.open(filename, 'wb'){|f| f.write value.read }\n value.rewind\n value\n end",
"def set(key, value)\n @content[key] = ActiveSupport::SafeBuffer.new(value.to_s)\n end",
"def blob; end",
"def blob; end",
"def stored_key(key)\n h(key)\n end",
"def store(key, data, bucket = nil, options = {})\n validate_key!(key)\n # Must build path before infering content type in case bucket is being used for options\n path = path!(bucket, key, options)\n infer_content_type!(key, options)\n \n put(path, options, data) # Don't call .success? on response. We want to get the etag.\n end",
"def save(key, data)\n self.ready\n \n unless @validId.nil?\n\t\t\t\traise SwapDmi::CacheSaveError.new(key) unless self.instance_exec(key, &@validId)\n end\n \n self.evict(key) if @evictWhen[:save]\n self.instance_exec(key, data, &@save)\n self\n end",
"def store(key, value)\n filename = File.join(dir, key)\n File.write(filename, value)\n filename\n end",
"def store(hash)\n store_for_id(@id, hash)\n end",
"def store(key_store_file, password)\n\n end",
"def put_object(obj, id)\n find_blob(id, true).write_object(id, serialize(obj))\n end",
"def store(id, data)\n storage[id] = data\n end",
"def read_keyblob(type); end",
"def restoreSerialised( handle, key )\n obj = nil\n data = handle[ key ];\n obj = Marshal.load( data )\n return obj\nend",
"def add_write(key, value, binary = false)\n if (@is_commit)\n raise RuntimeError.new('No further request supported after a commit!')\n end\n @requests << {'write' => {key => JSONConnection.encode_value(value, binary)}}\n self\n end",
"def read(key)\n key.freeze if key.is_a? String\n\n if @memory_store.has_key? key\n @memory_store[key]\n else\n @file_store.transaction do\n @memory_store[key] = @file_store[key]\n end\n @memory_store[key]\n end\n end",
"def store_buffer\n return unless buffer?\n @buffer.binmode\n @buffer.pos = 0 # TODO: なんか頭が落ちるので!\n File.open(stored_file_path, \"wb\") do |f|\n f.write(@buffer.read)\n end\n end",
"def set(key, value)\n self.data ||= {}\n self.data[key.to_s] = value\n self.save!\n end",
"def record_write bytes\n @reader.record_write bytes, @state\n end",
"def []=(key, content)\n temp_file = File.join(root, ['tmp', $$, Thread.current.object_id].join('-'))\n File.open(temp_file, 'wb') do |dest|\n if content.respond_to? :to_str\n dest.write(content.to_str)\n else\n content.each {|s| dest.write(s) }\n end\n end\n\n path = cache_path(key)\n File.unlink path if File.exist?(path)\n FileUtils.mkdir_p File.dirname(path), :mode => 0755\n FileUtils.mv temp_file, path\n rescue\n File.unlink temp_file rescue nil\n ensure\n content\n end",
"def store(keyname, value)\n @keystore.store(key: keyname, value: value)\n end",
"def set_checkpoint_key(value)\n @redis.write(@checkpoint_key, value)\n end",
"def store(key, contents)\n raise NotImplementedError.new 'Implement store(key, contents) in your CacheManager'\n end",
"def store_content(key, klass, content)\n raise MogileFS::ReadOnlyError if readonly?\n\n new_file key, klass do |mfp|\n if content.is_a?(MogileFS::Util::StoreContent)\n mfp.streaming_io = content\n else\n mfp << content\n end\n end\n\n content.length\n end",
"def save\n raise 'Blob is empty' if !data\n repository.put(self) if modified?\n id\n end",
"def write(key, value, opts = {})\n _key = Digest::SHA1.hexdigest key\n ttl = opts[:ttl] || @default_ttl\n \n # We don't want to cache errors\n return if value.is_a?(Faraday::Response) && !value.success?\n\n if (value.is_a?(Faraday::Response) && !value.headers['expires'].nil?)\n resp_ttl = DateTime.parse(value.headers['expires']).to_time.to_i - Time.now.to_i\n ttl = resp_ttl if resp_ttl > 0\n end\n\n _value = Marshal.dump value\n\n @memory_store[_key] = value\n $LOG.debug \"Writing to JDG cache hashed #{_key} for #{key}\"\n @conn.put do |req|\n req.url \"/rest/jbossdeveloper/#{@profile}_#{_key}\"\n req.headers['Content-Type'] = opts[:content_type] || 'application/ruby+object'\n req.headers['timeToLiveSeconds'] = ttl.to_s # need to see if we're actually a request and full from that\n req.body = _value\n end\n end",
"def put_raw_object(raw, id)\n find_blob(id, true).write_object(id, raw)\n end",
"def set key, value, expiration\n backend.set key.to_s, serialize(value), expiration rescue nil\n end",
"def store_object(robject, options = {})\n raw_data = begin; robject.raw_data.dup; rescue TypeError; robject.raw_data; end\n\n bucket_data(robject.bucket, options[:type])[:keys][robject.key] = {\n :value => raw_data,\n :content_type => robject.content_type.dup,\n :links => robject.links.dup,\n :indexes => robject.indexes.dup,\n :meta => robject.meta.dup,\n :etag => Digest::MD5.hexdigest(raw_data.to_s),\n :last_modified => Time.now.gmtime,\n :vclock => Base64.encode64(Time.now.to_f.to_s).chomp\n }\n end",
"def save!(private_key)\n bitcoin.sendrawtransaction to_signed_tx(private_key)\n end",
"def hash_end(_key)\n save_batch\n end",
"def key_data; end",
"def key_data; end",
"def add_blob\n repository.add(blob_path)\n end",
"def invoke_write_key(key)\n write_key(key)\n end",
"def set(key, value)\n @store[key] = value\n end",
"def image(key)\n return @data[key].clone\n end",
"def []=(key, value)\n @storage[key] = value\n end",
"def store_archive(hash)\n raise NotImplementedError\n end",
"def write(key, value)\n filepath = realpath(key)\n FileUtils.mkdir_p(File.dirname(filepath))\n IO.binwrite(filepath, Marshal.dump(value))\n true\n end",
"def store(path, record)\n # Sanitize path\n path = \"#{Paths::VFS}/#{path}\" unless path.start_with?(Paths::VFS)\n path = sanitize_path(path)\n\n @api.post(path, :body => record)\n end",
"def []=(key, val)\n @write_lock ||= true\n @data ||= restore\n @data[key] = val\n end",
"def put_record(stream, key, value)\n raise NotImplementedError\n end",
"def save(key, value)\n s3_write key, value\n end",
"def read(key)\n _key = Digest::SHA1.hexdigest key\n\n unless @memory_store.has_key? _key\n response = @conn.get \"/rest/jbossdeveloper/#{@profile}_#{_key}\"\n if response.success?\n @memory_store[_key] = Marshal.load(response.body)\n end\n end\n @memory_store[_key]\n end",
"def add_key_data(key_data_); end",
"def store identifier, object\n @storage.shift if @storage.size >= @size_limit\n @storage[identifier] = object\n end",
"def store(sender)\n raise ShadowHashError.new(ShadowHashError::UNSUPPORTED_OBJECT_ERR) unless sender.is_a? MacAdmin::User\n @data = { @label => convert_to_blob(@hash) }.to_plist\n sender['ShadowHashData'] = [@data]\n end",
"def add(host, key)\n File.open(source, \"a\") do |file|\n blob = [Net::SSH::Buffer.from(:key, key).to_s].pack(\"m*\").gsub(/\\s/, \"\")\n file.puts \"#{host} #{key.ssh_type} #{blob}\"\n end\n end",
"def persist(key)\n node_for(key).persist(key)\n end",
"def []=(key, value)\n @data[key] = value\n\n save if autosave?\n end",
"def []=(key,value)\n doozer_pool.with_connection do |doozer|\n doozer[full_key(key)] = @serializer.serialize(value)\n end\n end",
"def store(key, value)\n value = apply_store_hook(key, value)\n key = aliases[key] || key\n super(key, value) unless @frozen_keys.include?(key)\n end",
"def persist(key)\n send_command([:persist, key], &Boolify)\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 add(key)\n @internal_hash[key] = true\n end",
"def import_by_using_cached_keys\n CommitKeyCreator.update_key_associations @blob.keys.to_a, @commit\n end",
"def load(key)\n #Open the persistent store read-only, and return the value under the given key.\n value = nil\n storage.transaction(true) {value = storage[key]}\n fail \"'#{key}' not found in storage.\" if value == nil\n value\n end",
"def save(data)\n\t\t\tredis.sadd(key, data)\n\t\tend",
"def write_key(*key); end",
"def redis_save(src, dst, eta)\n @redis.set redis_key(src, dst), eta\n end",
"def write(key, content)\n temp_file = File.join(root, ['tmp', $$, Thread.current.unique_id].join('-'))\n File.open(temp_file, 'wb') do |dest|\n if content.respond_to? :to_str\n dest.write(content.to_str)\n else\n content.each {|s| dest.write(s) }\n end\n end\n\n path = cache_path(key)\n if File.exist?(path)\n File.unlink temp_file\n else\n FileUtils.mkdir_p File.dirname(path), :mode => 0755\n FileUtils.mv temp_file, path\n end\n true\n rescue\n File.unlink temp_file rescue false\n false\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 write(key, content)\n bucket.objects[key].write(content)\n end",
"def save( oid, metadata )\n\t\toid = normalize_oid( oid )\n\t\t@storage[ oid ] = metadata.dup\n\tend",
"def []=(key, value)\n @store[key] = value\n end",
"def []=(key, value)\n @lock.synchronize { @store[key] = value }\n end",
"def save_hashes_for_write\n \n end",
"def buffer=(buffer)\n @buffer = buffer\n return unless buffer?\n self.name = buffer.original_filename\n self.unique_key = genkey()\n end",
"def save\n return if @blob.data == content\n repository.store(self, commit_message)\n end",
"def set(key, value)\n path = File.join(@root, \"#{key}.cache\")\n\n # Ensure directory exists\n FileUtils.mkdir_p File.dirname(path)\n\n # Check if cache exists before writing\n exists = File.exist?(path)\n\n # Serialize value\n marshaled = Marshal.dump(value)\n\n # Compress if larger than 4KB\n if marshaled.bytesize > 4 * 1024\n deflater = Zlib::Deflate.new(\n Zlib::BEST_COMPRESSION,\n Zlib::MAX_WBITS,\n Zlib::MAX_MEM_LEVEL,\n Zlib::DEFAULT_STRATEGY\n )\n deflater << marshaled\n raw = deflater.finish\n else\n raw = marshaled\n end\n\n # Write data\n PathUtils.atomic_write(path) do |f|\n f.write(raw)\n @size = size + f.size unless exists\n end\n\n # GC if necessary\n gc! if size > @max_size\n\n value\n end",
"def save(attrs)\n sha = git.set(:blob, JSON.generate(attrs))\n cache[sha] = attrs\n sha\n end"
] |
[
"0.62603575",
"0.61220354",
"0.61051315",
"0.61051315",
"0.61026686",
"0.60126024",
"0.5987433",
"0.59291893",
"0.5908089",
"0.58582526",
"0.5855919",
"0.5833741",
"0.5833741",
"0.5708418",
"0.5665019",
"0.56210124",
"0.5606915",
"0.5598862",
"0.55907345",
"0.556864",
"0.55490434",
"0.5547746",
"0.5538247",
"0.5523792",
"0.5483619",
"0.5483509",
"0.54692537",
"0.54652727",
"0.54632354",
"0.5458943",
"0.5453265",
"0.5453265",
"0.5425928",
"0.5425243",
"0.5423249",
"0.5415187",
"0.5402767",
"0.53993285",
"0.5396157",
"0.5368294",
"0.5368214",
"0.5351994",
"0.5351705",
"0.534463",
"0.5333661",
"0.5326664",
"0.5324225",
"0.531623",
"0.53132343",
"0.52998966",
"0.5293807",
"0.5287243",
"0.52854097",
"0.5284495",
"0.5273971",
"0.5272567",
"0.52684754",
"0.5245743",
"0.5241905",
"0.52410036",
"0.52410036",
"0.5239386",
"0.52277744",
"0.5224594",
"0.5219319",
"0.52160126",
"0.52055836",
"0.5204759",
"0.51996297",
"0.5195043",
"0.5190659",
"0.51579916",
"0.51452154",
"0.51424676",
"0.5139256",
"0.51287884",
"0.5127036",
"0.5123598",
"0.51205134",
"0.5120345",
"0.5115724",
"0.5108601",
"0.5106351",
"0.5101849",
"0.50914574",
"0.50893915",
"0.5089307",
"0.50870705",
"0.50774395",
"0.50759554",
"0.5072461",
"0.5069369",
"0.50680137",
"0.5064303",
"0.50611115",
"0.5058476",
"0.5054545",
"0.5053465",
"0.5051669",
"0.50455517"
] |
0.5331013
|
45
|
allows users to show their individual address information based on their user id
|
def show
user = User.find(params[:id])
render json: user.address
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n @user = User.find(params[:id])\n @address = @user.address || Address.new\n \n respond_to do |format|\n format.html # show.html.erb\n end\n end",
"def show\n @address = current_user.addresses.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @address }\n end\n end",
"def show\n @user_address = UserAddress.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_address }\n end\n end",
"def show\n\t @addresses = @user.addresses\n end",
"def set_user_address\n @user_address = UserAddress.find(current_user.id)\n # @user_address = UserAddress.find(params[:id])\n end",
"def set_user_address\n @user_address = UserAddress.find(params[:id])\n end",
"def set_user_address\n @user_address = UserAddress.find(params[:id])\n end",
"def show_address(id)\n get(\"addresses/#{id}\")\n end",
"def get_address(id)\n UserAddress.includes(user_location: :user).where(users: {:id => id}, user_locations: {:type => \"1\"})\n end",
"def show\n @user_address = UserAddress.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user_address }\n end\n end",
"def show\n id = params[:id].to_i - 1\n if (id < 0) or (id > @addresses.length)\n respond_to do |format|\n format.html { redirect_to \"/#{@user.name}\", alert: 'Address was not found.'}\n format.json { render json: @address }\n end\n else\n @address = @addresses[id]\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @address }\n end\n end\n \n end",
"def show\n @address = Address.find(params[:id])\n end",
"def show\n @address = Address.find(params[:id])\n end",
"def edit\n\t\t@address = current_user.addresses.find(params[:id])\n\tend",
"def address\n user.address\n end",
"def address_listing\n @addresses = current_user.addresses\n end",
"def set_address\n @address = Address.find_by(id: params[:id], user_profile_id: current_user.user_profile_id)\n end",
"def edit\n @user = User.find(params[:id])\n @address = @user.address || @user.build_address\n end",
"def replicate_address_from_current_user_details(id, user)\n\n address = Address.find(id)\n\n address.update(\n line1: user.line1,\n line2: user.line2,\n line3: user.line3,\n town_city: user.townCity,\n county: user.county,\n postcode: user.postcode\n )\n\n end",
"def show\n @user = User.find(params[:id]) if params[:id].present? && params[:id] != \"show\"\n unless @user\n @user = current_user\n end\n\n client = YahooWeather::Client.new\n @location = 'New York'\n if @user.locations.any?\n @location = @user.locations.first.address\n end\n\n\n end",
"def show\n @user = User.find(params[:id])\n render :partial => \"address_card\", :locals => { :user => @user }\n end",
"def show\n @address = Address.find_by(id: @caller.address_id)\n end",
"def user_address\n\tend",
"def get_address_book(user_id)\n self.class.get(\"https://api.yesgraph.com/v0/address-book/#{user_id}\",\n {\n :headers => @options\n }\n )\n end",
"def show\n @person = Person.find(params[:id])\n @addresses = @person.addresses\n end",
"def show_user_profile\n\t\t# find the home address\n\t\t@home_addresses = @profile_setting.addresses.where(address_type: \"home\")\n\tend",
"def show\n @address = @user_contribution.address\n @user_contributions = @address.user_contributions\n end",
"def index\n @addresses = current_user.addresses\n @address = Address.new\n end",
"def index\n\t@addresses=current_user.addresses\nend",
"def index\n @user_addresses = current_user.user_addresses\n end",
"def retrieve_address\n address_id = params[:address_id] \n @address = Address.find(address_id)\n end",
"def address_details\n @address_details ||= user.addresses.map { |address| AddressDetails.new user, address }\n end",
"def showAddress\n @posting=Posting.find(params[:id])\n if([email protected]_id.nil?)\n @address=Address.find(@posting[:address_id])\n else\n @address = Address.new\n end\n end",
"def edit\n @addresses = @user.addresses\n end",
"def index\n\t\t@addresses = current_user.addresses\n\tend",
"def index\n @users_and_address = {}\n @users.each do |user|\n @users_and_address[user] = user.has_role?(:doctor) ? Address.business_for(user) : Address.home_for(user)\n end\n end",
"def show\n redirect_to edit_address_path(@address)\n end",
"def set_address_detail\n @address_detail = AddressDetail.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def index\n @user_addresses = UserAddress.all\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def show\n @customers_address = CustomersAddress.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customers_address }\n end\n end",
"def show\n @taddress = Taddress.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @taddress }\n end\n end",
"def show\n @address = Address.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @address }\n end\n end",
"def show\n @address = Address.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @address }\n end\n end",
"def show\n @address = Address.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @address }\n end\n end",
"def menu_user\n find('.profile-address')\n \n end",
"def index\n #@addresses = Address.all\n #@addresses = @user.Address.all\n #@addresses = Address.\n @user = current_user\n @address = @user.address\n @appointment = @user.appointment\n \n end",
"def set_address\n @address = Address.find params[:id]\n end",
"def set_address\n @address = Address.find params[:id]\n end",
"def do_address_identifier_search\n @address_summary = AddressSummary.new(search_params)\n @search_results = @address_summary.search\n @show_manual_address = false\n # We need to carry the default country set up forward as the address currently\n @address_detail = Address.new(default_country: params[:address][:default_country])\n end",
"def visit_user_addresses(user)\n visit spree.edit_admin_user_path(user)\n expect_address_list\n\n expect_user_addresses(user)\n end",
"def address(address_id)\n from_resource :address,\n connection.get(api_uri(\"addresses/#{address_id}\"))\n end",
"def show\n @contributor_address = ContributorAddress.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contributor_address }\n end\n end",
"def handle_address_id(id)\n case id\n when AuthorizeNet::Address\n set_fields(:customer_address_id => id.customer_address_id.to_s)\n when nil\n nil\n else\n set_fields(:customer_address_id => id.to_s)\n end\n end",
"def show\n @address_type_list = AddressTypeList.find(params[:id])\n\tend",
"def show\n render :partial => 'show', :object => @address\n end",
"def update\n @user = User.find(params[:user_id])\n @address = @user.addresses.find(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:address])\n format.html { redirect_to admin_user_address_path(@user, @address), notice: 'Address was successfully updated.' }\n format.json { head :no_content }\n format.js\n else\n format.html { render action: \"edit\" }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def show\n @address_customer = AddressCustomer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @address_customer }\n end\n end",
"def set_address\n @address = @company.addresses.find(params[:id])\n end",
"def create\n @address = Address.new(params[:address])\n current_user.address = @address\n respond_to do |format|\n if @address.save\n format.html { render :partial => 'addresses/show', notice: 'Address was successfully created.' }\n else\n format.html { render :partial => 'addresses/new' }\n end\n end\n end",
"def check_address_owner(id, type)\n if a = Spree::Address.find_by_id(id)\n if a.user_id.present? && a.user_id != self.user_id\n raise \"Attempt to assign address #{a.id.inspect} from user #{a.user_id.inspect} to order #{self.number} from user #{self.user_id.inspect}\"\n end\n end\n\n id = a.try(:id)\n if type == :bill\n self['bill_address_id'] = id\n self.bill_address.try(:reload) if id\n else\n self['ship_address_id'] = id\n self.ship_address.try(:reload) if id\n end\n end",
"def set_ag_address\n @ag_address = Ag::Address.find(params[:id])\n end",
"def update\n @address = current_user.addresses.find(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:address])\n format.html { redirect_to user_address_path(current_user, @address), notice: 'Address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_address\n if @location\n @address = @locations.find(params['id'])\n else\n @address = Address.find(params['id'])\n end\n end",
"def show\n @billing_address = BillingAddress.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @billing_address }\n end\n end",
"def set_person_address\n @person_address = PersonAddress.find(params[:id])\n end",
"def address_params\n params[:address].permit(:user_id, :street, :city, :pin, :title)\n end",
"def edit\n # find address to edit\n @user_address = UserAddress.find_by_id(params[:id])\n \n # get location type and name\n @location_type = @user_address.location_type\n if @user_address.location_type == \"Other\"\n @location_name = @user_address.other_name\n @row_status = \"show\"\n else\n @location_name = @user_address.location_type\n @row_status = \"hidden\"\n end\n @header = \"Edit \" + @location_name\n \n # set session to remember page arrived from \n session[:return_to] = request.referer\n \n end",
"def show_addresses(**params)\n get('addresses', params)\n end",
"def set_address\n\t\t@address = Contact.find(params[:contact_id]).address\n\tend",
"def create\n @address = Address.new(params[:address])\n @address.user_id=current_user.id\n\n respond_to do |format|\n if @address.save\n format.html { redirect_to @address, notice: 'Address was successfully created.' }\n format.json { render json: @address, status: :created, location: @address }\n else\n format.html { render action: \"new\" }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n add_breadcrumb :details\n @map_opt = {\n :zoom => 2,\n :auto_adjust => true,\n :auto_zoom => false,\n :detect_location => true\n }\n @user = User.find(params[:id], :include => [:positions => [:company]])\n if (current_user.id != @user.id)\n Visit.create! :ip => request.ip, :ua => request.env['HTTP_USER_AGENT'], :user_id => current_user.id, :visitor_id => @user.id\n end\n respond_to do |format|\n format.html do #show.html.erb\n @markers = @user.to_gmaps4rails do |user, marker|\n marker.infowindow render_to_string(:partial => \"marker_template\", :locals => {:usr => @user})\n marker.json({:id => user.id})\n end\n end\n format.xml { render :xml => {:user => @user} }\n format.json { render :json => {:user => @user} }\n end\n end",
"def address\n '310 S Harrington'\n end",
"def current_uf\n\t\tcurrent_user.address_user\n\tend",
"def main_address\n addresses.first\n end",
"def address_inhabitant?\n unless(@address.id == current_user.address_id)\n redirect_to root_path, notice: \"You are not authorized to access that address!\"\n end\n end",
"def show\r\n\t\trender_result(\r\n\t\t\tdata: @addr_country,\r\n\t\t\tmeta: {}\r\n\t\t)\r\n\tend",
"def show\n puts \"\n ID: #{id}\n Last Name: #{last_name}\n First Name: #{first_name}\n Address: #{address}\n City: #{city}\n State: #{state}\"\n end",
"def show\n @address = Address.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @address }\n end\n end",
"def create \n @address=Address.new(address_params)\n @address.user_id=current_user.id\n\n if @address.save\n redirect_to addresses_path\n else\n \t render action: 'new'\n end\nend",
"def set_account_address\n @account_address = AccountAddress.find(params[:id])\n end",
"def index\n @user_locations = ::Users::UserLocation.where(user_id: auth_user.id).order('is_primary desc')\n @page_title = 'Your Addresses'\n\n respond_to do|format|\n format.html\n format.json { render json: @user_locations }\n end\n end",
"def create\n @user = User.find(params[:user_id])\n @address = @user.addresses.new(params[:address])\n\n respond_to do |format|\n if @address.save\n format.html { redirect_to admin_user_address_path(@user, @address), notice: 'Address was successfully created.' }\n format.json { render json: admin_user_address_path(@user, @address), status: :created, location: @address }\n format.js\n else\n format.html { render action: \"new\" }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def list_addresses\n Address.list(@id)\n end"
] |
[
"0.7939871",
"0.78729117",
"0.7737967",
"0.77083284",
"0.7403518",
"0.7371526",
"0.7371526",
"0.7359308",
"0.7356225",
"0.73513573",
"0.7276466",
"0.72709596",
"0.72709596",
"0.72358954",
"0.7220212",
"0.7137535",
"0.70764905",
"0.7036032",
"0.700668",
"0.6998792",
"0.6995277",
"0.6963763",
"0.6920883",
"0.6904154",
"0.68742424",
"0.6859822",
"0.6852167",
"0.684158",
"0.6830281",
"0.6800702",
"0.67724144",
"0.6742422",
"0.671234",
"0.66872287",
"0.6680996",
"0.6677663",
"0.6671292",
"0.66373277",
"0.6623078",
"0.6621859",
"0.65819234",
"0.65819234",
"0.65819234",
"0.65819234",
"0.6572802",
"0.6572802",
"0.6572802",
"0.6572802",
"0.6572802",
"0.6572802",
"0.6572802",
"0.6572802",
"0.6572802",
"0.6572802",
"0.6572802",
"0.6572802",
"0.65710795",
"0.6560903",
"0.65561724",
"0.65561724",
"0.65561724",
"0.6531292",
"0.64762074",
"0.6460578",
"0.6460578",
"0.6459626",
"0.6455005",
"0.6416468",
"0.64049613",
"0.64004236",
"0.6400029",
"0.6388484",
"0.6387684",
"0.63516724",
"0.6335766",
"0.63146937",
"0.62956595",
"0.6268488",
"0.6234858",
"0.62344724",
"0.62296396",
"0.6222724",
"0.62026834",
"0.61891854",
"0.6174417",
"0.6172149",
"0.6157034",
"0.6152287",
"0.6150657",
"0.614798",
"0.61379755",
"0.6127767",
"0.61254704",
"0.61200273",
"0.61190504",
"0.6117547",
"0.61171573",
"0.61049145",
"0.6088202",
"0.6087856"
] |
0.7389067
|
5
|
allows users to update address information
|
def update
user = User.find(params[:id])
if user.address.update(address_params)
render status: :ok
else
render status: :unprocessable_entity #was :bad_request
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def edit_address\n traveller = Traveller.find(params[:pk])\n address = params[:value]\n\n coordinates = GoogleAPIGeocoder.do_geocode(address)\n\n if coordinates.nil?\n render json: {success: false, msg: 'Unable to find the location of the given address. Please check that it is correct.'}\n else\n traveller.update(address: address, latitude: coordinates[0], longitude: coordinates[1])\n\n if current_user.nil?\n if session[:trip] != nil\n travellers = session[:trip].travellers\n travellers[travellers.index(traveller)].address = params[:value]\n end\n\n if session[:travellers] != nil\n session[:travellers][session[:travellers].index(traveller)].address = params[:value]\n end\n end\n\n render json: {success: true}\n end\n end",
"def update\n @address = current_user.addresses.find(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:address])\n format.html { redirect_to user_address_path(current_user, @address), notice: 'Address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @address.update(address_params)\n format.html { redirect_to admin_path(current_user), notice: 'Address was successfully updated.' }\n format.json { render :show, status: :ok, location: @address }\n else\n format.html { render admin_path(current_user), error: 'Issue.' }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n begin\n saved = @address.update!(address_params)\n save_redirector saved, @address, \"Address was successfully updated.\"\n rescue ActiveRecord::RecordInvalid => e\n redirect_to edit_address_path(@address), notice: e.message\n end\n end",
"def update\n @address = @addressable.addresses.find_by_id(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:address])\n format.html { redirect_to current_user, notice: 'address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @address.update(address_params)\n format.html { redirect_to home_path, notice: 'Address was successfully updated.' }\n format.json { render :show, status: :ok, location: @address }\n else\n format.html { render :edit }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @address = current_user.addresses.find(params[:id])\n respond_to do |format|\n if @address.update_attributes(params[:address])\n format.html { redirect_to \"/#{current_user.name}\", notice: 'Address was successfully updated.' }\n format.json { head :no_content }\n else\n @address.phones.build\n @address.faxs.build\n @address.emails.build\n format.html { render action: \"edit\" }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @address.update_attributes(params[:address]) and (@address.status == 'live' or @address.user_input)\n flash[:notice] = 'Address was successfully updated.'\n render :partial => 'show', :object => @address\n else\n render :partial => 'edit', :object => @address, :status => 409\n end\n end",
"def update\n if current_user\n @address = Address.find(params[:id])\n if current_user == @address.user\n address = Address.new(params[:address])\n address.user = current_user\n if address.save\n @address.update_attributes(:status => 'deleted')\n flash[:notice] = I18n.t(\"stizun.address.address_changed\")\n redirect_to user_addresses_path(current_user)\n else\n flash[:error] = I18n.t(\"stizun.address.address_couldnt_be_saved\")\n render :action => 'edit'\n end\n else\n flash[:error] = I18n.t(\"stizun.address.you_have_no_permission_to_edit\")\n redirect_to root_path\n end\n end\n end",
"def update_address\n\t\tif !params[:profile_setting].present?\n\t\t\tredirect_to user_profile_data_profile_path \n\t\telse\n\t\t\t@address = @user.update_attributes(address_params)\n\t\t\tif @address\n\t\t\t\t# redirect to the profile app page\n\t\t\t\tredirect_to user_profile_data_profile_path\n\t\t\telse\n\t\t\t\t# redirect to the user address page\n\t\t\t\tredirect_to user_address_profiles_path(type: params[:address_type])\n\t\t\t\tflash[:notice] = \"Address can't be blank\"\n\t\t\tend\n\t\tend\n\tend",
"def update\n if @address.update(address_params)\n render json: @address\n else\n render json: @address.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @ag_address.update(ag_address_params)\n format.html { redirect_to @ag_address, notice: 'Address was successfully updated.' }\n format.json { render :show, status: :ok, location: @ag_address }\n else\n format.html { render :edit }\n format.json { render json: @ag_address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @address = args[:address] if args.key?(:address)\n end",
"def update\n @user_address = UserAddress.find(params[:id])\n\n respond_to do |format|\n if @user_address.update_attributes(params[:user_address])\n format.html { redirect_to @user_address, notice: 'User address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @address.update(address_params)\n format.html { redirect_to root_path, notice: 'Address was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end",
"def update\n respond_to do |format|\n if @address.update(address_params)\n format.html { redirect_to @address, notice: 'Address was successfully updated.' }\n format.json { render :show, status: :ok, location: @address }\n else\n format.html { render :edit }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @address.update(address_params)\n format.html { redirect_to @address, notice: \"Address was successfully updated.\" }\n format.json { render :show, status: :ok, location: @address }\n else\n format.html { render :edit }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user_address.update(user_address_params)\n format.html { redirect_to user_addresses_path, notice: 'User address was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user_address.update(user_address_params)\n format.html { redirect_to @user_address, notice: \"User address was successfully updated.\" }\n format.json { render :show, status: :ok, location: @user_address }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @user_address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:user_id])\n @address = @user.addresses.find(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:address])\n format.html { redirect_to admin_user_address_path(@user, @address), notice: 'Address was successfully updated.' }\n format.json { head :no_content }\n format.js\n else\n format.html { render action: \"edit\" }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def update\n @user_address = UserAddress.find(params[:id])\n\n respond_to do |format|\n if @user_address.update_attributes(params[:user_address])\n format.html { redirect_to(@user_address, :notice => 'User address was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user_address.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @address.update(address_params)\n format.html { redirect_to @address, notice: 'Form was updated successfully!' }\n format.json { render :show, status: :ok, location: @address }\n else\n format.html { render :edit }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @address = Address.find(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:address])\n format.html { redirect_to @address, :notice => 'Address was successfully updated.' }\n format.json { render :json => @address }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @address.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit_address(edited_address)\n address = Address.find(edited_address.uid)\n address.attributes = edited_address.attributes\n address.save!\n end",
"def update\n @address = Address.find(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:address])\n format.html { redirect_to @address, notice: 'Address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @address = Address.find(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:address])\n format.html { redirect_to @address, notice: 'Address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @address = Address.find(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:address])\n format.html { redirect_to @address, notice: 'Address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @address = Address.find(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:address])\n format.html { redirect_to @address, notice: 'Address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @address = Address.find(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:address])\n flash[:notice] = 'Address was successfully updated.'\n #format.html { redirect_to admin_user_path(@address.user_id) } if authorized?\n format.html { redirect_to( :action=>'show', :id=>@address.id ) } # here we're editing from the user profile; add a conditional for editing from payment process\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @address.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @address = args[:address] if args.key?(:address)\n @geo_location = args[:geo_location] if args.key?(:geo_location)\n end",
"def edit_address(order_or_user, address_id, expect_success, values, type=nil)\n visit_edit_address(order_or_user, address_id)\n fill_in_address(values, type)\n click_button Spree.t('actions.update')\n\n if expect_success\n expect_address_collection_path(order_or_user)\n expect(page).to have_content(Spree.t(:successfully_updated, resource: Spree::Address.model_name.human))\n else\n expect(page).to have_no_content(Spree.t(:successfully_updated, resource: Spree::Address.model_name.human))\n expect(path_with_query).to eq(spree.admin_address_path(address_id, user_id: @user_id, order_id: @order_id))\n end\n end",
"def update\n @user = User.find(params[:id])\n @address = @user.address || @user.build_address\n\n respond_to do |format|\n if @user.update_attributes(params[:user]) && @address.update_attributes(params[:address])\n flash[:notice] = 'User was successfully updated.'\n format.html { redirect_to(@user) }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update\n respond_to do |format|\n if @address.update(address_params)\n format.html { redirect_to edit_company_path(@company), notice: 'Address was successfully updated.' }\n format.json { render :show, status: :ok, location: @address }\n else\n format.html { render :edit }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @address\n\n respond_to do |format|\n if @address.update(@pars)\n flash[:success] = \"Address was successfully updated. #{@pars.inspect}\"\n format.html { redirect_to addresses_path }\n format.json { render json: {locale: I18n.locale,\n user_id: @user_id,\n recyclable: @address.recyclable} }\n else\n flash[:danger] = \"There was a problem updating the address.\"\n format.html { render action: 'edit' }\n format.json { render json: @address.errors,\n status: :unprocessable_entity }\n end\n end\n end",
"def update_contact_info post\n AddressManager::set_user_address post.user, post\n end",
"def update\n respond_to do |format|\n if @post_address.update(post_address_params)\n format.html { redirect_to @post_address, notice: 'Adress uppdaterad.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post_address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @address_detail.update(address_detail_params)\n format.html { redirect_to @address_detail, notice: 'Address detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @address_detail }\n else\n format.html { render :edit }\n format.json { render json: @address_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # @address = Address.find(params[:id])\n @address = Address.find_by_permalink!(params[:id])\n \n respond_to do |format|\n if @address.update_attributes(params[:address])\n \n flash[:notice] = 'Address was successfully updated.'\n format.html { redirect_to(@address) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @address.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n save_phone_number\n\n respond_to do |format|\n\n if @user_location.update_attributes(params[resource_param_name])\n format.html { redirect_to next_after_save, notice: 'Address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @address = args[:address] if args.key?(:address)\n @phone_number = args[:phone_number] if args.key?(:phone_number)\n end",
"def update\n @address = Address.find(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:test])\n format.html { render :partial => 'addresses/show', notice: 'Address was successfully updated.' }\n else\n format.html { render :partial => 'addresses/edit' }\n end\n end\n end",
"def update\n @customers_address = CustomersAddress.find(params[:id])\n\n respond_to do |format|\n if @customers_address.update_attributes(params[:customers_address])\n format.html { redirect_to @customers_address, notice: 'Customers address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @customers_address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit\n\t\t@address = current_user.addresses.find(params[:id])\n\tend",
"def update\n respond_to do |format|\n if @account_address.update(account_address_params)\n format.html { redirect_to @account_address, notice: 'Account address was successfully updated.' }\n format.json { render :show, status: :ok, location: @account_address }\n else\n format.html { render :edit }\n format.json { render json: @account_address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_address\n @address = Address.find_by(id: params[:id], user_profile_id: current_user.user_profile_id)\n end",
"def set_address\n @address = Address.find params[:id]\n end",
"def set_address\n @address = Address.find params[:id]\n end",
"def delivery_address_update\n # stores the current delivery address\n delivery_address = @current_user.addresses.find_by(delivery_address: true)\n delivery_address.delivery_address = nil\n delivery_address.save!\n # changes the current delivery address to the given address id as a parameter\n address = @current_user.addresses.find(params[:id])\n address.delivery_address = true\n address.save!\n redirect_to cart_items_path\n end",
"def update\n\n logger.info \"Updating address for #{@type} ID: #{@model_object.id}\"\n\n @model_object.validate_address = true\n\n @model_object.update(model_params)\n\n if @model_object.valid?\n\n logger.info \"Finished updating address for #{@type} ID: \" \\\n \"#{@model_object.id}\"\n\n if @type == 'organisation'\n redirect_to organisation_mission_path(params['id'])\n elsif @type == 'project'\n redirect_to funding_application_gp_project_description_path(@model_object.funding_application.id)\n elsif @type == 'user'\n\n # Caters to a situation where original applicants have no person assigned to the user.\n check_and_set_person_address(@model_object) if @model_object.person.present?\n\n redirect_to :authenticated_root\n\n end\n\n else\n\n logger.info 'Validation failed when attempting to update address for ' \\\n \"#{@type} ID: #{@model_object.id}\"\n\n log_errors(@model_object)\n\n render :show\n\n end\n\n end",
"def update\n if @contact.address.update(address_params)\n render json: @contact.address\n else\n render json: @contact.errors, status: :unprocessable_entity\n end\n end",
"def update!(**args)\n @address = args[:address] if args.key?(:address)\n @administrative_area = args[:administrative_area] if args.key?(:administrative_area)\n @locality = args[:locality] if args.key?(:locality)\n @postal_code = args[:postal_code] if args.key?(:postal_code)\n @recipient = args[:recipient] if args.key?(:recipient)\n @region_code = args[:region_code] if args.key?(:region_code)\n end",
"def update_address\n address_zip = ZipCodes.identify(zip_code) || {}\n self.city = address_zip[:city]\n self.state = address_zip[:state_name]\n self.state_code = address_zip[:state_code]\n end",
"def update\n @address = Address.find(params[:id])\n @address.update_attributes(params[:address])\n @addresses = Address.paginate(:page => params[:page], :per_page => 30).order('updated_at DESC')\n end",
"def update_address(id, params)\n put(\"addresses/#{id}\", address: params, change_case: false)\n end",
"def save_address\n end",
"def add_or_update_address\n if @property.address !=nil\n @address = @property.address\n #client id added in query\n @address.update_attributes(params[:real_estate_property][:address_attributes])\n else\n #client id added in query\n @address = Address.store_address_details(params[:real_estate_property][:address_attributes][:txt],params[:real_estate_property][:address_attributes][:city], params[:real_estate_property][:address_attributes][:zip],params[:real_estate_property][:address_attributes][:province])\n @property.address_id = @address.id\n end\n end",
"def update\n respond_to do |format|\n if @client_address.update(client_address_params)\n format.html { redirect_to @client_address, notice: 'Client address was successfully updated.' }\n format.json { render :show, status: :ok, location: @client_address }\n else\n format.html { render :edit }\n format.json { render json: @client_address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_customer_address\n authenticate_request!\n current_customer.assign_attributes(customer_address_params)\n\n if current_customer.save!\n json_response(current_customer)\n else\n json_response({ errors: customer.errors.full_messages }, status: :bad_request)\n end\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @person_address.update(person_address_params)\n format.html { redirect_to @person_address, notice: 'Person address was successfully updated.' }\n format.json { render :show, status: :ok, location: @person_address }\n else\n format.html { render :edit }\n format.json { render json: @person_address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_contact_info txn\n AddressManager::set_user_address txn.user, txn\n end",
"def edit\n @user = User.find(params[:id])\n @address = @user.address || @user.build_address\n end",
"def update\n @taddress = Taddress.find(params[:id])\n \n respond_to do |format|\n if @taddress.update_attributes(params[:taddress])\n format.html { redirect_to @taddress, notice: 'Taddress was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @taddress.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def edit_library_address(selected)\n\tl = Library.find(selected)\n\tprint \"To edit the library address please enter here: \"\n\taddress = gets.chomp\n\tl.update_attributes(address: address)\nend",
"def update\n @address = Address.all\n respond_to do |format|\n if @shipping_information.update(shipping_information_params)\n format.html { redirect_to @shipping_information, notice: 'La información de envío se actualizó correctamente.' }\n format.json { render :show, status: :ok, location: @shipping_information }\n else\n format.html { render :edit }\n format.json { render json: @shipping_information.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_address(address, profile_id)\n @type = Type::CIM_UPDATE_ADDRESS\n @fields.merge!(address.to_hash)\n handle_profile_id(profile_id)\n make_request\n end",
"def update\n respond_to do |format|\n if @ripple_address.update(ripple_address_params)\n format.html { redirect_to @ripple_address, notice: 'Ripple address was successfully updated.' }\n format.json { render :show, status: :ok, location: @ripple_address }\n else\n format.html { render :edit }\n format.json { render json: @ripple_address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @customer_address.update(customer_address_params)\n format.html { redirect_to @customer_address, notice: 'Customer address was successfully updated.' }\n format.json { render :show, status: :ok, location: @customer_address }\n else\n format.html { render :edit }\n format.json { render json: @customer_address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @address = args[:address] if args.key?(:address)\n @address_line = args[:address_line] if args.key?(:address_line)\n @administrative_area = args[:administrative_area] if args.key?(:administrative_area)\n @dependent_locality = args[:dependent_locality] if args.key?(:dependent_locality)\n @language_code = args[:language_code] if args.key?(:language_code)\n @lat_lng = args[:lat_lng] if args.key?(:lat_lng)\n @locality = args[:locality] if args.key?(:locality)\n @postal_code = args[:postal_code] if args.key?(:postal_code)\n @region_code = args[:region_code] if args.key?(:region_code)\n @sorting_code = args[:sorting_code] if args.key?(:sorting_code)\n end",
"def update!(**args)\n @address = args[:address] if args.key?(:address)\n @business_name = args[:business_name] if args.key?(:business_name)\n end",
"def update\n respond_to do |format|\n if @electronic_address.update(electronic_address_params)\n format.html { redirect_to @electronic_address, notice: 'Electronic address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @electronic_address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_address\n end",
"def update!(**args)\n @address = args[:address] if args.key?(:address)\n @city = args[:city] if args.key?(:city)\n @country = args[:country] if args.key?(:country)\n @email = args[:email] if args.key?(:email)\n @phone = args[:phone] if args.key?(:phone)\n @postal_code = args[:postal_code] if args.key?(:postal_code)\n @state = args[:state] if args.key?(:state)\n @web_url = args[:web_url] if args.key?(:web_url)\n end",
"def update\n respond_to do |format|\n if @address_record.update(address_record_params)\n format.html { redirect_to @address_record, notice: 'Address record was successfully updated.' }\n format.json { render :show, status: :ok, location: @address_record }\n else\n format.html { render :edit }\n format.json { render json: @address_record.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_or_create_address(attributes)\n if attributes[:id]\n # TODO: Delete this part of the IF? It never gets called during tests.\n address = Spree::Address.find(attributes[:id])\n if address.editable?\n address.update_attributes(attributes)\n else\n address.errors.add(:base, I18n.t(:address_not_editable, scope: [:address_book]))\n end\n else\n address = Spree::Address.new(attributes)\n end\n address\n end",
"def update_geo_address\n self.geo_address = self.address1.to_s + \" \" + address2.to_s + \" \" + address3.to_s\nend",
"def update!(**args)\n @addr_fprint = args[:addr_fprint] if args.key?(:addr_fprint)\n @address = args[:address] if args.key?(:address)\n @lat_e7 = args[:lat_e7] if args.key?(:lat_e7)\n @lng_e7 = args[:lng_e7] if args.key?(:lng_e7)\n end",
"def update\n respond_to do |format|\n if @mortgage_address.update(mortgage_address_params)\n format.html { redirect_to @mortgage_address, notice: 'Mortgage address was successfully updated.' }\n format.json { render :show, status: :ok, location: @mortgage_address }\n else\n format.html { render :edit }\n format.json { render json: @mortgage_address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_address\n if @location\n @address = @locations.find(params['id'])\n else\n @address = Address.find(params['id'])\n end\n end",
"def change_address\n site = Site.find(params[:id])\n site.address = params[:url]\n site.save\n render :nothing => true\n end",
"def update\n @place = Place.find(params[:id])\n\n if not @place.address == \"\"\n @place.lat = Geocoder.coordinates(@place.address)[0];\n @place.lon = Geocoder.coordinates(@place.address)[1];\n end\n\n respond_to do |format|\n if @place.update_attributes(params[:place])\n format.html { redirect_to(@place, :notice => 'Place was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @place.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_user_address\n @user_address = UserAddress.find(params[:id])\n end",
"def set_user_address\n @user_address = UserAddress.find(params[:id])\n end",
"def business_details_page_change_business_address(postcode: 'BS1 5AH',\n address: 'HARMSEN GROUP, TRIODOS BANK, DEANERY ROAD, BRISTOL, BS1 5AH')\n\n fill_in 'sPostcode', with: postcode\n click_button 'find_address'\n select address\n business_details_page_submit_business_details_page\n end"
] |
[
"0.79523236",
"0.79081094",
"0.7890272",
"0.7873885",
"0.78191274",
"0.7731957",
"0.77282935",
"0.77171177",
"0.7712302",
"0.7662275",
"0.7648914",
"0.7622569",
"0.76196766",
"0.7610492",
"0.76064456",
"0.76033616",
"0.7598274",
"0.75687027",
"0.75624585",
"0.75400907",
"0.7526505",
"0.75180596",
"0.75105405",
"0.74739146",
"0.7467224",
"0.7467224",
"0.7467224",
"0.7467224",
"0.74350864",
"0.7419718",
"0.7388205",
"0.7371852",
"0.73599386",
"0.7354575",
"0.7327913",
"0.7327699",
"0.72895",
"0.72871053",
"0.7272261",
"0.726045",
"0.72556365",
"0.7235736",
"0.7234229",
"0.72337204",
"0.7223621",
"0.7220181",
"0.7220181",
"0.72145075",
"0.71978325",
"0.71836895",
"0.7182571",
"0.7180018",
"0.7165392",
"0.7163562",
"0.7152648",
"0.71517813",
"0.71454144",
"0.71420825",
"0.71236205",
"0.71236205",
"0.71236205",
"0.71236205",
"0.71236205",
"0.71236205",
"0.71236205",
"0.71236205",
"0.71236205",
"0.71236205",
"0.71236205",
"0.71236205",
"0.71186",
"0.71175516",
"0.71089166",
"0.7106313",
"0.7077451",
"0.7076161",
"0.7076161",
"0.7076161",
"0.7076161",
"0.7042131",
"0.70235103",
"0.7013665",
"0.701206",
"0.70115054",
"0.70014817",
"0.6993156",
"0.6986671",
"0.6985087",
"0.6981146",
"0.696172",
"0.696055",
"0.6958271",
"0.6947997",
"0.6947614",
"0.69279945",
"0.69199723",
"0.6915138",
"0.68838555",
"0.68838555",
"0.6877859"
] |
0.77593267
|
5
|
defines the permitted parameters that can be inputted
|
def address_params
params.require(:address).permit(:street, :suburb, :state, :postcode)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def valid_params?; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def check_params; true; end",
"def valid_params_request?; end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def expected_permitted_parameter_names; end",
"def accepted_parameters\n required_parameters + optional_parameters\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 submission_params\n allowed = :student_number, :last_name, :first_name, :week, :hours, :comments, :email, :github, :challenging\n (1..Course.current.exercises_max).each do |i|\n allowed << \"a#{i}\".to_s\n end\n params.require(:submission).permit(allowed)\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 parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def formulary_params\n allow = [:responsable_llenado,:cod01,:cod02,:ape01,:ape04,:ape07,:ape02,:ape05,:ape03,:ape06,:api01,:api04,:api02,:ssb01,:api03,:cao01,:cao04,:cao07,:cao10,:tit01,:cao02,:cao05,:cao08,:cao11,:cao03,:cao06,:cao09,:cao12,:uni01,:uni02,:uni03,:ben01,:ben02,:per01,:per02,:user_id]\n params.require(:formulary).permit(allow)\n end",
"def user_params\r\n end",
"def parameter_control_params\n params.require(:parameter_control).permit(:result_no, :generate_no, :e_no, :cond, :day, :mod, :cvp, :pvp)\n end",
"def permit_params\n params.require(:permit).permit(:permit_type, :applicant_name, :start_date, :end_date, :address, :payload, :geometry)\n end",
"def student_params(*args) #is the helper method \n\n\t\tparams.require(:student).permit(*args)\n\t\t#uses .require and .permit methods as stronger params to prevent hacks through inspect element right click edit html \n\t\t#require restricts, permit allows, and *args is for the custom arguments\n\tend",
"def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end",
"def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n\n params[:scope] ||= DEFAULT_SCOPE\n params[:approval_prompt] ||= 'force'\n end\n end",
"def parameters=(_); end",
"def parameters(params)\n allowed = [:start,:num,:type,:id,:filter,:tagged,:search,:state,:email,:password]\n params.merge! defaults if defaults\n params.reject {|key,value| !allowed.include? key }\n end",
"def user_params\n params.require(:choice)\n end",
"def params() @param_types end",
"def permitted=(_arg0); end",
"def permitted_params\n []\n end",
"def attr_params\n params[:attr].permit(:name, :type, :value, :foreign_key, :ordinal, :group, :visible, :editable, :required, :input)\n end",
"def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend",
"def user_params\n end",
"def activity_params \n \n raw_parameters = { \n :activity_Name => \"#{params[:activity_name]}\",\n :active => \"#{params[:active]}\",\n :activity_description => \"#{params[:activity_description]}\",\n :is_page => \"#{params[:is_page]}\"\n }\n parameters = ActionController::Parameters.new(raw_parameters)\n parameters.permit( :activity_Name, :active, :activity_description, :is_page)\n \n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def possible_params\n params.require(:possible).permit(:name, :email, :ip_add, :receive, :humanizer_answer, :humanizer_question_id)\n end",
"def check_params\n true\n end",
"def permitted_create_params\n fail NotImplementedError\n end",
"def param_whitelist\n [:role, :title]\n end",
"def all_params; end",
"def evaluation_params\n params.permit(:date_completed,:purpose ,:contribution, :team_contribution, :managers, :manager_performance, :outstanding_participation, :poor_participation, :other)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def setting_params\n puts params\n params.require(:user).permit(:phone, :other_phone, :other_email)\n end",
"def quote_params\n params.permit!\n end",
"def permitted_params\n columns.map { |name,multiple| multiple ? { name => [] } : name }\n end",
"def user_page_setting_params\n params.permit(:is_regist_group, :is_edit_group, :is_edit_sub_rep, :is_edit_place, :is_edit_power_order, :is_edit_rental_order, :is_edit_stage_order, :is_edit_employee, :is_edit_food_product, :is_edit_purchase_list,:add_power_order,:add_rental_order,:add_employee,:add_food_product,:add_purchase_list, :fes_year_id)\n end",
"def setdefault_params\n params.require(:setdefault).permit(:chef, :runner, :user_id)\n end",
"def required_parameters\n must_be_defined_in_derived_class\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 user_input_params\n params.require(:user_input).permit(:input_x, :input_y)\n end",
"def params\n raise NotImplementedError\n end",
"def params=(_); end",
"def inputParameters paramsnum \n\n\n #input parameters \n\t\n\n \t\n #input must not have limit info\n puts \"has (must not have type) limit? please input 0 or 1(0 means no limit,1 means has limit)\"\n haslimit = gets\n if haslimit.to_i == 1\n @haslimit = true\n puts \"please input the group num of limitValue\"\n gnum = gets\n inputMustNotHaveLimitValues gnum.to_i\n else\n @haslimit = false\n end\n\n\n #input must have limit info\n=begin puts \"has (must have type) limit? please input 0 or 1(0 means no limit,1 means has limit)\"\n musthavelimit = gets\n if musthavelimit.to_i == 1\n @musthavelimit = true\n puts \"please input the group num of limitValue\"\n gnum = gets\n inputMustHaveLimitValues gnum.to_i\n else\n @musthavelimit = false\n end\n=end\n \n\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 sample_params\n\t\t params.permit(\n\t\t \t:user_id,\n\t\t \t:contact_id, \n\t\t \t:company_id, \n\t\t \t:inquiry_id, \n\t\t \t:quote_id, \n\t\t \t:product_id, \n\t\t \t:name, \n\t\t \t:status, \n\t\t \t:note_to_receiver, \n\t\t \t:note_to_sales, \n\t\t \t:price, \n\t\t \t:lead_time, \n\t\t \t:street, \n\t\t \t:suite,\n\t\t \t:city, \n\t\t \t:state, \n\t\t \t:zip_code, \n\t\t \t:shipping_method, \n\t\t \t:drop_ship, \n\t\t \t:custom_color, \n\t\t \t:custom_length, \n\t\t \t:custom_width, \n\t\t \t:custom_other, \n\t\t \t)\n\t\t end",
"def access_control_params\n params.require(:access_control).permit(:uuid, :role_id, :ability_to_create_stream, :ability_to_create_discussion, :ability_to_comment, :ability_to_create_question, :ability_to_create_answer, :ability_to_administrate)\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def validate_params!\n self.params ||= Hash.new\n self.class.instance_variable_get(:@__required_params).each do |e|\n raise ArgumentError, \"Insufficient parameters set (#{e} not supplied)\" if self.params[e].nil?\n end\n end",
"def request_params; end",
"def <%= singular_name %>_params\n params.require(:<%= singular_name %>).permit(<%= attributes_allowed %>)\n end",
"def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def request_parameters; end",
"def user_params\nend",
"def commontoolissuance_params\n params.fetch(:commontoolissuance,{}).permit!\n end",
"def preco_rotum_params\n params.permit()\n end",
"def allow_params_authentication!; end",
"def notable_place_params\n params.require(:notable_place).permit(:campaign_id,:system_id, :name, :description, :rule, :wealth, :crime, :tech, :weird)\n end",
"def params=(value); end",
"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 accepted_params\n [\n :Amount,\n :isPreAuth,\n :ServiceId, \n :RequestLang, \n :FullName, \n :Email, \n :Phone, \n :MaxInstallments,\n :MerchantTrns,\n :CustomerTrns,\n :SourceCode,\n :PaymentTimeOut,\n :ExpirationDate,\n :AllowRecurring,\n :Tags,\n :AllowTaxCard,\n :ActionUser,\n :DisableCash,\n :DisableCard\n ]\n end",
"def valued_pre_parameter_params\n params.require(:valued_pre_parameter).permit(:value, :parameter_id, :preprocessing_id)\n end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def help_params\n params.permit(:need_housing, :gender, :has_kids, :help_type)\n end",
"def preference_params\n params.require(:options)\n params.require(:obs)\n params.require(:aux1)\n params.require(:user_id)\n params.permit(:options, :obs, :aux1, :user_id)\n end",
"def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def engagement_params\n #params.require(:branch).permit(:name, :active, :user_id)\n\n raw_parameters = { :name => \"#{params[:name]}\", :active => \"#{params[:active]}\", :user_id => \"#{params[:user_id]}\", :description => \"#{params[:description]}\" }\n parameters = ActionController::Parameters.new(raw_parameters)\n parameters.permit(:name, :active, :description, :user_id)\n \n end",
"def 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 filtered_parameters; end"
] |
[
"0.72998637",
"0.7266968",
"0.7178188",
"0.71122015",
"0.7051836",
"0.6958611",
"0.6958611",
"0.69330776",
"0.689223",
"0.6827",
"0.68039495",
"0.6722076",
"0.6698462",
"0.6698462",
"0.6698462",
"0.6698462",
"0.6698462",
"0.6698462",
"0.6698462",
"0.6698462",
"0.6665949",
"0.6665949",
"0.6665949",
"0.6665949",
"0.6665949",
"0.6665949",
"0.6665949",
"0.6665949",
"0.6665949",
"0.6665949",
"0.6665949",
"0.6665949",
"0.6665949",
"0.6665949",
"0.6665949",
"0.6665949",
"0.6665949",
"0.66628873",
"0.66489834",
"0.66489637",
"0.6644574",
"0.6613668",
"0.6609976",
"0.6594263",
"0.65855473",
"0.65855443",
"0.65645695",
"0.65614563",
"0.6558439",
"0.6558074",
"0.6546123",
"0.65356404",
"0.6533632",
"0.65314186",
"0.65239143",
"0.6518867",
"0.6516572",
"0.6507932",
"0.64886165",
"0.64868855",
"0.64505774",
"0.6442756",
"0.64369607",
"0.64319736",
"0.64269656",
"0.64223105",
"0.64064026",
"0.64062035",
"0.6404222",
"0.6403136",
"0.6401672",
"0.63967824",
"0.6383449",
"0.63822436",
"0.63689095",
"0.63630134",
"0.6360283",
"0.635949",
"0.63571244",
"0.6353761",
"0.6352835",
"0.63475555",
"0.63473445",
"0.63458794",
"0.63349485",
"0.6327675",
"0.63264906",
"0.6324407",
"0.63133544",
"0.6307967",
"0.6307095",
"0.6299999",
"0.6297717",
"0.62976223",
"0.6297126",
"0.62873816",
"0.628727",
"0.6287266",
"0.6286367",
"0.6286025",
"0.6283436"
] |
0.0
|
-1
|
Pass the url to the RSS feed you would like to keep tabs on by default this will request the rss from the server right away and fill the tasks array
|
def initialize(url, refresh = true)
self.pics = []
self.url = url
self.refresh if refresh
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def fetch\n @jobs = fetch_rss(url, Sources::STACKOVERFLOW)\n end",
"def initialize(url, refresh = true)\n self.tasks = []\n self.url = url\n self.refresh if refresh\n end",
"def scrape_tasks(url)\n tasks = []\n doc = Nokogiri::HTML(open(url))\n doc.css(\"li.task_event\").each do |node|\n task = scrape_task(node)\n\n tasks << task unless task.empty? or task.nil?\n end\n\n return tasks\nend",
"def search_and_fetch_jobs\n feed = RSS::Parser.parse(open(target_url_with_query))\n feed.items.take(10)\n end",
"def fetch_feeds_from_urls(feed_urls)\n threads = []\n feeds = []\n feed_urls.each do |feed_url|\n threads << Thread.new {\n feeds << RSS::Parser.parse(feed_url, false)\n }\n end\n threads.each {|t| t.join}\n feeds\nend",
"def run\n begin\n # make an rss_pull\n rss_pull=RssPull.new(url) rescue raise(\"This seems to be a bad URL. Did you include the http:// ?\")\n\n # set total, so we can say \"0 of 25\"\n self.total=rss_pull.num_items\n\n # Now that everything's there to start doing items, we'll run.\n self.status='running' ; save\n\n # For each item, do it, then \n # increment self.finished.\n rss_pull.each do |item|\n handle_item item\n self.finished+=1 ; save\n end\n\n # Clean up the filehandle.\n file_handle.close\n\n # And we're through.\n self.status='finished' ; save\n rescue\n file_handle.close rescue nil\n\n # If something went wrong, stuff it in self.error,\n # set the status, and we'll wait for the poller to\n # display it.\n self.error=$!.to_s\n self.status='error'\n save\n end\n end",
"def scrape\n\t\topen(@url) do |rss|\n\t\t\tfeed = RSS::Parser.parse(rss)\n\t\t\tfeed.items.each do |item|\n\t\t\t\tif date_valid?(item.pubDate) and item.title\n\t\t\t\t\tcreate_article(@default_author, item.title, item.description,\\\n\t\t\t\t\t\t\"\", @source_name, item.pubDate.to_date, item.link)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@articles\n\tend",
"def scrape\n open(@url) do |rss|\n feed = RSS::Parser.parse(rss)\n\n feed.items.each do |item|\n # Remove the p tag and retrieve image url from the description\n # if it exists\n p_tag = item.description[%r{<p>.*</p>}]\n if p_tag\n item.description.slice! p_tag\n img_url = p_tag.match(/src=\"(?<img>[^\"]*)\"/)[:img]\n else\n img_url = nil\n end\n\n # Sanitize HTML\n item.title = CGI.unescapeHTML(item.title)\n item.description = CGI.unescapeHTML(item.description)\n\n @articles.push(\n title: item.title,\n summary: item.description,\n image_url: img_url,\n source: @source,\n url: item.link,\n pub_date: item.pubDate.to_s,\n guid: item.guid.content\n )\n end\n end\n end",
"def feed!\n http_fetch(feed_url)\n end",
"def scrape\n\t\topen(@url) do |rss|\n\t\t\tfeed = RSS::Parser.parse(rss)\n\t\t\t@source_name = feed.channel.title\n\t\t\tfeed.items.each do |item|\n\t\t\t\tif date_valid?(item.pubDate) and item.title\n\t\t\t\t\tcreate_article(item.dc_creator, item.title, item.description,\\\n\t\t\t\t\t\t\"\", @source_name, item.pubDate.to_date, item.link)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@articles\n\tend",
"def parse_feed\n remove_previous_entries\n @items = @content[\"rss\"][\"channel\"][\"item\"]\n if [email protected]?\n for item in @items do\n item[\"pubDate\"] ||= \"\"\n item[\"creator\"] ||= \"\"\n item[\"guid\"] ||= \"\"\n item[\"title\"] ||= \"\"\n item[\"description\"] ||= \"\"\n clean_content(item[\"encoded\"] ||= \"\")\n item[\"link\"] ||= \"\"\n params = { \n :pubdate => item[\"pubDate\"], \n :creator => item[\"creator\"], \n :guid => relative_link(item[\"guid\"]), \n :title => item[\"title\"], \n :description => item[\"description\"], \n :content => @content, \n :link => relative_link(item[\"link\"])\n }\n insert_entry(params)\n end\n end\n end",
"def scrape\n\t\topen(@url) do |rss|\n\t\t\tfeed = RSS::Parser.parse(rss)\n\t\t\t@source_name = feed.channel.title\n\t\t\tfeed.items.each do |item|\n\t\t\t\tif date_valid?(item.pubDate) and item.title\n\t\t\t\t\tcreate_article(get_author(item), item.title, item.description,\\\n\t\t\t\t\t\tget_images(item), @source_name, item.pubDate.to_date,\\\n\t\t\t\t\t\titem.link, get_image_length(item))\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@articles\n\tend",
"def readrss(name, t) # finds url from database, parses it and returns an array\n if (t>5); return [\"http://www.justfuckinggoogleit.com\"]; end\n\n s = []\n url = $db.execute( \"select link from rss where name = ?\", name )\n i = RSS::Parser.parse(open(url.flatten.to_s), false)\n i.items.first(t).each do |it|\n s.push(it.title+\" - \"+it.link)\n end\n return s\nend",
"def process(tabs, gettab = nil)\n tabs_parse = []\n process_limit = 10 # Max number of items per feed to process\n\n tabs.each {|tab|\n tab_name = tab[:tabname]\n # if there is a gettab value set then we\n # will get only that tab\n unless gettab.nil?\n if gettab != tab_name.downcase\n # skip it\n next\n end\n end\n temp = []\n position = 1\n tab[:tabrss].each {|feed|\n\n $g.report('myg.fetch', 1)\n start_time = Time.now\n res = fetch(feed)\n if res.nil?\n next\n end\n feed_title = res.nil? ? \"Untitled\" : res.title\n processed_feed = _process(tab[:tab_id], res, process_limit)\n\n if processed_feed.nil?\n $g.report('myg.fetch_error', 1)\n else\n self.set_feed_name(tab[:tab_id], position, processed_feed[0]['feed_title']) \n end\n f = {\n 'id' => Digest::MD5.hexdigest(feed_title),\n 'feed_title' => feed_title,\n 'feed_data' => processed_feed\n }\n temp << f\n position = position + 1\n duration = Time.now - start_time\n $g.report(\"myg.parsetime\", duration)\n }\n\n tabs_parse << {\n :tab_name => tab_name,\n :tab_data => temp\n }\n } \n return tabs_parse\n end",
"def collect2 pages\n id = 'joshuabaer'\n results = []\n tasks = []\n 1.upto pages do |page|\n puts \"queueing page #{page}\"\n task = BackgroundTask.new do \n http_get id, page\n end\n tasks << task\n task.run\n end\n tasks.each do |task|\n puts \"task retrieved\"\n results += task.result\n end\n results\nend",
"def fetch_articles\n current_feed = get_rss_feed( self.url )\n current_feed.entries.each do |article|\n unless self.array_of_article_urls.include?(article.url)\n a = Article.new(title: article.title, url: article.url, clicks: 0)\n a.title ||= article.summary\n self.articles.push a \n end\n end\n\tend",
"def loadRSSFeeds \n @raw_data = RSS::Parser.parse('http://www.nachrichten.at/storage/rss/rss/weltspiegel.xml', false)\n end",
"def news\n do_scrape\n @posts = UbuEntry.all(:order => \"id DESC\", :limit => 400)\n render :layout => false, :content_type => Mime::RSS\n end",
"def crawl\n update_all_feeds\n fetch_and_store_articles\n end",
"def make_request(url, limit = 0)\n return nil if limit > 5\n\n Typhoeus.get url, followlocation: true, connecttimeout: 5\n rescue StandardError => e\n Honeybadger.notify \"Problem retrieving RSS content: #{e.message}\"\n end",
"def parse_feed url=rss_url, now = Time.now\n\n options = {\n user_agent: 'Geolinguist Test',\n max_redirects: 2,\n compress: true\n }\n\n\n f = Feedjira::Feed.fetch_and_parse url, options\n if f.url != rss_url.sub(RSS_SUFFIX,'')\n self.base_url = f.url.sub(RSS_SUFFIX,'').sub(SUFFIX,'')\n url = rss_url\n save\n f = Feedjira::Feed.fetch_and_parse url, options\n end\n\n\n if f.last_modified.blank?\n save_and_update_last_fetched now if self.last_fetched.blank?\n return\n end\n if last_fetched.blank? || f.last_modified > last_fetched\n puts f.inspect\n f.entries.each do |entry|\n if last_fetched.blank? || last_fetched < entry.published\n self.total_entries += 1\n body = [entry.title,entry.summary].join(\"\\n\")\n matches = LanguageRecognizer.recognize body\n if matches.blank?\n self.no_matches += 1\n else\n matches.each {|match| self[match] += 1}\n end\n end\n end\n save_and_update_last_fetched now\n end\n end",
"def parse_by_rss_feed(url,rss_link_id)\n feeds = RssFeed::RssFeed.parse_rss_url(url)\n feeds.entries.each do |item|\n params = {\n :title => item.title,\n :description => ActionController::Base.helpers.strip_tags(item.description),\n :link => item.link,\n :author => item.author,\n :publication_date => item.published,\n :media_contents => (item.media_image ? [{:url => item.media_image}] : []),\n :media_description => item.media_description,\n :media_credit => item.media_credit,\n :keywords => (item.categories.present? ? item.categories.join(\",\") : \"\"),\n :rss_link_id => rss_link_id\n }\n f = Feed.new(params)\n if f.save\n activity = Activity.new({:action => \"Create\", :parent_id => rss_link_id, :parent_type => \"RssLink\", :data => params}) \n activity.save\n puts \"*\" * 50\n puts \"Title: \" + f.title + \" parsed and saved\"\n end\n end if feeds && feeds.entries\n end",
"def retrieve_posts\n # Get posts\n rss = RSS::Parser.parse(AWL_RSS_URL)\n\n # Grab shortened URLs\n links = rss.items.map(&:guid).map(&:content)\n\n @articles = []\n\n links.each do |link|\n @articles << Article.new(link)\n end\n\n # TODO: Only grab the tags for articles that haven't already be tweeted\n @articles.map(&:retrieve_tags)\n end",
"def spawn_feeds\n\tFile.open(\"feeds.txt\", \"r\").each_line do |line|\n\t\tFeed.create(:url => line.strip) unless !Feed.find_by_url(line.strip).nil?\n\tend\nend",
"def get_new_articles\n # Download the RSS feed and save to self.doc\n get_source\n \n # Keep track of which articles are in the feed \n articles = []\n \n article_links = (self.doc/'li.mjItemMain').collect do |mjItem|\n mjItem.at('a.mjLinkItem')\n end\n \n # For each item in the RSS feed \n article_links.each_with_index do |link, index|\n \n # Create or update the article in the db\n articles << Article.factory(\n :category => self.category,\n :description => '',\n :feed => self,\n :url => \"http://online.wsj.com#{link.attributes['href']}\",\n :priority => index\n )\n end\n \n articles\n end",
"def scrape\r\n @article_arr = []\r\n\t\turl = 'http://feeds.news.com.au/heraldsun/rss/heraldsun_news_technology_2790.xml'\r\n open(url) do |rss|\r\n \tfeed = RSS::Parser.parse(rss, false)\r\n \tputs \"Title: #{feed.channel.title}\"\r\n puts \"*********************************\"\r\n puts \" \"\r\n feed.items.each do |item|\r\n \t@article_arr << HSArticle.new(author: \"nil\", title: item.title.to_s.gsub(/,/,' ').gsub(/\"/,' ').gsub(/'s/,'s').gsub(/'/, ''), \r\n summary: item.description.to_s.gsub(/,/,' ').gsub(/\\\"/,'\\'').gsub(/'s/,''), images: item.enclosure.url, source: item.link,\r\n date: item.pubDate.to_s.gsub(/,/,'').gsub(/\\\"/,'\\'').gsub(/'s/,''))\r\n end\r\n end\r\n @articles.concat(@article_arr)\r\n end",
"def collect3 pages\n id = 'barackobama'\n results = []\n tasks = TaskCollection.new( 50 )\n 1.upto pages do |page|\n puts \"queueing page #{page}\"\n task = BackgroundTask.new do \n http_get id, page\n end\n tasks << task\n end\n i=0\n loop do\n i+=1\n puts \"getting next task...\"\n task = tasks.next_finished\n if !task\n puts \"no more tasks\"\n break\n else\n puts \"task retrieved #{i}\"\n results += task.result\n end\n end\n results\nend",
"def tasks\n uri = URI(BASE_URL + TASKS_ENDPOINT)\n\n make_request(uri)\n end",
"def get_urlposts( url )\n urlposts = []\n urlcode = Digest::MD5.hexdigest(url)\n url = \"http://feeds.delicious.com/rss/url/#{urlcode}\"\n\n response = Net::HTTP.get_response(URI.parse(url)).body\n doc = REXML::Document.new(response)\n\n doc.elements.each(\"//item\") do |item|\n urlposts << { \"user\" => item.elements[\"dc:creator\"].text }\n end\n\n sleep 1\n return urlposts\n end",
"def setTaskURL(taskUrl)\r\n\t\t\t\t\t@taskUrl = taskUrl\r\n\t\t\t\tend",
"def parse(tabs, gettab = nil)\n\n\n raise \"Don't be using this method anymore\"\n\n start_time = Time.now\n\n num_feeds = 0 \n tabs_parse = []\n mytabs = {} # trying out storing it as a hash\n\n $g.report('myg.init', 1)\n\n tabs.each {|tab|\n tname = tab[:tabname]\n unless gettab.nil?\n if gettab != tname.downcase\n # $logger.info(\"Skipping #{tname}\")\n next\n end\n end\n\n $logger.info(\"Fetch RSS feeds in #{tname}\")\n\n tab_temp = []\n mytabs[tname.downcase.to_sym] = {}\n tab_feeds = 0\n\n tab[:tabrss].each {|rss|\n\n # FIXME\n # next if tab_feeds > 2 \n\n $logger.info(\"\\tFetching #{rss}\")\n\n res = fetchFeed(rss)\n\n tab_feeds = tab_feeds + 1\n num_feeds = num_feeds + 1\n\n feed_title = res.empty? ? \"Untitled Feed\" : res.title\n\n pfeed = processFeed(res, 10) \n f = { \n 'id' => Digest::MD5.hexdigest(feed_title),\n 'feed_title' => feed_title,\n 'feed_data' => pfeed \n }\n tab_temp << f\n\n mytabs[tname.downcase.to_sym] = f\n\n } # end of each tabrss\n\n tabs_parse << { \n 'id' => tname,\n 'tab_name' => tname,\n 'tab_data' => tab_temp\n }\n } # end of all tabs\n\n duration = Time.now - start_time\n $logger.info(\"Parsed #{num_feeds} feed; took #{duration} seconds\")\n $g.report(\"myg.parsetime\", duration)\n\n return tabs_parse\n end",
"def fetch_feeds\n Delayed::Job.enqueue Jobs::RssFeedJob.new\n flash[:notice] = t('flash.voices.fetch_feeds.fetching')\n redirect_to :action => 'index'\n end",
"def feed_urls\n nil\n end",
"def scrape\r\n @article_arr = []\r\n\t\turl = 'http://www.theage.com.au/rssheadlines/technology-news/article/rss.xml'\r\n open(url) do |rss|\r\n \tfeed = RSS::Parser.parse(rss, false)\r\n puts \" \"\r\n puts \"*********************************\"\r\n \tputs \"Title: #{feed.channel.title}\"\r\n puts \"--------------------------------\"\r\n feed.items.each do |item|\r\n \t@article_arr << AgeArticle.new(author: \"nil\", title: item.title.to_s.gsub(/,/,''), \r\n summary: (item.description).match(/\\<\\/p\\>[\\w ?,''\"\"]+/).to_s.gsub(/\\<\\/p\\>/,'').gsub(/,/,'').gsub(/\\\"/,''), \r\n images: (item.description).match(/http.+\\.(jpg|png)/), source: item.link, date: item.pubDate.to_s.gsub(/,/,''))\r\n end\r\n end\r\n @articles.concat(@article_arr)\r\n end",
"def main\n\n feedlist = File.foreach('parselist') do |wholeline|\n\n wholeline.strip!\n\n next if wholeline.empty?\n\n line = wholeline.split(\",\")\n url = line[0].strip\n tag = line[1].strip\n\n #parse each feed\n\n rss = SimpleRSS.parse(open(url).read)\n\n puts ' '\n puts rss.feed.title\n puts ' '\n\n rss.items[0..2].each do|i|\n puts \"Date: #{i.pubDate or i.published}\"\n puts \"Title: #{i.title}\"\n puts \"Link: #{i.link}\"\n puts \"=\" * 80\n end\n\n end\n\nend",
"def scrape\n Job.reset\n puts 'Enter a URL to scrape (or press enter for default):'\n url = gets.strip\n url = 'https://news.ycombinator.com/item?id=16052538' if url == ''\n puts \"Scraping...\\n\\n\"\n jobs_data = Scraper.scrape(url)\n jobs_data.each_with_index do |job_data, i|\n job = Job.new(job_data.merge({id: i+1}))\n end\n puts list\n end",
"def feed_sorter\n\t\[email protected] do |url|\n\t\t\topen(url) do |rss|\n \t\t\tfeed = RSS::Parser.parse(rss)\n\t\t\t\n\t\t\t\tcase \n\t\t\t\twhen feed.feed_type == \"rss\"\n\t\t\t\t\trss_parser(feed)\n\t\t\t\twhen feed.feed_type == \"atom\"\n\t\t\t\t\tatom_parser(feed) \n\t\t\t\tend \n\t\t\tend \n\t\tend \n\tend",
"def get_feed(url)\n source = URI.open(url, 'User-Agent' => 'Mozilla/5.0')\n feed = RSS::Parser.parse(source)\nend",
"def get_feed(params)\n\n #Rails.logger.info(\" [RAILS] [LIB] [SCREEN_SCRAP] [GET_FEED] Entering\")\n\n url = process_node(params)\n\n if url && String === url && url !~ /^http/ && params[:url]\n url = URI.join(params[:url] , url).to_s\n elsif url && Array === url\n url.map! do |u|\n if u !~ /^http/ && params[:url]\n URI.join(params[:url], u).to_s\n else\n u\n end\n end\n url.uniq!\n end\n\n #Rails.logger.info(\" [RAILS] [LIB] [SCREEN_SCRAP] [GET_FEED] Leaving\")\n params[:output][\"feed\"] = url\n\n rescue => e\n Rails.logger.error(\"[RAILS] [LIB] [SCREEN_SCRAP] [GET_FEED] **** RESCUE **** #{e.message} \")\n nil\n end",
"def parse_task(t)\n @builder.outline(\"text\" => t[\"name\"], \"type\" => \"link\", \"url\" => t[\"url\"], \"created\" => t[\"created\"]) do\n \tt[\"tasks\"].each { |st| parse_task(st) }\n end\n end",
"def generate_rss_feed tweets, old_items\n version = \"2.0\"\n long_url = nil\n\n @logger.info \"Generating RSS feed to #{@rss_outfile}.\"\n\n content = RSS::Maker.make(version) do |m|\n m.channel.title = \"tweetfeed RSS feed #{@hashtags}\"\n m.channel.link = \"http://github.com/madhatter/tweetfeed\"\n m.channel.description = \"Automatically generated news from Twitter hashtags\"\n m.items.do_sort = true # sort items by date\n\n tweets.each do |tweet|\n orig_url = tweet.urls[0].url\n expanded_url = tweet.urls[0].expanded_url\n @logger.debug \"URL to fetch: #{orig_url}\"\n @logger.debug \"Already expanded url: #{expanded_url}\"\n short_url = expanded_url\n title = tweet['text'].sub(/(#{orig_url})/, \"\")\n long_url = @url_parser.get_original_url short_url\n\n # TODO: Maybe some kind of domain filter would be nice here...\n i = m.items.new_item\n i.title = title.gsub(/\\n/,\"\")\n #i.link = tweet['attrs']['entities']['urls'][0]['url']\n unless long_url == nil\n i.link = long_url.gsub(/\\r/,\"\")\n else\n i.link = orig_url.gsub(/\\r/,\"\") unless orig_url == nil\n end\n i.date = tweet['created_at']\n end\n\n @logger.debug \"Adding the old stuff...:\"\n old_items.items.each do |item|\n i = m.items.new_item\n i.title = item.title\n @logger.debug \"Adding item '#{item.title}'\"\n i.link = item.link\n i.date = item.date\n end unless old_items.nil?\n end\n save_rss_feed(content)\n end",
"def scrape\n @articles = []\n url = 'http://feeds.news.com.au/heraldsun/rss/heraldsun_news_technology_2790.xml'\n open(url) do |rss|\n feed = RSS::Parser.parse(rss, false)\n feed.items.each do |item|\n article = Article.create(title: item.title.to_s.tr('\"', '\\''),\n summary: item.description.to_s\n .gsub(/’/, '\\'').gsub(/\\\"/, '\\''),\n imageURL: item.enclosure.url,\n link: item.link,\n pubDate: DateTime.parse(item.pubDate.to_s),\n source: HSImporter.source_name)\n @articles << article\n end\n end\n @articles\n end",
"def list_tasks(api_object)\n puts \"Current Tasks:\"\n doc = Nokogiri::XML.parse api_object.read\n puts doc\n descriptions = doc.xpath('tasks/task/description').collect {|e| e.text }\n puts descriptions.join(\", \")\n puts \"\"\nend",
"def scrape\n articles = []\n url = 'http://feeds.news.com.au/heraldsun/rss/heraldsun_news_sport_2789.xml'\n\n open(url) do |rss|\n feed = RSS::Parser.parse(rss)\n feed.items.each do |item|\n articles << (interpret item)\n end\n end\n articles\n end",
"def load_remote_feed!\n @live = true\n if self.http_headers.nil? && !(self.cache_object.nil?) &&\n !(self.cache_object.http_headers.nil?)\n @http_headers = YAML.load(self.cache_object.http_headers)\n end\n \n if (self.href =~ /^feed:/) == 0\n # Woah, Nelly, how'd that happen? You should've already been\n # corrected. So let's fix that url. And please,\n # just use less crappy browsers instead of badly defined\n # pseudo-protocol hacks.\n self.href = FeedTools::UriHelper.normalize_url(self.href)\n end\n \n # Find out what method we're going to be using to obtain this feed.\n begin\n uri = URI.parse(self.href)\n rescue URI::InvalidURIError\n raise FeedAccessError,\n \"Cannot retrieve feed using invalid URL: \" + self.href.to_s\n end\n retrieval_method = \"http\"\n case uri.scheme\n when \"http\"\n retrieval_method = \"http\"\n when \"ftp\"\n retrieval_method = \"ftp\"\n when \"file\"\n retrieval_method = \"file\"\n when nil\n raise FeedAccessError,\n \"No protocol was specified in the url.\"\n else\n raise FeedAccessError,\n \"Cannot retrieve feed using unrecognized protocol: \" + uri.scheme\n end\n \n # No need for http headers unless we're actually doing http\n if retrieval_method == \"http\"\n begin\n @http_response = (FeedTools::RetrievalHelper.http_get(\n self.href, :feed_object => self) do |url, response|\n # Find out if we've already seen the url we've been\n # redirected to.\n follow_redirect = true\n\n begin\n cached_feed = FeedTools::Feed.open(url,\n :disable_update_from_remote => true)\n if cached_feed.cache_object != nil &&\n cached_feed.cache_object.new_record? != true\n if !cached_feed.expired? &&\n !cached_feed.http_headers.blank?\n # Copy the cached state\n self.href = cached_feed.href\n \n @feed_data = cached_feed.feed_data\n @feed_data_type = cached_feed.feed_data_type\n \n if @feed_data.blank?\n raise \"Invalid cache data.\"\n end\n \n @title = nil; self.title\n self.href\n @link = nil; self.link\n \n self.last_retrieved = cached_feed.last_retrieved\n self.http_headers = cached_feed.http_headers\n self.cache_object = cached_feed.cache_object\n @live = false\n follow_redirect = false\n end\n end\n rescue\n # If anything goes wrong, ignore it.\n end\n follow_redirect\n end)\n case @http_response\n when Net::HTTPSuccess\n @feed_data = self.http_response.body\n @http_headers = {}\n self.http_response.each_header do |key, value|\n self.http_headers[key.downcase] = value\n end\n self.last_retrieved = Time.now.gmtime\n @live = true\n when Net::HTTPNotModified\n @http_headers = {}\n self.http_response.each_header do |key, value|\n self.http_headers[key.downcase] = value\n end\n self.last_retrieved = Time.now.gmtime\n @live = false\n else\n @live = false\n end\n rescue Exception => error\n @live = false\n if self.feed_data.nil?\n raise error\n end\n end\n elsif retrieval_method == \"https\"\n # Not supported... yet\n elsif retrieval_method == \"ftp\"\n # Not supported... yet\n # Technically, CDF feeds are supposed to be able to be accessed\n # directly from an ftp server. This is silly, but we'll humor\n # Microsoft.\n #\n # Eventually. If they're lucky. And someone demands it.\n elsif retrieval_method == \"file\"\n # Now that we've gone to all that trouble to ensure the url begins\n # with 'file://', strip the 'file://' off the front of the url.\n file_name = self.href.gsub(/^file:\\/\\//, \"\")\n if RUBY_PLATFORM =~ /mswin/\n file_name = file_name[1..-1] if file_name[0..0] == \"/\"\n end\n begin\n open(file_name) do |file|\n @http_response = nil\n @http_headers = {}\n @feed_data = file.read\n @feed_data_type = :xml\n self.last_retrieved = Time.now.gmtime\n end\n rescue\n @live = false\n # In this case, pulling from the cache is probably not going\n # to help at all, and the use should probably be immediately\n # appraised of the problem. Raise the exception.\n raise\n end\n end\n unless self.cache_object.nil?\n begin\n self.save\n rescue\n end\n end\n end",
"def read_rss\n query = \"http://news.google.ru/news?hl=ru&topic=#{@topic}&output=rss&ned=ru_ru&num=30&&scoring=n\"\n feed = Feedjira::Feed.fetch_and_parse(query)\n feed.entries.map do |entry|\n {\n uuid: SecureRandom.uuid,\n title: entry.title,\n url: entry.url.match(GOOGLE_URI_REGEX)[0],\n published_datetime: entry.published,\n published_unixtime: entry.published.to_i\n }\n end\n end",
"def fetch_feed\n endpoint = @current_feed.values.first\n\n begin\n document = SimpleRSS.parse(URI.open(endpoint, 'User-Agent' => 'Ruby-wget'))\n rescue StandardError => e\n puts \"Error: <#{e}> while trying to call <#{@current_feed_link}>\"\n # effectively skip document\n document = { title: Rss::NO_VALUE, items: {} }\n end\n\n # Ensuring string access instead of symbol access.\n # I know there's probably a better way to do this...\n # but I can't remember if with_indifferent_access is\n # a rails thing...\n @cache[@current_feed.keys.first] = JSON.parse(document.items.to_json)\n end",
"def rss_entries(url)\n\t\tresponse = fetch(url)\n\t\tresponse[\"feed\"][\"entry\"]\n\tend",
"def task_lists\n\t\t@task_lists ||= fetch_latest_task_lists\n\tend",
"def httpdownload_callback\r\n Emergency.delete_all()\r\n file = File.new(@@feedPath)\r\n doc = REXML::Document.new(file)\r\n firstLoop = true\r\n #Parse each item element in this XML document.\r\n doc.elements.each(\"*/channel/item\")do |elm|\r\n title = elm.elements[\"title\"].text\r\n desc = elm.elements[\"description\"].text\r\n date_time = elm.elements[\"pubDate\"].text\r\n category = elm.elements[\"category\"].text\r\n # We want the \"fulltime\" element in our database to be a UNIX time-stamp because comparisons are easier.\r\n alertTime = Time.parse(date_time)\r\n nixTimeStamp = alertTime.to_i\r\n date_array = \"PlaceHolder\", \"PlaceHolder\"\r\n # Convert the RSS pubDate to an easily readable format\r\n date_array[0] = alertTime.month.to_s + \"/\" + alertTime.day.to_s + \"/\" + alertTime.year.to_s\r\n if alertTime.hour > 12\r\n hours = alertTime.hour - 12\r\n pm = true\r\n else\r\n hours = alertTime.hour\r\n pm = false\r\n end\r\n date_array[1] = hours.to_s + \":\" + alertTime.min.to_s\r\n if pm == true\r\n date_array[1] = date_array[1] + \" PM\"\r\n else\r\n date_array[1] = date_array[1] + \" AM\"\r\n end\r\n # Create this Emergency object in the database.\r\n Emergency.create({ \"title\" => title, \"description\" => desc, \"time\" => date_array[1], \"date\" => date_array[0], \"fullTime\" => nixTimeStamp, \"category\" => category})\r\n end\r\n file.close\r\n end",
"def process_feed(url, limit=200)\n rss = SimpleRSS.parse open(url)\n rss.items.each_with_index do |item, index|\n puts \"Parsing RSS item #{item.title}\"\n screenshoot(item.link, to_filename(item.title, IMG_FILENAME_SIZE))\n puts \"... donez\"\n puts \"\"\n break if index == limit-1\n end \nend",
"def index\n # Load the latest full blog feed for Frank's blog as per \n @latest_blog_posts = load_blog_feed_for_url('http://blog.rietta.com/feeds/posts/default?alt=rss')\n \n # Load the latest posts for the Marketing label feed. Labels are case sensitive - Marketing != marketing\n # Please note that the example of the Google website has an error on its label example. The alt=rss comes after\n # the label in the feed URL\n @latest_marketing_posts = load_blog_feed_for_url('http://blog.rietta.com/feeds/posts/default/-/Marketing?alt=rss')\n \n # Load the latest posts for the SQL Converter label feed (space in the tag)\n @latest_sql_converter_posts = load_blog_feed_for_url('http://blog.rietta.com/feeds/posts/default/-/SQL%20Converter?alt=rss')\n end",
"def build_rss\n ::RSS::Maker.make('2.0') do |maker|\n maker.channel.link = @wiki.settings.url\n maker.channel.title = @wiki.settings.title\n maker.channel.description = @wiki.settings.description.to_s\n maker.channel.author = @wiki.settings.author.to_s\n maker.channel.updated = Time.now.to_s\n maker.items.do_sort = true\n\n posts.each do |post|\n html = post.content\n date = Time.parse(post.post_date)\n\n next if date > Time.now unless @wiki.settings.future\n\n if i = html.index('</p>')\n text = html[0..i+4]\n else\n text = html\n end\n\n maker.items.new_item do |item|\n item.title = post.title\n item.link = File.join(@wiki.settings.url, post.href)\n item.date = date\n item.description = text\n end\n end\n end\n end",
"def rss\n @rss ||= build_rss\n end",
"def run\n loop { sleep 5 while @feeds.alive? }\n end",
"def entries\n settings.inject([]) do |rss_entries, url|\n rss_entries + parse_rss_entries(url)\n end\n end",
"def collect4 pages\n id = 'barackobama'\n results = []\n tp = ThreadPool.new( 10 )\n tasks = TaskCollection.new( 10, tp )\n i=0\n 1.upto pages do |page|\n puts \"queueing page #{page}\"\n tasks.add_task do\n http_get id, page\n end\n if tasks.task_ready?\n i+=1\n puts \"GOT A TASK FINISHED WHILE STILL ADDING TASKS\"\n results += tasks.next_finished.result\n end\n end\n puts \"getting next task...\"\n while task = tasks.next_finished\n i+=1\n puts \"task retrieved #{i}\"\n results += task.result\n puts \"getting next task...\"\n end\n results\nend",
"def feed\n end",
"def get_userposts( user )\n posts = []\n url = \"http://feeds.delicious.com/rss/#{user}\"\n\n response = Net::HTTP.get_response(URI.parse(url)).body\n doc = REXML::Document.new(response)\n\n doc.elements.each(\"//item\") do |item|\n posts << { \"href\" => item.elements[\"link\"].text }\n end\n\n sleep 1\n return posts\n end",
"def feed\n\n end",
"def scrape\n\t\turl = 'http://www.wsj.com/xml/rss/3_7455.xml'\n open(url) do |rss|\n \tfeed = RSS::Parser.parse(rss, false)\n puts \" \"\n puts \"*********************************\"\n \tputs \"Title: #{feed.channel.title}\"\n puts \"--------------------------------\"\n feed.items.each do |item|\n tags = tag_article(item.title.to_s)\n \tarticle = Article.new(title: item.title.to_s, \n summary: item.description.to_s.gsub(/\\\"/,''), \n link: item.link, \n date: item.pubDate.to_s.gsub(/,/,''),\n tag_list: tags, \n source: \"Wall Street Journal\")\n article.save\n end\n end\n end",
"def fetch_latest_task_lists\n\t\tresponse = @client.execute(api_method: @gtasks.tasklists.list)\n\t\tputs \"***************** ERROR FETCHING TASK LISTS *****************\" if response.status != 200\n\t\tputs response.body\n\t\t@task_lists = response.data.items\n\tend",
"def fetch_latest_tasks_for(list)\n\t\t@tasks[list] = @client.execute(api_method: @gtasks.tasks.list, parameters: { 'tasklist' => list.id }).data.items\n\tend",
"def run\n scraper = ThreatDetector::Scraper.new options\n\n fetch_feeds.map do |item|\n next unless valid_feed?(item)\n\n scraper.for(item['name'], item['url'])\n scraper.parse_and_save_entries\n\n yield(item, scraper) if block_given?\n item.slice('name', 'url', 'source')\n end.compact\n end",
"def tasks\n @tasks ||= Harvest::API::Tasks.new(credentials)\n end",
"def process_articles(url)\n # Create an array to store the processed articles\n processed = []\n # Grab the article items from the feed\n articles = (retrieve(url)/\"rss\"/\"channel\"/\"item\")\n # Loop through them\n articles.each do |a|\n # Build the permalink\n permalink = URI.parse((a/\"guid\").text).request_uri\n # Find the article, or create a new one\n article = Article.first(:permalink => permalink) || Article.new\n # Grab the information from the article feed item\n article.title = (a/\"title\").text\n article.content = (a/\"description\").text\n article.published = \"1\"\n article.published_at = DateTime.parse((a/\"pubdate\").text)\n article.permalink = permalink\n article.user_id = self.current_user.id\n # Add the tags, if present in the feed, and if the tagging plugin is active\n article.tag_list = (a/\"category\").collect { |c| c.children.first }.join(\",\") if is_plugin_active(\"feather-tagging\") && defined?(Tag) && defined?(Tagging) && article.respond_to?(\"tag_list=\") && (a/\"category\") && (a/\"category\").length > 0\n # Save the article\n article.save\n # Add it to the list of processed articles\n processed << article\n end\n # Return the list of processed articles\n processed\n end",
"def fetch_urls_from_feedly\n yaml = YAML.load_file('env.yaml')\n client = Feedlr::Client.new(oauth_access_token: yaml['account']['feedly']['access_token'])\n client.user_subscriptions.map{|m|\n # puts m.id\n hotentries = client.stream_entries_contents(m.id, :count => 5 ).items\n return hotentries\n };\nend",
"def initialize(url, refresh = true)\n\tself.items = []\n\tself.url = url\n\tself.refresh if refresh\n end",
"def scrape_today\n url = \"https://www.timeout.com/melbourne/things-to-do/things-to-do-in-melbourne-today\"\n unparsed_page = HTTParty.get(url)\n parsed_page = Nokogiri::HTML(unparsed_page.body)\n items = parsed_page.css('div.card-content')\n items.each do |activity|\n activity = {\n title: activity.css('h3.card-title').text.strip,\n description: activity.css('p').text } \n @today_activities << activity \n end \n end",
"def tasks(list)\n list_obj = list.is_a?(Wunderlist::List) ? list : lists[list]\n list = list.id if list.is_a? Wunderlist::List\n\n request = prepare_request(Net::HTTP::Get.new \"#{@path}/ajax/lists/id/#{list}\")\n response = @http.request request\n result = []\n\n Nokogiri::HTML(JSON.parse(response.body)[\"data\"]).css(\"li.more\").each do |html_task|\n task = Wunderlist::Task.new\n task.id = html_task.attributes[\"id\"].value.to_i\n task.name = html_task.css(\"span.description\").first.content\n task.important = html_task.css(\"span.fav\").empty? ? false : true\n task.done = html_task.attributes[\"class\"].value.split(\" \").include?(\"done\")\n html_timestamp = html_task.css(\"span.timestamp\")\n task.date = Time.at(html_timestamp.first.attributes[\"rel\"].\n value.to_i).to_date unless html_timestamp.empty?\n task.note = html_task.css('span.note').first.content\n task.api = self\n task.list = list_obj\n\n result << task\n end\n\n result\n end",
"def insert_news_if_necessary(url)\n latest_date = latest_news_date(Feed.id_from_url(url))\n latest_date = Setting.keep_news_time if latest_date.zero?\n\n channel = Arss::FeedParser.parse_uri(url).feed['channel']\n return unless channel.has_key? 'items'\n\n channel['items'].each do |item|\n if Setting.get_delete_after_days.nonzero?\n next if (item['pubDate'] <= latest_date or item['pubDate'] < Setting.keep_news_time)\n end\n\n create(:user_id => User.current_user_id, :feed_id => Feed.id_from_url(url),\n :title => item['title'], :description => item['description'],\n :url => item['link'], :read => 0, :date => item['pubDate'])\n end\n end",
"def links_feed\n end",
"def parse_feed\n feed = self.download_feed\n Nokogiri::XML(feed).xpath(\"//item\").map do |item|\n enclosure = item.xpath(\"enclosure\").first\n\n title = CGI::unescapeHTML(item.xpath(\"title\").text.chomp)\n publish_date = Time.parse(item.xpath(\"pubDate\").inner_html.chomp)\n type = enclosure ? enclosure[:type] : nil\n url = enclosure ? enclosure[:url] : nil\n Podcast.new title, publish_date, type, url, self\n end\n end",
"def meeting_feed_url\n \"#{@baseurl}/rss/rss.aspx\"\n end",
"def feed\n cached = Rails.cache.read(\"rss\")\n return cached unless cached.nil?\n\n resp = HTTParty.get(Rails.configuration.x.application.blog_rss)\n return [] unless resp.code == 200\n\n rss = RSS::Parser.parse(resp.body, false).items.first(5)\n cache_content(\"rss\", rss)\n rss\n rescue StandardError => e\n # If we were unable to connect to the blog rss\n logger.error(\"Caught exception RSS parse: #{e}.\")\n []\n end",
"def update_from_feed()\n\t\t\n\t@links = Link.all \n\n\[email protected] do |link| \n\n\t\tfeed = Feedzirra::Feed.fetch_and_parse(link.url)\n\n\t\tputs \"pulling feeds\"\n\t\tfeed.entries.each do |entry|\n\n\t\t\tif entry.published > link.updated_at\n\n\t\t\t\tif entry.url =~ /^#{URI::regexp}$/\n\t\t\t\t\tfind_keywords(entry.url, link.tags)\n\t\t\t\t\tputs entry.url\t\n\t\t\t\telse\n\t\t\t\t\tputs \"bad url\"\n\t\t\t\t\tputs entry.url\t\n\t\t\t\tend\n\t\t\t\t\t\n\t\t\tend\n\t\tend\n\n\tend\n\nend",
"def feed_for(name)\n find_articles(name) \n articles_to_list\n feed = @page.page_parts.where(name: 'feed').first\n process_with_filter(feed) \n end",
"def cache_feeds\n puts \"Caching feeds... (can be slow)\"\n feeds = Conf.feeds.map do |uri|\n # silly to need this, but if the feed fails to fetch,\n # don't kill the ruby thread ...\n begin\n feed = FeedTools::Feed.open( uri )\n { :uri => uri, :title => feed.title, \n :items => feed.items.map { |item| { :title => item.title, :author => item.author.name, :published => item.published, :link => item.link } } }\n rescue FeedTools::FeedAccessError\n puts uri\n next\n end\n end\n feeds.each { |feed|\n new = CachedFeed.find_or_initialize_by_uri( feed[:uri] )\n new.parsed_feed = feed\n new.save!\n }\n end",
"def run(task_array)\r\n pool = Thread.pool(@thread_count)\r\n task_array.each do |task| \r\n case task\r\n when Array\r\n pool.process {@archiever.read_and_save_url(task[1], task[0])} \r\n when String\r\n pool.process {@archiever.read_and_save_url(task)} \r\n end\r\n end\r\n pool.shutdown()\r\n end",
"def get_rss_feed( rss_url )\n\t\tfeed = false\n\t\tuntil feed.class == Feedzirra::Parser::RSS\n\t\t\tfeed = Feedzirra::Feed.fetch_and_parse( rss_url )\n\t\tend\n\t\tfeed\n\tend",
"def tasks\n task_list.tasks\n end",
"def rss\n render_rss_feed_for Idea.find(:all, :order => 'created_at DESC',\n :limit => 10), {\n :feed => {\n :title => 'OpenMind New Ideas',\n :link => url_for(:controller => 'ideas', :action => 'list', :only_path => false),\n :pub_date => :created_at\n },\n :item => {\n :title => :title,\n :description => :formatted_description,\n :link => Proc.new{|idea| url_for(:controller => 'ideas',\n :action => 'show', :id => idea.id)}\n }\n }\n end",
"def tasks\n @tasks ||= @dom.css(\"BusinessObject[@Name=Task]\").map do |element|\n Task.new(element.to_xml)\n end\n end",
"def fetch!\n parsed_feed = FeedNormalizer::FeedNormalizer.parse open(self.feed_url)\n \n self.update_attributes( :title => parsed_feed.title,\n :url => parsed_feed.url\n #:etag => parsed_feed.etag\n #:last_modified => parsed_feed.last_modified\n )\n \n parsed_feed.entries.each do |entry|\n self.entries.create(:url => entry.url,\n :title => entry.title,\n :author => entry.author,\n #:summary => entry.summary,\n :content => entry.content\n #:published => entry.published\n #:categories => entry.categories\n ) if !Entry.find_by_url(entry.url)\n end\n end",
"def get_feed(url, opts)\n\n opts.extra = Hash.new\n opts.extra[\"Connection\"] = \"close\"\n # some sites need User-Agent field\n opts.extra[\"User-Agent\"] = \"RSSClient/2.0.9\"\n\n # Ask for changes (get 304 code in response)\n # opts.since is Time::\n if not opts.forceUpdate and opts.since\n time = Time.parse(opts.since.to_s)\n opts.extra[\"If-Modified-Since\"] = time.httpdate() if time\n end\n\n begin\n @rssc_raw = get_url(url, opts)\n return nil unless @rssc_raw\n\n case @rssc_raw.status\n when 200 # good\n when 301, 302 # follow redirect ...\n @rssc_raw = get_url(@rssc_raw.header[\"Location\"], opts)\n return nil unless @rssc_raw\n\n when 304 # Not modified - nothing to do\n return nil\n\n # errors\n when 401\n raise RuntimeError, \"access denied, \" + @rssc_raw.header['WWW-Authenticate'].to_s\n when 404\n raise RuntimeError, \"feed [ #{url} ] not found\"\n else\n raise RuntimeError, \"can't fetch feed (unknown response code: #{@rssc_raw.status})\"\n end\n\n return nil unless @rssc_raw.content\n\n # Parse the raw RSS\n begin\n FeedNormalizer::FeedNormalizer.parse(@rssc_raw.content, :try_others => true)\n rescue NoMethodError\n # undefined method `channel' for #<RSS::Atom::Feed:0x9f03b70>\n # try a simpler parser ...\n FeedNormalizer::FeedNormalizer.parse(@rssc_raw.content,\n :try_others => true, :force_parser => FeedNormalizer::SimpleRssParser\n )\n end\n rescue RuntimeError => error\n @rssc_error = error\n return nil\n end \n end",
"def feed( category, message, feedOptions = nil )\n feedTask = FeedTask.new( @web, self, category, message, feedOptions )\n feedTask.perform()\n end",
"def prepopulate\n # AtomFeedReaderHelper.prepopulate\n # @atom_feed_reads = AtomFeedRead.where(successfully_read: false).order('avalon_last_updated ASC')\n # render 'atom_feed_reader/index'\n AtomFeedReaderTask.new.perform\n end",
"def add_to_rss\n require 'open-uri'\n require 'cgi'\n\n fname = Wiki_path + \"/rss-temp\"\n\n internalurl = cururl.split(\"/\").last\n url = \"#{Internet_path}/#{internalurl}\"\n\n # load existing holding file, or start form scratch\n if File.exists?(fname)\n rss_entries = Marshal::load(File.read(fname))\n else\n rss_entries = Array.new\n end\n\n page_contents = open(\"http://localhost/wiki/#{internalurl}?vecdo=print\").read\n contents = page_contents.scan(/<\\!\\-\\- start rendered wiki content \\-\\-\\>(.+?)\\<\\!\\-\\- end rendered wiki content \\-\\-\\>/m)[0][0]\n\n contents.gsub!(/\\<div class\\=\\\"hiddenGlobal(.+?)\\<div class\\=\\\"plugin_include_content/m, '<div ')\n\n # remove title (already given in metadata)\n contents.remove!(\n /\\<h1 class\\=\\\"sectionedit1\\\"\\>(.+?)\\<\\/a\\>\\<\\/h1\\>/,\n /\\<\\!\\-\\- TOC START \\-\\-\\>(.+?)\\<\\!\\-\\- TOC END \\-\\-\\>/m,\n /\\<span class\\=\\\"tip\\\"\\>(.+?)\\<\\/span\\>/, # remove citation tooltips\n /\\<div class\\=\\\"plugin\\_include\\_content\\ plugin\\_include\\_\\_clip(.+?)\\<\\/div\\>/m, # remove wiki clippings\n /\\<div class\\=\\\"plugin\\_include\\_content\\ plugin\\_include\\_\\_kindle(.+?)\\<\\/div\\>/m\n )\n\n title = page_contents.scan(/\\<h1(.+?)id(.+?)>(.+)\\<(.+?)\\<\\/h1\\>/)[0][2]\n title = CGI.unescapeHTML(title)\n\n entry_contents = {:title => title, :date => Time.now, :link => url, :description => contents}\n\n exists = false\n\n rss_entries.map! do |entry|\n if entry[:link] == url\n exists = true\n entry_contents\n else\n entry\n end\n end\n\n unless exists\n rss_entries << entry_contents\n end\n\n rss_entries = rss_entries.drop(1) if rss_entries.size > 15\n\n File.write(fname, Marshal::dump(rss_entries))\n\n if exists\n growl(\"Article updated\", \"Article #{title} updated\")\n else\n growl(\"Article added to feed\", \"'#{title}' added to RSS feed\")\n end\nend",
"def pull_tasks_harvest\n harvest_uri = URI(\"https://api.harvestapp.com/v2/task_assignments?updated_since=#{last_updated_time}\")\n\n Net::HTTP.start(harvest_uri.host, harvest_uri.port, use_ssl: true) do |http|\n harvest_request = Net::HTTP::Get.new harvest_uri\n\n harvest_request[\"Authorization\"] = \"Bearer #{harvest_access_token}\"\n harvest_request[\"Harvest-Account-ID\"] = harvest_account_id\n harvest_request[\"User-Agent\"] = harvest_user_agent\n \n harvest_response = http.request harvest_request\n json_response = JSON.parse(harvest_response.body)\n return json_response[\"task_assignments\"]\n end\n\n end",
"def scrape_article\n\n url=\"http://sbs.feedsportal.com/c/34692/f/637303/index.rss\"\n open(url) do |rss|\n feed = RSS::Parser.parse(rss)\n feed.items.each do |item|\n temp_article=Article.new\n temp_article.author=item.author\n temp_article.title=item.title\n\n # input was in form of several paragraphs in html format\n # the code splits the paragraphs to arrays so only the relevent\n # text is displayed\n temp_article.summary=item.description.split('<')[0]\n temp_article.images=get_http(item.description)\n temp_article.source=SbsImporter.source_name\n temp_article.link=item.link\n temp_article.date=item.pubDate.to_date\n\n\n\n\n\n if(temp_article.date <= @end && temp_article.date>=@start && is_unique(temp_article))\n #if article is with the start and end date insert into array and is unique\n\n temp_article.save\n\n\n end\n\n end\n\n\n\n\n end\n end",
"def fetch_data\n rss_provider = RssProvider.find(params[:format])\n unless rss_provider.rss_url.include?(\"indiatvnews\" ) || rss_provider.rss_url.include?(\"hindu\" ) || rss_provider.rss_url.include?(\"zee\" )\n xml = HTTParty.get(rss_provider.rss_url)\n ProviderContent.create(xml: xml, rss_provider_id: rss_provider.id)\n feeds = xml[\"rss\"][\"channel\"][\"item\"]\n feeds.each do |feed|\n if rss_provider.rss_url.include?(\"indiatoday\" )\n title = News.find_by(title: feed[\"title\"])\n unless title.present?\n\n\n index_of_summary = feed[\"description\"].index(\"</a>\")\n summary = feed[\"description\"][index_of_summary..].delete_prefix(\"</a> \")\n index_of_image = feed[\"description\"].index(\"src\")\n image_url = feed[\"description\"][(index_of_image+5)..(index_of_summary-4)]\n News.create(title: feed[\"title\"], summary: summary, \n published_on: feed[\"pubDate\"], url: feed[\"link\"], media_url: image_url,\n rss_provider_id: rss_provider.id, category_id: rss_provider.category.id, \n provider_id: rss_provider.provider.id, media_credit: rss_provider.provider.provider_name)\n rss_provider.update(news_updated_at: Time.now.localtime)\n\n end\n\n \n elsif rss_provider.rss_url.include?(\"news18\")\n title = News.find_by(title: feed[\"title\"])\n unless title.present?\n index_of_image = feed[\"description\"].index(\"https\")\n summary_index = feed[\"description\"].index(\" />\")\n last_index_of_image = feed[\"description\"].index(\"jpg\")\n image_url = feed[\"description\"][(index_of_image)..(last_index_of_image)] + \"pg\"\n summary = feed[\"description\"][(summary_index+3)..]\n News.create(title: feed[\"title\"], summary: summary,published_on: feed[\"pubDate\"], url: feed[\"link\"], media_url: image_url, rss_provider_id: rss_provider.id, category_id: rss_provider.category.id, \n provider_id: rss_provider.provider.id, media_credit: rss_provider.provider.provider_name)\n rss_provider.update(news_updated_at: Time.now.localtime)\n end\n\n\n elsif rss_provider.rss_url.include?(\"bbc\")\n title = News.find_by(title: feed[\"title\"])\n unless title.present?\n News.create(title: feed[\"title\"], summary: feed[\"description\"], \n published_on: feed[\"pubDate\"], url: feed[\"link\"], media_url: feed[\"fullimage\"], \n rss_provider_id: rss_provider.id, category_id: rss_provider.category.id, \n provider_id: rss_provider.provider.id, media_credit: rss_provider.provider.provider_name)\n rss_provider.update(news_updated_at: Time.now.localtime)\n end\n\n\n elsif rss_provider.rss_url.include?(\"ndtv\")\n title = News.find_by(title: feed[\"title\"])\n unless title.present?\n News.create!(title: feed[\"title\"], summary: feed[\"description\"], \n published_on: feed[\"updatedAt\"], url: feed[\"link\"], media_url: feed[\"fullimage\"], \n rss_provider_id: rss_provider.id, category_id: rss_provider.category.id,provider_id: rss_provider.provider.id, media_credit: rss_provider.provider.provider_name)\n rss_provider.update(news_updated_at: Time.now.localtime)\n end\n\n\n \n elsif rss_provider.rss_url.include?(\"timesofindia\")\n title = News.find_by(title: feed[\"title\"])\n\n unless title.present?\n\n if rss_provider.category.category_name == \"Top Story\" \n News.create(title: feed[\"title\"], summary: feed[\"description\"], \n published_on: feed[\"pubDate\"], url: feed[\"link\"], media_url: \"\", \n rss_provider_id: rss_provider.id,category_id: rss_provider.category.id, \n provider_id: rss_provider.provider.id, media_credit: rss_provider.provider.provider_name)\n rss_provider.update(news_updated_at: Time.now.localtime) \n else\n unless feed[\"description\"] == nil \n index_of_image = feed[\"description\"].index(\"src\")\n last_index_of_image = feed[\"description\"][index_of_image..].index(\"/>\")+index_of_image\n image_url = feed[\"description\"][(index_of_image+5)..(last_index_of_image-3)]\n summary_index = feed[\"description\"].index(\"</a>\")\n summary = feed[\"description\"][(summary_index+4)..]\n News.create(title: feed[\"title\"], summary: summary, \n published_on: feed[\"pubDate\"], url: feed[\"link\"], media_url: image_url, \n rss_provider_id: rss_provider.id, category_id: rss_provider.category.id, \n provider_id: rss_provider.provider.id, media_credit: rss_provider.provider.provider_name)\n rss_provider.update(news_updated_at: Time.now.localtime)\n end\n end\n end\n \n\n end\n\n end\n end\n\n unless rss_provider.rss_url.include?(\"timesofindia\" ) || rss_provider.rss_url.include?(\"ndtv\" ) || rss_provider.rss_url.include?(\"bbc\" ) ||\n rss_provider.rss_url.include?(\"news18\") || rss_provider.rss_url.include?(\"indiatoday\") \n\n\n if rss_provider.rss_url.include?(\"indiatvnews\" )\n xml = HTTParty.get(rss_provider.rss_url)\n ProviderContent.create(xml: xml, rss_provider_id: rss_provider.id)\n\n xml = xml.body\n feeds = Feedjira.parse(xml)\n feeds.entries.each do |feed|\n index_of_summary = feed.summary.index(\"</a>\")\n summary = feed.summary[index_of_summary+4..]\n index_of_image = feed.summary.index(\"src\")\n image_url = feed.summary[(index_of_image+5)..(index_of_summary-5)]\n title = News.find_by(title: feed.title)\n unless title.present?\n News.create(title: feed.title, summary: summary, \n published_on: feed.published, url: feed.url, media_url: image_url, \n rss_provider_id: rss_provider.id, category_id: rss_provider.category.id, \n provider_id: rss_provider.provider.id, media_credit: rss_provider.provider.provider_name)\n end\n\n end\n rss_provider.update(news_updated_at: Time.now.localtime)\n\n elsif rss_provider.rss_url.include?(\"thehindu\")\n xml = HTTParty.get(rss_provider.rss_url)\n ProviderContent.create(xml: xml, rss_provider_id: rss_provider.id)\n xml = xml.body\n feeds = Feedjira.parse(xml)\n feeds.entries.each do |feed|\n title = News.find_by(title: feed.title)\n unless title.present?\n News.create(title: feed.title, summary: feed.summary.strip, \n published_on: feed.published, url: feed.url,rss_provider_id: rss_provider.id, category_id: rss_provider.category.id, \n provider_id: rss_provider.provider.id, media_credit: rss_provider.provider.provider_name)\n end\n\n end\n rss_provider.update(news_updated_at: Time.now.localtime)\n\n elsif rss_provider.rss_url.include?(\"zee\")\n xml = HTTParty.get(rss_provider.rss_url)\n ProviderContent.create(xml: xml, rss_provider_id: rss_provider.id)\n xml = xml.body\n feeds = Feedjira.parse(xml)\n feeds.entries.each do |feed|\n title = News.find_by(title: feed.title)\n unless title.present?\n News.create(title: feed.title, summary: feed.summary.strip, \n published_on: feed.published, url: feed.url,rss_provider_id: rss_provider.id, category_id: rss_provider.category.id, \n provider_id: rss_provider.provider.id, media_credit: rss_provider.provider.provider_name)\n end\n\n end\n rss_provider.update(news_updated_at: Time.now.localtime)\n end\n\n end\n\n unless rss_provider.rss_url.include?(\"timesofindia\" ) || rss_provider.rss_url.include?(\"ndtv\" ) || rss_provider.rss_url.include?(\"bbc\" ) ||\n rss_provider.rss_url.include?(\"news18\") || rss_provider.rss_url.include?(\"indiatoday\") ||\n rss_provider.rss_url.include?(\"indiatvnews\") || rss_provider.rss_url.include?(\"thehindu\") ||\n rss_provider.rss_url.include?(\"zee\")\n\n xml = HTTParty.get(rss_provider.rss_url)\n ProviderContent.create(xml: xml, rss_provider_id: rss_provider.id)\n xml = xml.body\n feeds = Feedjira.parse(xml)\n feeds.entries.each do |feed|\n title = News.find_by(title: feed.title)\n unless title.present?\n News.create(title: feed.title, summary: feed.summary.strip, \n published_on: feed.published, url: feed.url,rss_provider_id: rss_provider.id, category_id: rss_provider.category.id, \n provider_id: rss_provider.provider.id, media_credit: rss_provider.provider.provider_name)\n end\n\n end\n rss_provider.update(news_updated_at: Time.now.localtime)\n\n end\n redirect_to admin_rss_providers_path, alert: \"Fetched Successfully \"\n\n end",
"def run_ticker(m)\n config = YAML.safe_load(File.read(\"config/google.yml\"))\n source = \"http://www.google.com/appsstatus/rss/en\"\n current_msg = String.new\n \n # Get current RSS message without reporting it.\n raw = String.new\n open(source) do |input|\n raw = input.read\n end\n rss = RSS::Parser.parse(raw, false)\n\n if !rss.items.empty?\n current_msg = rss.items[0].description\n end\n\n # Begin checking for new RSS messages.\n while @@active\n sleep(config['frequency'])\n\n raw = String.new\n open(source) do |input|\n raw = input.read\n end\n rss = RSS::Parser.parse(raw, false)\n\n # If there are any entries in the RSS feed, check if they\n # are different from what we already have. If so, update, then\n # print them out.\n if !rss.items.empty?\n if (rss.items[0].description != current_msg)\n current_msg = rss.items[0].description\n\n cleaned_rss = Sanitize.clean(rss.items[0].description)\n # Google has an interesting way of dividing up different entries...\n # with the following Unicode character delimiter.\n msg_set = cleaned_rss.split \"\\u00A0\"\n msg_set.each { |msg| msg.strip! }\n msg_set.delete_if { |msg| msg.empty? }\n \n reply = \"[#{rss.items[0].title}] \"\n reply << (msg_set[0]).to_s\n \n # Report RSS results to each channel in the list.\n config['channels'].each do |chname|\n max_msg_size = 512 - m.bot.nick.size - chname.size - 43\n Channel(chname).send reply[0,max_msg_size]\n Channel(chname).send \"More info at: #{rss.items[0].link}\"\n end\n\n end\n end\n end\n\n end",
"def scrape\n\t\turi = URI.parse(@url)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\thttp.use_ssl = false\n\t\t#Make a GET request to the given url\n\t\tresponse = http.send_request('GET', @request_url)\n\t\t# Parse the response body\n\t\tforecast = JSON.parse(response.body)\n\t\tforecast[\"response\"][\"results\"].each do |article|\n\t\t\tif date_valid?(article[\"webPublicationDate\"])\n\t\t\t\tcreate_article(article[\"type\"], article[\"sectionId\"],\n\t\t\t\t\tarticle[\"webTitle\"], article[\"webPublicationDate\"],\n\t\t\t\t\tarticle[\"id\"], article[\"webUrl\"], article[\"apiUrl\"],\n\t\t\t\t\tarticle[\"sectionName\"])\n\t\t\tend\n\t\tend\n\t\t@articles\n\tend",
"def getItems\n url = 'http://b.hatena.ne.jp/sh19e/atomfeed'\n while url\n nodes = []\n puts url\n hatena = Hatena.new(url)\n nodes.unshift(hatena.getXML).flatten!\n model = Mymodel.new\n model.insertData(nodes)\n if model.isUpdate?\n puts \"Database is updated\"\n break\n end\n url = hatena.next?\n exit 1\n end\nend",
"def update_from_feed(feed_url)\n\t\tputs \"pulling feeds\"\n\t\tfeed = Feedzirra::Feed.fetch_and_parse(feed_url)\n\t\t# feed.last_modified - if it's been modified since last time\n\t\tfeed.entries.each do |entry|\n\t\t\t# if the post occured after it was last checked\n\t\t\tfind_keywords(entry.url)\n\t\t\tputs entry.url\n\t\t\t# call the keyword check and save on the actual post url\t\n\t\tend\nend",
"def scrape_article\n\n url='http://www.theage.com.au/rssheadlines/political-news/article/rss.xml'\n puts url\n open(url) do |rss|\n\n feed = RSS::Parser.parse(rss)\n\n #For each article gather the relevent information and put it in the article\n feed.items.each do |item|\n\n temp_article=Article.new\n temp_article.author=item.author\n temp_article.title=item.title\n # input was in form of several paragraphs in html format\n # the code splits the paragraphs to arrays so only the relevent\n # text is displayed\n temp_article.summary = item.description.split('</p>')[1]\n temp_article.images=get_http(item.description.split('</p>')[0].split('><')[1])\n\n temp_article.source=AgeImporter.source_name\n temp_article.link=item.link\n temp_article.date=item.pubDate.to_date\n\n\n\n if(temp_article.date <= @end && temp_article.date>=@start && is_unique(temp_article))\n # if article is with the start and end date insert into array and is unique\n\n temp_article.save\n\n\n end\n\n end\n\n\n\n\n end\n end",
"def feed\n @data.feed ||= parsed_document.xpath(\"//link\").select{ |link|\n link.attributes[\"type\"] && link.attributes[\"type\"].value =~ /(atom|rss)/\n }.map { |link|\n absolutify_url(link.attributes[\"href\"].value)\n }.first rescue nil\n end",
"def getScrapingURLs(shared)\n\tFile.open(\"urls.txt\").each do |line|\n\t\tshared.pushurl(line.chomp)\n\tend\nend",
"def get_rss\n #version = \"1.0\" # [\"0.9\", \"1.0\", \"2.0\"]\n version = @version\n\n content = RSS::Maker.make(@version) do |m|\n m.channel.title = @title\n m.channel.description = @description \n m.channel.link = @link \n m.channel.language = @language\n m.channel.about = @about\n m.items.do_sort = true # sort items by date\n m.channel.updated = Time.now.to_s\n m.channel.author = NAME\n\n if @image != nil\n m.image.url = @image\n m.image.title = @title\n end\n\n for mp3 in @mp3s \n item = m.items.new_item\n item.title = mp3\n ## add a base url \n if base != ''\n link = base + '/' + URI::escape(mp3.path)\n else \n link = URI::escape(mp3.path)\n end\n item.link = link\n item.date = mp3.mtime\n item.enclosure.url = link\n item.enclosure.length = mp3.length\n item.enclosure.type = mp3.type\n end\n end\n\n return content\n end",
"def latest_news(feed_url, options={})\n div_id = options[:div_id] || \"news_feed\"\n s = <<-EOF\n<div id=\"#{div_id}\"></div>\n\n<script type=\"text/javascript\">\n\n google.load(\"feeds\", \"1\");\n\n function #{div_id}_init() {\n var feed = new google.feeds.Feed(\"#{feed_url}\");\n feed.setNumEntries(3)\n feed.load(function(result) {\n if (!result.error) {\n var container = $(\"##{div_id}\");\n for (var i = 0; i < result.feed.entries.length; i++) {\n var entry = result.feed.entries[i];\n container.append('<div><div class=\"blog_title\"><a href=\"' + entry.link + '\">' + entry.title + '</a></div>'\n + '<div class=\"blog_body\">' + entry.contentSnippet + '</div>'\n + '<div class=\"blog_date\">' + entry.publishedDate + '</div>'\n + '</div>');\n }\n }\n });\n }\n google.setOnLoadCallback(#{div_id}_init);\n</script>\n EOF\n s.html_safe\n end",
"def fetch\n @raw_feed = HTTParty.get(@url).response.body unless @raw_feed\n end"
] |
[
"0.67619574",
"0.66635495",
"0.6576879",
"0.64510477",
"0.62617916",
"0.6113688",
"0.6113044",
"0.6090623",
"0.60790443",
"0.60670173",
"0.59725815",
"0.5923344",
"0.5922108",
"0.5905358",
"0.58835614",
"0.5875817",
"0.5856877",
"0.5826789",
"0.5818325",
"0.5797949",
"0.57960343",
"0.57838726",
"0.5774822",
"0.5749016",
"0.572529",
"0.5720978",
"0.5720786",
"0.5706987",
"0.5703627",
"0.56949425",
"0.5670515",
"0.564804",
"0.56312966",
"0.56217086",
"0.56170034",
"0.5608709",
"0.558635",
"0.558318",
"0.55809414",
"0.55732334",
"0.5558768",
"0.553383",
"0.5527955",
"0.5519524",
"0.5515656",
"0.55132574",
"0.55117697",
"0.5510803",
"0.5510147",
"0.55081356",
"0.55019736",
"0.54990214",
"0.54799455",
"0.5445764",
"0.54432666",
"0.5432839",
"0.5424264",
"0.54189503",
"0.5416265",
"0.54054385",
"0.54013807",
"0.53965384",
"0.5390581",
"0.53897375",
"0.5381455",
"0.5378391",
"0.53704864",
"0.5361192",
"0.5355097",
"0.53539234",
"0.5332305",
"0.5307152",
"0.5305379",
"0.5302198",
"0.5284008",
"0.5280898",
"0.5280097",
"0.5278445",
"0.5276415",
"0.52708095",
"0.5261783",
"0.52607095",
"0.52596503",
"0.52489823",
"0.52418715",
"0.5238928",
"0.5237626",
"0.52361864",
"0.52275115",
"0.52246606",
"0.52175486",
"0.5207712",
"0.5203309",
"0.5187492",
"0.5181843",
"0.51771665",
"0.51741827",
"0.5172771",
"0.51671535",
"0.51618636",
"0.5159038"
] |
0.0
|
-1
|
This method lets you refresh the tasks int the tasks array useful if you keep the object cached in memory and
|
def refresh
open(@url) do |http|
parse(http.read)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def tasks=( array )\n @tasks = array\n update_internal_task_lists()\n end",
"def refresh(*managers)\n @iterator.each do |iter|\n task = iter[0]\n if task.done?\n removal_time = @done_tasks[task]\n if not removal_time\n @done_tasks[task] = Time.now + TASK_REMOVAL_TIMEOUT\n @tasks.delete(task)\n self.set(iter, task, TASK_REMOVAL_TIMEOUT)\n elsif Time.now > removal_time\n iter.remove()\n @done_tasks.delete(task)\n else\n time_left = (removal_time - Time.now + 1).to_i\n self.set(iter, task, time_left)\n end\n else\n self.set(iter, task)\n end\n end\n\n tasks = managers.map(&:tasks).flatten\n tasks_to_add = tasks - @tasks\n self.add(tasks_to_add)\n end",
"def reload\n @tasks_scope = nil\n end",
"def sync_tasks\n\n #TODO make this line optional\n @account_info = @authenticator.get_account\n\n #Add any tasks that needed to be added\n new_tasks = @tasks.keys.select{|task| task.brand_new?}\n @authenticator.add_tasks(new_tasks.collect {|task| task.json_parsed}) unless @new_tasks.new_tasks.empty?\n\n #Record that the tasks have already been added\n new_tasks.each {|task| task.no_longer_new}\n\n #Delete any tasks that were marked as deleted locally but not yet removed from @tasks\n deleted_tasks = @tasks.keys.select{|task| task.deleted?}\n @authenticator.delete_tasks(deleted_tasks.collect {|task| task.id}) unless deleted_tasks.empty?\n \n if lastedit_task > @last_task_sync\n #Get (recently edited) tasks\n tasks = @authenticator.get_tasks {:after => lastedit_task}\n \n locally_edited = []\n\n #TODO we may need to put this in a loop and load tasks page by page\n tasks.each do |task|\n if not @tasks[task.id]\n #If for some reason the task doesn't exist yet locally, add it\n @tasks[task.id] = task\n else\n #Compare modification times, update local copy when necessary, and resolve editing conflicts\n #Do NOT use task.last_mod, because that will just refer to the time that the get_tasks function was called!\n #Instead, we care about the time that the last edits were actually saved on the Toodledo server\n if task.modified > @tasks[task.id].last_mod\n #The server-stored task was modified more recently than the local task\n #TODO make sure all other locations are properly mutating the task, rather than creating parallel/outdated instances\n #If we simply overwrote the task instead of updating task.json_parsed, any past references to the task would point to an invalid/outdated\n @tasks[task.id].json_parsed = task.json_parsed\n @tasks[task.id].edit_saved\n else\n #The local task was modified more recently than the server-stored task\n #Realistically, the two timestamps cannot be the same, but if they are, we will assume the local copy is more accurate\n locally_edited.push(@tasks[task.id])\n end\n end\n end\n end\n\n if lastdelete_task > @last_task_sync\n #Query the deleted tasks (on the Toodledo server) and delete them here locally\n @user.get_deleted_tasks.collect{|task| task.id}.each do |id| \n #The delete boolean will be set just in case there are other references to the task, in which case it would not be garbage-collected\n @tasks[id].delete!\n @tasks[id].edit_saved #Make sure it won't be edited-saved in the future\n @tasks.delete(id)\n end\n end\n\n locally_edited = locally_edited.select{|task| not task.deleted?}\n @user.edit_tasks(locally_edited.collect{|task| task.json_parsed}) unless locally_edited.empty?\n \n #After this, the modified timestamp on the server will be the current time, which is later than the task.last_mod for any task stored locally\n \n #TODO check if there were repeating tasks that needed to be rescheduled\n \n #Remove any deleted tasks from @tasks. There may still be references elsewhere to them (depending on the application), so they may not necessarily be garbage-collected\n @tasks = @tasks.select{|task| not task.deleted?}\n\n @last_task_sync = Time.now\n end",
"def tasks\n @tasks ||= {}\n end",
"def reload_tasks(dir=@tasks_dir)\n @task_files = []\n load_tasks(dir)\n end",
"def reload_tasks(dir=@tasks_dir)\n @task_files = []\n load_tasks(dir)\n end",
"def tasks=(value)\n @tasks = value\n end",
"def tasks=(value)\n @tasks = value\n end",
"def tasks=(value)\n @tasks = value\n end",
"def reload_cached_tasks(command_name)\n # we clear @current since this will be reloaded\n @current = nil\n\n load_context(command_name)\n end",
"def refresh_task_table\n @task_table.refresh(@download_manager, @resolver_manager)\n end",
"def update_internal_task_lists\n\n # Security - discard tasks the user should not be able to see.\n\n if ( @current_user.restricted? )\n @tasks.select do | task |\n task.is_permitted_for?( @current_user )\n end\n end\n\n # Now the fiddly bit! Sort the task objects by augmented title, then\n # retrospectively rebuild the task ID arrays using the reordered list.\n\n Task.sort_by_augmented_title( @tasks )\n\n @task_ids = []\n @active_task_ids = []\n @inactive_task_ids = []\n\n @tasks.each do | task |\n @task_ids << task.id\n @active_task_ids << task.id if ( task.active )\n @inactive_task_ids << task.id unless ( task.active )\n end\n end",
"def update!(**args)\n @reload_tasks = args[:reload_tasks] if args.key?(:reload_tasks)\n end",
"def update(task_number, task) # Update task based on task number\n all_tasks[task_number -1] = task # Updates task\n end",
"def all_tasks\n @all_tasks ||= []\n end",
"def new_tasks_pending tasks\n tasks ||= []\n self.task_ids += tasks\n\n # Salva a instancia apos adicionar as novas task's\n self.save\n end",
"def update!(**args)\n @tasks = args[:tasks] if args.key?(:tasks)\n end",
"def clear()\n shutdown()\n @tasks = {}\n _clear()\n end",
"def load_tasks\n end",
"def tasks\n @tasks ||= Evoke.tasks\n end",
"def initialize\n @tasks = []\n @futures = nil\n end",
"def tasks\n @tasks ||= Task.find(self.task_ids)\n end",
"def update_tasks(tasks)\n tasks.each_with_index do |task, i|\n if line_renderer = line_renderers[i]\n line_renderer.task = task\n else\n line_renderers[i] = LineRenderer.new(task)\n end\n end\n if tasks.count < line_renderers.count\n (tasks.count...line_renderers.count).each do |i|\n line_renderers[i].task = nil\n end\n end\n end",
"def registered_tasks\n @task_register_lock.synchronize do\n @registered_tasks.values\n end\n end",
"def registered_tasks\n @task_register_lock.synchronize do\n @registered_tasks.values\n end\n end",
"def update_task_completion_status_cache!(tasks = nil)\n self.task_completion_status_cache ||= {}\n tasks ||= offering.tasks.find(:all, :conditions => \"context = 'applicant' AND completion_criteria != ''\")\n tasks = [tasks] unless tasks.is_a?(Array)\n for task in tasks\n tcs = task_completion_statuses.find_or_create_by_task_id(task.id)\n tcs.result = self.instance_eval(task.completion_criteria.to_s)\n tcs.complete = tcs.result == true\n tcs.save\n self.task_completion_status_cache[task.id] = tcs.attributes\n end\n task_completion_status_cache\n end",
"def initialize # Initialize method that is similar to a Constructor in Java\n @all_tasks = [] # Method includes an array that stores all tasks\n end",
"def tasks() []; end",
"def tasks_data_today \n tasks_of_today = self.tasks_due_today\n tasks = []\n tasks_of_today.each do |task|\n task = {\n task_name: task.name, \n completion_value: task.completions.last.completion_value,\n completion_max: task.completion_max,\n completion_unit: task.completion_unit\n }\n tasks << task \n end\n tasks \n end",
"def tasks_for(list)\n\t\t@tasks[list] ||= fetch_latest_tasks_for(list)\n\tend",
"def clear_completed\n\t\t\t@completed_tasks = Hash.new\n\t\t\tupdate\n\t\tend",
"def jeweler_tasks=(_arg0); end",
"def tasks(project_id, reload = false)\n self.cache(CostAgent::Task, project_id, reload) do\n (self.api(\"projects/#{project_id}/tasks\")/\"task\").collect do |task|\n # Find the project for this task\n project = self.project((task/\"project-id\").text.to_i)\n # Calculate rates\n billing_rate = (task/\"billing-rate\").text.to_f\n billing_period = (task/\"billing-period\").text\n hourly_rate = (billing_period == \"hour\" ? billing_rate : billing_rate / project.hours_per_day)\n daily_rate = (billing_period == \"hour\" ? billing_rate * project.hours_per_day : billing_rate)\n # Build the task out using the task data and the project it's tied to\n Task.new(\n :id => (task/\"id\").text.to_i,\n :name => (task/\"name\").text,\n :project_id => project.id,\n :project => project,\n :hourly_billing_rate => hourly_rate,\n :daily_billing_rate => daily_rate,\n :billable => (task/\"is-billable\").text == \"true\")\n end\n end\n end",
"def update_late_tasks\n # find project\n project = Project.find(params[:id])\n # check user is manager of project\n if (!@superuser_is_superadmin && !(superuser_is_part_of_project? project))\n flash[:warning] = \"You can't do this action for this project\"\n redirect_to lato_core.root_path and return false\n end\n # find tasks\n today = Date.today\n tasks = project.tasks.where(status: ['wait', 'develop']).where('end_date < ?', today)\n # update tasks\n tasks.each do |task|\n days_long = task.end_date - task.start_date\n task.update(start_date: today, end_date: today + days_long)\n end\n # return result\n flash[:success] = 'Operation done'\n redirect_to lato_swpmanager.project_tasks_path(id: project.id)\n end",
"def added_tasks(tasks)\n\t\tsuper if defined? super\n\t\tPlanModificationHooks.added_objects(self, tasks)\n\t end",
"def assign_tasks(incoming_tasks=[])\n incoming_tasks.each do |task_data|\n task = Task.find_or_initialize_by(list: self, id: task_data[:id])\n task.update(task_data)\n end\n end",
"def tasks\n task_list.tasks\n end",
"def fetch_tasks\n tasks = BgTask.all\n tasks = load_tasks if tasks.nil? || tasks.empty?\n tasks\n end",
"def task_lists\n\t\t@task_lists ||= fetch_latest_task_lists\n\tend",
"def tasks\n @tasks ||= Harvest::API::Tasks.new(credentials)\n end",
"def set_tasks\n @b_task = backup.b_task.find(params[:id])\n end",
"def initialize(url, refresh = true)\n self.tasks = []\n self.url = url\n self.refresh if refresh\n end",
"def reset!\n @tasks.synchronize {\n @tasks.delete_if { |t| t.terminate! }\n @timestamp = Timestamp.new\n }\n end",
"def refresh\n self.operation = \"#{operation}#refresh\"\n\n return if params_missing?\n\n # Connection settings\n set_connection_data!\n logger.info_ext(operation, \"Connection set successfully\")\n\n # Get all tasks\n tasks, @refresh_state_uuid = {}, SecureRandom.uuid\n @parts_requested_cnt, @parts_received_cnt = Concurrent::AtomicFixnum.new(0), Concurrent::AtomicFixnum.new(0)\n @source_refs_requested, @source_refs_received = [], Concurrent::Array.new\n\n params.to_a.each do |task|\n if task['task_id'].blank? || task['source_ref'].blank?\n logger.warn_ext(operation, \"Missing data for task: #{task}\")\n next\n end\n tasks[task['task_id']] = task['source_ref']\n\n if tasks.length == REFS_PER_REQUEST_LIMIT\n refresh_part(tasks)\n tasks = {}\n end\n end\n\n refresh_part(tasks) unless tasks.empty?\n\n archive_not_received_service_instances unless on_premise?\n rescue => err\n metrics_err_type = on_premise? ? :receptor : :cloud unless endpoint.nil?\n metrics&.record_error(metrics_err_type || :general)\n logger.error_ext(operation, \"Error: #{err.message}\\n#{err.backtrace.join(\"\\n\")}\")\n end",
"def reset\n @tasks_have_failed = false\n @tasks_are_finished = false\n @tasks_are_successful = false\n end",
"def initialize\r\n load_tasks\r\n end",
"def setSubtasks(tasks)\r\n\t\t\t\t\t@tasks = tasks\r\n\t\t\t\tend",
"def update task\n now = Time.now.to_i\n wait = task.wait.nil? ? now : task.wait\n wake = now + wait\n tasks = @db[:tasks]\n r = tasks.where(:id => task.id).update :changed => now,\n :status => task.getStatus,\n :wake => wake,\n :data => Marshal::dump(task)\n end",
"def clear clear_all\n\t\t\tclear_completed\n\t\t\tif clear_all\n\t\t\t\t@tasks = Hash.new\n\t\t\t\t@completed_count = 0\n\t\t\t\t@count = 0\n\t\t\t\tputs \"Cleared list.\"\n\t\t\telse\n\t\t\t\tputs \"Cleared completed tasks.\"\n\t\t\tend\n\t\t\tupdate\n\t\tend",
"def flush\n loop do\n before = @tasks.size\n\n @tasks.delete_if do |task|\n create_or_update(**task[:entity])\n rescue Morrow::UnknownEntity => ex\n task[:last_error] = ex\n false\n end\n\n break if @tasks.empty? or @tasks.size == before\n end\n end",
"def add(tasks)\n tasks.each do |task|\n iter = @model.append()\n self.set(iter, task)\n end\n @tasks += tasks\n end",
"def get_taskarray\n @task_array\n end",
"def initialize\n @which = @@last_day_num\n @@last_day_num += 1\n @tasks = []\n end",
"def all_tasks_to_run\n self.all_tasks - all_tasks_previously_run - all_tasks_duplicates\n end",
"def remove_inactive_tasks\n self.tasks = self.tasks.active\n end",
"def tasks\n return @tasks\n end",
"def tasks\n return @tasks\n end",
"def tasks\n return @tasks\n end",
"def run_tasks()\n self.task_queue.each do |task|\n\n self.task_list << task\n trigger_event(:start,:task)\n\n result = self.send(task[:name],*(task[:args]))\n if result[:status] == :failed\n break\n end\n\n\n self.task_list.last[:result]=result\n trigger_event(:end,:task)\n end\n end",
"def set_tasks\n @events = current_user.events.all\n @tasks = current_user.tasks.all\n @task_grouping = @tasks.group_by {|t| t.event_id }\n @attendees = current_user.attendees.all\n if @event.present?\n @attendee_grouping = @event.attendees.order(\"response ASC\").group_by {|a| a.response }\n end\n \n @latest_events = @events.order(\"starts DESC\").first(60)\n\n @events.each do |event|\n task = Task.find_by(event_id: event.gid)\n if task.present?\n task.event_title = event.title\n task.save!\n end\n end\n end",
"def each_task\n tasks.each do | task |\n section, is_new_section, group, is_new_group = retrieve( task.id.to_s )\n yield( task, section, is_new_section, group, is_new_group )\n end\n end",
"def tasks\n if @tasks.nil?\n @tasks = tasks_by_filters\n @tasks = filter_by_tags(@tasks)\n @tasks += unread_tasks if session[:show_all_unread].to_i > 0\n @tasks = sort_tasks(@tasks)\n end\n\n return @tasks\n end",
"def reload_schedule!\n @schedule = all_schedules\n end",
"def each_task(&block)\n tasks.each_value(&block)\n end",
"def invoked_tasks\n @invoked_tasks\n end",
"def update(options = {})\n self.merge!(Vermonster::Client.connection.put(\"tasks/#{self[\"id\"]}\", \"{\\\"task\\\": #{options.to_json}}\").body)\n end",
"def start_task(task)\n @tasks.synchronize {\n @tasks << Task.new(task)\n @timestamp.renew!\n }\n task\n end",
"def reset\n num_removed = completed_task_ids.size\n self.completed_task_ids = []\n\n self.set_current_task_id=(lesson.tasks.first.id)\n @last_completed_task_id = 0\n self.points = 0\n\n num_removed\n end",
"def update\r\n @tasks = Task.find(params[:id])\r\n if @tasks.update(task_params)\r\n render json: @tasks\r\n else\r\n render json: @tasks.errors, status: :unprocessable_entity\r\n end\r\n end",
"def all_tasks\n @task = Task.get_all_tasks_user_can_see(current_user)\n end",
"def each\n buckets = task_buckets_to_run.map { |bucket| tasks.delete(bucket) }.compact\n buckets.each do |tasks_in_bucket|\n tasks_in_bucket.each do |task|\n yield task\n reschedule_task(task)\n end\n end\n end",
"def rebuild_task_cache\n user = User.find_by_id(session[:id])\n user.kunis.all.each do |kuni|\n kuni.tasks.all.each do |task|\n puts task.s_count\n task.s_count = task.solutions.count\n task.save\n end\n end\n end",
"def flush()\n wakeup()\n @tasks.each_value { |t| t.flush() }\n while busy?\n sleep(0.2)\n end\n end",
"def tasks\n EarLogger.instance.log \"Getting tasks for #{self}\"\n TaskManager.instance.get_tasks_for(self)\n end",
"def tasks\n uri = URI(BASE_URL + TASKS_ENDPOINT)\n\n make_request(uri)\n end",
"def _wait_tasks\n @wait_tasks\n end",
"def configure_tasks\n end",
"def clean\n # Each the tasks\n @tasks.each do |task|\n # Clean all of them\n task.clean\n end\n end",
"def initialize\n self.tasks = Array.new\n self.run_queue = Queue.new\n self.schedule\n end",
"def wakeup()\n @tasks.each_value { |t| t.wakeup() }\n end",
"def jeweler_tasks; end",
"def intern(task_class, task_name)\n @tasks[task_name.to_s] ||= task_class.new(task_name, self)\n end",
"def pop\n with_lock do\n tasks.shift\n end\n end",
"def tasks\n return self.class.get('/tasks').parsed_response.map do |task|\n Task.new(\n task['task_id'],\n task['template_id'],\n task['status'],\n task['started_at']\n )\n end\n end",
"def done\n done_ids = @tasks.keys.find_all do |id|\n @tasks[id].done?\n end\n done_tasks = done_ids.inject({}) do |map, id|\n map[id] = @tasks[id]\n map\n end\n done_ids.each do |id|\n @tasks.delete(id)\n end\n return done_tasks\n end",
"def tasks\n TapirLogger.instance.log \"Getting tasks for #{self}\"\n tasks = TaskManager.instance.get_tasks_for(self)\n tasks.sort_by{ |t| t.name.downcase }\n end",
"def tasks\n TapirLogger.instance.log \"Getting tasks for #{self}\"\n tasks = TaskManager.instance.get_tasks_for(self)\n tasks.sort_by{ |t| t.name.downcase }\n end",
"def check_tasks\n if !(@free_workers.empty? || @tasks_to_assign.empty?)\n @free_workers.each { |worker| find_task_for(worker) }\n end\n end",
"def next_process_in_time(tasks)\n task = smallest_task(tasks)\n tasks.delete(task)\n task\n end",
"def task=(value)\n @task = value\n end",
"def fetch_latest_tasks_for(list)\n\t\t@tasks[list] = @client.execute(api_method: @gtasks.tasks.list, parameters: { 'tasklist' => list.id }).data.items\n\tend",
"def refresh; schedule_update end",
"def init\r\n @tasks = {\r\n on_update: {},\r\n on_scene_switch: {},\r\n on_dispose: {},\r\n on_init: {},\r\n on_warp_start: {},\r\n on_warp_process: {},\r\n on_warp_end: {},\r\n on_hour_update: {},\r\n on_getting_tileset_name: {},\r\n on_transition: {}\r\n }\r\n @storage = {}\r\n end",
"def update_related_tasks\n tasks = self.user_tasks\n if tasks.present?\n UserTask.update_all({:work_subtype_complexity_id => nil}, {:id => tasks.map(&:id)})\n end\n end",
"def dedup\n new_tasks = []\n old_tasks = {}\n @tasks.each do |t|\n if not t.toodleid\n new_tasks << t\n elsif old_tasks.key?(t.toodleid)\n # retain only the last update\n old_tasks[t.toodleid] = [old_tasks[t.toodleid], t].max\n else\n old_tasks[t.toodleid] = t\n end\n end\n @tasks = new_tasks + old_tasks.values\n self\n end",
"def refresh\n\t\t\t#tl = MTodoList.where(basecamp_id: @id).first_or_initialize\n\t\t\ttl = @@store[@id]\n\t\t\tif tl != nil\n\t\t\t\toptions = {:headers => {\"If-Modified-Since\" => tl[:etag] ,\"If-None-Match\" => tl[:etag], 'User-Agent' => 'Lofty Word Hotlist ([email protected])'}}\n\t\t\telse\n\t\t\t\toptions = {}\n\t\t\tend\n\t\t\tresponse = Logan::Client.get \"/projects/#{@project_id}/todolists/#{@id}.json\", options\n\t\t\tif response.headers[\"status\"].strip == \"304 Not Modified\" && @@store[@id] != nil\n\t\t\t\tinitialize(@@store[@id][:payload])\n\t\t\telse\n\t\t\t\tinitialize(response.parsed_response)\n\t\t\t\t@@store[@id] = {\n\t\t\t\t\t:payload => response.parsed_response,\n\t\t\t\t\t:etag => response.headers['etag']\n\t\t\t\t}\n\t\t\tend\n\t\tend",
"def push_taskarray(task)\n @task_array << task\n end",
"def push_donearray\n get_taskarray.each do |object|\n if object.status_done\n get_donearray.push(object)\n end\n end\n end",
"def tasks\n return @tasks.values\n end",
"def set_task\n @task = Task.includes(:todo).find(params[:id])\n @todo = @task.todo\n @list = @todo.list\n end"
] |
[
"0.7222479",
"0.6934714",
"0.690522",
"0.68356204",
"0.67352945",
"0.6627029",
"0.6627029",
"0.6597282",
"0.6597282",
"0.6597282",
"0.6487773",
"0.6436789",
"0.6405407",
"0.6363743",
"0.63490933",
"0.6324891",
"0.63235146",
"0.63204193",
"0.62680507",
"0.62630826",
"0.6244139",
"0.6235684",
"0.6223196",
"0.61937714",
"0.61801326",
"0.61799455",
"0.6149748",
"0.6135918",
"0.6132377",
"0.613226",
"0.61172587",
"0.61121976",
"0.6097949",
"0.6097929",
"0.60947263",
"0.6077063",
"0.60519356",
"0.6010266",
"0.5973896",
"0.59624004",
"0.5951698",
"0.59206325",
"0.5905676",
"0.5873312",
"0.5872807",
"0.5851597",
"0.5848895",
"0.5841929",
"0.5789241",
"0.5784756",
"0.57826066",
"0.5780654",
"0.57638747",
"0.5763728",
"0.5750778",
"0.5749696",
"0.57485825",
"0.57485825",
"0.57485825",
"0.574419",
"0.5741088",
"0.5717209",
"0.5668849",
"0.5653106",
"0.5649117",
"0.56458586",
"0.56388134",
"0.5629775",
"0.562484",
"0.56221545",
"0.56149083",
"0.5599863",
"0.55923325",
"0.558599",
"0.5580977",
"0.55767435",
"0.5575207",
"0.5566405",
"0.55636746",
"0.55616087",
"0.5559693",
"0.55549777",
"0.55537045",
"0.5550492",
"0.5550489",
"0.5550056",
"0.5541078",
"0.5541078",
"0.5535587",
"0.5534661",
"0.55318385",
"0.5519629",
"0.5508534",
"0.5505245",
"0.55028945",
"0.5501944",
"0.5501257",
"0.5498022",
"0.5494866",
"0.5477521",
"0.54742396"
] |
0.0
|
-1
|
Asserts that the request has been redirected to the specified url.
|
def assert_redirected_to(url)
assert_equal(url, responses.first.location)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def assert_redirected_to(url)\n assert [301, 302].include?(@integration_session.status),\n \"Expected status to be 301 or 302, got #{@integration_session.status}\"\n\n assert_url url, @integration_session.headers[\"Location\"]\n end",
"def assert_redirected_to(url, message=nil)\n assert_response :redirect\n assert_equal url, extract_redirection_url, message\n end",
"def ensure_redirect response, url_matcher\n expect(response.code).to eq('301').or eq('302')\n expect(response.header['location']).to match url_matcher\n # href = document(response.body).css('a').attr('href').value\n # expect(href).to match url_matcher\n response.header['location']\n end",
"def assert_redirect(path)\n assert_redirected_to path\n follow_redirect!\n assert_response :success\n end",
"def assert_redirected_to(path, message = nil)\n assert_response :redirect, message\n assert_equal response.header[\"Location\"], path, message\n end",
"def test_redirection_location\n process :redirect_internal\n assert_equal 'http://test.host/nothing', @response.redirect_url\n\n process :redirect_external\n assert_equal 'http://www.rubyonrails.org', @response.redirect_url\n end",
"def assert_redirected_to(page_name)\n assert_match(/#{Goldberg.settings.send(page_name).url}$/,\n response.redirected_to)\n end",
"def assert_redirect(res, location)\n assert_in_array [\"301\", \"302\", \"303\", \"307\"], res.code\n assert_header res, \"Location\", location\n end",
"def test_redirect_url_match\n process :redirect_external\n assert @response.redirect?\n assert @response.redirect_url_match?(\"rubyonrails\")\n assert @response.redirect_url_match?(/rubyonrails/)\n assert [email protected]_url_match?(\"phpoffrails\")\n assert [email protected]_url_match?(/perloffrails/)\n end",
"def should_have_redirected_to(regex)\n last_response.redirect?.should == true\n last_response.location.should =~ regex\nend",
"def test_redirection\n process :redirect_internal\n assert @response.redirect?\n\n process :redirect_external\n assert @response.redirect?\n\n process :nothing\n assert [email protected]?\n end",
"def skipped_test_raises_error_on_invalid_redirect_location\n assert_raise(ArgumentError) {\n http.get \"/redirect-to?url=foo\"\n }\n end",
"def assert_redirected_to_login\n assert_not flash.empty?\n assert_redirected_to login_url\n end",
"def assert_redirected_to_sam(options={})\n assert_response :redirect\n sam_url = signup_url(options)\n assert_equal(sam_url, redirect_to_url)\n end",
"def assert_redirected_to_login\n assert_equal({ :controller => 'goldberg/auth',\n :action => 'login' },\n response.redirected_to)\n end",
"def redirect(url)\n headers['Location'] = url\n self.status = 302\n raise FinishRequest\n end",
"def redirect(url); end",
"def redirect_to(url)\n prepare_response do\n res['location'] = url\n res.status = 302\n end\n end",
"def assert_redirected_to(options = {}, message=nil)\n clean_backtrace do\n assert_response(:redirect, message)\n\n if options.is_a?(String)\n msg = build_message(message, \"expected a redirect to <?>, found one to <?>\", options, @session.response.redirect_url)\n url_regexp = %r{^(\\w+://.*?(/|$|\\?))(.*)$}\n eurl, epath, url, path = [options, @session.response.redirect_url].collect do |url|\n u, p = (url_regexp =~ url) ? [$1, $3] : [nil, url]\n [u, (p[0..0] == '/') ? p : '/' + p]\n end.flatten\n\n assert_equal(eurl, url, msg) if eurl && url\n assert_equal(epath, path, msg) if epath && path \n else\n @session.response_diff = options.diff(@session.response.redirected_to) if options.is_a?(Hash) && @session.response.redirected_to.is_a?(Hash)\n msg = build_message(message, \"response is not a redirection to all of the options supplied (redirection is <?>)#{', difference: <?>' if @session.response_diff}\", \n @session.response.redirected_to || @session.response.redirect_url, @session.response_diff)\n\n assert_block(msg) do\n if options.is_a?(Symbol)\n @session.response.redirected_to == options\n else\n options.keys.all? do |k|\n if k == :controller then options[k] == ActionController::Routing.controller_relative_to(@session.response.redirected_to[k], @controller.class.controller_path)\n else options[k] == (@session.response.redirected_to[k].respond_to?(:to_param) ? @session.response.redirected_to[k].to_param : @session.response.redirected_to[k] unless @session.response.redirected_to[k].nil?)\n end\n end\n end\n end\n end\n end\n end",
"def test_redirect\n get :index\n assert_redirected_to :action => \"login\", :controller => \"main\"\n assert_not_equal \"\", flash[:login_notice]\n end",
"def test_users\n get '/users'\n assert_equal 302, last_response.status\n end",
"def redirected?\n raise @invalid_uri_error if invalid_uri_error?\n raise @fetch_error if fetch_error?\n @redirect_log.size > 1\n end",
"def expect_login_request_for page\n expect(page).to redirect_to(login_path)\n end",
"def test_http_redirects_to_https\r\n\t \r\n\t sleep(1)\r\n lynx_assert_actual_url(EXPECTED_HTTPS_URL, 'not redirected to HTTPS login when the site is accessed via HTTP')\r\n\r\n end",
"def test_profile_url_redirects\r\n\r\n @place_holder.login_with_proper_credentials\r\n\r\n @place_holder.logout_using_gear_icon\r\n\r\n exp_https_url = PropertiesReader.get_exp_https_login_url\r\n #Verify the redirection to the secure login takes place after signing out\r\n @place_holder.assert_actual_url(exp_https_url, 'Not redirected to HTTPS login page after signing out using gear icon')\r\n\r\n @place_holder.go_to(PropertiesReader.get_recipient_profile_url)\r\n sleep(1)\r\n\r\n @place_holder.assert_actual_url(exp_https_url, 'Attempting to access a profile using profile URL after signing out using gear icon does not redirect to the HTTPS login page')\r\n\r\n end",
"def redirect_to(url)\n if !already_built_response?\n @res[\"location\"] = url\n @res.status = 302\n @already_built_response = true\n else\n raise \"exception\"\n end\n session.store_session(res)\n # storing the flash will fail the last spec\n flash.store_flash(res)\n end",
"def redirect_to(url)\n raise \"Already built response!\" if already_built_response?\n @res['Location'] = url\n @res.status = 302\n finalize_response(:redirect)\n end",
"def test_profile_url_redirects\r\n\r\n login_with_proper_credentials\r\n\r\n logout_using_gear_icon\r\n\r\n #Verify the redirection to the secure login takes place after signing out\r\n lynx_assert_actual_url(EXPECTED_HTTPS_URL, 'Not redirected to HTTPS login page after signingout using gear icon')\r\n\r\n $browser.goto(PROFILE_TO_ACCESS_AFTER_LOGOUT)\r\n sleep(1)\r\n\r\n lynx_assert_actual_url(EXPECTED_HTTPS_URL, 'Attempting to access a profile using profile URL after signing out using gear icon does not redirect to HTTPS login page')\r\n\r\n end",
"def test_mock_without_param\n get \"/mock\"\n assert_equal last_response.status, 302\n end",
"def redirected?\n !!headers[\"Location\"]\n end",
"def redirect(location, status = '302'); request.redirect(location, status); end",
"def expect_successful_login(user, target_url = nil)\n expect(controller.send(:current_user)).to eq(user)\n expect(controller.send(:current_group)).to eq(user.current_group)\n expect(response.body).to match(/location.href.*#{target_url}/)\n end",
"def should_open?(url, &block)\n resp = Net::HTTP.get_response(URI(url))\n case resp\n when Net::HTTPRedirection\n location = resp['location']\n puts \"Redirecting #{url} to #{location}\"\n should_open?(location) { |resp1| block.call(resp1) }\n when Net::HTTPSuccess\n block.call(resp)\n when Net::HTTPNotFound\n false\n else\n p url\n p resp.code\n false\n end\nend",
"def assert_on_page(page)\n raise \"page must begin with '/': #{page}\" unless page[0] == ?\\/\n assert \"http://example.org#{page}\" == last_request.url,\n \"Expected to be on page http://example.org#{page} but was on #{last_request.url}\"\n end",
"def test_index_should_redirect_to_list\n get :index\n assert_redirected_to :action=>'list'\n end",
"def expect_redirect_sessions_new\n @controller.expects(:redirect_to).with :controller => :sessions,\n :action => :new\n end",
"def assert_redirected_to(options = {}, message=nil)\n clean_backtrace do\n assert_response(:redirect, message)\n return true if options == @response.redirected_to\n ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty?\n\n begin\n url = {}\n original = { :expected => options, :actual => @response.redirected_to.is_a?(Symbol) ? @response.redirected_to : @response.redirected_to.dup }\n original.each do |key, value|\n if value.is_a?(Symbol)\n value = @controller.respond_to?(value, true) ? @controller.send(value) : @controller.send(\"hash_for_#{value}_url\")\n end\n\n unless value.is_a?(Hash)\n request = case value\n when NilClass then nil\n when /^\\w+:\\/\\// then recognized_request_for(%r{^(\\w+://.*?(/|$|\\?))(.*)$} =~ value ? $3 : nil)\n else recognized_request_for(value)\n end\n value = request.path_parameters if request\n end\n\n if value.is_a?(Hash) # stringify 2 levels of hash keys\n if name = value.delete(:use_route)\n route = ActionController::Routing::Routes.named_routes[name]\n value.update(route.parameter_shell)\n end\n\n value.stringify_keys!\n value.values.select { |v| v.is_a?(Hash) }.collect { |v| v.stringify_keys! }\n if key == :expected && value['controller'] == @controller.controller_name && original[:actual].is_a?(Hash)\n original[:actual].stringify_keys!\n value.delete('controller') if original[:actual]['controller'].nil? || original[:actual]['controller'] == value['controller']\n end\n end\n\n if value.respond_to?(:[]) && value['controller']\n value['controller'] = value['controller'].to_s\n if key == :actual && value['controller'].first != '/' && !value['controller'].include?('/')\n new_controller_path = ActionController::Routing.controller_relative_to(value['controller'], @controller.class.controller_path)\n value['controller'] = new_controller_path if value['controller'] != new_controller_path && ActionController::Routing.possible_controllers.include?(new_controller_path) && @response.redirected_to.is_a?(Hash)\n end\n value['controller'] = value['controller'][1..-1] if value['controller'].first == '/' # strip leading hash\n end\n url[key] = value\n end\n\n @response_diff = url[:actual].diff(url[:expected]) if url[:actual]\n msg = build_message(message, \"expected a redirect to <?>, found one to <?>, a difference of <?> \", url[:expected], url[:actual], @response_diff)\n\n assert_block(msg) do\n url[:expected].keys.all? do |k|\n if k == :controller then url[:expected][k] == ActionController::Routing.controller_relative_to(url[:actual][k], @controller.class.controller_path)\n else parameterize(url[:expected][k]) == parameterize(url[:actual][k])\n end\n end\n end\n rescue ActionController::RoutingError # routing failed us, so match the strings only.\n msg = build_message(message, \"expected a redirect to <?>, found one to <?>\", options, @response.redirect_url)\n url_regexp = %r{^(\\w+://.*?(/|$|\\?))(.*)$}\n eurl, epath, url, path = [options, @response.redirect_url].collect do |url|\n u, p = (url_regexp =~ url) ? [$1, $3] : [nil, url]\n [u, (p.first == '/') ? p : '/' + p]\n end.flatten\n\n assert_equal(eurl, url, msg) if eurl && url\n assert_equal(epath, path, msg) if epath && path\n end\n end\n end",
"def redirect_to(url)\n raise \"double render error\" if constructed_response?\n\n @response.status = 302\n @response[\"Location\"] = url\n\n @constructed_response = true\n\n session.store_session(@response)\n\n nil\n end",
"def test_guest_access_to_userland_gives_login_screen\n get '/in/index'\n assert last_response.redirect?\n follow_redirect!\n\n assert last_request.url.ends_with?(\"/login\")\n assert last_response.ok?\n assert last_response.body.include?('Login to continue') \n end",
"def redirection(url = nil)\n url ||= @uri.to_s\n response = Browser.get(url)\n\n if response.code == 301 || response.code == 302\n redirection = response.headers_hash['location']\n\n # Let's check if there is a redirection in the redirection\n if (other_redirection = redirection(redirection))\n redirection = other_redirection\n end\n end\n\n redirection\n end",
"def redirect?\n\t\t\thttp_response = Net::HTTP.get_response(URI.parse(@page[:url]))\n\t\t\thttp_response == Net::HTTPRedirection\n\t\trescue Net::HTTPBadResponse\n\t\t\t# Dont do anything, as it is supposed to be raised.\n\t\tend",
"def test_should_index_redirect_to_list\n get :index\n assert_redirected_to :action=>'list'\n end",
"def followed_redirects?\n current_url != @url\n end",
"def redirect_to(url)\n self.res.status = 302\n #how would I know about location\n self.res.header[\"location\"] = url\n session.store_session(self.res)\n\n #self.res.set_redirect(WEBrick::HTTPStatus::TemporaryRedirect, url)\n if already_rendered?\n raise \"Can't render/redirect twice\"\n end\n\n #following might be wrong b/c of no setter\n @already_built_response = true\n nil\n end",
"def redirect_to(url)\n unless already_built_response?\n @res[\"location\"] = url\n @res.status = 302\n @already_built_response = true\n else\n fail\n end\n session.store_session(res)\n end",
"def gringotts_redirect_to(url)\n # save url for redirecting back after we verify\n flash[:gringotts_next_url] = request.original_url\n \n # keep other flash items (e.g., success messages)\n flash.keep\n \n # last but not least ... redirect\n redirect_to url\n end",
"def test_ssl_redirect_with_ssl_host\n SslRequirement.ssl_host = @ssl_host_override\n assert_not_equal \"on\", @request.env[\"HTTPS\"]\n get :a\n assert_response :redirect\n assert_match Regexp.new(\"^https://#{@ssl_host_override}\"),\n @response.headers['Location']\n SslRequirement.ssl_host = nil\n end",
"def redirect(url)\n raise \"To be implemented by client application\"\n end",
"def test_pending_request\n get '/goldberg/users/list'\n assert_redirected_to_login\n\n form_login('admin', 'admin')\n assert_match /goldberg\\/users\\/list/, response.redirected_to\n end",
"def redirect_ok\n @agent.redirect_ok\n end",
"def redirect(uri)\n @response.status = 302\n @response.header['Location'] = uri\n @response.body = ''\n halt\n end",
"def test_offers\r\n get :offers, :id => 5072\r\n assert_response 301\r\n assert_redirected_to '/Ear-Force-X2-Wireless-Headphones-for-Xbox-reviews'\r\n end",
"def test_success_scenario\n assert last_response.ok?\n end",
"def redirect!(url, opts = {})\n self.headers[\"Location\"] = url\n self.status = opts[:permanent] ? 301 : 302\n self.status = opts[:status] if opts[:status]\n self.body = opts[:message] || \"<div>You are being redirected to <a href='#{url}'>#{url}</a></div>\"\n halt!\n return true\n end",
"def assert_authentication_failed\n assert_response :found\n assert_redirected_to new_user_session_path\n end",
"def expect_forbidden(response)\n expect(response).to redirect_to(root_url)\nend",
"def redirect uri, *args\n if @env[HTTP_VERSION] == 'HTTP/1.1' && @env[REQ_METHOD] != 'GET'\n status 303\n else\n status 302\n end\n\n @response[LOCATION] = url_to(uri.to_s)\n halt(*args)\n end",
"def redirect_client(client, url)\n client.puts(\"HTTP/1.1 302 Found\\r\\nLocation: #{url}\\r\\n\\r\\n\")\nend",
"def redirect?\n @response.is_a? Net::HTTPRedirection\n end",
"def url_should_be(url)\n raise(Exception::UrlMatchError, \"The URL #{@browser.url} is not correct; it should be #{url}\") unless\n @browser.url == url\n end",
"def test_index\n get :index\n \n assert_redirected_to :action => :unread\n end",
"def test_referrer_on_non_get_requests\n controller = new_controller\n fake_request controller, '/path1', nil, get?: false\n assert_equal nil, controller.session['_referer']\n end",
"def redirect_to(url)\n if already_built_response?\n raise\n else\n res.status = 302\n res.header[\"location\"] = url\n end\n @already_built_response = true\n @session.store_session(res) if @session\n @flash.store_flash(res) if @flash\n end",
"def test_cache_link\n get '/' + TEST_PAGE\n assert_redirected_to :link => TEST_PAGE_LINK\n \n follow_redirect!\n assert_no_errors\n assert_page_cached(TEST_PAGE_LINK)\n end",
"def redirect_url(url_string)\n Net::HTTP.get_response(URI.parse(url_string)).header[\"location\"]\n end",
"def redirect_to(url)\n raise \"Already delivered response\" if self.already_built_response?\n res.status = 302\n res['Location'] = url\n @already_built_response = true\n self.session.store_session(res)\n self.flash.store_flash(res)\n end",
"def redirect_to(url)\n raise \"double render error\" if @already_built_response\n # Issuing a redirect consists of two parts, setting the 'Location'\n # field of the response header to the redirect url and setting the\n # response status code to 302\n @already_built_response = true\n res.location = url\n res.status = 302\n @session.store_session(res)\n end",
"def test_bounce_not_logged_in\n get :panel\n assert_redirected_to :controller => \"users\", :action => \"login\"\n end",
"def redirect_to(url)\n raise 'Already responded' if already_built_response?\n flash.store_flash(res)\n res['Location'] = url\n res.status = 302\n @already_built_response = true\n session.store_session(res)\n end",
"def get_response_with_redirect(uri)\n r = Net::HTTP.get_response(uri)\n if r.code == \"301\"\n r = Net::HTTP.get_response(URI.parse(r.header['location']))\n end\n r\nend",
"def will_redirect(url = nil)\n if url.present?\n session['app.redirect'] = url\n else\n session['app.redirect'] ||= true\n end\n end",
"def test_login\n get \"my/page\"\n assert_redirected_to \"/login?back_url=http%3A%2F%2Fwww.example.com%2Fmy%2Fpage\"\n log_user('jsmith', 'jsmith')\n\n get \"my/account\"\n assert_response :success\n assert_template \"my/account\"\n end",
"def test_1\n\n res = get \"http://localhost:7777/things\", :no_redirections => true\n assert_equal 303, res.code.to_i\n\n res = get(\"http://localhost:7777/things\", :noredir => true)\n assert_equal 303, res.code.to_i\n\n expect 200, {}, get(\"http://localhost:7777/items\", :noredir => true)\n end",
"def test_home_page_redirects\n \n post('admin_home', {}, {})\n assert_redirected_to(:controller => 'tracker', :action => 'index')\n \n post('reviewer_home', {}, {})\n assert_redirected_to(:controller => 'tracker', :action => 'index')\n \n post('manager_home', {}, {})\n assert_redirected_to(:controller => 'tracker', :action => 'index')\n \n post('pcb_admin_home', {}, {})\n assert_redirected_to(:controller => 'tracker', :action => 'index')\n \n post('designer_home', {}, {})\n assert_redirected_to(:controller => 'tracker', :action => 'index')\n \n end",
"def redirect_to(url)\n raise DoubleRenderError if already_built_response?\n res.header['location'] = url\n res.status = 302\n @already_built_response = true\n session.store_session(res)\n end",
"def redirect_to(url, options={})\n full_url = absolute_url(url, options)\n response[LOCATION] = full_url\n respond_with 302\n full_url\n end",
"def be_redirected_to(path)\n BeRedirected.new(path)\nend",
"def test_on_non_referrer_requests\n controller = new_controller\n fake_request controller, '/path1', nil\n assert_equal nil, controller.session['previous_paths']\n end",
"def redirect_ok; end",
"def redirect_ok; end",
"def redirected?\r\n @Out.redirected?\r\n end",
"def working_url?(url, max_redirects=5)\r\n response = nil\r\n seen = Set.new \t\t\t#Ensures no duplicate entries\r\n loop do\r\n url = URI.parse(url)\r\n break if seen.include? url.to_s\t\t\t\t#Break out of the loop is the url argument is found in the set\r\n break if seen.size > max_redirects\t\t\t#Break out of the loop if you're redirected more than 5 times\r\n seen.add(url.to_s)\r\n request = Net::HTTP.new(url.host, url.port)\r\n request.use_ssl = true\r\n response = request.request_head(url.path)\r\n if response.kind_of?(Net::HTTPRedirection) #Detect a HTTP redirect\r\n url = response['location'] \t\t\t #Add the new redirect location to the set if detected\r\n else\r\n break\t\t\t\t\t\t\t\t\t\t#This means there were no redirects\r\n end\r\n end\r\n response.kind_of?(Net::HTTPSuccess) && url.to_s #Return true only if a URL argument was passed to the method and it was reached successfully\r\nend",
"def redirects; end",
"def redirect_to(url)\n check_already_rendered\n session.store_session(response)\n response.status = 302\n response['Location'] = url\n @already_rendered = true\n end",
"def redirect?\n # redirects are 3xx\n return @status >= 300 && @status < 400\n end",
"def assert_response_success( opts = {} )\n assert_block \"@response is nil\" do\n [email protected]?\n end\n\n if @response.error?\n puts @response.body\n elsif @response.redirect?\n raise Test::Unit::AssertionFailedError.new( \"Expected success, was redirect to #{@response.redirected_to} with flash #{flash}\" )\n end\n\n assert_response :success\n assert_template opts[:template] if opts[:template]\n end",
"def redirect_to(url)\n if self.already_built_response?\n raise \"Double render error!\"\n else\n @res.status = 302\n @res.location = url\n @already_built_response = true\n end\n end",
"def redirect_url(url_string)\n url = URI.parse(URI.escape(url_string))\n https = Net::HTTP.new(url.host, url.port)\n https.use_ssl = true if url.scheme == \"https\"\n req = Net::HTTP::Get.new(url.path, \"User-Agent\" => \"Ruby\")\n response = https.request(req)\n response.header[\"location\"]\n end",
"def redirect_to(url)\n if already_built_response?\n raise \"DoubleRenderError\" \n else \n @res.status = 302 \n # @res.set_header('Content-Type', content_type)\n @res.set_header('location', url)\n # @res.write(content) \n session.store_session(res)\n # debugger\n @already_built_response = true \n # debugger\n end \n end",
"def redirect_to(url)\n raise \"already built response\" if already_built_response?\n @res.status = 302\n @res[\"Location\"] = url\n @already_built_response = true\n self.session.store_session(@res)\n self.flash.store_flash(@res)\n end",
"def assert_location_ends_in(url)\n expected_url_base, expected_url_parameters = url.split('?')\n actual_url_base, actual_url_parameters = selenium.get_location.split('?')\n assert_match /#{Regexp.escape(expected_url_base)}$/, actual_url_base\n actual_parameters = actual_url_parameters.nil? ? nil : actual_url_parameters.split(\"&\")\n expected_parameters = expected_url_parameters.nil? ? nil : expected_url_parameters.split(\"&\")\n if actual_parameters.nil? || expected_parameters.nil?\n assert_equal expected_parameters, actual_parameters\n else\n assert_equal expected_parameters.sort, actual_parameters.sort\n end\n end",
"def http_redirect?\n @get_resp.kind_of?(Net::HTTPRedirection)\n end",
"def http_redirect?\n @get_resp.kind_of?(Net::HTTPRedirection)\n end",
"def redirect_to(url, options={})\n full_url = absolute_url(url, options)\n response[LOCATION] = full_url\n respond_with 302\n full_url\n end",
"def assert_requests!\n super\n expect(action_request.uri.to_s).to eq(current_config[:voice_request_url])\n end",
"def check_redirect\n url = \"http://autodiscover.#{@domain}/autodiscover/autodiscover.svc\"\n begin\n res = HTTPClient.head(url)\n rescue\n return nil\n end\n return nil unless res.status_code == 302\n @redirect = res.header[\"Location\"][0]\n end",
"def redirect_to(url)\n raise \"Already built response!\" if already_built_response?\n @res[\"Location\"] = url\n @res.status = 302\n @already_built_response = true\n session.store_session(@res)\n flash.store_flash(@res)\n end",
"def test_referrer_on_async_requests\n controller = new_controller\n fake_request controller, '/path1', nil, xhr?: true\n assert_equal nil, controller.session['_referer']\n end",
"def redirect_to(url)\n response = Rack::Response.new\n response.redirect(url, 301) # moved permanently\n response.finish\n response.to_a\n end",
"def test_when_referrer_equals_to_current\n controller = new_controller\n fake_request controller, \"/same_path\", \"/same_path\"\n assert_equal 0, controller.session['previous_paths'].length\n end"
] |
[
"0.81954974",
"0.80881244",
"0.74768996",
"0.738156",
"0.73555833",
"0.7233924",
"0.7090405",
"0.7052969",
"0.70433927",
"0.7002601",
"0.69074434",
"0.6830566",
"0.6822",
"0.6742068",
"0.67251766",
"0.65992767",
"0.6558291",
"0.65293366",
"0.64743644",
"0.6421921",
"0.64097804",
"0.63292676",
"0.63227415",
"0.62963396",
"0.6237528",
"0.62177247",
"0.6208083",
"0.6205259",
"0.6142735",
"0.6141326",
"0.6138738",
"0.6135373",
"0.6125884",
"0.6119254",
"0.6110711",
"0.6105015",
"0.61046284",
"0.60926515",
"0.6080656",
"0.6075965",
"0.60694754",
"0.60551417",
"0.6054342",
"0.6010427",
"0.60100543",
"0.59847987",
"0.5920961",
"0.58847994",
"0.58830345",
"0.58798593",
"0.5862772",
"0.58417803",
"0.58382106",
"0.5831454",
"0.5824967",
"0.5812371",
"0.58112633",
"0.5805211",
"0.58012354",
"0.57954776",
"0.5793429",
"0.5791889",
"0.5774354",
"0.57488495",
"0.5709171",
"0.5708928",
"0.567412",
"0.566951",
"0.5663755",
"0.56624776",
"0.56480265",
"0.56474954",
"0.5644938",
"0.5635674",
"0.56230813",
"0.5621482",
"0.56182826",
"0.5609007",
"0.5607567",
"0.5607567",
"0.5600443",
"0.55992866",
"0.55990857",
"0.5581424",
"0.55780303",
"0.5570519",
"0.55591035",
"0.5558616",
"0.55403763",
"0.5536852",
"0.55362916",
"0.5532357",
"0.5532357",
"0.5527699",
"0.5524605",
"0.5520958",
"0.5511131",
"0.5511",
"0.55025977",
"0.550213"
] |
0.8786609
|
0
|
Asserts that the specified cookie has been set to the specified value.
|
def assert_cookie(name, value)
assert cookies[name.to_s]
assert_equal value, cookies[name.to_s]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_cookie(name, value)\n test_cookies[name] = value\n end",
"def assert_cookie(name, pat, message=nil)\n assert_match pat, @cookies[name], message\n end",
"def set_WithCookie(value)\n set_input(\"WithCookie\", value)\n end",
"def cookie=(val)\n @xmlrpc.cookie = val\n end",
"def check_cookie(response)\n\t\t\t if response.get_fields('set-cookie')\n \t\t\tset_cookie(response)\n \t\t\tprint \"new cookie: \"\n \t\t\tputs response.get_fields('set-cookie')\n \t\t\tputs @cookies\n \t\tend\n\t\tend",
"def test_cookie_has_sugar_set_method\n # Given: A cookie with 6g of Sugar and 15g of Butter\n c=Cookie.new(6,15)\n # When\n c.sugar= 10\n # Then\n assert_equal(c.sugar,10)\n end",
"def set_cookie_value\n cookie_value = User.using_client_shard(client: @client).get_cookie_value(@user.id, @user.password, @browser_user_agent)\n success_with_data({cookie_value: cookie_value, user_token_sale_state: @user.get_token_sale_state_page_name})\n end",
"def assert_no_cookie(name)\n assert !cookies[name.to_s]\n end",
"def set_cookie(env, headers, cookie)\n request = Rack::Request.new(env)\n if request.cookies[@key] != cookie[:value] || cookie[:expires]\n Utils.set_cookie_header!(headers, @key, cookie)\n end\n end",
"def set_cookie(name, value)\n @cookies[\"flexi_#{@id}_#{name}\"] = value\n return value\n end",
"def set_cookie(key, value)\n ::Rack::Utils.set_cookie_header!(@_headers, key, value)\n end",
"def set_cookie(key, value)\n ::Rack::Utils.set_cookie_header!(@_headers, key, value)\n end",
"def set_cookie(name, value, attributes = {})\n cookie = Webmachine::Cookie.new(name, value, attributes).to_s\n case headers['Set-Cookie']\n when nil\n headers['Set-Cookie'] = [cookie]\n when Array\n headers['Set-Cookie'] << cookie\n end\n end",
"def set_cookie name, value=nil, opts={}\n if Hash === value\n opts = value\n else\n opts[:value] = value\n end\n\n @response.set_cookie name, opts\n end",
"def test_affiliate_code_cookie\n # Setup - write cookie\n affil = affiliates(:joes_marketing)\n @request.cookies['affiliate'] = affil.code\n # Exercise\n get :index\n assert_response :success\n # Verify\n assert_kind_of Order, assigns(:order)\n assert_equal affil.code, assigns(:order).affiliate_code\n assert_equal affil, assigns(:order).affiliate\n end",
"def manually_set_cookie(value, expire_in)\n expire_date = expire_in.from_now.gmtime.strftime('%a, %d %b %Y %H:%M:%S GMT')\n response['Set-Cookie'] =\n \"cookiePermissions=#{value}; Expires=#{expire_date}; Path=/; SameSite=Lax\"\n end",
"def set_cookie(response)\n\t\ttest_cookie = response.get_fields('set-cookie')\n\n\t\tif @cookie_array.include? test_cookie\n\t\t\t@cookies\n\t\telse\n\t\t\t@cookie_array << test_cookie\n \t\t\t@cookies = @cookie_array.join('; ')\n \t\tend\n\t\t#@cookies = response.get_fields('set-cookie')\n\tend",
"def value=(value)\n\t\t# {{{\n\t\tif value.class.superclass == Integer || value.class == Float\n\t\t\tvalue = value.to_s\n\t\telsif value.class != String && value != nil\n\t\t\traise TypeError, \"The value of a cookie must be a string, integer, float or nil\", caller\n\t\tend\n\t\t@value = value\n\t\t# }}}\n\tend",
"def set_cookie(cookie=nil)\n self.headers[\"Cookie\"] = cookie\n end",
"def set_cookie(name, value, options = {})\n @_options_lookup[name] = options\n self[name] = value\n end",
"def from_cookie(value)\n ticket = value && find_by_value(value)\n ticket\n end",
"def set_cookie(request_uri, set_cookie_value)\n request_uri = URI.parse(request_uri)\n \n CookieStore::Cookie.parse_cookies(request_uri, set_cookie_value) do |cookie|\n # reject as per RFC2965 Section 3.3.2\n return if !cookie.request_match?(request_uri) || !(cookie.domain =~ /.+\\..+/ || cookie.domain == 'localhost')\n \n # reject cookies over the max-bytes\n return if cookie.to_s.size > MAX_COOKIE_LENGTH\n \n add(cookie)\n end\n end",
"def test_laptop_has_cookies\n end",
"def value=( cookie_octets )\n\t\t# self.log.debug \"Setting cookie value to: %p\" % [ cookie_octets ]\n\t\traise Strelka::CookieError,\n\t\t\t\"invalid cookie value; value must be composed of non-control us-ascii characters \" +\n\t\t\t\"other than SPACE, double-quote, comma, semi-colon, and backslash. \" +\n\t\t\t\"Use #base64_value= for storing arbitrary data.\" unless\n\t\t\tcookie_octets =~ /^#{COOKIE_VALUE}$/\n\n\t\t@value = cookie_octets\n\tend",
"def set_cookie(name, value, expires)\n (headers['Set-Cookie'] ||=[]) << (Merb::Const::SET_COOKIE % [\n name.to_s, \n ::Merb::Request.escape(value.to_s), \n # Cookie expiration time must be GMT. See RFC 2109\n expires.gmtime.strftime(Merb::Const::COOKIE_EXPIRATION_FORMAT)\n ])\n end",
"def assert_session_started\n assert_not_nil @cookies[\"camping_sid\"], \n \"The session ID cookie was empty although session should have started\"\n end",
"def []= key, val\n return if confined?\n @response.set_cookie key, val\n end",
"def test_cookie_using_url_path\n url = URI.parse('http://rubygems.org/login.php')\n cookie_params = {}\n cookie_params['expires'] = 'expires=Sun, 27-Sep-2037 00:00:00 GMT'\n cookie_params['path'] = 'path=/'\n cookie_params['domain'] = 'domain=.rubygems.org'\n cookie_params['httponly'] = 'HttpOnly'\n cookie_value = '12345%7D=ASDFWEE345%3DASda'\n\n expires = Time.parse('Sun, 27-Sep-2037 00:00:00 GMT')\n\n cookie_params.keys.combine.each do |c|\n next if c.find { |k| k == 'path' }\n cookie_text = \"#{cookie_value}; \"\n c.each_with_index do |key, idx|\n if idx == (c.length - 1)\n cookie_text << \"#{cookie_params[key]}\"\n else\n cookie_text << \"#{cookie_params[key]}; \"\n end\n end\n\n cookie = assert_cookie_parse url, cookie_text\n\n assert_equal('12345%7D=ASDFWEE345%3DASda', cookie.to_s)\n assert_equal('/', cookie.path)\n\n # if expires was set, make sure we parsed it\n if c.find { |k| k == 'expires' }\n assert_equal(expires, cookie.expires)\n else\n assert_nil(cookie.expires)\n end\n end\n end",
"def set_cookie(response)\n response.set_cookie(Webmetrics::Config.cookie_name, {\n :value => self.id,\n :path => \"/\",\n :expires => Time.now+Webmetrics::Config.cookie_expiration\n })\n end",
"def http_cookie=(content)\n logger.debug { content ? \"Setting Cookie: #{content}\" : 'Clearing Cookie' }\n http.cookie = content\n end",
"def cookie(name, value = nil, duration = 15)\n if value\n response.set_cookie name, { \n :value => value,\n :expires => Time.now + (60 * duration),\n :path => \"/\",\n :httponly => true,\n :secure => production?\n }\n else\n request.cookies[name]\n end\n end",
"def cookie_value; end",
"def test_cookie_with_secure\n url = URI.parse('http://rubygems.org/')\n cookie_params = {}\n cookie_params['expires'] = 'expires=Sun, 27-Sep-2037 00:00:00 GMT'\n cookie_params['path'] = 'path=/'\n cookie_params['domain'] = 'domain=.rubygems.org'\n cookie_params['secure'] = 'secure'\n cookie_value = '12345%7D=ASDFWEE345%3DASda'\n\n expires = Time.parse('Sun, 27-Sep-2037 00:00:00 GMT')\n\n cookie_params.keys.combine.each do |c|\n next unless c.find { |k| k == 'secure' }\n cookie_text = \"#{cookie_value}; \"\n c.each_with_index do |key, idx|\n if idx == (c.length - 1)\n cookie_text << \"#{cookie_params[key]}\"\n else\n cookie_text << \"#{cookie_params[key]}; \"\n end\n end\n\n cookie = assert_cookie_parse url, cookie_text\n\n assert_equal('12345%7D=ASDFWEE345%3DASda', cookie.to_s)\n assert_equal('/', cookie.path)\n assert_equal(true, cookie.secure)\n\n # if expires was set, make sure we parsed it\n if c.find { |k| k == 'expires' }\n assert_equal(expires, cookie.expires)\n else\n assert_nil(cookie.expires)\n end\n end\n end",
"def add_cookie(cookie, value = nil)\n @response_cookies ||= {}\n\n if value\n @response_cookies[cookie] = Cookie.new(cookie, value)\n else \n @response_cookies[cookie.name] = cookie\n end\n end",
"def add_cookie(key,value)\n $LOG.info \"adding cookie with key => #{key} and value => #{value}\"\n begin\n $driver.manage.add_cookie(:name => \"#{key}\", :value => \"#{value}\")\n rescue Exception => e\n $LOG.error \"Add Cookie can't be completed \"+e.message\n raise \"Add Cookie can't be completed \"+e.message\n end\n end",
"def set_cookie(cookie_name, value, expires)\n cookies[cookie_name.to_sym] = {\n value: value,\n expires: expires,\n domain: GlobalConstant::Base.cookie_domain,\n http_only: true,\n secure: Rails.env.production?,\n same_site: :strict\n }\n end",
"def set_cookie\n if File.exist?('cookie.txt')\n puts 'Cookie exists'\n File.read('cookie.txt')\n else\n ''\n end\nend",
"def cookie_test\n\t\tif cookies[\"cookie_test\"].blank?\n\t\t\tlogger.warn(\"=== cookies are disabled\")\n\t\t\trender :template => \"shared/cookies_required\"\n\t\telse\n\t\t\tredirect_to(building_path)\n\t\tend\n\tend",
"def valid_cookie?\n if (decrypted_cookie_value = IiifAuthService.decrypt_cookie(cookies[\"bearer_token\"]))\n valid_cookie_date?(decrypted_cookie_value)\n else\n false\n end\n end",
"def send_cookie(name, value = nil)\n @context.add_cookie(name, value)\n end",
"def valid_cookie?\n cookie = @handshake.headers['Cookie']\n puts \"Cookie: #{cookie}\"\n return false unless cookie\n end",
"def set_uuid_cookie\n uuid = cookies[:uuid] || UUIDTools::UUID.random_create.to_s\n cookies[:uuid] = { value: uuid, expires: 5.years.from_now }\n end",
"def cookie(cookie)\n raise \"No HTTP-session attached to this thread.\" if !_httpsession\n raise \"HTTP-session not active.\" if !_httpsession.resp\n raise \"Not a hash: '#{cookie.class.name}', '#{cookie}'.\" unless cookie.is_a?(Hash)\n _httpsession.resp.cookie(cookie)\n return nil\n end",
"def cookie\n self[HttpClient::SET_COOKIE]\n end",
"def set_cookie(src, dst)\n if str = src['set-cookie']\n cookies = []\n str.split(/,\\s*/).each{|token|\n if /^[^=]+;/o =~ token\n cookies[-1] << \", \" << token\n elsif /=/o =~ token\n cookies << token\n else\n cookies[-1] << \", \" << token\n end\n }\n dst.cookies.replace(cookies)\n end\n end",
"def hubssolib_set_secure_cookie_data(name, value)\n if (@hubssolib_have_written_cookie)\n raise \"HubSsoLib: Attmept to set cookie '#{name}' more than once\"\n end\n\n @hubssolib_have_written_cookie = true\n\n # Using cookies.delete *should* work but doesn't. Set the\n # cookie with nil data instead.\n\n data = value.nil? ? nil : HubSsoLib::Crypto.encode_object(value, request.remote_ip)\n\n # No expiry time; to aid security, use session cookies only.\n\n cookies[name] = {\n :value => data,\n :path => HUBSSOLIB_COOKIE_PATH,\n :secure => true\n }\n end",
"def setCookies(cookies)\n @fields['cookies'] = cookies\n self\n end",
"def setCookies(cookies)\n @fields['cookies'] = cookies\n self\n end",
"def cookies\n test_cookies\n end",
"def test_get_person_id_from_cookie\n\t\tres = DB.exec(\"SELECT login_person_domain(5, 'muckwork.com')\")\n\t\tcookie = res.getvalue(0, 0)\n\t\tres = DB.exec(\"SELECT * FROM get_person_id_from_cookie('%s')\" % cookie)\n\t\tassert_equal 5, res[0]['person_id'].to_i\n\t\tcookie[0, 1] = 'Z'\n\t\tres = DB.exec(\"SELECT * FROM get_person_id_from_cookie('%s')\" % cookie)\n\t\tassert_nil res[0]['person_id']\n\tend",
"def valid_cookie_value?(value)\n ! Regexp.new('[\\x0-\\x1f\\x7f,;]').match(value)\n end",
"def assert_no_session\n assert_nil @cookies[\"camping_sid\"], \n \"A session cookie was sent although this should not happen\"\n end",
"def set_cookie(env, headers, cookie)\n Utils.set_cookie_header!(headers, @key, cookie)\n end",
"def set_cookie(name, value, path = '/', httponly = true, secure = true)\n \n cookie = WEBrick::Cookie.new(name, value)\n cookie.path = path\n cookie.httponly = httponly\n cookie.secure = secure\n \n # add cookie to response header\n @header['Set-Cookie'] = cookie.to_s\n end",
"def cookies_required\n return true unless cookies[\"cookie_test\"].blank?\n cookies[\"cookie_test\"] = Time.now\n session[:return_to] = request.request_uri\n redirect_to(cookies_test_path)\n end",
"def assert_cached(res, value=nil)\n if value\n assert_header res, \"Cache-Control\", value\n else\n assert_header_present res, \"Cache-Control\"\n end\n end",
"def set_cookie\n self.current_user.remember\n cookies[:auth_token] = { \n :value => self.current_user.remember_token, \n :expires => self.current_user.remember_token_expires_at }\n end",
"def clean?(cookie)\n key, value = cookie.split('=', 2)\n decodable?(key) && decodable?(value)\n end",
"def cookies_test\n super\n end",
"def emulate_javascript_set_cookie\n @browser.get(HOST + \"Login.asp\")\n @browser.get(HOST + \"Search.asp\")\n end",
"def persist_by_cookie\n if cookie_credentials\n self.unauthorized_record = search_for_record(\"find_by_persistence_token\", cookie_credentials)\n valid?\n else\n false\n end\n end",
"def cookie\n { :value => Crypt.encrypt(cookie_value), :expires => 1.year.from_now }\n end",
"def cookie= cookie_str\n @headers['Cookie'] = cookie_str if @use_cookies\n end",
"def cookie= cookie_str\n @headers['Cookie'] = cookie_str if @use_cookies\n end",
"def cookie_redirected?\n params[:cookies].present?\n end",
"def set_cookies(response)\n cookie_str = response.header['set-cookie']\n return if cookie_str.nil?\n\n fields = cookie_str.split(\"; \").inject({}) { |h, field|\n key, value = field.split(\"=\")\n h[key] = value\n\n h\n }\n\n # This is obviously not a generalized cookie implementation. Heh.\n fields.delete('path')\n @cookies = fields\n end",
"def assertTest value\n assert value\n end",
"def cookies_required\n\t\treturn true unless cookies[\"cookie_test\"].blank?\n\t\tcookies[\"cookie_test\"] = Time.now\n\t\tsession[:return_to] = request.original_url\n\t\tredirect_to(cookie_test_path)\n\tend",
"def set(resource)\n @cookies.signed[cookie_name] = {value: [resource.id, Time.now.to_i]}.merge(cookie_options)\n end",
"def set_cooky\n @cooky = Cookie.find(params[:id])\n end",
"def set_cooky\n @cooky = Cookie.find(params[:id])\n end",
"def set_cooky\n @cooky = Cookie.find(params[:id])\n end",
"def cookie_named(name); end",
"def is_cookie_token_valid?\n return true if self.class.els_options.has_key? 'faker'\n raise \"No cookies instance found\" if cookies.nil?\n token = cookies[self.class.els_options['cookie']]\n if token.nil? || !Runner.is_token_valid?(token,self.class.els_options)\n false\n else\n true\n end\n end",
"def set_cookie(uri, sc)\n cookie = Cookie.new\n name, sc = sc.split '=', 2\n value, sc = sc.split ';', 2\n cookie.name, cookie.value = CGI::unescape(name), CGI::unescape(value)\n \n opts = {}\n sc && sc.split(';').each do |opt|\n opt, optval = opt.split '=', 2\n opts[opt.downcase] = (optval && CGI::unescape(optval)) || true\n end\n \n # restrict by domain-- not spec-compliant and possibly unsafe (allows \n # infinite levels of subdomains)\n if opts['domain'] && opts['domain'] != uri.host\n if opts['domain'].end_with?('.'+uri.host)\n cookie.domain = opts['domain']\n else\n return false\n end\n else\n cookie.domain = uri.host\n end\n \n if opts['path']\n cookie.path = opts['path']\n else\n # the resource path is the \"directory\" containing the request path\n ri = uri.path.rindex '/'\n cookie.path = ri ? uri.path[0..ri] : '/'\n end\n \n if opts['expires']\n begin\n cookie.expires = DateTime.parse opts['expires']\n rescue ArgumentError; end\n end\n \n cookie.secure = opts.has_key?('secure')\n \n @jar << cookie\n return true\n end",
"def check_cookie_auth(auth_cookie)\n if !auth_cookie.blank?\n username, hmac = auth_cookie.to_s.split('--')\n digest = OpenSSL::Digest::SHA1.new\n secret = configatron.secret_token\n expected = OpenSSL::HMAC.hexdigest(digest, secret, username)\n\n @user = Repositories::User.find(username).first if hmac == expected\n\n [email protected]?\n else\n false\n end\n end",
"def set_cookie(cookie, uri = nil)\n cookie_jar.merge(cookie, uri)\n end",
"def []=( name, value )\n\t\tvalue = Strelka::Cookie.new( name.to_s, value ) unless value.is_a?( Strelka::Cookie )\n\t\traise ArgumentError, \"cannot set a cookie named '%s' with a key of '%s'\" %\n\t\t\t[ value.name, name ] if value.name.to_s != name.to_s\n\n\t\tself << value\n\tend",
"def store_cookie variable_name\r\n command 'storeCookie', variable_name\r\n end",
"def cookie\n # 'frontend=aaa'\n nil\n end",
"def cookie(params = nil)\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"cookie \" + params.to_s + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end",
"def is_valid_cookie!(cookie)\n return false if \"#{cookie[:key]}=#{cookie[:value]}\".bytesize > Cookiefilter::Rules::COOKIE_LIMIT\n return false if /[\\u{1F36A}]/.match(cookie[:value])\n Cookiefilter::Rules::safelist.each do |allowed_cookie|\n if allowed_cookie[:key].match(cookie[:key])\n regex = allowed_cookie[:value]\n\n # Set sacred attribute\n cookie[:sacred] = allowed_cookie[:sacred]\n\n # Cookies with nil as value-regex, pass validation.\n return true if regex.nil?\n\n return true if regex.match(cookie[:value])\n\n # Not matching value regex, fail validation.\n return false\n end\n end\n # Unknown cookie. Log this and fail\n false\n end",
"def set_cookie\n puts \"hello\"\n # puts @order.as_json\n puts \"-==-=-=-\"\n puts \"-==-=-=-\"\n puts cookies[:name] = current_admin.name\n puts \"-==-=-=-\"\n puts \"-==-=-=-\"\n end",
"def validate_cookie\n if cookies[:caboose_user_id] && User.exists?(cookies[:caboose_user_id])\n user = User.find(cookies[:caboose_user_id])\n login_user(user)\n return true\n end\n return false\n end",
"def add_set_cookie *ck\n\t\t\tif ck.length > 0\n\t\t\t\th = (@headers[\"Set-cookie\"] ||= [])\n\t\t\t\tck.each {|c| h << c}\n\t\t\tend\n\t\tend",
"def cookie\n @cookie ||= Coca::AuthCookie.new(cookies, scope)\n end",
"def test_remember_me\n login_valid_user\n assert_response :redirect\n assert_redirected_to :controller => \"user\", :action => \"index\"\n\n browser_closing_simulation\n get \"site/index\"\n assert logged_in?\n assert_equal @user.id, session[:user_id]\n end",
"def test_set_key_if_it_exists\n # Given\n refute @redis.exists( @key )\n\n # When\n @redis.set @key, @val, xx: true\n\n # Then \n refute @redis.get( @key )\n\n # ...and...\n\n # Given\n @redis.set @key, \"\"\n assert @redis.exists( @key )\n\n # When\n @redis.set @key, @val, xx: true\n\n # Then \n assert_equal @val, @redis.get( @key )\n end",
"def set_admin_auth_cookie_value\n\n if @has_valid_mfa_session\n @admin_auth_cookie_value_expiry_time = GlobalConstant::Cookie.double_auth_expiry\n\n @admin_auth_cookie_value = Admin.get_cookie_value(\n @admin.id,\n @admin.password,\n @admin.last_otp_at,\n @browser_user_agent,\n GlobalConstant::Cookie.double_auth_prefix\n )\n else\n @admin_auth_cookie_value_expiry_time = GlobalConstant::Cookie.single_auth_expiry\n\n @admin_auth_cookie_value = Admin.get_cookie_value(\n @admin.id,\n @admin.password,\n @admin.last_otp_at,\n @browser_user_agent,\n GlobalConstant::Cookie.single_auth_prefix\n )\n end\n\n success\n end",
"def path=(path)\n\t\t# {{{\n\t\tunless path.class == String || path == nil\n\t\t\traise TypeError, \"The path of a cookie must be nil or a string\", caller\n\t\tend\n\t\t@path = path\n\t\t# }}}\n\tend",
"def []=(name, value)\n if value.is_a?(Hash)\n value = value.collect {|key, val| \"#{key}=#{val.gsub('=', '^^')}\" }.join('|')\n end\n options = { :value => value }\n\n options[:path] = \"/\" unless options.has_key?(:path)\n super(name.to_s, options[:value])\n @controller.response.set_cookie(name, options)\n end",
"def set_cookie(cookie_name, value, expires, encrypt=false)\n cookie_obj = (encrypt == true) ? cookies.encrypted : cookies\n cookie_obj[cookie_name.to_sym] = {\n value: value,\n expires: expires,\n domain: request.host,\n http_only: true,\n secure: !(Rails.env.development? || Rails.env.staging?),\n same_site: :strict\n }\n end",
"def assert_value(locator, value)\n assert_element_present locator\n wait_for do |context|\n actual = selenium.get_value(locator)\n context.message = \"Expected '#{locator}' to be '#{value}' but was '#{actual}'\"\n value == actual\n end\n end",
"def eql?( other_cookie )\n\t\t# self.log.debug \"Comparing %p with other cookie: %p\" % [ self, other_cookie ]\n\t\treturn (self.name == other_cookie.name) ? true : false\n\tend",
"def valid_cookie?\n if cookie_credentials\n self.unauthorized_record = search_for_record(\"find_by_#{persistence_token_field}\", cookie_credentials)\n return valid?\n end\n \n false\n end",
"def get_cookie\n resp = @cookie\n if @atl_token != \"\"\n resp = resp + \"; atl.xsrf.token=#{@atl_token}\"\n end\n puts \"Using cookie: #{resp}\".yellow\n resp\n end",
"def valid?\n !!cookie_content\n end",
"def valid?\n !!cookie_content\n end",
"def set_cookie(email=nil, nav=false)\n if nav\n cookies[\"bunch__nav\"] = {\n value: \"open\", \n expires: 365.days.from_now\n }\n end\n end",
"def set_cookie!\n cookies[:user_session] = {\n :value => token,\n :secure => controller.request.ssl?,\n :httponly => true,\n :expires => self.expires_at\n }\n end"
] |
[
"0.73221475",
"0.6829366",
"0.66600424",
"0.64230716",
"0.63613164",
"0.6349922",
"0.63215524",
"0.627164",
"0.626359",
"0.6192877",
"0.61041784",
"0.61041784",
"0.6070704",
"0.60611427",
"0.604766",
"0.60050315",
"0.5986121",
"0.594535",
"0.591734",
"0.5901529",
"0.5901268",
"0.5844939",
"0.58369255",
"0.58364815",
"0.58297694",
"0.5702378",
"0.5669922",
"0.5639109",
"0.5635167",
"0.56304276",
"0.5602624",
"0.5594926",
"0.55821764",
"0.55795",
"0.5552613",
"0.55506057",
"0.55417675",
"0.54944897",
"0.54592866",
"0.54589516",
"0.5452011",
"0.5450236",
"0.543151",
"0.54191595",
"0.54108757",
"0.53921914",
"0.53856796",
"0.53856796",
"0.5382879",
"0.5376193",
"0.5369751",
"0.53693837",
"0.53671545",
"0.536102",
"0.5330514",
"0.53237206",
"0.53202224",
"0.5302765",
"0.5288091",
"0.52461594",
"0.52432716",
"0.5238747",
"0.5229918",
"0.5229918",
"0.5221975",
"0.5220948",
"0.5215514",
"0.5204117",
"0.51824296",
"0.51746583",
"0.51746583",
"0.51746583",
"0.51718736",
"0.5169192",
"0.51623356",
"0.5148542",
"0.5144754",
"0.51304245",
"0.51294005",
"0.5115665",
"0.5091282",
"0.50799084",
"0.5066404",
"0.50648445",
"0.506113",
"0.5048408",
"0.5046023",
"0.5042007",
"0.5041614",
"0.50410026",
"0.5040817",
"0.50320596",
"0.5025922",
"0.50256556",
"0.50256306",
"0.50220835",
"0.5019638",
"0.5019638",
"0.5019479",
"0.50135803"
] |
0.8278769
|
0
|
Asserts that there is no cookie set for the specified cookie
|
def assert_no_cookie(name)
assert !cookies[name.to_s]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def assert_no_session\n assert_nil @cookies[\"camping_sid\"], \n \"A session cookie was sent although this should not happen\"\n end",
"def cookie_test\n\t\tif cookies[\"cookie_test\"].blank?\n\t\t\tlogger.warn(\"=== cookies are disabled\")\n\t\t\trender :template => \"shared/cookies_required\"\n\t\telse\n\t\t\tredirect_to(building_path)\n\t\tend\n\tend",
"def cookies_required\n\t\treturn true unless cookies[\"cookie_test\"].blank?\n\t\tcookies[\"cookie_test\"] = Time.now\n\t\tsession[:return_to] = request.original_url\n\t\tredirect_to(cookie_test_path)\n\tend",
"def cookie_invalid(response)\n response.code == 401 && response.body =~ /cookie/i\n end",
"def cookies_required\n return true unless cookies[\"cookie_test\"].blank?\n cookies[\"cookie_test\"] = Time.now\n session[:return_to] = request.request_uri\n redirect_to(cookies_test_path)\n end",
"def assert_cookie(name, value)\n assert cookies[name.to_s]\n assert_equal value, cookies[name.to_s]\n end",
"def assert_session_started\n assert_not_nil @cookies[\"camping_sid\"], \n \"The session ID cookie was empty although session should have started\"\n end",
"def assert_cookie(name, pat, message=nil)\n assert_match pat, @cookies[name], message\n end",
"def test_laptop_has_cookies\n end",
"def validate_session_cookie(_item)\n nil\n end",
"def valid_cookie?\n cookie = @handshake.headers['Cookie']\n puts \"Cookie: #{cookie}\"\n return false unless cookie\n end",
"def test_current_user__session_nil\n assert_equal @user, current_user\n assert user_authenticated?, 'User should be logged in when there is a valid, current login cookie'\n end",
"def validate_user_cookie(_item)\n nil\n end",
"def check_cookie(response)\n\t\t\t if response.get_fields('set-cookie')\n \t\t\tset_cookie(response)\n \t\t\tprint \"new cookie: \"\n \t\t\tputs response.get_fields('set-cookie')\n \t\t\tputs @cookies\n \t\tend\n\t\tend",
"def test_no_login\r\n\t\tget :home\r\n\t\tassert_response :success\r\n\r\n\t\t# make sure the user_id is nil in the session\r\n\t\tassert_nil(session[:user_id])\r\n\tend",
"def cookies?\n cookies.length > 0\n end",
"def is_cookie_token_valid?\n return true if self.class.els_options.has_key? 'faker'\n raise \"No cookies instance found\" if cookies.nil?\n token = cookies[self.class.els_options['cookie']]\n if token.nil? || !Runner.is_token_valid?(token,self.class.els_options)\n false\n else\n true\n end\n end",
"def assert_not_cached(url)\n assert !page_cache_exists?(url), \"#{url} is cached\"\n end",
"def test_no_unauthenticated_access\n # make sure that we can't get to 'home'\n assert_nil @request.session[:user]\n get :home\n assert_redirected_to :action => \"login\"\n assert_match /You need to log in/, flash[:message] \n end",
"def validate_cookie\n if cookies[:caboose_user_id] && User.exists?(cookies[:caboose_user_id])\n user = User.find(cookies[:caboose_user_id])\n login_user(user)\n return true\n end\n return false\n end",
"def valid_cookie?\n if cookie_credentials\n self.unauthorized_record = search_for_record(\"find_by_#{persistence_token_field}\", cookie_credentials)\n return valid?\n end\n \n false\n end",
"def test_bad_login\r\n\t\tpost :home, :login => 'login', :email => '[email protected]', :password => 'worsethanyou'\r\n\t\tassert_response :success\r\n\r\n\t\t# make sure the user_id is nil in the session\r\n\t\tassert_nil(session[:user_id])\r\n\tend",
"def cookie_redirected?\n params[:cookies].present?\n end",
"def cookies_test\n super\n end",
"def has_auth_cookie?\n raise NotImplementedError\n end",
"def has_auth_cookie?\n raise NotImplementedError\n end",
"def check_for_removal\n if @value && @unused && @unused[\"unused\"]\n @res.cookies << create_cookie(\"unused\", false, 'flash_unused')\n elsif @value\n @value = nil\n @res.cookies << create_cookie(\"unused\", nil, 'flash_unused')\n @res.cookies << create_cookie(\"message\", nil)\n end\n end",
"def test_should_delete_token_on_logout\n login_as :quentin\n get :logout\n assert_equal @response.cookies[\"auth_token\"], []\n end",
"def set_cookie\n if File.exist?('cookie.txt')\n puts 'Cookie exists'\n File.read('cookie.txt')\n else\n ''\n end\nend",
"def valid_cookie?\n if (decrypted_cookie_value = IiifAuthService.decrypt_cookie(cookies[\"bearer_token\"]))\n valid_cookie_date?(decrypted_cookie_value)\n else\n false\n end\n end",
"def valid?\n !!cookie_content\n end",
"def valid?\n !!cookie_content\n end",
"def needs_new_cookie?\n @_new_cookie\n end",
"def close_cookies_alert\n if page.has_css? '#cookie-notice'\n within '#cookie-notice' do\n find('button.close').click\n end\n expect(page).not_to have_css '#cookie-notice', visible: true\n end\nend",
"def cookie_valid?\n cookies[:clickfunnels_auth].present? && session[:user_id].present? && cookies[:clickfunnels_auth].to_s == session[:user_id].to_s\n end",
"def test_session_and_challenge_empty\n challenged_session = ChallengedSession.new\n assert !challenged_session.save\n end",
"def needs_new_cookie!\n @_new_cookie = true\n end",
"def needs_new_cookie!\n @_new_cookie = true\n end",
"def needs_new_cookie!\n @_new_cookie = true\n end",
"def check_cookie_auth(auth_cookie)\n if !auth_cookie.blank?\n username, hmac = auth_cookie.to_s.split('--')\n digest = OpenSSL::Digest::SHA1.new\n secret = configatron.secret_token\n expected = OpenSSL::HMAC.hexdigest(digest, secret, username)\n\n @user = Repositories::User.find(username).first if hmac == expected\n\n [email protected]?\n else\n false\n end\n end",
"def assert_no_app_error\n assert_nil flash[:error]\n end",
"def assert_redirected_to_login\n assert_not flash.empty?\n assert_redirected_to login_url\n end",
"def test_guest_cant_delete_self\n post '/delete_self'\n assert last_response.ok?\n assert last_response.body.include?('You are not logged in')\n end",
"def test_capybara_can_ensure_something_is_not_found\n on_visiting_browserkoans_test_page do\n assert_equal __(false), page.has_selector?('#not-there')\n assert_nothing_raised do\n expect(page).to_not have_selector(__('#not-there'))\n end\n end\n end",
"def test_login_no_data\n get 'index'\n assert assigns['question']\n assert_response :success\n assert flash['answer']\n end",
"def assertNilTest value\n assertNil value\n end",
"def cookie(cookie)\n raise \"No HTTP-session attached to this thread.\" if !_httpsession\n raise \"HTTP-session not active.\" if !_httpsession.resp\n raise \"Not a hash: '#{cookie.class.name}', '#{cookie}'.\" unless cookie.is_a?(Hash)\n _httpsession.resp.cookie(cookie)\n return nil\n end",
"def cookies\n test_cookies\n end",
"def rc_facebook_check_cookie\n return if rc_facebook.authorized? ||\n !cookies[\"fbs_#{rc_facebook.app_id}\"]\n\n rc_facebook.parse_cookies!(cookies)\n logger.debug(\"DEBUG: Facebook: detected cookies, parsed:\" \\\n \" #{rc_facebook.data.inspect}\")\n end",
"def do_not_set_cookie\n request.session_options[:skip] = true\n end",
"def do_not_set_cookie\n request.session_options[:skip] = true\n end",
"def do_not_set_cookie\n request.session_options[:skip] = true\n end",
"def user_should_not_be_logged_in\n expect(page).to have_no_css 'div.navbar div.navbar-inner ul li a#sign_out', visible: false\nend",
"def assert_no_records_match\n sleep 2\n expect(@polaris.login_home_page.text).to include(\"No matching records found\")\n end",
"def test_index_unauthorized\n get :index\n assert_response :redirect\n assert_redirected_to :action => \"login\"\n assert_equal \"Please log in first\", flash[:notice]\n end",
"def assert_have_no_selector(expected)\n hs = HaveSelector.new(expected)\n assert !hs.matches?(response_body), hs.negative_failure_message\n end",
"def delete_cookie(name); end",
"def valid_cookie?\n \n cookie = request.cookies[\"kindle\"]\n \n # attempt to look up cookie in registration DB\n reg = Registration.first(:content => cookie)\n \n if $DEBUG\n puts \"Cookie: \" + (cookie.nil? ? \"nil\" : cookie.to_s )\n puts \"Registration: \" + (reg.nil? ? \"nil\" : reg.to_s )\n end\n \n return true if $DEBUG\n return !reg.nil?\n end",
"def test_affiliate_code_cookie\n # Setup - write cookie\n affil = affiliates(:joes_marketing)\n @request.cookies['affiliate'] = affil.code\n # Exercise\n get :index\n assert_response :success\n # Verify\n assert_kind_of Order, assigns(:order)\n assert_equal affil.code, assigns(:order).affiliate_code\n assert_equal affil, assigns(:order).affiliate\n end",
"def non_existing_cart\n\t\t# A user goes to the orders page\n\t\tget \"/carts/243233\"\n\n\t\t# He is re directed to store index with a error message at the top of the page\n\t\tassert_redirected_to store_url\n\t\tassert_equal 'Invalid cart', flash[:notice]\n\n\t\t# An email is sent to the Administrator telling the error had occured.\n\t\tmail = ActionMailer::Base.deliveries.last\n\t\tassert_equal [\"[email protected]\"], mail.to\n\t\tassert_equal 'Depot Application <[email protected]>', mail[:from].value\n\t\tassert_equal 'Pragmatic Store Error Raised', mail.subject\n\n\tend",
"def assert_have_no_selector(expected)\n hs = HaveSelector.new(expected)\n assert !hs.matches?(response), hs.negative_failure_message\n end",
"def has_auth_cookie?\n request = Rack::Request.new(@env)\n cookie = request.cookies[TOKEN_COOKIE]\n !cookie.nil? && cookie.length == 40\n end",
"def clean?(cookie)\n key, value = cookie.split('=', 2)\n decodable?(key) && decodable?(value)\n end",
"def test02_fb_login_existing_not_approved_TC_24862\n\t\tfb_cleanup\n\t\t$browser.goto($patch_login)\n\t\t$sign_in_facebook.wait_until_present\n\t\t$sign_in_facebook.click\n\t\tfb_login\n\t\tfb_allow\n\t\tsleep 2\n\t\t\n\t\tbegin \n\t\tassert $logged_in_avatar.exists?\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"L2T2: FAILED! Unable to login via Facebook.\"\n\t\tend\n\t\t\n\t\tfb_cleanup\n\tend",
"def deny(assertion)\n assert !assertion\n end",
"def has_auth_cookie?\n old_cookie = @request.cookies[OLD_TOKEN_COOKIE]\n new_cookie = @request.cookies[NEW_TOKEN_COOKIE]\n !old_cookie.nil? && !new_cookie.nil?\n end",
"def local_cookie?\n if File.exist?($CONF['cookie'])\n return true\n end\n false\nend",
"def non_existing_cart\n\t\t# A user goes to the orders page\n\t\tget \"/orders/243233\"\n\n\t\t# He is re directed to store index with a error message at the top of the page\n\t\tassert_redirected_to store_url\n\t\tassert_equal 'Invalid order', flash[:notice]\n\n\t\t# An email is sent to the Administrator telling the error had occured.\n\t\tmail = ActionMailer::Base.deliveries.last\n\t\tassert_equal [\"[email protected]\"], mail.to\n\t\tassert_equal 'Depot Application <[email protected]>', mail[:from].value\n\t\tassert_equal 'Pragmatic Store Error Raised', mail.subject\n\n\tend",
"def fresh_choices\n #clear choices\n #logger.warn \"Headerish #{response.headers['cookie']}\"\n \n cookies.each do |cookie|\n if cookie[0] =~ /test_([a-z0-9_]+)/\n logger.warn \"Deleting cookie #{cookie[0]}\"\n cookies.delete cookie[0]\n end\n end\n \n flash[:notice] = \"Your tests have been cleared from cookies.\"\n redirect_to :back\n end",
"def assert_cached(url)\n assert page_cache_exists?(url), \"#{url} is not cached\"\n end",
"def test_invalid_oauth_token_response\n # Setup\n @user = setup_user({ 'email' => @user.email })\n\n # Step 1\n headers = { 'Authorization' => \"Bearer #{@user.oauth_token}\" }\n\n get '/me', {}, headers\n assert_response(@response, :success)\n\n # Step 2\n headers = { 'Authorization' => \"Bearer #{@user.cookie_id}\" }\n\n get '/me', {}, headers\n assert_response(@response, :client_error)\n end",
"def test_flash_have_nots\n process :nothing\n assert [email protected]_flash?\n assert [email protected]_flash_with_contents?\n assert_nil @response.flash['hello']\n end",
"def clear_cookie\n create_accesses_cookie\n end",
"def cookies_enabled\n return true unless cookies[\"cookieTest\"].blank?\n cookies[\"cookieTest\"] = Time.now\n session[:return_to] = request.fullpath\n if cookies[\"cookie_test\"].blank?\n return false\n end\n return true\n end",
"def is_valid_cookie!(cookie)\n return false if \"#{cookie[:key]}=#{cookie[:value]}\".bytesize > Cookiefilter::Rules::COOKIE_LIMIT\n return false if /[\\u{1F36A}]/.match(cookie[:value])\n Cookiefilter::Rules::safelist.each do |allowed_cookie|\n if allowed_cookie[:key].match(cookie[:key])\n regex = allowed_cookie[:value]\n\n # Set sacred attribute\n cookie[:sacred] = allowed_cookie[:sacred]\n\n # Cookies with nil as value-regex, pass validation.\n return true if regex.nil?\n\n return true if regex.match(cookie[:value])\n\n # Not matching value regex, fail validation.\n return false\n end\n end\n # Unknown cookie. Log this and fail\n false\n end",
"def validate_facebook_cookie( consumer_secret, cookie )\n \n # Parse the cookie to a more useable form\n params = Hash[*CGI.parse(cookie.gsub(/^\"|\"$/, '')).sort.flatten]\n\n # Get the cookie signature\n sig = params[\"sig\"]\n \n # Generates the signature base\n signature_base = ''\n params.sort.each do |pair|\n key, value = pair\n signature_base = signature_base + \"#{key}=#{value}\" if key != \"sig\"\n end\n \n # returns whether or not signature matches the consumer secret\n return sig == Digest::MD5.hexdigest(signature_base + consumer_secret )\n \n end",
"def shib_session_exists?\n !cookies.detect { |key, val| key.include? SHIBBOLETH_COOKIE_PATTERN }.nil?\n end",
"def assert_unauthorized(mock)\n assert_response :unauthorized\n assert_select 'h1', '401 Unauthorized', response.body\n assert_mock mock\n end",
"def has_auth_cookie?\n cookie = @request.cookies[TOKEN_COOKIE]\n !cookie.nil? && cookie.length == 32\n end",
"def test_blank_login\n get :login\n post :login, :user_login => \"\", :user_password => \"afds\"\n assert_equal I18n.t(:username_not_blank), flash[:login_notice]\n end",
"def delete_cookie(name)\n cookie = Cookie.new(name, \"\")\n cookie.expires = 1.year.ago \n @context.add_cookie(cookie) \n end",
"def assert_no_errors_in_response\n assert_equal [nil, nil], response.data.values_at(\"error_type\", \"message\")\n end",
"def assert_no_error_occurred\n @status.must_equal 0\n end",
"def test_cant_save_empty_challenge\n challenge = Challenge.new\n assert !challenge.save\n end",
"def valid_remember_cookie?\n return nil unless @current_user\n (@current_user.remember_token?) && \n (cookies[:auth_token] == @current_user.remember_token)\n end",
"def valid_remember_cookie?\n return nil unless @current_user\n (@current_user.remember_token?) &&\n (cookies[:auth_token] == @current_user.remember_token)\n end",
"def assert_no_error_occurred\n assert_exit_status(0)\n end",
"def handle_unverified_request\n super\n cookies.delete(:autologin)\n end",
"def valid_remember_cookie?\n return nil unless @current_user\n (@current_user.remember_token?) && (cookies[:auth_token] == @current_user.remember_token)\n end",
"def assert_empty(exp, msg=nil)\n EmptyAssay.assert!(exp, :message=>msg, :backtrace=>caller)\n end",
"def root_not_logged_in?\n get root_url\n\n assert_redirected_to public_url\n follow_redirect!\n\n assert_response :success\n assert_template 'sessions/new'\n end",
"def user_visited_a_non_ssl_page_since_login?\n cookies[:insecure].nil? || cookies[:insecure] == true\n end",
"def test_blank_login_and_pwd\n get :login\n post :login, :user_login => \"\", :user_password => \"\"\n assert_not_equal \"\", flash[:login_notice]\n end",
"def test_new_view\n get :new\n assert_response :redirect\n assert_redirected_to user_new_path(:cookie_test => \"true\")\n\n get :new, :params => { :cookie_test => \"true\" }, :session => { :cookie_test => true }\n assert_response :success\n\n assert_select \"html\", :count => 1 do\n assert_select \"head\", :count => 1 do\n assert_select \"title\", :text => /Sign Up/, :count => 1\n end\n assert_select \"body\", :count => 1 do\n assert_select \"div#content\", :count => 1 do\n assert_select \"form[action='/user/new'][method='post']\", :count => 1 do\n assert_select \"input[id='user_email']\", :count => 1\n assert_select \"input[id='user_email_confirmation']\", :count => 1\n assert_select \"input[id='user_display_name']\", :count => 1\n assert_select \"input[id='user_pass_crypt'][type='password']\", :count => 1\n assert_select \"input[id='user_pass_crypt_confirmation'][type='password']\", :count => 1\n assert_select \"input[type='submit'][value='Sign Up']\", :count => 1\n end\n end\n end\n end\n end",
"def teardown\n SessionManager.instance.delete(@cookie)\n end",
"def delete_cookie name\n @response.delete_cookie name\n end",
"def admin_should_not_be_logged_in\n page.should_not have_content('Log Out')\n end",
"def test_blank_pwd\n get :login\n post :login, :user_login => \"afds\", :user_password => \"\"\n assert_equal I18n.t(:password_not_blank), flash[:login_notice]\n end",
"def test_bounce_not_logged_in\n get :panel\n assert_redirected_to :controller => \"users\", :action => \"login\"\n end",
"def clear_cookies(browser)\n if browser.respond_to?(:clear_cookies)\n browser.clear_cookies\n else\n browser.manage.delete_all_cookies\n end\nrescue NoMethodError\n raise 'Browser does not support clear cookies'\nend"
] |
[
"0.79016745",
"0.7114096",
"0.6766862",
"0.6756039",
"0.67066807",
"0.6616807",
"0.64259046",
"0.6383399",
"0.633417",
"0.62969947",
"0.6286759",
"0.61462235",
"0.61324775",
"0.61206853",
"0.6081937",
"0.60798013",
"0.6018382",
"0.60078233",
"0.596126",
"0.5927276",
"0.5897901",
"0.588617",
"0.587989",
"0.5845603",
"0.5818505",
"0.5818505",
"0.5783962",
"0.57800996",
"0.5766816",
"0.5751486",
"0.5727072",
"0.5727072",
"0.5659814",
"0.5655786",
"0.561096",
"0.559111",
"0.5586858",
"0.5586858",
"0.5586858",
"0.55775946",
"0.55709916",
"0.5568571",
"0.554222",
"0.55137545",
"0.5511912",
"0.5476448",
"0.54735935",
"0.5466075",
"0.54626006",
"0.5460443",
"0.5460443",
"0.5460443",
"0.5448743",
"0.5443168",
"0.54354686",
"0.5434988",
"0.5433305",
"0.54187405",
"0.5415539",
"0.5409543",
"0.54090524",
"0.5388691",
"0.5380809",
"0.5366552",
"0.5365602",
"0.536227",
"0.53399616",
"0.5339511",
"0.5338484",
"0.5329339",
"0.5320722",
"0.5289528",
"0.5281019",
"0.527963",
"0.5278663",
"0.5269367",
"0.5261331",
"0.5256129",
"0.5240228",
"0.5238782",
"0.52362686",
"0.52347296",
"0.52233523",
"0.5219177",
"0.52125365",
"0.5209457",
"0.5200631",
"0.5199126",
"0.519768",
"0.5197296",
"0.5196082",
"0.51868796",
"0.51806444",
"0.51751834",
"0.51735264",
"0.51718104",
"0.51697797",
"0.5166256",
"0.51590776",
"0.5155747"
] |
0.84439355
|
0
|
uses one char of each string at a given starting point given b852fe780d104254823cf8749c401153 should get 4212870
|
def decrypted_place_in_queue(encrypted_place_in_queue)
return encrypted_place_in_queue[ 30..30 ] + encrypted_place_in_queue[ 3..3 ] + encrypted_place_in_queue[ 11..11 ] +
encrypted_place_in_queue[ 20..20 ] + encrypted_place_in_queue[ 7..7 ] + encrypted_place_in_queue[ 26..26 ] +
encrypted_place_in_queue[ 9..9 ]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_char_summery(string, count)\n string[0..count]\n end",
"def substrings_at_start(str)\n str.each_char.map.with_index do |char, index|\n str[0..index]\n end\nend",
"def substrings_at_start(string)\n results = []\n\n string.chars.each_with_index do |char, index|\n results << string.chars[0..index].inject(:+)\n end\n results\nend",
"def substrings_at_start(str)\r\n chars = str.chars\r\n chars.each_with_object([]).with_index { |(el,memo), idx| memo << chars.take(idx+1).join('').to_s }\r\nend",
"def substrings_at_start(str)\n str.chars.map.with_index do |_, i|\n str[0..i]\n end\nend",
"def substrings_at_start(string)\n string.size.times.with_object([]) { |idx, arr| arr << string.chars.take(idx + 1).join}\nend",
"def substrings_at_start(str)\n str.chars.map.with_index { |_, idx| str[0, idx + 1] }\nend",
"def substrings_at_start(string)\n susbtrings = []\n string.size.times do |count|\n susbtrings << string.slice(0, count + 1)\n end\n susbtrings\nend",
"def substrings_at_start(string)\n string.chars.map.with_index { |_, index| string[0..index] }\nend",
"def substrings_at_start(string)\n string.size.times.with_object([]) { |idx, arr| arr << string[0..idx] }\nend",
"def substrings_at_start(string)\n (1..string.size).map { |count| string[0, count] }\nend",
"def substrings_at_start(str)\n results = []\n count = 1\n \n str.size.times do\n results << str.slice(0, count)\n count += 1\n end\n results\nend",
"def substrings_at_start(str)\n\n results = []\n\n str.chars.each_with_index do |ss, idx|\n results << str.slice(0..idx)\n end\n\n results\n\nend",
"def substrings_at_start(string)\n substrings = []\n string.length.times do |i|\n substrings.push(string[0..i])\n end\n\n substrings\nend",
"def substrings_at_start(str)\n (1..str.length).map { |size| str[0, size] }\nend",
"def substrings_at_start(str)\n (1..str.length).map { |size| str[0, size] }\nend",
"def substrings_at_start(string)\n (0...string.size).map do |length|\n string[0..length]\n end\nend",
"def substrings_at_start(str)\n subs = []\n str.size.times { |i| subs << str[0..i] }\n subs\nend",
"def start_of_word (str, num)\n\n str[0, num]\n\nend",
"def substrings_at_start(string)\n result = []\n string.length.times { |idx| result << string[0..idx] }\n result\nend",
"def start_of_word(str, number)\n\treturn str[0, number]\nend",
"def substrings_at_start(string)\n \n new_array = []\n string.size.times do |idx|\n new_array << string[0..idx]\n end\n new_array\nend",
"def substrings_at_start(string)\n results = []\n\n string.length.times do\n results << string\n string = string.chop\n end\n\n results.reverse\nend",
"def substrings_at_start(string)\n result = []\n 0.upto(string.size - 1) do |idx|\n result << string[0..idx]\n end\n p result\nend",
"def substrings_at_start(string)\n results = []\n\n string.length.times do |count|\n results << string.slice(0, count +1)\n end\n results\nend",
"def substrings_at_start(string)\n substrings = []\n string.chars.each_with_index do | _, idx |\n substrings << string.slice(0..idx)\n end\n substrings\nend",
"def substrings_at_start(str)\n result = []\n index = 0\n while index < str.size\n result << str[0..index]\n index += 1\n end\n result\nend",
"def start_of_word (string, number)\n number = number - 1\n string[0..number]\nend",
"def substrings_at_start(string)\n string.split(\"\").map.with_index do |_, index|\n string[0..index]\n end\nend",
"def cutinfo(string)\n inf=/\\024/=~string1\n inf=inf+2\n trans=string1[inf..-1]\nend",
"def start_of_word(word, num_chars)\n word[0, num_chars]\nend",
"def substrings_at_start(string)\n result = []\n index = 0\n while index < string.size\n result << string[0..index]\n index += 1\n end\n result\nend",
"def substrings_at_start(str)\n results = []\n substring = ''\n \n str.chars.each do |char|\n substring += char\n results << substring\n end\n \n results\nend",
"def substrings_at_start(str)\n counter = 1\n array = str.chars\n return_array = []\n\n loop do\n break if counter > array.size\n return_array << array.take(counter).join\n counter += 1\n end\n return_array\nend",
"def substrings_at_start(string)\n sub_strings = []\n 1.upto(string.size) do |count|\n sub_strings << string[0, count]\n end\n\n sub_strings\nend",
"def fix_start(string)\n char_array = string.split(\"\")\n first_char = string[0]\n new_array = Array.new\n\n char_array.each do |i|\n if i == \"b\"\n new_array.push(\"*\")\n else\n new_array.push(i)\n end\n end\n\n new_array[0] = first_char\n puts new_array\nend",
"def substrings_at_start(string)\n substring = string\n results = []\n n = -1\n \n string.length.times do\n results << substring\n substring = substring.chop\n end\n \n results.reverse\nend",
"def substrings_starting_at(string, index)\n substrings_at = []\n string = string[index...string.size]\n (0...string.size).each do |index|\n substrings_at << string[0..index]\n end\n substrings_at\nend",
"def substrings_at_start(string)\n result = []\n string.size.times do |index|\n result << string.split(//).slice(0, index + 1).join\n end\n result\nend",
"def start_of_word(word, nbr)\n\treturn \"#{word}\".slice(0, nbr )####renvoie une sous-chaine de caractère (position, nbr caractere recupérés)\nend",
"def substrings_at_start(string)\n string_array = string.chars\n array_final = []\n\n 1.upto(string.size) do |count|\n array_final << string_array.slice(0, count).join\n end\n array_final\nend",
"def substrings_at_start(string)\n result = []\n 1.upto(string.length) { |n| result << string.slice(0, n) }\n result\nend",
"def substrings_at_start(string)\n result = []\n 1.upto(string.length) { |n| result << string.slice(0, n) }\n result\nend",
"def substrings_at_start2(str)\n result = []\n (0..str.size - 1).each { |idx| result << str[0..idx] }\n result\nend",
"def substrings_at_start(string)\n substrings = []\n counter = 1\n\n until counter > string.size\n substrings << string[0, counter]\n counter += 1\n end\n\n substrings\nend",
"def substrings_at_start(string)\n substrings = []\n counter = 1\n\n until counter > string.size\n substrings << string[0, counter]\n counter += 1\n end\n\n substrings\nend",
"def substrings_at_start(string)\n substrings = []\n 1.upto(string.length) do |index|\n substrings << string.slice(0, index)\n end\n substrings\nend",
"def get_sandwich(str)\n b = \"bread\"\n count = 0\n countb = 0\n str.size.times do |i|\n if str[i..(i+4)] == b\n countb = i - 1\n end \n end\n str.size.times do |i| \n if str[i..(i+4)] == b\n count = i + 5\n return str[count..(countb)]\n end \n end\nend",
"def substrings_at_start(string)\n results = []\n\n string.length.times do\n results << string\n string = string.chop\n end\n\n results.sort\nend",
"def substrings_at_start(string)\n leading_substrings = []\n 0.upto(string.size - 1) do |index|\n leading_substrings << string.slice(0..index)\n end\n \n leading_substrings\nend",
"def leading_substrings(string, result, counter)\r\n counter.upto(string.size - 1) do |index|\r\n result << string[counter..index]\r\n end\r\nend",
"def substrings_at_start(string)\n array_of_strings = []\n count = 0\n\n loop do\n 0.upto(count) do |idx|\n array_of_strings[idx] = string[0..idx] \n end\n count += 1\n break if count == string.length\n end\n\n array_of_strings\nend",
"def substrings_at_start(string)\n array_of_strings = []\n count = 0\n\n loop do\n 0.upto(count) do |idx|\n array_of_strings[idx] = string[0..idx] \n end\n count += 1\n break if count == string.length\n end\n\n array_of_strings\nend",
"def substrings_at_start(str)\n result_arr = []\n 0.upto(str.size-1) do |num|\n result_arr << str[0..num]\n end\n result_arr\nend",
"def substrings_at_start(string)\n result = []\n 0.upto(string.size - 1) do |index|\n result << string[0..index]\n end\n result\nend",
"def substrings_at_start(string)\n result = []\n 0.upto(string.size - 1) do |index|\n result << string[0..index]\n end\n result\nend",
"def decode(str)\n decoded_word = str.chars\n p decoded_word\n new_string = []\n\n decoded_word.each do |char|\n\n if char.match(/\\d/)\n if char.to_i.zero?\n decoded_word.shift\n else\n decoded_word.shift(char.to_i + 1) # problem child skip 1st index\n end\n p \"h: \", decoded_word\n else\n new_string << char\n next\n end\n end\n p \"end: \", new_string\nend",
"def character_by_character(string)\nend",
"def substrings_at_start(string)\n count = 0\n new_array = []\n while count < string.length\n new_array << string[0..count]\n count += 1\n end\n new_array\nend",
"def substrings_at_start(string)\n count = 0\n new_array = []\n while count < string.length\n new_array << string[0..count]\n count += 1\n end\n new_array\nend",
"def leading_substrings(str)\n substrings = []\n str.each_char.with_index do |char, idx|\n substrings << str[0..idx]\n end\n substrings\nend",
"def substrings_at_start(string)\n result = []\n 0.upto(string.size - 1) do |index| # iterates from 0 to the string size.\n result << string[0..index] # iterates each index from 0..0 to 0..index, which is string size.\n end\n result\nend",
"def start_of_word(str, n = 1)\n str[0, n]\nend",
"def find_substrings_from_start(str)\n substrings = []\n str.size.times { |i| substrings << str[0..i] }\n substrings\nend",
"def chars_until(str); end",
"def first_char_idx\n dewey? ? 3 : 0\n end",
"def substrings_at_start(string)\n result = []\n 1.upto(string.size) do |index|\n result << string.slice(0, index)\n end\n result\nend",
"def leading_substrings(str)\n running_str = ''\n sub_strings = []\n str.each_char { |chr| sub_strings << running_str += chr }\n sub_strings\nend",
"def leading_substrings(string)\n result = []\n (string.size).times do |sub_num|\n result << string[0..sub_num]\n end\n result\nend",
"def substrings_at_start(string)\n result = []\n string = string.chars\n string.size.times do\n result << string.join('')\n string.pop\n end\n\n result.sort\nend",
"def extract_string(range, strscan); end",
"def substrings_at_start(str)\n index = 0\n length = 1\n arry = []\n\n while length <= str.size\n arry << str[index, length]\n length += 1\n end\n arry\nend",
"def substrings_at_start(str)\n index = 0\n length = 1\n arry = []\n\n while length <= str.size\n arry << str[index, length]\n length += 1\n end\n arry\nend",
"def substrings_at_start(str)\n index = 0\n length = 1\n arry = []\n\n while length <= str.size\n arry << str[index, length]\n length += 1\n end\n arry\nend",
"def substrings_at_start(str)\n new_arr = []\n 0.upto(str.size) do |i|\n next if i == 0 \n new_arr << str.slice(0,i)\n end\n new_arr\nend",
"def start_of_word(str, l); l == 1 ? str[0] : str[0...l] end",
"def substrings_at_start(str)\n subs = []\n str.chars.each_with_index do |ch, i|\n subs << str.slice(0..i)\n end \n subs.sort {|a, b| a.length <=> b.length} \nend",
"def start_of_word(str,index)\n if str.length > 1\n str.slice(0,index)\n else\n alphabet= (\"a\"..\"z\").to_a\n alphabet_seq = (\"a\"..alphabet[index]).to_a\n alphabet_seq.join\n end\nend",
"def substrings_at_start(string)\n length = 0\n substrings = []\n while length < string.size\n substrings << string[0..length]\n length += 1\n end\n substrings\nend",
"def start_of_word(word, number)\n word[0..number-1]\nend",
"def leading_substrings(string)\n 0.upto(string.size - 1).map { |count| string[0..count] }\nend",
"def start_of_word(word,nb)\n\tword[0...nb]\nend",
"def leading_substrings(string)\n substrings = []\n for num in 1..string.length\n substrings << string[0, num]\n end\n substrings\nend",
"def substrings_at_start(string)\n array = []\n for i in (0..string.length - 1)\n array << string[0..i]\n end\n array\nend",
"def substrings_at_start(string, initial_index)\n result = []\n 0.upto(string.size-1) do |i|\n result << string[initial_index..i]\n end\n result\nend",
"def leading_substrings(str)\n result = []\n str.size.times { |index| result << str[0..index] }\n result\nend",
"def get_sandwich(str) # needs some work\n (str.size - 4).times do |i|\n slice = str[i..(i + 4)]\n if slice != \"bread\"\n puts slice\n end\n end\n\nend",
"def get_sandwich(str)\n new_str = \"\"\n (str.size - 4).times do |ingred|\n slice = str[ingred..(ingred + 4)]\n if slice == \"bread\"\n new_str = str[str.index(slice) + 5..str.rindex(slice) - 1]\n end\n end\n return new_str\nend",
"def substrings_at_start(string)\n result = []\n 1.upto(string.size) do |substring|\n result << string.slice(0, substring)\n end\n result\nend",
"def substrings_at_start(string)\n result = []\n 1.upto(string.size) do |substring|\n result << string.slice(0, substring)\n end\n result\nend",
"def leading_substrings(string)\n substrings = []\n string.each_char.with_index { |_, index| substrings << string[0..index] }\n substrings\nend",
"def leading_substrings(string)\n substring = []\n string.each_char.with_index { |_, index| substring << string[0..index] }\n substring\nend",
"def substrings_at_start(string)\n strings_array = (1..(string.length)).map { |idx| string[0, idx] }\n strings_array.sort_by { |string| string.length }\nend",
"def substrings_at_start(string)\n strings_array = (1..(string.length)).map { |idx| string[0, idx] }\n strings_array.sort_by { |string| string.length }\nend",
"def pincrement_string(str)\n chars = str.chars\n last = chars[-1]\n if last == last.to_i.to_s\n last = (last.to_i + 1).to_s\n end\n chars\nend",
"def leading_substrings(str)\n index = 1\n arr = []\n loop do\n break if index > str.length\n arr << str[0, index]\n index += 1\n end\n arr\nend",
"def substrings_at_start(string)\n array_of_strings = []\n split_string = string.split('')\n substring = ''\n split_string.each_index do |position|\n substring += split_string[position]\n array_of_strings << substring\n end\n array_of_strings\nend",
"def substrings_at_start(str)\n new_arr = []\n 1.upto(str.size) do |count| \n substring = ''\n substring += str.slice(0, count)\n new_arr << substring\n end\n new_arr\nend",
"def get_first_half_of_string(string)\n half_string = (string.length.to_f/2).ceil\n string[0,half_string] \nend",
"def substrings_at_start(string)\n sub_arr = []\n string.chars.each_index do |idx|\n sub_arr << string.slice(0, idx + 1)\n end\n sub_arr.sort\nend",
"def substrings_at_start(str)\n substr_arr = []\n 1.upto(str.length) do |n|\n substr_arr << str.slice(0, n)\n end\n substr_arr\nend"
] |
[
"0.6932621",
"0.68905",
"0.6767006",
"0.6749849",
"0.66960794",
"0.669067",
"0.6660333",
"0.6595196",
"0.6526488",
"0.65249115",
"0.65224165",
"0.64914",
"0.64843196",
"0.6481589",
"0.6477352",
"0.6477352",
"0.6470632",
"0.64453954",
"0.64212626",
"0.64153993",
"0.63935626",
"0.6375594",
"0.6368861",
"0.6368497",
"0.6367951",
"0.6365388",
"0.63627243",
"0.6349835",
"0.6349035",
"0.6343037",
"0.63336146",
"0.63269246",
"0.630475",
"0.6299845",
"0.6275244",
"0.62702334",
"0.62644315",
"0.6262644",
"0.6260939",
"0.62542",
"0.62176",
"0.62088567",
"0.62088567",
"0.6202496",
"0.61976355",
"0.61976355",
"0.6193069",
"0.61916184",
"0.61884415",
"0.61809456",
"0.6168732",
"0.61528254",
"0.61528254",
"0.6141044",
"0.61298275",
"0.61298275",
"0.6129638",
"0.61283696",
"0.61223274",
"0.61223274",
"0.6119385",
"0.61157686",
"0.6108532",
"0.61030394",
"0.61007017",
"0.6097885",
"0.6097059",
"0.60882497",
"0.6085297",
"0.6080163",
"0.6079464",
"0.6075868",
"0.6075868",
"0.6075868",
"0.60748565",
"0.60727847",
"0.60672456",
"0.606259",
"0.6057072",
"0.6056852",
"0.60413945",
"0.6038026",
"0.6022367",
"0.6018455",
"0.60017204",
"0.59967047",
"0.59964484",
"0.59935606",
"0.5993262",
"0.5993262",
"0.599307",
"0.597433",
"0.5968386",
"0.5968386",
"0.5962904",
"0.59602636",
"0.5958363",
"0.5957634",
"0.5956504",
"0.59311026",
"0.59309006"
] |
0.0
|
-1
|
TODO add timestamp check
|
def verify_md5_hash?(url, expected_hash, secret_key)
url_no_hash = "#{url[ 0..-33 ]}#{secret_key}"
actual_hash = Digest::MD5.hexdigest(url_no_hash)
return (expected_hash == actual_hash)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def timestamp; end",
"def timestamp; end",
"def timestamp; end",
"def timestamp; end",
"def timestamp; end",
"def timestamp; end",
"def timestamp=(_arg0); end",
"def timestamp=(_arg0); end",
"def timestamp=(_arg0); end",
"def timestamp=(_arg0); end",
"def date() updated; end",
"def timestamp() @timestamp ||= Time.now.strftime(\"%Y%m%d%H%M%SZ\") end",
"def timestamp\n nil\n end",
"def outdated; end",
"def date; end",
"def date; end",
"def date; end",
"def date; end",
"def read_date; end",
"def private; end",
"def created_at=(_arg0); end",
"def read_date=(_); end",
"def mtime; end",
"def mtime; end",
"def creation_date=(_); end",
"def modification_date=(_); end",
"def modification_date; end",
"def now; end",
"def now; end",
"def outdated?; end",
"def add_dynamic_timestamp(text)\nend",
"def get_timestamp(*params); raise('Stub or mock required.') end",
"def validate_timestamp(obj)\n if !obj[:timestamp].nil?\n if obj[:timestamp].match(/\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}.\\d{3}/)\n return true\n end\n end\n false\nend",
"def create_time(); @create_time; end",
"def asctime\n end",
"def past; end",
"def check_for_timestamp name\n @created_at = true if name == CREATED_AT_FIELD\n @updated_at = true if name == UPDATED_AT_FIELD\n nil\n end",
"def start_time; end",
"def created_at; super; end",
"def hit(timestamp)\n \n end",
"def now=(_arg0); end",
"def created_at; end",
"def asctime() end",
"def extendbyfourteendays\n updated_at = Time.now\n end",
"def stime=(*) end",
"def check_timestamp\n @recent.save! if Time.now - @recent.updated_at >= 600\n end",
"def created; BoxesConsoleHelpers.simple_time(created_at) rescue \"nil\"; end",
"def timestamp?\n !!(self =~ /^Rel\\d\\d\\d\\d\\d\\d\\d\\d$/ ||\n self =~ /^\\w\\w\\w?_\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d$/)\n end",
"def utc() end",
"def time_class; end",
"def timestamp\n self[:timestamp]\n end",
"def version_added; end",
"def timestamp\n @timestamp ||= Time.parse(@origdate)\n end",
"def interesting_date\n marked_as_fast_growing_at\n end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def sub_wf_launched_at; h.sub_wf_launched_at; end",
"def date; raw_changeset.time; end",
"def get_timestamp\n Time.now.utc.strftime(\"%b%d%Y\")\nend",
"def timestamp\n TimeStamp.new\n end",
"def record_userstamp\n !duplicating?\n end",
"def record_userstamp\n !duplicating?\n end",
"def record_userstamp\n !@duplicating\n end",
"def timestamp\n @java.getTimestamp\n end",
"def utc?() end",
"def parse_timestamps\n super\n @updated = updated.to_i if updated.is_a? String\n @updated = Time.at(updated) if updated\n end",
"def timestamp\n\t\tTime.now.to_i\n\tend",
"def started_at; end",
"def started_at; end",
"def started_at; end",
"def started_at; end",
"def started_at; end",
"def mtime() end",
"def mtime() end",
"def get(key, timestamp)\n \n end",
"def finished_at; @doc['finished_at']; end",
"def last_seen_at() ; info_time(:last_seen) ; end",
"def start_time_idx() return (self.start_date.strftime(\"%Y%m%d%H%M\") rescue nil); end",
"def timestamp\n @timestamp ||= Time.now.xs_datetime\n end",
"def creation_date\n# stat.ctime\n @bson['uploadDate'] || Date.new\n end",
"def started_at=(_arg0); end",
"def started_at=(_arg0); end",
"def started_at=(_arg0); end",
"def timestamp\n _timestamp.as_time\n end",
"def timestamp?\n type == \"TIMESTAMP\"\n end",
"def timestamp\n first(:timestamp)\n end",
"def timestamp\n Time.now.to_s\n end",
"def created_at; @doc['created_at']; end",
"def old() @time < Time.now.to_f end",
"def restore_times; end",
"def restore_times; end",
"def timestamp \n\ttime = Time.new\n\t\"#{time.day}/#{time.month}/#{time.year}\"\nend",
"def timeRecordsForDate(brick, date)\n end",
"def last_epoch_time; end"
] |
[
"0.7535297",
"0.7535297",
"0.7535297",
"0.7535297",
"0.7535297",
"0.7535297",
"0.6830647",
"0.6830647",
"0.6830647",
"0.6830647",
"0.6411448",
"0.6351457",
"0.6238869",
"0.62087655",
"0.620513",
"0.620513",
"0.620513",
"0.620513",
"0.61418706",
"0.6095786",
"0.60408103",
"0.6036244",
"0.60186076",
"0.60186076",
"0.6003916",
"0.59611464",
"0.595044",
"0.5912723",
"0.5912723",
"0.59048927",
"0.5903455",
"0.58861643",
"0.5884795",
"0.58789515",
"0.5864316",
"0.5810015",
"0.5799805",
"0.57720405",
"0.5759676",
"0.5732337",
"0.57252836",
"0.57227504",
"0.57106966",
"0.57083535",
"0.5706445",
"0.5682609",
"0.56645226",
"0.56584597",
"0.5656995",
"0.56290454",
"0.56255627",
"0.56222034",
"0.55964524",
"0.5580799",
"0.5577669",
"0.5577669",
"0.5577669",
"0.5577669",
"0.5577669",
"0.5577669",
"0.5577669",
"0.5577669",
"0.5577669",
"0.55719805",
"0.5562334",
"0.55547935",
"0.55538857",
"0.5553722",
"0.5553722",
"0.55480987",
"0.5536948",
"0.5531687",
"0.5524125",
"0.5520718",
"0.55172616",
"0.55172616",
"0.55172616",
"0.55172616",
"0.55172616",
"0.5513846",
"0.5513846",
"0.5511792",
"0.550495",
"0.55046135",
"0.550171",
"0.54998374",
"0.54813987",
"0.5467293",
"0.5467293",
"0.5467293",
"0.5465138",
"0.54621506",
"0.54609203",
"0.54577655",
"0.54538524",
"0.54491013",
"0.5441085",
"0.5441085",
"0.54263294",
"0.54247445",
"0.5421903"
] |
0.0
|
-1
|
Resize the original and singing images to 40% of their size and put them side by side.
|
def create_side_by_side_example
# Resize the original image to 40% of the size.
Commander.run!("convert #{@dir}/original.miff",
"-resize 40%",
"#{@dir}/original_smaller.miff")
# Resize the singing image to 40% of the size.
Commander.run!("convert",
Songster.output_folder.join("#{@fname}-singing.gif").to_s,
"-resize 40%",
"#{@dir}/singing_smaller.miff")
# Put two closed mouth side by side.
Commander.run!("convert",
"#{@dir}/original_smaller.miff #{@dir}/original_smaller.miff",
"+append",
"#{@dir}/sidebyside_closed.miff")
# Put a closed and opened mouth side by side.
Commander.run!("convert",
"#{@dir}/singing_smaller.miff",
"+append",
"#{@dir}/sidebyside_opened.miff")
Commander.run!("convert -loop 0 -delay 30",
"#{@dir}/sidebyside_closed.miff #{@dir}/sidebyside_opened.miff",
Songster.debug_folder.join("#{@fname}-sidebyside.gif").to_s)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def resizeImages\n # For each of the 9 images\n for counter in (1..9)\n pngName = \"./images/\" + counter.to_s() + \".png\"\n image = Magick::Image.read(pngName).first\n # Make the new image 25% larger\n thumb = image.scale(1.25)\n thumb.write(pngName)\n end\n end",
"def square_images\n @template[:message][:attachment][:payload][:image_aspect_ratio] = 'square'\n self\n end",
"def horizontal_images\n hrz = 'horizontal'\n @template[:message][:attachment][:payload][:image_aspect_ratio] = hrz\n self\n end",
"def convert_image\n i = 0 \n main = [small\t=\t[\"jpg\",\"small\",240,160], \n\t medium\t=\t[\"jpg\",\"medium\",640,427], \n\t large\t=\t[\"jpg\",\"large\",1024,683]]\n while i < main.count\n # Runs the resize function with params to each size\n resize_image(main[i])\n i +=1\n end\n end",
"def resize\n @image.resize \"#{@placement[:a]}x#{OUTER}\\!\"\n end",
"def process_small_image\n small_image.encode!(:png).convert!('-resize 50x50 -gravity center -background none -extent 50x50')\n end",
"def recreate\n #photo = Photo.find(params[:id])\n #degrees = if params[:direction] == 'left' then -90 else 90 end\n\n #~ #main photo\n #~ image = Magick::ImageList.new(photo.file)\n #~ image = image.rotate(degrees)\n #~ image.write(photo.file)\n\n # thumb\n @photoset = Photoset.find(params[:id])\n #@photos = Photo.find(:all)\n for photo in @photoset.photos \n # render :text => photo.id and return\n photo = Photo.find(photo.id)\n if !photo.image.blank?\n original_image = RAILS_ROOT + \"/public/photo/image/#{photo.id}/#{File.basename(photo.image)}\"\n \n main = RAILS_ROOT + \"/public/photo/image/#{photo.id}/main/#{File.basename(photo.image)}\"\n \n #~ thumbnail = RAILS_ROOT + \"/public/photo/image/#{photo.id}/thumbnail/#{File.basename(photo.image)}\"\n \n #~ submain = RAILS_ROOT + \"/public/photo/image/#{photo.id}/submain/#{File.basename(photo.image)}\"\n \n\n \n \n image = Magick::ImageList.new(original_image) \n image = image.change_geometry!('600x450>') { |c, r, i| i.resize!(c, r) } \n image.write(main)\n \n #~ image = Magick::ImageList.new(original_image) \n #~ image = image.change_geometry!('51x51!') { |c, r, i| i.resize!(c, r) } \n #~ image.write(thumbnail)\n \n #~ image = Magick::ImageList.new(original_image) \n #~ image = image.change_geometry!('97x97!') { |c, r, i| i.resize!(c, r) } \n #~ image.write(submain) \n \n end\n \n end\n render :text => \"image croped\"\n #redirect_to :action => 'index'\n end",
"def resize_all(size_constraint)\n require 'rmagick'\n\n Dir.new('.').each do |f|\n if f.match(/jpg/)\n if (i = Magick::Image.read(f).first)\n i.resize_to_fit!(size_constraint)\n i.write(f)\n end\n end\n end\nend",
"def adapt_design_size \n hits = 0\n while space_factor < Constants::Min_allowed_factor and hits < 3\n if @vertical \n @height /= Constants::Shrink_factor\n @height += @height%20 == 0 ? 0 : 20-@height%20\n elsif not @vertical\n @width /= Constants::Shrink_factor\n @width += @width%20 == 0 ? 0 : 20-@width%20\n end\n composite_main_image_position\n generate_white_spaces\n white_space_area = white_space_w * white_space_h\n hits +=1\n end\n end",
"def setup\n size 200, 200\n @a = load_image 'construct.jpg'\n @b = load_image 'wash.jpg'\n @offset = 0.0\nend",
"def resize_and_move_holst(holst, frame_width, frame_height)\n photo = Image.read(URI.decode('public' + holst.image.url))[0]\n move = translation_holst(holst.positions, photo, frame_width, frame_height)\n photo = resize_to_fill_holst(photo, frame_width, frame_height)\n photo_done = Image.new(frame_width, frame_height).composite!(photo, move[0], move[1], OverCompositeOp)\n end",
"def convert images_directory , pdfs_directory\n\n # Get all files from that directory\n all_images = Dir.entries(images_directory)\n\n #Segregate only the required the question paper images , just in case the directory contains other files\n all_images.keep_if { |a| ((a.start_with? \"mid-\") || (a.start_with? \"end-\")) && ((a.end_with? \".jpg\") || (a.end_with? \".png\") || (a.end_with? \".tif\") || (a.end_with? \".gif\") || (a.end_with? \".svg\") || (a.end_with? \".bmp\"))}\n\n #Store number of images as a variable to show % finished\n number_of_images = all_images.count\n\n # Initialisation of variables like Array of names of papers , eg. mid-spring-2016-MA20104\n Dir.chdir(images_directory)\n papernames_array = []\n i = 0\n all_images = all_images.sort\n stack = Magick::ImageList.new\n\n #Loop through all paper images & batch merge them into PDFs , even if a paper has 3 pages / images\n all_images.each do |file|\n papernames_array[i] = file[0..22]\n if i == 0\n Dir.chdir(images_directory)\n stack = Magick::ImageList.new\n incoming = Magick::ImageList.new file\n stack.concat(incoming)\n else\n if papernames_array[i].eql? papernames_array[i-1]\n Dir.chdir(images_directory)\n incoming = Magick::ImageList.new file\n stack.concat(incoming)\n else\n Dir.chdir(pdfs_directory)\n stack.write(papernames_array[i-1]+\".pdf\")\n Dir.chdir(images_directory)\n stack = Magick::ImageList.new\n incoming = Magick::ImageList.new file\n stack.concat(incoming)\n end\n if i == number_of_images-1\n Dir.chdir(pdfs_directory)\n stack.write(papernames_array[i]+\".pdf\")\n end\n end\n i = i + 1\n percentage = (i.to_f/number_of_images.to_f) * 100\n puts \"Processing #{i}/#{number_of_images} images , #{percentage}% done\"\n end\nend",
"def resize_and_crop(size) \n manipulate! do |image| \n if image[:width] < image[:height]\n remove = (image[:height] - 135).round \n image.shave(\"0x#{remove}\") \n elsif image[:width] > image[:height] \n remove = ((image[:width] - image[:height])/2).round\n image.shave(\"#{remove}x0\")\n end\n image.resize(\"#{size}\")\n image\n end\n end",
"def images_holder\n images_quantity = self.images.count\n if images_quantity < 5\n images_needed = 5 - images_quantity\n images_needed.times do\n self.images << Image.new\n end\n end\n end",
"def cut_white_space_edges\n x1_array = Array.new\n x2_array = Array.new\n y1_array = Array.new\n y2_array = Array.new\n \n @groups.each do |g|\n x1_array << g.x_pos\n x2_array << g.x_pos + g.width\n y1_array << g.y_pos\n y2_array << g.y_pos + g.height\n end\n \n if @vertical\n #Normal position of the image (up)\n if values_bits[Constants::V_Image_position]< 4.5 \n @height = y2_array.max + @upper_margin\n #Alternative position(down)\n else \n new_height = @height - (y1_array.min-@upper_margin)\n \n @groups.each do |g|\n g.y_pos -= (@height - new_height)\n end\n @main_image.y_pos -= (@height - new_height)\n \n @height = new_height\n end\n else\n #Normal position of the image (left)\n if values_bits[Constants::V_Image_position]< 4.5\n @width = x2_array.max + @sides_margin\n #Alternative position of the image (right)\n else \n new_width = @width - (x1_array.min-@sides_margin)\n \n @groups.each do |g|\n g.x_pos -= (@width - new_width)\n end\n @main_image.x_pos -= (@width - new_width)\n \n @width = new_width\n end\n end\n end",
"def process_images(dir)\n pattern = File.join(\"**\", dir, \"*.png\")\n files = Dir.glob(pattern)\n files.each do |f|\n unless f.include?(IMG_THUMB) || f.include?(IMG_FINAL)\n puts \"Converting image #{f}\"\n f2 = f.gsub /.png/, ''\n # thumbs\n system \"convert #{f} -resize #{IMG_THUMB_SIZE}^ -extent #{IMG_THUMB_SIZE} #{f2}#{IMG_THUMB}.png\" unless File.exists?(\"#{f2}#{IMG_THUMB}.png\")\n # final\n system \"convert #{f} -resize #{IMG_SIZE} #{f2}#{IMG_FINAL}.png\" unless File.exists?(\"#{f2}#{IMG_FINAL}.png\") \n end\n end\nend",
"def collage\n @photos = []\n @photos = Photo.where(:tag => 'dogs').limit(3)\n imgList = Magick::ImageList.new('public' + @photos[0].attachment_url,\n 'public' + @photos[1].attachment_url,\n 'public' + @photos[2].attachment_url)\n @img = Photo.new\n @img = imgList.append(true)\n @img.write('public/uploads/photo/attachment/collage.jpg')\n end",
"def generate_image_sizes()\n\tKernel.system \"mkdir -p #{DESTINATION_DIRECTORY_NAME}\"\n\tSIZES.each do |size|\n\t\timagemagick_command = \"find . -maxdepth 1 -type f \\\\( -name '*.tif' -o -name '*.png' \\\\) | xargs -I@ #{IMAGEMAGICK_COMMAND} @ -resize #{size[:max_width]} -quality #{JPEG_QUALITY} -set filename:name '%t' '#{DESTINATION_DIRECTORY_NAME}/%[filename:name]-#{size[:name]}.#{OUTPUT_FILE_EXTENSION}'\"\n\t\tputs imagemagick_command\n\t\tKernel.system imagemagick_command\n\tend\nend",
"def resize_and_crop(size)\n manipulate! do |image|\n Rails.logger.error '----------- image:'\n Rails.logger.error image.inspect\n\n if image[:width] < image[:height]\n remove = ((image[:height] - image[:width]) / 2).round\n image.shave(\"0x#{remove}\")\n elsif image[:width] > image[:height]\n remove = ((image[:width] - image[:height]) / 2).round\n image.shave(\"#{remove}x0\")\n end\n image.resize(\"#{size}x#{size}\")\n image\n end\n end",
"def resize_to_limit(new_width, new_height)\n manipulate! do |image|\n image = resize_image(image,new_width,new_height) if new_width < image.x_size || new_height < image.y_size\n image\n end\n end",
"def copy_generated_images(parent)\n img = parent.find_inspire_image\n mobile = parent.image_for img, 'mobile_inspire'\n desktop = parent.image_for img, 'desktop_inspire'\n thumbnails = parent.image_for '', 'thumbnails'\n\n FileUtils.cp(mobile, \"#{data_path}/inspire/mobile\")\n FileUtils.cp(desktop, \"#{data_path}/inspire/desktop\")\n FileUtils.cp_r(\"#{thumbnails}/.\", \"#{data_path}/thumbnails\")\n end",
"def resize\n\t\t@image = Qt::Image.new @parent.width/2, @parent.width/2, 7\n\t\[email protected] Qt::Color.new \"#ffffff\"\n\tend",
"def make_mosaic_image(name, size)\n mosaic_image = Magick::ImageList.new\n (0..SIDE_PICTURES_COUNT - 1).each do |index|\n line_image_name = get_image_name(index)\n line_image = Magick::ImageList.new(line_image_name)\n line_image.first.resize!(size)\n mosaic_image << line_image.append(true)\n line_image.destroy!\n end\n mosaic_image.append(true).write(name)\n mosaic_image.destroy!\n end",
"def resize_to_limit(new_width, new_height)\n manipulate! do |image|\n image = resize_image(image,new_width,new_height) if new_width < image.width || new_height < image.height\n image\n end\n end",
"def resize_to_fit(new_width, new_height)\n manipulate! do |image|\n resize_image(image,new_width,new_height)\n end\n end",
"def resize_to_fit(new_width, new_height)\n manipulate! do |image|\n resize_image(image,new_width,new_height)\n end\n end",
"def small(input) # Method that returns the image\n self.images[input].variant(resize: \"300x300\").processed # Resizing the image and return it\n end",
"def display_image\n image.variant(resize_to_limit: [500,500])\n end",
"def make_responsive(img,width)\n [\n [\"-resize 'x#{width}>'\", \"-#{width}.webp\"],\n [\"-resize 'x#{width * 2}>'\", \"-#{width}@2x.webp\"],\n ].each do |i|\n convert(img, i.first, i.last)\n end\nend",
"def substrate_images\n Dir.chdir(\"source\") do\n allnames = Dir.glob(\"images/substrates/**/*\")\n filenames = allnames.select { |f| !File.directory?(f) }\n\n filenames.map do |f|\n basename = File.basename(f, File.extname(f))\n extra = nil\n # if identify_dimensions\n if false\n identify = `identify #{f}`\n dimensions = /\\d+x\\d+/.match(identify)[0]\n extra = dimensions\n else\n extra = \"\"\n end\n\n [ f, \"#{basename} #{extra}\" ]\n end\n end\n end",
"def compute_image_positions!\r\n case layout\r\n when SMART\r\n calculate_smart_positions\r\n when DIAGONAL\r\n calculate_diagonal_dimensions\r\n calculate_diagonal_positions\r\n when HORIZONTAL\r\n @height = height_for_horizontal_layout\r\n calculate_horizontal_positions\r\n @width = width_for_horizontal_layout\r\n else\r\n @images.sort! do |a,b| \r\n if (b.size <=> a.size) === 0\r\n a.name <=> b.name\r\n else\r\n b.size <=> a.size\r\n end\r\n end\r\n\r\n @width = width_for_vertical_layout\r\n calulate_vertical_postions\r\n @height = height_for_vertical_layout\r\n if @images.any?(&:repeat_x?)\r\n calculate_repeat_extra_width!\r\n tile_images_that_repeat\r\n end\r\n end\r\n end",
"def profile_photo\n @profile = Profile.find(:all)\n \n for profile in @profile\n if !profile.profile_image.blank?\n original_image = RAILS_ROOT + \"/public/profile/profile_image/#{profile.id}/#{File.basename(profile.profile_image)}\"\n # main = RAILS_ROOT + \"/public/profile/profile_image/#{profile.id}/main/#{File.basename(profile.profile_image)}\"\n submain = RAILS_ROOT + \"/public/profile/profile_image/#{profile.id}/submain/#{File.basename(profile.profile_image)}\"\n image = Magick::ImageList.new(original_image) \n image = image.change_geometry!('171x171!') { |c, r, i| i.resize!(c, r) } \n image.write(submain) \n end \n end\n \n \n end",
"def large_process\n case [model.attachable_type, model.image_type]\n when ['User', 'avatar'] then\n resize_to_fill 1024, 683 # 3x2\n when ['User', 'inspiration'] then\n resize_to_fit 1024, 9999 # fixed width\n when ['Message', 'avatar'] then\n resize_to_fit 1024, 9999 # fixed width\n when ['Message', 'alternate'] then\n resize_to_fit 1024, 9999 # fixed width\n when ['Alternative', 'avatar'] then\n resize_to_fill 1024, 683 # 3x2\n else\n resize_to_fit 1024, 9999 # fixed width\n end\n # TODO: Test and implement this.\n # fix_exif_rotation\n quality 70\n end",
"def resize_pic(filename,resizewidth,out_path)\n nw = resizewidth\n n = File.basename(filename)\n i = QuickMagick::Image.read(filename).first\n w = i.width.to_f # Retrieves width in pixels\n h = i.height.to_f # Retrieves height in pixels\n pr = w/h\n nh = nw/pr \n i.resize \"#{nw}x#{nh}!\"\n i.save \"#{out_path}/#{n}\"\nend",
"def scale\n scale_factor = 20 # template.png height divided by canvas height\n self.image_x *= scale_factor\n self.image_y *= scale_factor\n self.height *= scale_factor\n self.width *= scale_factor\n self.rotation *= 180 / Math::PI\n end",
"def resizePngs\n destination=\"./Convert/\"\n search_for=[\"*.png\"]\n \n @files=readDirectoryFiles(destination,search_for)\n @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)\n @viewport.z=999999\n \n @bar=Sprite.new(@viewport)\n @bar.bitmap=Bitmap.new(Graphics.width,34)\n pbSetSystemFont(@bar.bitmap)\n \n for i in [email protected]\n @files[i]=@files[i].gsub(/.png/) {\"\"}\n end\n \n return false if !Kernel.pbConfirmMessage(_INTL(\"There is a total of #{@files.length} PNG(s) available for conversion. Would you like to begin the process?\"))\n for i in [email protected]\n file=@files[i]\n \n width=((i*1.000)/@files.length)*Graphics.width\n @bar.bitmap.clear\n @bar.bitmap.fill_rect(0,0,Graphics.width,34,Color.new(255,255,255))\n @bar.bitmap.fill_rect(0,0,Graphics.width,32,Color.new(0,0,0))\n @bar.bitmap.fill_rect(0,0,width,32,Color.new(25*4,90*2,25*4))\n text=[[\"#{i}/#{@files.length}\",Graphics.width/2,2,2,Color.new(255,255,255),nil]]\n pbDrawTextPositions(@bar.bitmap,text)\n \n next if RTP.exists?(\"#{destination}New/#{file}.png\")\n \n sprite=pbBitmap(\"#{destination}#{file}.png\")\n width=sprite.width\n height=sprite.height\n \n bitmap=Bitmap.new(width/2,height/2)\n bitmap.stretch_blt(Rect.new(0,0,width/2,height/2),sprite,Rect.new(0,0,width,height))\n bitmap.saveToPng(\"#{destination}New/#{file}.png\")\n sprite.dispose\n pbWait(1)\n RPG::Cache.clear\n end\n @bar.dispose\n @viewport.dispose\n Kernel.pbMessage(_INTL(\"Done!\"))\nend",
"def display_image \r\n self.image.variant(resize_to_limit: [1000, 1000]) \r\n end",
"def strict_resize image, w, h\n image.resize \"#{ w }x#{ h }!\"\n image\n end",
"def size_calculation(file_name)\n\t\t#file_name = \"file:///home/frakinho/image_manipulation/server_serial_port/app/assets/images/coisa.jpg\"\n\t original = Magick::Image::read(file_name).first\n\t\t\n\t\tpath_debug = get_path_without_image_name(file_name)\n\t \n\n\t #Copy for debug mod\n\t image = original\n\n\t #Apply Fitler twice for remove a max of noise \n\t image = image.median_filter(radius=3)\n\t image = image.median_filter(radius=3)\n\t \timage.write(\"#{path_debug}first_filter.jpg\")\n\t image = image.edge(radius=2)\n\t \timage.write(\"#{path_debug}edge.jpg\")\n\n\t image.image_type = Magick::BilevelType\n\t image.write(\"#{path_debug}BileveType.jpg\")\n\t image = image.median_filter(radius=1)\n\t image.write(\"#{path_debug}last_filter.jpg\")\n\n\t \t# Get Bounding_box\n\t\tbound = image.bounding_box\n\n\t\t#Calculate value in CM\n\t #Value top in CM\n\t # 237 is a variable value, depend the distance between table and camera\n\t value_width_cm = ((bound.width) * 21) / 380.0\n\t #Value of height\n\t value_height_cm = ((bound.height) * 21) / 380.0\n\n\n\t # Debug MOD \n\t\tif ServerSerialPort::Application.config.my_app.debug\n\t\t gc_1 = Magick::Draw.new\n\t\t gc_1.stroke(\"gray50\")\n\t\t gc_1.fill_opacity(0)\n\t\t gc_1.rectangle(bound.x, bound.y, bound.x+bound.width, bound.y+bound.height)\n\t\t gc_1.stroke(\"red\")\n\t\t gc_1.circle(bound.x, bound.y, bound.x+2, bound.y+2)\n\t\t gc_1.circle(bound.x+bound.width, bound.y, bound.x+bound.width+2, bound.y+2)\n\t\t gc_1.circle(bound.x, bound.y+bound.height, bound.x+2, bound.y+bound.height+2)\n\t\t gc_1.circle(bound.x+bound.width, bound.y+bound.height, bound.x+bound.width+2, bound.y+bound.height+2)\n\t\t gc_1.fill(\"white\")\n\t\t gc_1.stroke(\"transparent\")\n\t\t gc_1.text(bound.x-15, bound.y-5, \"\\'#{bound.x},#{bound.y}\\'\")\n\t\t gc_1.text(bound.x+(bound.width/2),bound.y-15,\"#{value_width_cm}\")\n\t\t gc_1.text(bound.x - 15,(bound.height / 2),\"#{value_height_cm}\")\n\t\t gc_1.text(bound.x+bound.width-15, bound.y-5, \"\\'#{bound.x+bound.width},#{bound.y}\\'\")\n\t\t gc_1.text(bound.x-15, bound.y+bound.height+15, \"\\'#{bound.x},#{bound.y+bound.height}\\'\")\n\t\t gc_1.text(bound.x+bound.width-15, bound.y+bound.height+15, \"\\'#{bound.x+bound.width},#{bound.y+bound.height}\\'\")\t \n\t\t gc_1.draw(original)\n\t\t original.write(\"#{path_debug}bounding.jpg\")\n\t\t\n\t\tend\n\t\timage_crop = original.crop(bound.x, bound.y, bound.width, bound.height)\n\t\timage_crop = image_crop.rotate(90)\n\t\n\t\timage_crop.write(\"#{path_debug}image_crop.jpg\")\n\n\n\n\t return value_width_cm,value_height_cm\n\tend",
"def resize_to_fill(new_width, new_height)\n manipulate! do |image|\n\n image = resize_image image, new_width, new_height, :max\n\n if image.x_size > new_width\n top = 0\n left = (image.x_size - new_width) / 2\n elsif image.y_size > new_height\n left = 0\n top = (image.y_size - new_height) / 2\n else\n left = 0\n top = 0\n end\n\n image.extract_area(left, top, new_width, new_height)\n\n end\n end",
"def blue_shift\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.blue_shift(2)\n img.write('public' + @photo.attachment_url)\n end",
"def create_resized_image\n create_image do |xfrm|\n if size\n MiniMagick::Tool::Convert.new do |cmd|\n cmd << xfrm.path # input\n cmd.flatten\n cmd.resize(size)\n cmd << xfrm.path # output\n end\n end\n end\n end",
"def show\n maybe_update_aspect_ratio @image\n end",
"def display_image\n image.variant(resize_to_limit: [500, 500])\n end",
"def display_image\n image.variant(resize_to_limit: [500, 500])\n end",
"def display_image\n image.variant(resize_to_limit: [500, 500])\n end",
"def display_image\n image.variant(resize_to_limit: [500, 500])\n end",
"def display_image\n image.variant(resize_to_limit: [500, 500])\n end",
"def display_image\n image.variant(resize_to_limit: [500, 500])\n end",
"def resize\n if size.max > 1024\n res = %x( #{magick_bin_name(\"convert\")} -auto-orient -resize 1024x768 #{Shellwords.shellescape path} #{Shellwords.shellescape path})\n Rails.logger.info res\n end\n unless has_thumbnail?\n unless File.exists? path.gsub(/(.+)\\/.+/, '\\1/thumbs')\n Dir.mkdir path.gsub(/(.+)\\/.+/, '\\1/thumbs')\n end\n ## that's a bit broken on windows - why?\n res = %x( #{magick_bin_name(\"convert\")} -verbose -auto-orient -strip -thumbnail 300x160 #{Shellwords.shellescape path} #{Shellwords.shellescape path.gsub(/(.+)\\/(.+)/, '\\1/thumbs/\\2')})\n Rails.logger.info res\n end\n end",
"def sequence_images\n \n end",
"def process_contained_images\n require 'active_support/secure_random'\n image_folder = \"#{RAILS_ROOT}/public/assets/#{self.class.to_s.pluralize.underscore}/#{self.id}/contained_images\"\n public_image_folder = \"/assets/#{self.class.to_s.pluralize.underscore}/#{self.id}/contained_images\"\n FileUtils.mkdir(image_folder) unless File.directory?(image_folder)\n for attribute in self.image_containers\n contents = self.send(attribute)\n if contents\n matches = contents.scan(/\\/stored_images\\/[\\w]*\\/[\\w. -]*/).uniq\n for match in matches\n match_file_name = match.gsub(/\\/stored_images\\/[\\w ]*\\//, '')\n random_file_name = \"#{ActiveSupport::SecureRandom.hex(6)}_#{match_file_name}\"\n FileUtils.cp \"#{RAILS_ROOT}/public/assets#{match}\", \"#{image_folder}/#{random_file_name}\"\n self.send(\"#{attribute.to_s}=\", contents.gsub(\"../../../assets#{match}\", \"../../assets#{match}\"))\n self.send(\"#{attribute.to_s}=\", contents.gsub(\"../../assets#{match}\", \"../../#{public_image_folder}/#{random_file_name}\"))\n end\n end\n end\n self.save\n end",
"def process_image(src, dest, maxw, maxh)\n i = QuickMagick::Image.read(src).first\n # AMF - added quality setting to limit size of images (some sites had high quality jpeg, so files sizes were still big)\n i.quality = 75\n w, h = i.width, i.height\n extra = (w - h/(maxh.to_f/maxw.to_f)).to_i\n if extra > 0\n i.shave(\"#{extra>>1}x0\") if i.width > i.height\n w -= extra\n end\n if w > maxw or h > maxh\n i.resize(\"#{maxw}x#{maxh}\")\n end\n i.save(dest)\n end",
"def resize_to_fill(new_width, new_height)\n manipulate! do |image|\n\n image = resize_image image, new_width, new_height, :max\n\n if image.width > new_width\n top = 0\n left = (image.width - new_width) / 2\n elsif image.height > new_height\n left = 0\n top = (image.height - new_height) / 2\n else\n left = 0\n top = 0\n end\n\n # Floating point errors can sometimes chop off an extra pixel\n # TODO: fix all the universe so that floating point errors never happen again\n new_height = image.height if image.height < new_height\n new_width = image.width if image.width < new_width\n\n image.extract_area(left, top, new_width, new_height)\n\n end\n end",
"def main\n ImageManip::inspect_image(@image_path)\n dimensions = ImageManip::get_dimensions(@image_path)\n sharp_pixels = get_accidental_pixels(@sharp_path)\n flat_pixels = get_accidental_pixels(@flat_path)\n edits = Hash.new\n edits[:lower_left] = [dimensions[0] / 2, dimensions[1] / 2]\n edits[:rgb_array] = sharp_pixels\n ImageManip::draw_2D_object(@image_path, './new_staff.gif', edits)\n edits[:lower_left] = [dimensions[0] / 3, dimensions[1] / 3]\n edits[:rgb_array] = flat_pixels\n ImageManip::draw_2D_object('./new_staff.gif', './new_staff.gif', edits)\n end",
"def resize_to_fit width, height\n manipulate! do |image|\n cols = image.width\n rows = image.height\n\n if width != cols or height != rows\n scale = [width/cols.to_f, height/rows.to_f].min\n cols = (scale * (cols + 0.5)).round\n rows = (scale * (rows + 0.5)).round\n image.resize cols, rows do |img|\n yield(img) if block_given?\n img.save current_path\n end\n end\n end\n end",
"def resize_to_fit(new_width, new_height)\n width, height = FastImage.size(self.current_path)\n width_ratio = new_width.to_f / width.to_f\n height_when_width_used = height * width_ratio\n if height_when_width_used <= new_height\n new_height = height_when_width_used\n else\n height_ratio = new_height.to_f / height.to_f\n new_width = width * height_ratio\n end\n FastImage.resize(self.current_path, self.current_path, new_width, new_height)\n end",
"def scaled_photos\n # How big is the area where we're showing phtoos\n row_width = grid_width\n\n scaled_photos = []\n\n # resolve the photos promise (if a promise)\n aspect_ratios = []\n photos = model.reject do |photo|\n if photo.height\n aspect_ratios << ((photo.width / photo.height) * 100).round\n false # keep\n else\n true # reject\n end\n end\n\n scaled_widths = summed_widths(photos)\n # Sum the width for the photos\n number_of_rows = (scaled_widths / row_width).round\n number_of_rows = [(number_of_rows / 2).round, 1].max\n\n partitions = `partition(aspect_ratios, number_of_rows)`\n\n index = 0\n\n partitions.map do |row|\n summed_ratios = row.sum\n row.each do |ratio|\n photo = photos[index]\n\n # the percent of the rows width this photo should take up\n percent_width = ratio / summed_ratios\n width = percent_width * row_width\n height = width / (ratio / 100.0)\n\n index += 1\n scaled_photos << ScaledPhoto.new(width.floor, height.floor, photo)\n end\n end\n\n scaled_photos\n end",
"def resize_and_optimize(width, height)\n manipulate! do |img|\n img.format(\"jpg\") do |c|\n c.quality \"70\"\n c.resize \"#{width}x#{height}\"\n end\n\n img\n end\n end",
"def whole_images\n ( self.images + self.variant_images ).uniq\n end",
"def modify_image\n if @vertical\n @main_image = @main_image.zooming_v\n else\n @main_image = @main_image.zooming_h\n end\n end",
"def portrait(size)\n unless File.exists? \"#{RAILS_ROOT}/public/system/characters/#{self.id}_#{size.to_i}.jpg\"\n begin\n File.open(\"#{RAILS_ROOT}/public/system/characters/#{self.id}_256.jpg\",\"wb\") do |f|\n Net::HTTP.start(\"image.eveonline.com\") do |http|\n resp = http.get(\"/Character/#{self.id}_256.jpg\")\n f << resp.body\n end\n end\n # Now use MiniMagick to bake some 16/32 images from the larger source\n \n image = MiniMagick::Image.from_file(\"#{RAILS_ROOT}/public/system/characters/#{self.id}_256.jpg\")\n image.resize \"16x16\"\n image.write(\"#{RAILS_ROOT}/public/system/characters/#{self.id}_16.jpg\")\n \n image = MiniMagick::Image.from_file(\"#{RAILS_ROOT}/public/system/characters/#{self.id}_256.jpg\")\n image.resize \"32x32\"\n image.write(\"#{RAILS_ROOT}/public/system/characters/#{self.id}_32.jpg\")\n \n image = MiniMagick::Image.from_file(\"#{RAILS_ROOT}/public/system/characters/#{self.id}_256.jpg\")\n image.resize \"64x64\"\n image.write(\"#{RAILS_ROOT}/public/system/characters/#{self.id}_64.jpg\")\n rescue\n return \"/images/logo_not_found_#{size}.jpg\"\n end\n end\n return \"/system/characters/#{self.id}_#{size.to_i}.jpg\"\n end",
"def resize_to_limit(width, height)\n width = dimension_from width\n height = dimension_from height\n manipulate! do |img|\n geometry = Magick::Geometry.new(width, height, 0, 0, Magick::GreaterGeometry)\n new_img = img.change_geometry(geometry) do |new_width, new_height|\n img.resize(new_width, new_height)\n end\n destroy_image(img)\n new_img = yield(new_img) if block_given?\n new_img\n end\n end",
"def target\n img = Magick::ImageList.new(TARGET_FILE_NAME + FILE_SUFFIX)\n img = img.resize(NEW_TARGET_SIDE_LENGTH, NEW_TARGET_SIDE_LENGTH)\n img = img.quantize(COLOR_VARIATION, Magick::GRAYColorspace)\n img.write(TARGET_FILE_NAME + NEW_TARGET_NAME_SUFFIX + FILE_SUFFIX)\n img.destroy!\n end",
"def resize!\n end",
"def gallery_images\n imgs = []\n images.each do |image|\n imgs << image.public_filename(:medium)\n end\n 1.upto(6 - imgs.size) do |i|\n imgs << \"/images/placeholder.png\"\n end\n imgs\n end",
"def move_images(docxml)\n FileUtils.rm_rf tmpimagedir\n FileUtils.mkdir tmpimagedir\n docxml.xpath(\"//*[local-name() = 'img']\").each do |i|\n i[\"width\"], i[\"height\"] = Html2Doc.image_resize(i, image_localfile(i),\n @maxheight, @maxwidth)\n next if /^data:image/.match i[\"src\"]\n @datauriimage ? datauri(i) : move_image1(i)\n end\n docxml\n end",
"def normalized_sizes(width, height)\n if width.to_i > @image.width\n width = @image.width\n end\n if height.to_i > @image.height\n height = @image.height\n end\n \"#{width}x#{height}\"\n end",
"def large_image_width\n 850\n end",
"def flip_horizontally!\n @picture.flip_horizontally!\n end",
"def set_aspect_ratio\n @columns = 25\n @rows = 25\n base_image_columns = @base_image[\"%w\"].to_i\n base_image_rows = @base_image[\"%h\"].to_i\n\n if base_image_columns > base_image_rows\n @columns *= (base_image_columns / base_image_rows.to_f)\n @columns = @columns.round\n else\n @rows *= (base_image_rows / base_image_columns.to_f)\n @rows = @rows.round\n end\n end",
"def old_resize_image(img, size)\n size = size.first if size.is_a?(Array) && size.length == 1 && !size.first.is_a?(Fixnum)\n if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))\n size = [size, size] if size.is_a?(Fixnum)\n img.thumbnail!(*size)\n elsif size.is_a?(String) && size =~ /^c.*$/ # Image cropping - example geometry string: c75x75\n dimensions = size[1..size.size].split(\"x\")\n img.crop_resized!(dimensions[0].to_i, dimensions[1].to_i)\n else\n img.change_geometry(size.to_s) { |cols, rows, image| image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows) }\n end\n self.width = img.columns if respond_to?(:width)\n self.height = img.rows if respond_to?(:height)\n img.strip! unless attachment_options[:keep_profile]\n quality = img.format.to_s[/JPEG/] && get_jpeg_quality\n out_file = write_to_temp_file(img.to_blob { self.quality = quality if quality })\n temp_paths.unshift out_file\n self.size = File.size(self.temp_path)\n end",
"def small_image_url\n self.small_image.convert('-resize 50%').url\n end",
"def design2image\n\n bkgImg = Image.read(\"#{Rails.root}/public/#{params[:bkg]}\").first\n\n sideTop = 36\n sideLeft = 95\n sideWidth = 216\n sideHeight = 353\n\n side = params[:side]\n if side == 'SLEEVE'\n sideWidth = 162\n sideHeight = 250\n end\n #ART Processing\n arts = params[:art];\n art_tops = params[:art_top];\n art_lefts = params[:art_left];\n \n \n #Image.new(columns, rows) ~ (width, height)\n containSide = Magick::Image.new(sideWidth, sideHeight) do\n self.background_color = 'none'\n end\n\n i=0\n if arts\n clipArt = Image.read(\"#{Rails.root}/public/#{arts[0]}\").first\n clipArtTop = art_tops[i].to_i if art_tops[i]\n clipArtLeft = art_lefts[i].to_i if art_lefts[i]\n containSide = containSide.composite(clipArt, clipArtLeft, clipArtTop, OverCompositeOp)\n end\n\n #TEXT Processing\n texts = params[:text];\n text_tops = params[:text_top];\n text_lefts = params[:text_left];\n\n\n if texts\n textArtTop = text_tops[i].to_i if text_tops[i]\n textArtLeft = text_lefts[i].to_i if text_lefts[i]\n gc = Magick::Draw.new\n textArt = Magick::Image.new(300, 200) do\n self.background_color = 'none'\n end\n gc.annotate(textArt, 0, 0, 0, 0, texts[i]) do\n self.gravity = Magick::NorthWestGravity\n self.pointsize = 22\n self.font_family = \"Times\"\n self.fill = '#0000A9'\n self.stroke = \"none\"\n end\n end\n\n containSide.composite!(textArt, textArtLeft || 0, textArtTop || 0, OverCompositeOp) if textArt\n \n bkgImg.composite!(containSide, sideLeft, sideTop, OverCompositeOp)\n bkgImg.scale!(0.5)\n\n send_data bkgImg.to_blob, :disposition => 'inline', :type => 'image/png'\n\n# output = get_working_image(@session_id)\n# unless File.exist?(output)\n# FileUtils.cp(\"#{RAILS_ROOT}/public/images/#{params[:textart]}.png\", output)\n# img = Image.read(output).first\n# img = img.scale(params[:rs].to_f) unless params[:rs].blank?\n# img = img.level_colors(params[:b] || \"\", params[:w] || \"\", true) if params[:b] || params[:w]\n# img.background_color = \"none\"\n# img = img.rotate(params[:r].to_f) unless params[:r].blank?\n# img.write(output)\n# end\n# img = Image.read(output).first\n# send_data img.to_blob, :disposition => 'inline', :type => 'image/png'\n\n end",
"def resize_picture picture_owner, path, filename_extension\n\n # if filename_extension == 'jpg'\n resize_factor = \"PICTURE_#{picture_owner.upcase}_PREVIEW_SIZE\".constantize.first # e.g. *PICTURE_COACH_PREVIEW_SIZE*\n system \"convert #{path}/original.#{filename_extension} -resize '#{resize_factor}' #{path}/preview.#{filename_extension}\"\n\n resize_factor = \"PICTURE_#{picture_owner.upcase}_VIEW_SIZE\".constantize.first # e.g. *PICTURE_COACH_VIEW_SIZE*\n system \"convert #{path}/original.#{filename_extension} -resize '#{resize_factor}' #{path}/view.#{filename_extension}\"\n # else\n # # for logo file: just symbol links to original one (nothing to resize)\n # system \"ln -s #{path}/original.#{filename_extension} #{path}/preview.#{filename_extension}\"\n # system \"ln -s #{path}/original.#{filename_extension} #{path}/view.#{filename_extension}\"\n # end\n # Thumb is and in Africa thumb\n resize_factor = \"PICTURE_#{picture_owner.upcase}_THUMB_SIZE\".constantize.first # e.g. *PICTURE_COACH_THUMB_SIZE*\n system \"convert #{path}/original.#{filename_extension} -resize '#{resize_factor}' #{path}/thumb.#{filename_extension}\"\n\n end",
"def create_resized_image\n create_image do |xfrm|\n if size\n xfrm.flatten\n xfrm.resize(size)\n end\n end\n end",
"def thumbnail(size); end",
"def resize_and_save_space(resizing)\n { resize: resizing, quality: \"85%\", strip: true, interlace: \"Plane\" }\n end",
"def images; end",
"def gallery_images\n imgs = images\n 1.upto(3 - imgs.size) do |i|\n imgs << \"/images/placeholder.png\"\n end\n imgs\n end",
"def compare_images(actual, expected, diff_image, image_difference_percentage_tolerance)\n images = [\n ChunkyPNG::Image.from_file(actual),\n ChunkyPNG::Image.from_file(expected)\n ]\n\n diff = []\n\n images.first.height.times do |y|\n images.first.row(y).each_with_index do |pixel, x|\n diff << [x, y] unless pixel == images.last[x, y]\n end\n end\n\n diff_percent = (diff.length.to_f / images.first.pixels.length) * 100\n\n if diff_percent > image_difference_percentage_tolerance\n x, y = diff.map { |xy| xy[0] }, diff.map { |xy| xy[1] }\n\n images.last.rect(x.min, y.min, x.max, y.max, ChunkyPNG::Color.rgb(0, 255, 0))\n images.last.save(diff_image)\n puts \"pixels (total): #{images.first.pixels.length}\"\n puts \"pixels changed: #{diff.length}\"\n puts \"pixels changed (%): #{diff_percent}%\"\n embed(diff_image, 'image/png', 'diff-screenshot')\n fail \"Images are not within the tolerence of #{image_difference_percentage_tolerance}%\"\n end\nend",
"def similarity\n size1 = pixel_count(@image_path_1)\n size2 = pixel_count(@image_path_2)\n\n if size1 < size2\n big = @image_path_2\n small = @image_path_1\n else\n big = @image_path_1\n small = @image_path_2\n end\n\n min_size = size(small)\n width = min_size[0] * @resize_factor\n height = min_size[1] * @resize_factor\n\n a = \"convert #{Shellwords.escape(small)} #{Shellwords.escape(big)} -resize '#{width}'x'#{height}'\\! MIFF:- | compare -metric AE -fuzz \\\"#{@color_fuzz}%\\\" - null: 2>&1\"\n result = `#{a}`\n\n result.to_i / (width * height)\n end",
"def resize\n # TODO\n # if aray is 75% full, double the array and copy all items over\n end",
"def create_advanced\n image_service = ImageGeneratingService.new(self, 'Advanced.jpg', 'image/jpeg', 69)\n output_path = image_service.generate\n original_size_mb = File.size(output_path).to_f / 2**20\n if original_size_mb > 1.0\n image_service.generate_resized(1200)\n end\n end",
"def resize_to_fill_and_save_dimensions(new_width, new_height)\n img = ::MiniMagick::Image.from_file(current_path)\n width, height = img['width'], img['height']\n \n resize_to_fill(new_width, new_height)\n \n w_ratio = width.to_f / new_width.to_f\n h_ratio = height.to_f / new_height.to_f\n \n ratio = [w_ratio, h_ratio].min\n \n model.send(\"#{mounted_as}_w=\", ratio * new_width)\n model.send(\"#{mounted_as}_h=\", ratio * new_height)\n model.send(\"#{mounted_as}_x=\", (width - model.send(\"#{mounted_as}_w\")) / 2)\n model.send(\"#{mounted_as}_y=\", (height - model.send(\"#{mounted_as}_h\")) / 2)\n end",
"def image_processing\n \tpixel_array_img1 = read_file_image(\"book4_no_table.jpg\")\n \tpixel_array_img2 = read_file_image(\"net_book5.jpg\")\n\n\n \tpixel_array_sq_img1 = []\n \tpixel_array_sq_img2 = []\n \tpixel_array_img1x2 = []\n \t##################FALTA AQUI ALGO\n\n \t###### ARRAY OF PIXEL ARRAY\n \t# SQUARE IMAGE IMG_1\n \tpixel_array_sq_img1 = square_array(pixel_array_img1)\t\t\n\t\tpixel_array_sq_img2 = square_array(pixel_array_img2)\n \tpixel_array_img1x2 = product_array(pixel_array_img1,pixel_array_img2)\n\n\t\t# Apply convolve filter two image array\n\t\timg_1_convolve_filter = convolve(pixel_array_img1,@gaussian_kernel)\n\t\timg_2_convolve_filter = convolve(pixel_array_img2,@gaussian_kernel)\n\n\t\t## Array Square\n\t\timg_1_convolve_filter_sq = square_array(img_1_convolve_filter)\n\t\timg_2_convolve_filter_sq = square_array(img_2_convolve_filter)\n\t\timg_2x1_convolve_filter = product_array(img_1_convolve_filter,img_2_convolve_filter)\n\n\t\t#Convolve FILTER Square IMG1 and IMG2\n\t\timg_1_sq_convolve_filter = convolve(pixel_array_sq_img1,@gaussian_kernel)\n\t\timg_2_sq_convolve_filter = convolve(pixel_array_sq_img2,@gaussian_kernel)\n\n\t\t#Convolve FILTER to Product IMG1 and IMG2 \n\t\timg_1x2_convolve_filter = convolve(pixel_array_img1x2,@gaussian_kernel)\n\n\t\timg_1_sq_convolve_filter = difference_array(img_1_sq_convolve_filter,img_1_convolve_filter_sq)\n\t\timg_2_sq_convolve_filter = difference_array(img_2_sq_convolve_filter,img_2_convolve_filter_sq)\n\t\timg_1x2_convolve_filter = difference_array(img_1x2_convolve_filter,img_2x1_convolve_filter)\n\n\n\n\t\t#c1/c2 constants\n\t #First use: manual fitting\n\t c_1=6.5025\n\t c_2=58.5225\n\t \n\t #Second use: change k1,k2 & c1,c2 depend on L (width of color map)\n\t l=255\n\t k_1=0.01\n\t c_1=(k_1*l)**2\n\t k_2=0.03\n\t c_2=(k_2*l)**2\n\t \n\t #Numerator of SSIM\n\t num_ssim = \n\t product_array(\n\t \tmultiple_and_factor_increment(2,img_2x1_convolve_filter,c_1),\n\t \tmultiple_and_factor_increment(2,img_1x2_convolve_filter,c_2))\n\t ##Denominator of SSIM\n\t den_ssim = product_array(sum_two_array_and_incremente(img_1_convolve_filter_sq,img_2_convolve_filter_sq,c_1),sum_two_array_and_incremente(img_1_sq_convolve_filter,img_2_sq_convolve_filter,c_2))\n\t ##SSIM\n\t index = division_and_average(num_ssim,den_ssim)\n\n\t puts index\n\n end",
"def rename_image_files(old_name)\n [ :original , :medium , :thumb ].each do |size|\n old_path = ImagesModule.image_path_for_basename(old_name, size, true)\n if old_path\n extension = File.extname(old_path)\n new_path = image_path(size, true, extension)\n FileUtils.mv(old_path, new_path) if old_path != new_path\n end\n end\n end",
"def my_resize(width, height)\n manipulate! do |img|\n img.resize \"#{width}x#{height}!\"\n img\n end\n end",
"def index\n @images = get_approved\n @left_images = []\n @right_images = []\n @center_images = []\n counter = 0\n @images.each do |image|\n counter+=1\n if counter == 1\n @left_images << image\n elsif counter ==2\n @center_images << image\n elsif counter ==3\n counter = 0\n @right_images << image\n end\n end\n end",
"def shrink_to_one image, xpos, ypos, width, height\n# if @intermediate_images\n# tmp_image = \"vo-#{xpos}-#{ypos}\".to_sym\n# copy_subimage image, xpos, ypos, width, height, tmp_image\n# d_write_image(tmp_image)\n# end\n img = get_image(image)\n checkbox_pixels = img.excerpt(xpos, ypos, width, height)\n shrink_to_one = checkbox_pixels.scale(1,1)\n return shrink_to_one.get_pixels(0,0,1,1)[0].red\n end",
"def prepare_image_apria\n images = []\n if @sitecode == \"00Q49\" # site code for DAP\n single_page_images = convert_multipage_to_singlepage\n single_page_images.each_with_index do |image_file, index|\n new_file_name = rename_image_for_dap(image_file, index)\n File.rename(image_file, new_file_name)\n @image_folder = Dir.glob(\"#{@location}/**/#{config['IMAGE']['image_folder']}*\", File::FNM_CASEFOLD)\n image = ImagesForJob.new :image => File.open(\"#{new_file_name}\",\"rb\")\n image.image_file_name = File.basename(new_file_name)\n image.is_splitted_image = true\n image = update_image image\n images << image\n end\n else\n image = ImagesForJob.new\n parse_values(\"IMAGE\", image)\n image_path = @image_folder.detect{|image_string| image_string.downcase == \"#{@image_path}/#{image.image_file_name}\".downcase}\n image.image = File.open(image_path, \"rb\")\n image_file_name = image.image_file_name.strip.split(\"\\\\\").last unless image.image_file_name.blank?\n path = Dir.glob(\"#{@location}/**/#{image_file_name}\").first\n count = %x[identify \"#{path}\"].split(image_file_name).length-1\n new_image_name = File.basename(\"#{path}\")\n if count>1\n dir_location = File.dirname(\"#{path}\")\n ext_name = File.extname(\"#{path}\")\n new_image_base_name = new_image_name.chomp(\"#{ext_name}\")\n if ((not ext_name.empty?) and (ext_name.casecmp(\".pdf\") == 0) ) then\n system \"pdftk '#{path}' burst output '#{dir_location}/#{new_image_base_name}_%d#{ext_name}'\"\n for image_count in 1..count\n image = ImagesForJob.new(:image_file_name=>\"#{new_image_base_name}_#{image_count}#{ext_name}\",:is_splitted_image=>true)\n image = update_image image\n images << image\n end\n else\n InputBatch.split_image(count,path, dir_location, new_image_base_name)\n single_images = Dir.glob(\"#{@location}/**/*\").select{|file| InputBatch.get_single_image(file, new_image_base_name)}.sort\n single_images.each_with_index do |single_image, index|\n new_image_name = \"#{dir_location}/#{new_image_base_name}_#{index}#{ext_name}\"\n File.rename(single_image, new_image_name)\n image = ImagesForJob.create(:image => File.open(new_image_name), :image_number => @img_count, :is_splitted_image=>true)\n @img_count += 1\n images << image\n end\n end\n else\n image = ImagesForJob.new(:image_file_name=>\"#{new_image_name}\")\n image = update_image image\n images << image\n end\n end\n return images\n end",
"def add_whitespace(image)\n require 'RMagick'\n # load in the original image\n file_path = self.send(image).path(:original)\n old_image = Magick::Image::read(file_path).first\n geometry = Paperclip::Geometry.from_file(self.send(image).to_file)\n original_width = geometry.width\n original_height = geometry.height\n # add 200 pixels of whitespace\n white_space = 200\n old_image.background_color = \"white\"\n new_image = old_image.extent((original_width + white_space), (original_height + white_space), (white_space/2), (white_space/2))\n # write over the original\n new_image.write(file_path)\n end",
"def images_for_mushroom_app # :nologin: :norobots:\n minimum_confidence = params[:minimum_confidence].blank? ? 1.5 : params[:minimum_confidence]\n minimum_quality = params[:minimum_quality].blank? ? 2.0 : params[:minimum_quality]\n target_width = params[:target_width].blank? ? 400 : params[:target_width]\n target_height = params[:target_height].blank? ? 600 : params[:target_height]\n minimum_width = params[:minimum_width].blank? ? target_width : params[:minimum_width]\n minimum_height = params[:minimum_height].blank? ? target_height : params[:minimum_height]\n confidence_reward = params[:confidence_reward].blank? ? 2.0 : params[:confidence_reward]\n quality_reward = params[:quality_reward].blank? ? 1.0 : params[:quality_reward]\n ratio_penalty = params[:ratio_penalty].blank? ? 0.5 : params[:ratio_penalty]\n\n # Last term in ORDER BY spec below penalizes images of the wrong aspect ratio.\n # If we wanted 600x400 it will penalize 400x400 images by 'ratio_penalty'.\n ratio_penalty = ratio_penalty.to_f / Math.log10(600.0/400)\n\n names = get_list_of_names(params[:names])\n names = names.map {|n| \"'\" + n.gsub(/'/, '\\\\\\'') + \"'\"}.join(',')\n\n data = Name.connection.select_rows(%(\n SELECT y.name, y.id, y.width, y.height\n FROM (\n SELECT x.text_name AS name, i.id AS id, i.width AS width, i.height AS height\n FROM (\n SELECT DISTINCT n1.text_name AS text_name, n2.id AS name_id\n FROM names n1\n JOIN names n2 ON IF(n1.synonym_id IS NULL, n2.id = n1.id, n2.synonym_id = n1.synonym_id)\n WHERE n1.rank = 'Species' AND n1.text_name IN (#{names})\n ) AS x, observations o, images i\n WHERE o.name_id = x.name_id\n AND i.id = o.thumb_image_id\n AND o.vote_cache >= #{minimum_confidence}\n AND i.vote_cache >= #{minimum_quality}\n AND i.width >= #{minimum_width} AND i.height >= #{minimum_height}\n ORDER BY\n o.vote_cache * #{confidence_reward} +\n i.vote_cache * #{quality_reward} -\n ABS(LOG(width/height) - #{Math.log10(target_width.to_f/target_height)}) * #{ratio_penalty} DESC\n ) AS y\n GROUP BY y.name\n ))\n\n if params[:test]\n render_test_image_report(data)\n else\n render_image_csv_file(data)\n end\n rescue => e\n render(:text => e.to_s, :layout => false, :status => 500)\n end",
"def resize_retina_image(image_filename)\n \n image_name = File.basename(image_filename)\n \n image = Magick::Image.read(image_filename).first # Read the image\n new_image = image.scale(SCALE_BY)\n \n if new_image.write(image_filename) # Overwrite image file\n puts \"Resizing Image (#{SCALE_BY}): #{image_name}\"\n else\n puts \"Error: Couldn't resize image #{image_name}\"\n end\n \nend",
"def cut_to_fit(options)\n %Q{-thumbnail #{options.width}x#{options.height}^ \\\n -gravity #{options.gravity} \\\n -unsharp 0x.5 \\\n -auto-orient \\\n -extent #{options.width}x#{options.height}}\n end",
"def prepare!(max_side, watermark_img)\n if size == 1 and (columns > max_side or rows > max_side)\n resize_to_fit! max_side\n end\n\n watermark_mc watermark_img\n\n strip!\n end",
"def mirror(params = {})\n params[:name] ||= @pictureName.gsub('.png', 'Mirrored.png')\n params[:save] ||= @picturePath\n \n mir = dup\n \n mirror_width = @width * 2\n mir.picture = ChunkyPNG::Image.new(mirror_width, @height)\n mir.height = @height\n mir.width = mirror_width\n \n mirror_width -= 1\n \n (0...@width).each do |i|\n (0...@height).each do |j|\n mir[i, j] = @picture[i, j]\n mir[mirror_width - i, j] = @picture[i, j]\n end\n end\n \n mir.pictureName, mir.picturePath = params[:name], params[:save]\n mir \n end",
"def scale\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.scale(1.5)\n img.write('public' + @photo.attachment_url)\n end",
"def new_dimensions_for(orig_width, orig_height)\n new_width = orig_width\n new_height = orig_height\n\n case @flag\n when :percent\n scale_x = @width.zero? ? 100 : @width\n scale_y = @height.zero? ? @width : @height\n new_width = scale_x.to_f * (orig_width.to_f / 100.0)\n new_height = scale_y.to_f * (orig_height.to_f / 100.0)\n when :<, :>, nil\n scale_factor =\n if new_width.zero? || new_height.zero?\n 1.0\n else\n if @width.nonzero? && @height.nonzero?\n [@width.to_f / new_width.to_f, @height.to_f / new_height.to_f].min\n else\n @width.nonzero? ? (@width.to_f / new_width.to_f) : (@height.to_f / new_height.to_f)\n end\n end\n new_width = scale_factor * new_width.to_f\n new_height = scale_factor * new_height.to_f\n new_width = orig_width if @flag && orig_width.send(@flag, new_width)\n new_height = orig_height if @flag && orig_height.send(@flag, new_height)\n when :aspect\n new_width = @width unless @width.nil?\n new_height = @height unless @height.nil?\n end\n\n [new_width, new_height].collect! { |v| v.round }\n end",
"def new_dimensions_for(orig_width, orig_height)\n new_width = orig_width\n new_height = orig_height\n\n case @flag\n when :percent\n scale_x = @width.zero? ? 100 : @width\n scale_y = @height.zero? ? @width : @height\n new_width = scale_x.to_f * (orig_width.to_f / 100.0)\n new_height = scale_y.to_f * (orig_height.to_f / 100.0)\n when :<, :>, nil\n scale_factor =\n if new_width.zero? || new_height.zero?\n 1.0\n else\n if @width.nonzero? && @height.nonzero?\n [@width.to_f / new_width.to_f, @height.to_f / new_height.to_f].min\n else\n @width.nonzero? ? (@width.to_f / new_width.to_f) : (@height.to_f / new_height.to_f)\n end\n end\n new_width = scale_factor * new_width.to_f\n new_height = scale_factor * new_height.to_f\n new_width = orig_width if @flag && orig_width.send(@flag, new_width)\n new_height = orig_height if @flag && orig_height.send(@flag, new_height)\n when :aspect\n new_width = @width unless @width.nil?\n new_height = @height unless @height.nil?\n end\n\n [new_width, new_height].collect! { |v| v.round }\n end"
] |
[
"0.64996207",
"0.61344165",
"0.6075757",
"0.5939927",
"0.59258044",
"0.5881704",
"0.5853281",
"0.57856125",
"0.5709361",
"0.56782377",
"0.5576887",
"0.54959357",
"0.5482878",
"0.54644835",
"0.54620826",
"0.54474014",
"0.5436985",
"0.54361",
"0.5413226",
"0.5411866",
"0.541123",
"0.54010105",
"0.539665",
"0.5396331",
"0.53695524",
"0.53695524",
"0.53517294",
"0.53435427",
"0.5333085",
"0.53299904",
"0.53293276",
"0.5302028",
"0.52906305",
"0.5283042",
"0.52823615",
"0.5256684",
"0.525469",
"0.52508503",
"0.5235467",
"0.52310103",
"0.5229792",
"0.522487",
"0.521262",
"0.52116895",
"0.52116895",
"0.52116895",
"0.52116895",
"0.52116895",
"0.52116895",
"0.5211361",
"0.5208978",
"0.5181477",
"0.51788396",
"0.51700634",
"0.5167238",
"0.51672256",
"0.5161064",
"0.51599205",
"0.51563674",
"0.51551473",
"0.51543015",
"0.5149917",
"0.51408595",
"0.51403487",
"0.5137551",
"0.5123756",
"0.5121525",
"0.51136386",
"0.5113318",
"0.51131976",
"0.5099598",
"0.5097925",
"0.5097529",
"0.5094105",
"0.5093338",
"0.5093068",
"0.5089328",
"0.5088655",
"0.50869316",
"0.50850016",
"0.5073255",
"0.5072708",
"0.5071698",
"0.50699687",
"0.50698316",
"0.5068894",
"0.5063396",
"0.5061006",
"0.5051663",
"0.5047158",
"0.50435287",
"0.504305",
"0.50411266",
"0.50403965",
"0.50370294",
"0.5036922",
"0.5030865",
"0.5026613",
"0.5025571",
"0.5025571"
] |
0.673461
|
0
|
Create a crop of the mouth upper lip with black padding on the bottom
|
def create_mouth_top_crop(mouth)
crop_size = "#{mouth.width}x#{mouth.height+5}"
crop_location = "+#{mouth.left_x}+#{mouth.top}"
Commander.run!("convert #{@dir}/original.miff",
"-fill black -stroke black",
"-draw \"path '",
# Start line at the top left point
" M #{mouth.left}",
# Draw a curve to the right point.
" C #{mouth.center_x},#{mouth.center_y+5}",
" #{mouth.center_x},#{mouth.center_y+5}",
" #{mouth.right}",
# Draw a straight line to a point below the right point.
" L #{mouth.right_x},#{mouth.bottom+5}",
# Draw a straight line to a point below the left point.
" L #{mouth.left_x},#{mouth.bottom+5}",
# Close the figure so it can be filled.
" Z",
"'\"",
"-crop #{crop_size}#{crop_location}",
"#{@dir}/top.miff")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create_mouth_bottom_crop(mouth)\n crop_size = \"#{mouth.width}x#{mouth.chin_height+mouth.opening_size}\"\n crop_location = \"+#{mouth.left_x}+#{mouth.middle}\"\n\n Commander.run!(\"convert #{@dir}/original.miff\",\n \"-fill black -stroke black\",\n\n \"-draw \\\"path '\",\n\n # Start line at the top left point\n \" M #{mouth.left}\",\n\n # Draw a curve to the right point\n \" C #{mouth.center_x},#{mouth.center_y+5}\",\n \" #{mouth.center_x},#{mouth.center_y+5}\",\n\n # Finish line at the right point.\n \" #{mouth.right}'\",\n \"\\\"\",\n\n # Add black padding to adjust how big the mouth opens.\n \"-gravity northwest -background black\",\n \"-splice 0x#{mouth.opening_size}+0+#{mouth.middle}\",\n\n # Crop to get the results.\n \"-crop #{crop_size}#{crop_location}\",\n\n \"#{@dir}/bottom.miff\")\n end",
"def with_crop(left, top, right, bottom); end",
"def crop_canvas(c, h)\n return c.crop(0, 0, c.width, h) if c.height > h\n c\n end",
"def crop(crop, input=nil, output=nil)\n inout \"crop=x=%{left}:y=%{top}:w=%{width}:h=%{height}\", input, output, crop\n end",
"def crop(t, l, b, r)\n orig_w = orig_h = 460\n new_w = r - l\n new_h = t - b\n o_x = l\n o_y = orig_h - t\n geom = \"#{new_w.round}x#{new_h.round}+#{o_x.round}+#{o_y.round}\"\n `convert #{@fn} -crop #{geom} +repage #{@fn}`\n end",
"def crop\n return unless model.can_be_cropped?\n manipulate! do |image|\n image.combine_options do |command|\n command.crop(model.magick_thumbnail_coordinates)\n end\n image\n end\n end",
"def magick_crop_rect\n [x1, y1, x2-x1, y2-y1]\n end",
"def crop image, x0 = 0, y0 = 0, w = 100, h = 100, scale = 1\n x0 = (x0.to_f * scale).to_i\n y0 = (y0.to_f * scale).to_i\n\n w = (w.to_f * scale).to_i\n h = (h.to_f * scale).to_i\n\n image.crop \"#{ w }x#{ h }+#{ x0 }+#{ y0 }\"\n image\n end",
"def trim!(border = pixels.first)\n x1 = [*0...width].index { |c| column(c).uniq != [border] }\n x2 = [*0...width].rindex { |c| column(c).uniq != [border] }\n y1 = [*0...height].index { |r| row(r).uniq != [border] }\n y2 = [*0...height].rindex { |r| row(r).uniq != [border] }\n\n crop! x1, y1, x2 - x1 + 1, y2 - y1 + 1\n end",
"def cropper(crop_width, crop_height)\n manipulate! do |img|\n width = img.columns\n height= img.rows\n if width == crop_width and height==crop_height then\n img\n else\n img.crop(width / 2,height / 2,crop_width,crop_height)\n end\n end\n end",
"def crop\n block = block_given? ? Proc.new : Arigatomation::LUMINANCE\n left_x, right_x, top_y, bottom_y = lrc.x, ulc.x, lrc.y, ulc.y\n changed = false\n\n each do |point|\n if !block.call(self[point])\n changed = true\n left_x = point.x if point.x < left_x\n right_x = point.x if point.x > right_x\n top_y = point.y if point.y < top_y\n bottom_y = point.y if point.y > bottom_y\n end\n end\n\n return self unless changed\n $log.debug \"CROPPED to #{[left_x, top_y, right_x, bottom_y].join(\", \")}\"\n capture(Arigatomation::Point.new(left_x, top_y), Arigatomation::Point.new(right_x, bottom_y))\n rescue\n $log.error \"Crop error: #{$!}\"\n end",
"def clip_to(x, y, w, h, &rendering_code); end",
"def crop! (xoff, yoff, width, height)\n @transforms << \"CR#{xoff},#{yoff},#{width},#{height}\"\n self\n end",
"def crop!(x,y,width,height)\n @x, @y, @w, @h = x, y, width, height\n self\n end",
"def crop\n return if model.crop_x.blank?\n resize_to_limit(300, 300)\n manipulate! do |img|\n x = model.crop_x.to_i\n y = model.crop_y.to_i\n w = model.crop_w.to_i\n h = model.crop_h.to_i\n img.crop!(x, y, w, h)\n end\n end",
"def crop(x, y, w, h)\n clone.crop!(x, y, w, h)\n end",
"def bottom\n self.ox = self.src_rect.width/2\n self.oy = self.src_rect.height\n end",
"def round_corners(dst)\n command = \"\\\"#{ File.expand_path(@thumbnail.path) }[0]\\\" #{ transformation } \\\"#{ File.expand_path(dst.path) }\\\"\"\n Paperclip.run('convert', command)\n dst\n end",
"def topping; end",
"def bottom!\n self.ox = self.width/2\n self.oy = self.height\n end",
"def trim(surface, trim, width, height)\n if trim > 0\n tmp = Cairo::ImageSurface.new(width-2*trim, height-2*trim)\n cc = Cairo::Context.new(tmp)\n cc.set_source(surface,-1*trim, -1*trim)\n cc.paint\n surface = tmp\n end\n surface\n end",
"def crop(rect)\n if self.scale > 1.0\n rect = CGRectMake(rect.origin.x * self.scale,\n rect.origin.y * self.scale,\n rect.size.width * self.scale,\n rect.size.height * self.scale)\n end\n\n cgimage = CGImageCreateWithImageInRect(self.CGImage, rect)\n result = UIImage.imageWithCGImage(cgimage, scale:self.scale, orientation:self.imageOrientation)\n\n return result\n end",
"def side_crop side, rowcol, image, starting, outimage=nil\n m_begin \"side_crop\"\n raise \"number expected\" unless starting.class == Fixnum\n raise \"side wrong: #{side}\" unless [:top, :bottom, :left, :right].member? side\n raise \"rowcol wrong: #{rowcol}\" unless [:row, :column].member? rowcol\n img = get_image(image)\n case [side, rowcol]\n when [:left, :column]\n cropped = img.excerpt(starting, 0, img.columns-starting, img.rows)\n when [:right, :column]\n cropped = img.excerpt(0, 0, img.columns-starting, img.rows)\n when [:top, :row]\n cropped = img.excerpt(0, starting, img.columns, img.rows-starting)\n when [:bottom, :row]\n cropped = img.excerpt(0, 0, img.columns, img.rows-starting)\n else\n raise \"invalid rowcol and side combination\"\n end\n outimage = image if outimage.nil?\n put_image(outimage, cropped)\n m_end \"side_crop\"\n end",
"def recreate_cropped_image\n if file.exists?\n img = ThumbMagick::Image.new(file.path('tocrop'))\n img.\n thumbnail(\"#{ (resize * 100).to_i }%\").\n crop(\"#{crop_w}x#{crop_h}\", crop_x, crop_y).\n write(file.path('cropped'))\n end \n end",
"def max_crop_area_growth(crop_from, crop_size)\n {\n top: crop_from[:y],\n right: image_size[:width] - crop_from[:x] - crop_size[:width],\n bottom: image_size[:height] - crop_from[:y] - crop_size[:height],\n left: crop_from[:x],\n }\n end",
"def clip\n max_h, max_w = w.h, w.w\n\n if x < 0 then\n self.x = x.abs\n return :west\n elsif x > max_w then\n self.x = 2 * max_w - x\n return :east\n end\n\n if y < 0 then\n self.y = y.abs\n return :south\n elsif y > max_h then\n self.y = 2 * max_h - y\n return :north\n end\n\n nil\n end",
"def crop_rows!\n if crop\n local_copy.in_place :tail, \"+#{crop.first}\"\n local_copy.in_place :head, (crop.last - crop.first + 1)\n end\n end",
"def trim(surface, trim, width, height)\n if trim > 0\n tmp = Cairo::ImageSurface.new(width - 2 * trim, height - 2 * trim)\n cc = Cairo::Context.new(tmp)\n cc.set_source(surface, -1 * trim, -1 * trim)\n cc.paint\n surface = tmp\n end\n surface\n end",
"def crop!(x, y, w, h)\n prefull, orig = model.actual_dimensions(:prefull), model.actual_dimensions\n ratio = [orig[0].to_f / prefull[0], orig[1].to_f / prefull[1]].min\n x, y, w, h = [x, y, w, h].map { |n| (n * ratio).floor }\n manipulate! do |img|\n img.crop \"#{w}x#{h}+#{x}+#{y}\"\n img = yield(img) if block_given?\n img\n end\n end",
"def crop_top_rows image, starting_row, outimage=nil\n raise \"number expected\" unless starting_row.class == Fixnum\n m_begin \"crop_top_rows\"\n img = get_image(image)\n cropped = img.excerpt(0, starting_row, img.columns, img.rows-starting_row)\n outimage = image if outimage.nil?\n put_image(outimage, cropped)\n m_end \"crop_top_rows\"\n end",
"def square_image_crop\n if (self.crops)\n if !(self.crop_x.nil? || self.crop_y.nil? || self.crop_w.nil? || self.crop_h.nil?)\n @image = MiniMagick::Image.open(self.photo.url)\n # if image is larger than our max screen size, the cropped image will be incorrect (resizing)\n @image.sample(((700/@image[:width].to_f) * 100).to_s + \"%\") if @image[:width] > 700\n @image.crop(\"#{self.crop_w}x#{self.crop_h}+#{self.crop_x}+#{self.crop_y}\")\n @image.set(\"page\", \"#{self.crop_w}x#{self.crop_h}+#{self.crop_x}+#{self.crop_y}\") \n self.square_image = @image\n end\n end\n end",
"def cut\n rmagick_img.crop_resized!(@x, @y, gravity)\n end",
"def merge_top_and_bottom_of_mouth\n Commander.run!(\"convert #{@dir}/top.miff #{@dir}/bottom.miff\",\n \"-append #{@dir}/opened_mouth.miff\")\n end",
"def resize_and_crop(size) \n manipulate! do |image| \n if image[:width] < image[:height]\n remove = (image[:height] - 135).round \n image.shave(\"0x#{remove}\") \n elsif image[:width] > image[:height] \n remove = ((image[:width] - image[:height])/2).round\n image.shave(\"#{remove}x0\")\n end\n image.resize(\"#{size}\")\n image\n end\n end",
"def crop!(left: 0, top: 0, width: nil, height: nil)\n manipulate! do |image|\n begin\n do_crop image, left, top, width, height\n rescue VIPS::Error => e\n e.message =~ /extract_area/ ? image : raise(e)\n end\n end\n end",
"def crop!(x, y, w, h)\n ptr = self.class.create_image_ptr(w, h, alpha_blending?)\n ::GD2::GD2FFI.send(:gdImageCopy, ptr, image_ptr, 0, 0, x.to_i, y.to_i, w.to_i, h.to_i)\n init_with_image(ptr)\n end",
"def maskify(cc)\n cc.size < 5 ? cc : cc[-4..-1].rjust(cc.size, '#')\nend",
"def padded(padding = 2, &block)\n r = bounds\n padding ||= 2\n bounding_box([padding, r.top - padding], width: r.width - (2 * padding), &block)\n end",
"def crop_avatar(args)\n self.crop_x = args[\"crop_x\"]\n self.crop_y = args[\"crop_y\"]\n self.crop_w = args[\"crop_w\"]\n self.crop_h = args[\"crop_h\"]\n avatar.reprocess!\n end",
"def pbBottomRight(window)\n window.x=Graphics.width-window.width\n window.y=Graphics.height-window.height\nend",
"def thumb_crop\n { x: model.profile_image_crop_param_x,\n y: model.profile_image_crop_param_y,\n width: model.profile_image_crop_param_width,\n height: model.profile_image_crop_param_height,\n crop: :crop\n }\n end",
"def crop(x, y, crop_width, crop_height)\n dup.crop!(x, y, crop_width, crop_height)\n end",
"def cropping_mask\n return if crop_from.blank? || crop_size.blank?\n\n crop_from = point_from_string(read_attribute(:crop_from))\n crop_size = sizes_from_string(read_attribute(:crop_size))\n\n point_and_mask_to_points(crop_from, crop_size)\n end",
"def crop_insets(number)\n jpg_path = $jpg_path.gsub(\"{CHART_NUMBER}\", number.to_s)\n preprocessed_jpg_path = $preprocessed_jpg_path.gsub(\"{CHART_NUMBER}\", number.to_s)\n \n res = $dbh.query(\"SELECT * FROM ocpn_nga_charts WHERE number=#{number}\")\n\n while row = res.fetch_hash do\n puts \"Cropping insets and generating their corners for chart #{row[\"number\"]}\"\n \n # If rotated, use preprocessed JPG\n if (row[\"prerotate\"].to_i != 0)\n jpg = preprocessed_jpg_path\n else\n jpg = jpg_path\n end\n end\n res = $dbh.query(\"SELECT *, (SELECT MIN(x) FROM ocpn_nga_kap_point WHERE point_type='CROP' AND active=1 AND kap_id=k.kap_id) AS x, (SELECT MAX(x) FROM ocpn_nga_kap_point WHERE point_type='CROP' AND active=1 AND kap_id=k.kap_id) AS x1, (SELECT MIN(y) FROM ocpn_nga_kap_point WHERE point_type='CROP' AND active=1 AND kap_id=k.kap_id) AS y, (SELECT MAX(y) FROM ocpn_nga_kap_point WHERE point_type='CROP' AND active=1 AND kap_id=k.kap_id) AS y1 FROM ocpn_nga_kap k WHERE bsb_type!='BASE' AND active=1 AND number=#{number}\")\n while row = res.fetch_hash do\n corner_size = row[\"cornersize\"]\n puts corner_size\n # check whether the data entered are ok\n if(row[\"x\"].to_i >= 0 && row[\"y\"].to_i >= 0 && row[\"x1\"].to_i > row[\"x\"].to_i && row[\"y1\"].to_i > row[\"y\"].to_i)\n inset_path = $inset_path.gsub(\"{CHART_NUMBER}\", number.to_s).gsub(\"{INSET}\", row[\"inset_id\"])\n `#{$convert_command} #{jpg} -crop #{row[\"x1\"].to_i - row[\"x\"].to_i}x#{row[\"y1\"].to_i - row[\"y\"].to_i}+#{row[\"x\"]}+#{row[\"y\"]} #{inset_path}`\n \n # create corner cut-outs\n corner_path = $corner_path.gsub(\"{CHART_NUMBER}\", number.to_s).gsub(\"{INSET}\", row[\"inset_id\"]).gsub(\"{CORNER}\", 'sw')\n `#{$convert_command} #{inset_path} -gravity SouthWest -crop #{corner_size}x#{corner_size}+0+0 -depth 8 -type Palette -colors 32 png8:#{corner_path}`\n corner_path = $corner_path.gsub(\"{CHART_NUMBER}\", number.to_s).gsub(\"{INSET}\", row[\"inset_id\"]).gsub(\"{CORNER}\", 'nw')\n `#{$convert_command} #{inset_path} -gravity NorthWest -crop #{corner_size}x#{corner_size}+0+0 -depth 8 -type Palette -colors 32 png8:#{corner_path}`\n corner_path = $corner_path.gsub(\"{CHART_NUMBER}\", number.to_s).gsub(\"{INSET}\", row[\"inset_id\"]).gsub(\"{CORNER}\", 'ne')\n `#{$convert_command} #{inset_path} -gravity NorthEast -crop #{corner_size}x#{corner_size}+0+0 -depth 8 -type Palette -colors 32 png8:#{corner_path}`\n corner_path = $corner_path.gsub(\"{CHART_NUMBER}\", number.to_s).gsub(\"{INSET}\", row[\"inset_id\"]).gsub(\"{CORNER}\", 'se')\n `#{$convert_command} #{inset_path} -gravity SouthEast -crop #{corner_size}x#{corner_size}+0+0 -depth 8 -type Palette -colors 32 png8:#{corner_path}`\n \n $dbh.query(\"UPDATE ocpn_nga_kap SET cropped=CURRENT_TIMESTAMP() WHERE kap_id=#{row[\"kap_id\"]}\")\n end\n end\n end",
"def unpadded_height\n height = 0\n padding = self.get_padding\n height = self.bounds.height - (padding[:top] + padding[:bottom])\n return height\n end",
"def crop_to(width, height)\n # Checks that crop area is defined and crop should be done.\n if ((crop_args[0] == crop_args[2]) || (crop_args[1] == crop_args[3]))\n # If not creates default image and saves it's dimensions.\n resize_to_fill_and_save_dimensions(width, height)\n else\n args = crop_args + [width, height]\n crop_and_resize(*args)\n end\n end",
"def crop(*args)\n with_command %(-crop \"#{Geometry.new(*args).to_s(true)}\")\n end",
"def crop(*args)\n @source = Cropper.new(@source, *args)\n self\n end",
"def trim(border = pixels.first)\n dup.trim!\n end",
"def merge_opened_mouth_on_canvas(mouth)\n Commander.run!(\"composite\",\n \"#{@dir}/opened_mouth.miff #{@dir}/opened_mouths.miff\",\n \"-gravity northwest -geometry +#{mouth.x}+#{mouth.y}\",\n \"#{@dir}/opened_mouths.miff\")\n end",
"def cropped_thumbnail(size) # :yields: image\n w, h = width, height\n l, t, r, b, half = 0, 0, w, h, (w - h).abs / 2\n\n l, r = half, half + h if w > h\n t, b = half, half + w if h > w\n\n with_crop(l, t, r, b) do |img|\n img.thumbnail(size) do |thumb|\n yield thumb\n end\n end\n end",
"def check_mouth\n\t\t\tx = @glabella_start_x_position + (@glabella_width / 2).round\n\t\t\ty = ((@glabella_start_y_position + @left_eye_width + @glabella_width + @right_eye_width) * 0.7).round\n\t\t\tmouth_pixel_color = @image.pixel_color(x, y)\n\t\t\t\n\t\t\tif mouth_pixel_color.red <= COLOR_THRESHOLD\n\t\t\t\tdebug_output(x, y)\n\t\t\t\twrite_to_image(x, y, '#f00')\n\t\t\t\treturn true\n\t\t\tend\n\t\t\treturn false\n\t\tend",
"def cropping_mask\n return if crop_from.blank? || crop_size.blank?\n crop_from = read_attribute(:crop_from).split('x')\n crop_size = read_attribute(:crop_size).split('x')\n {\n x1: crop_from[0].to_i,\n y1: crop_from[1].to_i,\n x2: crop_from[0].to_i + crop_size[0].to_i,\n y2: crop_from[1].to_i + crop_size[1].to_i\n }\n end",
"def easy_crop(geometry, anchor)\n ow,oh = dimensions # Before crop\n \t w,h = geometry.strip.split('x').map{|n|n.to_i} # Target dimensions\n \t\tanchor_x, anchor_y = case anchor\n \t\t\twhen :tl\n \t\t\t\t[ 0 , 0 ]\n \t\t\twhen :tc\n \t\t\t\t[ ((ow - w) / 2.0).round , 0]\n \t\t\twhen :tr\n \t\t\t\t[ ow - w , 0 ]\n \t\t\twhen :ml\n \t\t\t\t[ 0 , ((oh - h) / 2.0).round ]\n \t\t\twhen :mc\n \t\t\t\t[ ((ow - w) / 2.0).round , ((oh - h) / 2.0).round ]\n \t\t\twhen :mr\n \t\t\t\t[ ow - w , ((oh - h) / 2.0).round ]\n \t\t\twhen :bl\n \t\t\t\t[ 0 , oh - h]\n \t\t\twhen :bc\n \t\t\t\t[ ((ow - w) / 2.0).round , oh - h ]\n \t\t\twhen :br\n \t\t\t\t[ ow - w , oh - h]\n \t\tend\n \t\tmanual_crop(geometry, anchor_x, anchor_y)\n\t end",
"def fit_pinning_top\n union_frame = frame_for_subviews\n \n # # balance horizontally - offset x based on diff between old and new widths.\n # width_change = union_frame.width - self.width \n # new_x = self.x - width_change / 2\n new_x = self.x\n\n # pin at the top - offset y based on original top location and new height.\n new_y = self.frame.top_y - union_frame.height\n\n # we need to apply a vertical offset to all subviews later.\n delta_y = (new_y - self.y)\n\n # set the frame (and pray)\n self.frame = new_rect new_x, new_y, union_frame.width, union_frame.height\n\n self.subviews.each do |subview|\n if delta_y > 0 # we need to grow - move subview y up.\n subview.y += delta_y\n else # we need to shrink - move subview y down.\n subview.y -= delta_y\n end\n end\n end",
"def cover\n manipulate! do |frame, index|\n frame if index.zero?\n end\n end",
"def cut_image(source, width, height, dest = nil)\r\n dest ||= default_dest(source, \"cut\")\r\n image = MiniMagick::Image.from_file(source)\r\n image.crop \"#{width}x#{height}+0+0\"\r\n image.write dest\r\n dest\r\n end",
"def crop_logo\n logo.recreate_versions! if crop_logo_x.present?\n end",
"def midbottom; return self.centerx, self.bottom; end",
"def border_slicer(board)\n board.pop()\n board.shift()\n \n row = 0\n while row < self.height do\n board[row].pop()\n board[row].shift()\n row += 1\n end\n \n return board\n end",
"def mouth\n @mouth ||= Mouth.new self[:MOUTH_LEFT], self[:MOUTH_CENTER],\n self[:MOUTH_RIGHT]\n end",
"def banner_skrollr_offset(banner)\n (banner.img_height(SemiStatic::Engine.config.theme, :desktop)/4 - 50).to_s\n end",
"def outer_height; rect.height + @border_thickness * 2; end",
"def paper_white_area() barcode_bit_area -1 end",
"def cut_white_space_edges\n x1_array = Array.new\n x2_array = Array.new\n y1_array = Array.new\n y2_array = Array.new\n \n @groups.each do |g|\n x1_array << g.x_pos\n x2_array << g.x_pos + g.width\n y1_array << g.y_pos\n y2_array << g.y_pos + g.height\n end\n \n if @vertical\n #Normal position of the image (up)\n if values_bits[Constants::V_Image_position]< 4.5 \n @height = y2_array.max + @upper_margin\n #Alternative position(down)\n else \n new_height = @height - (y1_array.min-@upper_margin)\n \n @groups.each do |g|\n g.y_pos -= (@height - new_height)\n end\n @main_image.y_pos -= (@height - new_height)\n \n @height = new_height\n end\n else\n #Normal position of the image (left)\n if values_bits[Constants::V_Image_position]< 4.5\n @width = x2_array.max + @sides_margin\n #Alternative position of the image (right)\n else \n new_width = @width - (x1_array.min-@sides_margin)\n \n @groups.each do |g|\n g.x_pos -= (@width - new_width)\n end\n @main_image.x_pos -= (@width - new_width)\n \n @width = new_width\n end\n end\n end",
"def crop_layer(other_layer, crop_type)\n if crop_type == \"uni\"\n Log.info \"Uni dimension intersection\"\n # More cases have to be handled.\n new_bounds = self.bounds.outer_crop other_layer.bounds\n if self.type == Layer::LAYER_NORMAL\n left_offset = new_bounds.left - self.bounds.left\n top_offset = new_bounds.top - self.bounds.top\n self.crop_image_by_bounds(left_offset, top_offset, new_bounds.width, new_bounds.height)\n Log.info \"Cropped image #{self.extracted_image_path}\"\n end\n \n self.bounds = new_bounds\n self.initial_bounds = new_bounds\n end\n end",
"def from_top(y)\n bounds.top - bounds.bottom - y\n end",
"def pad\n truncate.center(truncate.size + 2)\n end",
"def crop\n @user = current_user\n end",
"def crop(geometry, anchor = :mc, anchor_y = nil)\n \t if anchor.is_a?(Symbol)\n easy_crop(geometry, anchor)\n\t else\n\t manual_crop(geometry, anchor, anchor_y)\n end\n \tend",
"def crop_bgimg\n if crop_x.present?\n bgimg.cache_stored_file!\n bgimg.retrieve_from_cache!(bgimg.cache_name)\n bgimg.recreate_versions!\n end\n end",
"def pad_image(image)\n\t\tdim = calc_side_length(image)\n\t\n\t\timage.background_color = @bg_color\n\t\t\n\t\tputs \"padding image\"\n\t\timage.extent(dim, dim)\n\tend",
"def test_alignBottomRight\n [@window, @sprite, @bitmap].each{|container|\n uc = UCIcon.new(container, Rect.new(0, 48, @window.contents.width, 72), 1, 2, 255, 2)\n uc.draw()\n }\n return true\n end",
"def split\n sw = (w / 2.0).round\n sh = (h / 2.0).round\n return Rect.new(x, y, sw, sh),\n Rect.new(x + sw, y, sw, sh),\n Rect.new(x, y + sh, sw, sh),\n Rect.new(x + sw, y + sh, sw, sh)\n end",
"def upper_centre\n @upper_centre ||= world.point(x_min + width/2.0, y_max)\n end",
"def crop(quality = 80)\n result = image.combine_options do |img|\n img.quality quality.to_s\n img.crop dimensions\n end\n File.open result.path\n end",
"def draw_diagonal_from_top_left(png, color)\n\tpng.polygon([0, 0, png.width, png.height], color)\nend",
"def resize_and_crop(size)\n manipulate! do |image|\n Rails.logger.error '----------- image:'\n Rails.logger.error image.inspect\n\n if image[:width] < image[:height]\n remove = ((image[:height] - image[:width]) / 2).round\n image.shave(\"0x#{remove}\")\n elsif image[:width] > image[:height]\n remove = ((image[:width] - image[:height]) / 2).round\n image.shave(\"#{remove}x0\")\n end\n image.resize(\"#{size}x#{size}\")\n image\n end\n end",
"def clip_padding(val = nil)\n return @properties[\"clipPadding\"] if !val\n @properties[\"clipPadding\"] = val\n return self\n end",
"def divide_top_bottom(top_fraction = 0.7)\n if top_fraction >= 1\n raise \"Error: Invalid top_fraction for TCanvas.divide_top_bottom().\"\n end\n @@Minification = 0.95\n cd(0)\n self.Divide(1, 2)\n self.GetPad(1).SetPad(0, (1 - top_fraction) * @@Minification,\n 1 * @@Minification, 1 * @@Minification)\n self.GetPad(2).SetPad(0, 0,\n 1 * @@Minification, (1 - top_fraction) * @@Minification)\n self.GetPad(1).SetFillStyle(0)\n self.GetPad(2).SetFillStyle(0)\n self.GetPad(1).SetMargin(0.15, 0.03, 0, 0.00)\n self.GetPad(2).SetMargin(0.15, 0.03, 0.26, 0.04)\n end",
"def crop_older(cutofftime)\n \tcrop_at(normalize_time_input(cutofftime))\n end",
"def trim_box(x0, y0, x1, y1)\n @pages.trim_box = [ x0, y0, x1, y1 ]\n end",
"def center_origins\n return if !self.bitmap\n self.ox = self.bitmap.width / 2\n self.oy = self.bitmap.height / 2\n end",
"def cropped\n lines.map { |line| columns(line) }\n end",
"def crop!(image, width, height, x_offset = 0, y_offset = 0, gravity: \"NorthWest\")\n with_minimagick(image) do |img|\n img.combine_options do |cmd|\n yield cmd if block_given?\n cmd.gravity gravity\n cmd.crop \"#{width}x#{height}+#{x_offset}+#{y_offset}\"\n end\n end\n end",
"def crop(success,message)\n $seed[:success] = success; $seed[:message] = message\n end",
"def clip(rect)\n self.dup.clip!(rect)\n end",
"def prepare!(max_side, watermark_img)\n if size == 1 and (columns > max_side or rows > max_side)\n resize_to_fit! max_side\n end\n\n watermark_mc watermark_img\n\n strip!\n end",
"def clip_off_wall\n if wall = clip then\n normal = NORMAL[wall]\n self.ga = (normal + random_turn(90)).degrees unless (normal - ga).abs < 45\n end\n end",
"def execute_crop(image, crop, x, y, width, height)\n require 'RMagick'\n # load in the original image\n old_image = Magick::Image::read(self.send(image).path).first\n # crop it at the desired position\n new_image = old_image.crop(x.to_i, y.to_i, width.to_i, height.to_i, true)\n # scale the image to the correct size if needed\n desired_width, desired_height = Image.detailed_dimensions(self.class, image, crop)\n if desired_width\n clean_desired_width = desired_width.gsub(/\\D/, '').to_f\n if desired_width.include?('>')\n new_image.scale!(clean_desired_width/width.to_f) if (width > clean_desired_width)\n elsif desired_width.include?('^')\n new_image.scale!(clean_desired_width/width.to_f) if (width < clean_desired_width)\n else\n new_image.scale!(clean_desired_width/width.to_f)\n end\n elsif desired_height\n clean_desired_height = desired_height.gsub(/\\D/, '').to_f\n if desired_height.include?('>')\n new_image.scale!(clean_desired_height/height.to_f) if (height > clean_desired_height)\n elsif desired_height.include?('^')\n new_image.scale!(clean_desired_height/height.to_f) if (height < clean_desired_height)\n else\n new_image.scale!(clean_desired_height/height.to_f)\n end\n end\n \n # need to make sure the image is the size it wanted to be in the first place as a pixel or 2 can b lost in the maths from the views\n # only do this if the requested dims allow it.\n if desired_width.to_i != 0 && desired_height.to_i != 0\n new_image.scale!(desired_width.to_i, desired_height.to_i)\n end\n \n FileUtils.mkdir_p(File.dirname(self.send(image).path(crop).to_s))\n new_image.write(self.send(image).path(crop).to_s)\n end",
"def padding; 3; end",
"def padding; end",
"def padding; end",
"def crop?\n @crop\n end",
"def crop?\n @crop\n end",
"def setup\n size 200, 200 \n no_stroke\n background 0 \n c = load_image \"cait.jpg\" \n xoff, yoff = 0, 0\n p = 2\n pix = p * 3 \n (c.width * c.height).times do |i| \n pixel = c.pixels[i] \n fill red( pixel ), 0, 0\n rect xoff, yoff, p, pix \n fill 0, green( pixel ), 0\n rect xoff+p, yoff, p, pix \n fill 0, 0, blue( pixel )\n rect xoff+p*2, yoff, p, pix \n xoff += pix\n if xoff >= (width-pix)\n xoff = 0\n yoff += pix\n end\n end \nend",
"def reset_clipping_rect\n @clip_x = @defaults[:clip_x]\n @clip_y = @defaults[:clip_y]\n @clip_width = @defaults[:clip_width]\n @clip_height = @defaults[:clip_height]\n end",
"def generate_white_spaces\n #Plain background\n if values_bits[Constants::V_Type_of_BG] > 4.5 \n if @vertical\n @white_space_w = @width - @sides_margin*2 \n @white_space_h = @height - (@main_image.height + @upper_img_margin + @upper_margin*2)\n @white_space_x = @sides_margin\n @white_space_y = values_bits[Constants::V_Image_position] < 4.5 ? @main_image.height+@upper_margin+@upper_img_margin : @upper_margin\n else\n @white_space_w = @width - (@main_image.width + @sides_img_margin + @sides_margin*2)\n @white_space_h = @height - @upper_margin*2\n @white_space_x = values_bits[Constants::V_Image_position] < 4.5 ? @main_image.width+2*@sides_margin : @sides_margin\n @white_space_y = @upper_margin\n end\n #Image as background\n else \n @white_space_w= @width - @sides_margin*2\n @white_space_h= @height - @upper_margin*2\n @white_space_x= @sides_margin\n @white_space_y= @upper_margin\n end\n \n @max_width = (@white_space_w.to_f * 0.60).to_i \n @max_width -= max_width%20 == 0 ? 0 : max_width%20\n # @groups.each do |g|\n # g.max_width = @max_width\n # end\n end",
"def crop(area)\n reset_meta_data\n segments.each do |seg|\n seg.crop(area)\n update_meta_data(seg) unless seg.empty?\n end\n segments.delete_if { |seg| seg.empty? }\n end",
"def black_bitmap\n bitmap = Bitmap.new(80, 60)\n bitmap.fill_rect(0,0,80,60,Color.new(10,10,10))\n return bitmap\n end"
] |
[
"0.73364794",
"0.7249829",
"0.6041177",
"0.59402835",
"0.59192324",
"0.58334166",
"0.5828233",
"0.578291",
"0.5733175",
"0.56458044",
"0.5579374",
"0.5560588",
"0.55474705",
"0.5534056",
"0.5444852",
"0.54284036",
"0.54114944",
"0.5406679",
"0.5357712",
"0.5355284",
"0.53462577",
"0.5311403",
"0.5306583",
"0.52998805",
"0.52997845",
"0.528894",
"0.52850986",
"0.5273311",
"0.52714753",
"0.52671105",
"0.5265959",
"0.52215415",
"0.5202265",
"0.5200434",
"0.51787156",
"0.51655656",
"0.51284915",
"0.5113195",
"0.51091075",
"0.5078136",
"0.50643826",
"0.5051559",
"0.50461215",
"0.5033408",
"0.5008951",
"0.5000244",
"0.49893844",
"0.4981066",
"0.4976773",
"0.4946208",
"0.4929044",
"0.49105242",
"0.49029452",
"0.49015474",
"0.48963773",
"0.4894631",
"0.48876384",
"0.48858666",
"0.4879914",
"0.4868618",
"0.484696",
"0.48453894",
"0.47935522",
"0.47856754",
"0.47854042",
"0.47810468",
"0.47753844",
"0.477525",
"0.47745568",
"0.47604087",
"0.47483864",
"0.47356924",
"0.47290897",
"0.47210026",
"0.47204822",
"0.4707337",
"0.47059298",
"0.47011974",
"0.46999493",
"0.46944982",
"0.46924818",
"0.4684599",
"0.46760193",
"0.46708938",
"0.46706536",
"0.46684727",
"0.4668385",
"0.4659",
"0.46477374",
"0.46450868",
"0.46357214",
"0.4623313",
"0.4623313",
"0.46209043",
"0.46209043",
"0.46191922",
"0.4592785",
"0.4585367",
"0.45839703",
"0.4581776"
] |
0.74008954
|
0
|
Create a crop of the mouth bottom lip with black padding on the top
|
def create_mouth_bottom_crop(mouth)
crop_size = "#{mouth.width}x#{mouth.chin_height+mouth.opening_size}"
crop_location = "+#{mouth.left_x}+#{mouth.middle}"
Commander.run!("convert #{@dir}/original.miff",
"-fill black -stroke black",
"-draw \"path '",
# Start line at the top left point
" M #{mouth.left}",
# Draw a curve to the right point
" C #{mouth.center_x},#{mouth.center_y+5}",
" #{mouth.center_x},#{mouth.center_y+5}",
# Finish line at the right point.
" #{mouth.right}'",
"\"",
# Add black padding to adjust how big the mouth opens.
"-gravity northwest -background black",
"-splice 0x#{mouth.opening_size}+0+#{mouth.middle}",
# Crop to get the results.
"-crop #{crop_size}#{crop_location}",
"#{@dir}/bottom.miff")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create_mouth_top_crop(mouth)\n crop_size = \"#{mouth.width}x#{mouth.height+5}\"\n crop_location = \"+#{mouth.left_x}+#{mouth.top}\"\n\n Commander.run!(\"convert #{@dir}/original.miff\",\n \"-fill black -stroke black\",\n\n \"-draw \\\"path '\",\n # Start line at the top left point\n \" M #{mouth.left}\",\n\n # Draw a curve to the right point.\n \" C #{mouth.center_x},#{mouth.center_y+5}\",\n \" #{mouth.center_x},#{mouth.center_y+5}\",\n \" #{mouth.right}\",\n\n # Draw a straight line to a point below the right point.\n \" L #{mouth.right_x},#{mouth.bottom+5}\",\n\n # Draw a straight line to a point below the left point.\n \" L #{mouth.left_x},#{mouth.bottom+5}\",\n\n # Close the figure so it can be filled.\n \" Z\",\n \"'\\\"\",\n\n \"-crop #{crop_size}#{crop_location}\",\n\n \"#{@dir}/top.miff\")\n end",
"def with_crop(left, top, right, bottom); end",
"def crop_canvas(c, h)\n return c.crop(0, 0, c.width, h) if c.height > h\n c\n end",
"def crop(t, l, b, r)\n orig_w = orig_h = 460\n new_w = r - l\n new_h = t - b\n o_x = l\n o_y = orig_h - t\n geom = \"#{new_w.round}x#{new_h.round}+#{o_x.round}+#{o_y.round}\"\n `convert #{@fn} -crop #{geom} +repage #{@fn}`\n end",
"def trim!(border = pixels.first)\n x1 = [*0...width].index { |c| column(c).uniq != [border] }\n x2 = [*0...width].rindex { |c| column(c).uniq != [border] }\n y1 = [*0...height].index { |r| row(r).uniq != [border] }\n y2 = [*0...height].rindex { |r| row(r).uniq != [border] }\n\n crop! x1, y1, x2 - x1 + 1, y2 - y1 + 1\n end",
"def crop(crop, input=nil, output=nil)\n inout \"crop=x=%{left}:y=%{top}:w=%{width}:h=%{height}\", input, output, crop\n end",
"def magick_crop_rect\n [x1, y1, x2-x1, y2-y1]\n end",
"def clip_to(x, y, w, h, &rendering_code); end",
"def bottom\n self.ox = self.src_rect.width/2\n self.oy = self.src_rect.height\n end",
"def crop\n return unless model.can_be_cropped?\n manipulate! do |image|\n image.combine_options do |command|\n command.crop(model.magick_thumbnail_coordinates)\n end\n image\n end\n end",
"def bottom!\n self.ox = self.width/2\n self.oy = self.height\n end",
"def crop image, x0 = 0, y0 = 0, w = 100, h = 100, scale = 1\n x0 = (x0.to_f * scale).to_i\n y0 = (y0.to_f * scale).to_i\n\n w = (w.to_f * scale).to_i\n h = (h.to_f * scale).to_i\n\n image.crop \"#{ w }x#{ h }+#{ x0 }+#{ y0 }\"\n image\n end",
"def crop(x, y, w, h)\n clone.crop!(x, y, w, h)\n end",
"def merge_top_and_bottom_of_mouth\n Commander.run!(\"convert #{@dir}/top.miff #{@dir}/bottom.miff\",\n \"-append #{@dir}/opened_mouth.miff\")\n end",
"def crop!(x,y,width,height)\n @x, @y, @w, @h = x, y, width, height\n self\n end",
"def round_corners(dst)\n command = \"\\\"#{ File.expand_path(@thumbnail.path) }[0]\\\" #{ transformation } \\\"#{ File.expand_path(dst.path) }\\\"\"\n Paperclip.run('convert', command)\n dst\n end",
"def crop_top_rows image, starting_row, outimage=nil\n raise \"number expected\" unless starting_row.class == Fixnum\n m_begin \"crop_top_rows\"\n img = get_image(image)\n cropped = img.excerpt(0, starting_row, img.columns, img.rows-starting_row)\n outimage = image if outimage.nil?\n put_image(outimage, cropped)\n m_end \"crop_top_rows\"\n end",
"def crop\n block = block_given? ? Proc.new : Arigatomation::LUMINANCE\n left_x, right_x, top_y, bottom_y = lrc.x, ulc.x, lrc.y, ulc.y\n changed = false\n\n each do |point|\n if !block.call(self[point])\n changed = true\n left_x = point.x if point.x < left_x\n right_x = point.x if point.x > right_x\n top_y = point.y if point.y < top_y\n bottom_y = point.y if point.y > bottom_y\n end\n end\n\n return self unless changed\n $log.debug \"CROPPED to #{[left_x, top_y, right_x, bottom_y].join(\", \")}\"\n capture(Arigatomation::Point.new(left_x, top_y), Arigatomation::Point.new(right_x, bottom_y))\n rescue\n $log.error \"Crop error: #{$!}\"\n end",
"def pbBottomRight(window)\n window.x=Graphics.width-window.width\n window.y=Graphics.height-window.height\nend",
"def topping; end",
"def cropper(crop_width, crop_height)\n manipulate! do |img|\n width = img.columns\n height= img.rows\n if width == crop_width and height==crop_height then\n img\n else\n img.crop(width / 2,height / 2,crop_width,crop_height)\n end\n end\n end",
"def trim(surface, trim, width, height)\n if trim > 0\n tmp = Cairo::ImageSurface.new(width-2*trim, height-2*trim)\n cc = Cairo::Context.new(tmp)\n cc.set_source(surface,-1*trim, -1*trim)\n cc.paint\n surface = tmp\n end\n surface\n end",
"def crop! (xoff, yoff, width, height)\n @transforms << \"CR#{xoff},#{yoff},#{width},#{height}\"\n self\n end",
"def trim(surface, trim, width, height)\n if trim > 0\n tmp = Cairo::ImageSurface.new(width - 2 * trim, height - 2 * trim)\n cc = Cairo::Context.new(tmp)\n cc.set_source(surface, -1 * trim, -1 * trim)\n cc.paint\n surface = tmp\n end\n surface\n end",
"def padded(padding = 2, &block)\n r = bounds\n padding ||= 2\n bounding_box([padding, r.top - padding], width: r.width - (2 * padding), &block)\n end",
"def crop_rows!\n if crop\n local_copy.in_place :tail, \"+#{crop.first}\"\n local_copy.in_place :head, (crop.last - crop.first + 1)\n end\n end",
"def unpadded_height\n height = 0\n padding = self.get_padding\n height = self.bounds.height - (padding[:top] + padding[:bottom])\n return height\n end",
"def crop!(x, y, w, h)\n ptr = self.class.create_image_ptr(w, h, alpha_blending?)\n ::GD2::GD2FFI.send(:gdImageCopy, ptr, image_ptr, 0, 0, x.to_i, y.to_i, w.to_i, h.to_i)\n init_with_image(ptr)\n end",
"def max_crop_area_growth(crop_from, crop_size)\n {\n top: crop_from[:y],\n right: image_size[:width] - crop_from[:x] - crop_size[:width],\n bottom: image_size[:height] - crop_from[:y] - crop_size[:height],\n left: crop_from[:x],\n }\n end",
"def crop!(x, y, w, h)\n prefull, orig = model.actual_dimensions(:prefull), model.actual_dimensions\n ratio = [orig[0].to_f / prefull[0], orig[1].to_f / prefull[1]].min\n x, y, w, h = [x, y, w, h].map { |n| (n * ratio).floor }\n manipulate! do |img|\n img.crop \"#{w}x#{h}+#{x}+#{y}\"\n img = yield(img) if block_given?\n img\n end\n end",
"def crop\n return if model.crop_x.blank?\n resize_to_limit(300, 300)\n manipulate! do |img|\n x = model.crop_x.to_i\n y = model.crop_y.to_i\n w = model.crop_w.to_i\n h = model.crop_h.to_i\n img.crop!(x, y, w, h)\n end\n end",
"def trim(border = pixels.first)\n dup.trim!\n end",
"def fit_pinning_top\n union_frame = frame_for_subviews\n \n # # balance horizontally - offset x based on diff between old and new widths.\n # width_change = union_frame.width - self.width \n # new_x = self.x - width_change / 2\n new_x = self.x\n\n # pin at the top - offset y based on original top location and new height.\n new_y = self.frame.top_y - union_frame.height\n\n # we need to apply a vertical offset to all subviews later.\n delta_y = (new_y - self.y)\n\n # set the frame (and pray)\n self.frame = new_rect new_x, new_y, union_frame.width, union_frame.height\n\n self.subviews.each do |subview|\n if delta_y > 0 # we need to grow - move subview y up.\n subview.y += delta_y\n else # we need to shrink - move subview y down.\n subview.y -= delta_y\n end\n end\n end",
"def recreate_cropped_image\n if file.exists?\n img = ThumbMagick::Image.new(file.path('tocrop'))\n img.\n thumbnail(\"#{ (resize * 100).to_i }%\").\n crop(\"#{crop_w}x#{crop_h}\", crop_x, crop_y).\n write(file.path('cropped'))\n end \n end",
"def divide_top_bottom(top_fraction = 0.7)\n if top_fraction >= 1\n raise \"Error: Invalid top_fraction for TCanvas.divide_top_bottom().\"\n end\n @@Minification = 0.95\n cd(0)\n self.Divide(1, 2)\n self.GetPad(1).SetPad(0, (1 - top_fraction) * @@Minification,\n 1 * @@Minification, 1 * @@Minification)\n self.GetPad(2).SetPad(0, 0,\n 1 * @@Minification, (1 - top_fraction) * @@Minification)\n self.GetPad(1).SetFillStyle(0)\n self.GetPad(2).SetFillStyle(0)\n self.GetPad(1).SetMargin(0.15, 0.03, 0, 0.00)\n self.GetPad(2).SetMargin(0.15, 0.03, 0.26, 0.04)\n end",
"def banner_skrollr_offset(banner)\n (banner.img_height(SemiStatic::Engine.config.theme, :desktop)/4 - 50).to_s\n end",
"def crop!(left: 0, top: 0, width: nil, height: nil)\n manipulate! do |image|\n begin\n do_crop image, left, top, width, height\n rescue VIPS::Error => e\n e.message =~ /extract_area/ ? image : raise(e)\n end\n end\n end",
"def cut\n rmagick_img.crop_resized!(@x, @y, gravity)\n end",
"def crop(rect)\n if self.scale > 1.0\n rect = CGRectMake(rect.origin.x * self.scale,\n rect.origin.y * self.scale,\n rect.size.width * self.scale,\n rect.size.height * self.scale)\n end\n\n cgimage = CGImageCreateWithImageInRect(self.CGImage, rect)\n result = UIImage.imageWithCGImage(cgimage, scale:self.scale, orientation:self.imageOrientation)\n\n return result\n end",
"def from_top(y)\n bounds.top - bounds.bottom - y\n end",
"def bottom_cut(pack,cut=nil)\n if cut == nil\n cut = rand(1...pack.length) * -1\n end\n bottom = pack.slice(cut..-1)\n top = pack.slice(0..cut-1)\n cut_pack = bottom + top\n p \"#{cut.abs} card(s) cut from bottom of deck.\"\n cut_pack\n end",
"def clip\n max_h, max_w = w.h, w.w\n\n if x < 0 then\n self.x = x.abs\n return :west\n elsif x > max_w then\n self.x = 2 * max_w - x\n return :east\n end\n\n if y < 0 then\n self.y = y.abs\n return :south\n elsif y > max_h then\n self.y = 2 * max_h - y\n return :north\n end\n\n nil\n end",
"def bottom_cut(pack,cut=nil)\nif cut == nil\ncut = rand(1...pack.length) * -1\nend\nbottom = pack.slice(cut..-1)\ntop = pack.slice(0..cut-1)\ncut_pack = bottom + top\np \"#{cut.abs} card(s) cut from bottom of deck.\"\ncut_pack\nend",
"def merge_opened_mouth_on_canvas(mouth)\n Commander.run!(\"composite\",\n \"#{@dir}/opened_mouth.miff #{@dir}/opened_mouths.miff\",\n \"-gravity northwest -geometry +#{mouth.x}+#{mouth.y}\",\n \"#{@dir}/opened_mouths.miff\")\n end",
"def thumb_crop\n { x: model.profile_image_crop_param_x,\n y: model.profile_image_crop_param_y,\n width: model.profile_image_crop_param_width,\n height: model.profile_image_crop_param_height,\n crop: :crop\n }\n end",
"def resize_and_crop(size) \n manipulate! do |image| \n if image[:width] < image[:height]\n remove = (image[:height] - 135).round \n image.shave(\"0x#{remove}\") \n elsif image[:width] > image[:height] \n remove = ((image[:width] - image[:height])/2).round\n image.shave(\"#{remove}x0\")\n end\n image.resize(\"#{size}\")\n image\n end\n end",
"def side_crop side, rowcol, image, starting, outimage=nil\n m_begin \"side_crop\"\n raise \"number expected\" unless starting.class == Fixnum\n raise \"side wrong: #{side}\" unless [:top, :bottom, :left, :right].member? side\n raise \"rowcol wrong: #{rowcol}\" unless [:row, :column].member? rowcol\n img = get_image(image)\n case [side, rowcol]\n when [:left, :column]\n cropped = img.excerpt(starting, 0, img.columns-starting, img.rows)\n when [:right, :column]\n cropped = img.excerpt(0, 0, img.columns-starting, img.rows)\n when [:top, :row]\n cropped = img.excerpt(0, starting, img.columns, img.rows-starting)\n when [:bottom, :row]\n cropped = img.excerpt(0, 0, img.columns, img.rows-starting)\n else\n raise \"invalid rowcol and side combination\"\n end\n outimage = image if outimage.nil?\n put_image(outimage, cropped)\n m_end \"side_crop\"\n end",
"def prepare_strip\r\n @strip = []\r\n for i in 0...@totalFrames\r\n bitmap = Bitmap.new(@width,@height)\r\n bitmap.stretch_blt(Rect.new(0,0,@width,@height),@bitmaps[i],Rect.new(0,0,@width,@height))\r\n @strip.push(bitmap)\r\n end\r\n end",
"def outer_height; rect.height + @border_thickness * 2; end",
"def cover\n manipulate! do |frame, index|\n frame if index.zero?\n end\n end",
"def square_image_crop\n if (self.crops)\n if !(self.crop_x.nil? || self.crop_y.nil? || self.crop_w.nil? || self.crop_h.nil?)\n @image = MiniMagick::Image.open(self.photo.url)\n # if image is larger than our max screen size, the cropped image will be incorrect (resizing)\n @image.sample(((700/@image[:width].to_f) * 100).to_s + \"%\") if @image[:width] > 700\n @image.crop(\"#{self.crop_w}x#{self.crop_h}+#{self.crop_x}+#{self.crop_y}\")\n @image.set(\"page\", \"#{self.crop_w}x#{self.crop_h}+#{self.crop_x}+#{self.crop_y}\") \n self.square_image = @image\n end\n end\n end",
"def cropped_thumbnail(size) # :yields: image\n w, h = width, height\n l, t, r, b, half = 0, 0, w, h, (w - h).abs / 2\n\n l, r = half, half + h if w > h\n t, b = half, half + w if h > w\n\n with_crop(l, t, r, b) do |img|\n img.thumbnail(size) do |thumb|\n yield thumb\n end\n end\n end",
"def maskify(cc)\n cc.size < 5 ? cc : cc[-4..-1].rjust(cc.size, '#')\nend",
"def midbottom; return self.centerx, self.bottom; end",
"def border_slicer(board)\n board.pop()\n board.shift()\n \n row = 0\n while row < self.height do\n board[row].pop()\n board[row].shift()\n row += 1\n end\n \n return board\n end",
"def crop_insets(number)\n jpg_path = $jpg_path.gsub(\"{CHART_NUMBER}\", number.to_s)\n preprocessed_jpg_path = $preprocessed_jpg_path.gsub(\"{CHART_NUMBER}\", number.to_s)\n \n res = $dbh.query(\"SELECT * FROM ocpn_nga_charts WHERE number=#{number}\")\n\n while row = res.fetch_hash do\n puts \"Cropping insets and generating their corners for chart #{row[\"number\"]}\"\n \n # If rotated, use preprocessed JPG\n if (row[\"prerotate\"].to_i != 0)\n jpg = preprocessed_jpg_path\n else\n jpg = jpg_path\n end\n end\n res = $dbh.query(\"SELECT *, (SELECT MIN(x) FROM ocpn_nga_kap_point WHERE point_type='CROP' AND active=1 AND kap_id=k.kap_id) AS x, (SELECT MAX(x) FROM ocpn_nga_kap_point WHERE point_type='CROP' AND active=1 AND kap_id=k.kap_id) AS x1, (SELECT MIN(y) FROM ocpn_nga_kap_point WHERE point_type='CROP' AND active=1 AND kap_id=k.kap_id) AS y, (SELECT MAX(y) FROM ocpn_nga_kap_point WHERE point_type='CROP' AND active=1 AND kap_id=k.kap_id) AS y1 FROM ocpn_nga_kap k WHERE bsb_type!='BASE' AND active=1 AND number=#{number}\")\n while row = res.fetch_hash do\n corner_size = row[\"cornersize\"]\n puts corner_size\n # check whether the data entered are ok\n if(row[\"x\"].to_i >= 0 && row[\"y\"].to_i >= 0 && row[\"x1\"].to_i > row[\"x\"].to_i && row[\"y1\"].to_i > row[\"y\"].to_i)\n inset_path = $inset_path.gsub(\"{CHART_NUMBER}\", number.to_s).gsub(\"{INSET}\", row[\"inset_id\"])\n `#{$convert_command} #{jpg} -crop #{row[\"x1\"].to_i - row[\"x\"].to_i}x#{row[\"y1\"].to_i - row[\"y\"].to_i}+#{row[\"x\"]}+#{row[\"y\"]} #{inset_path}`\n \n # create corner cut-outs\n corner_path = $corner_path.gsub(\"{CHART_NUMBER}\", number.to_s).gsub(\"{INSET}\", row[\"inset_id\"]).gsub(\"{CORNER}\", 'sw')\n `#{$convert_command} #{inset_path} -gravity SouthWest -crop #{corner_size}x#{corner_size}+0+0 -depth 8 -type Palette -colors 32 png8:#{corner_path}`\n corner_path = $corner_path.gsub(\"{CHART_NUMBER}\", number.to_s).gsub(\"{INSET}\", row[\"inset_id\"]).gsub(\"{CORNER}\", 'nw')\n `#{$convert_command} #{inset_path} -gravity NorthWest -crop #{corner_size}x#{corner_size}+0+0 -depth 8 -type Palette -colors 32 png8:#{corner_path}`\n corner_path = $corner_path.gsub(\"{CHART_NUMBER}\", number.to_s).gsub(\"{INSET}\", row[\"inset_id\"]).gsub(\"{CORNER}\", 'ne')\n `#{$convert_command} #{inset_path} -gravity NorthEast -crop #{corner_size}x#{corner_size}+0+0 -depth 8 -type Palette -colors 32 png8:#{corner_path}`\n corner_path = $corner_path.gsub(\"{CHART_NUMBER}\", number.to_s).gsub(\"{INSET}\", row[\"inset_id\"]).gsub(\"{CORNER}\", 'se')\n `#{$convert_command} #{inset_path} -gravity SouthEast -crop #{corner_size}x#{corner_size}+0+0 -depth 8 -type Palette -colors 32 png8:#{corner_path}`\n \n $dbh.query(\"UPDATE ocpn_nga_kap SET cropped=CURRENT_TIMESTAMP() WHERE kap_id=#{row[\"kap_id\"]}\")\n end\n end\n end",
"def bottom()\n return @top + @height\n end",
"def draw_diagonal_from_top_left(png, color)\n\tpng.polygon([0, 0, png.width, png.height], color)\nend",
"def crop(x, y, crop_width, crop_height)\n dup.crop!(x, y, crop_width, crop_height)\n end",
"def cut_white_space_edges\n x1_array = Array.new\n x2_array = Array.new\n y1_array = Array.new\n y2_array = Array.new\n \n @groups.each do |g|\n x1_array << g.x_pos\n x2_array << g.x_pos + g.width\n y1_array << g.y_pos\n y2_array << g.y_pos + g.height\n end\n \n if @vertical\n #Normal position of the image (up)\n if values_bits[Constants::V_Image_position]< 4.5 \n @height = y2_array.max + @upper_margin\n #Alternative position(down)\n else \n new_height = @height - (y1_array.min-@upper_margin)\n \n @groups.each do |g|\n g.y_pos -= (@height - new_height)\n end\n @main_image.y_pos -= (@height - new_height)\n \n @height = new_height\n end\n else\n #Normal position of the image (left)\n if values_bits[Constants::V_Image_position]< 4.5\n @width = x2_array.max + @sides_margin\n #Alternative position of the image (right)\n else \n new_width = @width - (x1_array.min-@sides_margin)\n \n @groups.each do |g|\n g.x_pos -= (@width - new_width)\n end\n @main_image.x_pos -= (@width - new_width)\n \n @width = new_width\n end\n end\n end",
"def pps(pp)\n [\n pp[:tl][:x], pp[:tl][:y], 0, 0,\n pp[:tr][:x], pp[:tr][:y], width, 0,\n pp[:br][:x], pp[:br][:y], width, height,\n pp[:bl][:x], pp[:bl][:y], 0, height\n ].join ' '\n end",
"def crop_avatar(args)\n self.crop_x = args[\"crop_x\"]\n self.crop_y = args[\"crop_y\"]\n self.crop_w = args[\"crop_w\"]\n self.crop_h = args[\"crop_h\"]\n avatar.reprocess!\n end",
"def _white_arrow\n b = Bitmap.new(56, 14)\n c1 = Color.new(0, 0, 0)\n c2 = Color.new(255, 255, 255)\n b.set_pixel(23, 0, c1)\n b.set_pixel(32, 0, c1)\n b.set_pixel(22, 1, c1)\n b.fill_rect(23, 1, 1, 12, c2)\n b.fill_rect(24, 1, 1, 12, c1)\n b.fill_rect(31, 1, 1, 12, c1)\n b.fill_rect(32, 1, 1, 12, c2)\n b.set_pixel(33, 1, c1)\n b.set_pixel(21, 2, c1)\n b.fill_rect(22, 2, 1, 10, c2)\n b.fill_rect(33, 2, 1, 10, c2)\n b.set_pixel(34, 2, c1)\n b.fill_rect(1, 3, 12, 1, c1)\n b.set_pixel(20, 3, c1)\n b.fill_rect(21, 3, 1, 8, c2)\n b.fill_rect(34, 3, 1, 8, c2)\n b.set_pixel(35, 3, c1)\n b.fill_rect(48, 3, 2, 1, c1)\n b.set_pixel(0, 4, c1)\n b.fill_rect(1, 4, 12, 1, c2)\n b.set_pixel(13, 4, c1)\n b.set_pixel(19, 4, c1)\n b.fill_rect(20, 4, 1, 6, c2)\n b.fill_rect(35, 4, 1, 6, c2)\n b.set_pixel(36, 4, c1)\n b.set_pixel(47, 4, c1)\n b.fill_rect(48, 4, 2, 6, c2)\n b.set_pixel(50, 4, c1)\n b.set_pixel(1, 5, c1)\n b.fill_rect(2, 5, 10, 1, c2)\n b.set_pixel(12, 5, c1)\n b.set_pixel(18, 5, c1)\n b.fill_rect(19, 5, 1, 4, c2)\n b.fill_rect(36, 5, 1, 4, c2)\n b.set_pixel(37, 5, c1)\n b.set_pixel(46, 5, c1)\n b.fill_rect(47, 5, 1, 5, c2)\n b.fill_rect(50, 5, 1, 5, c2)\n b.set_pixel(51, 5, c1)\n b.set_pixel(2, 6, c1)\n b.fill_rect(3, 6, 8, 1, c2)\n b.set_pixel(11, 6, c1)\n b.fill_rect(17, 6, 1, 2, c1)\n b.fill_rect(18, 6, 1, 2, c2)\n b.fill_rect(37, 6, 1, 2, c2)\n b.fill_rect(38, 6, 1, 2, c1)\n b.set_pixel(45, 6, c1)\n b.fill_rect(46, 6, 1, 4, c2)\n b.fill_rect(51, 6, 1, 4, c2)\n b.set_pixel(52, 6, c1)\n b.set_pixel(3, 7, c1)\n b.fill_rect(4, 7, 6, 1, c2)\n b.set_pixel(10, 7, c1)\n b.set_pixel(44, 7, c1)\n b.fill_rect(45, 7, 1, 3, c2)\n b.fill_rect(52, 7, 1, 3, c2)\n b.set_pixel(53, 7, c1)\n b.set_pixel(4, 8, c1)\n b.fill_rect(5, 8, 4, 1, c2)\n b.set_pixel(9, 8, c1)\n b.set_pixel(18, 8, c1)\n b.set_pixel(37, 8, c1)\n b.set_pixel(43, 8, c1)\n b.fill_rect(44, 8, 1, 2, c2)\n b.fill_rect(53, 8, 1, 2, c2)\n b.set_pixel(54, 8, c1)\n b.set_pixel(5, 9, c1)\n b.fill_rect(6, 9, 2, 1, c2)\n b.set_pixel(8, 9, c1)\n b.set_pixel(19, 9, c1)\n b.set_pixel(36, 9, c1)\n b.set_pixel(42, 9, c1)\n b.set_pixel(43, 9, c2)\n b.set_pixel(54, 9, c2)\n b.set_pixel(55, 9, c1)\n b.fill_rect(6, 10, 2, 1, c1)\n b.set_pixel(20, 10, c1)\n b.set_pixel(35, 10, c1)\n b.fill_rect(43, 10, 12, 1, c1)\n b.set_pixel(21, 11, c1)\n b.set_pixel(34, 11, c1)\n b.set_pixel(22, 12, c1)\n b.set_pixel(33, 12, c1)\n b.set_pixel(23, 13, c1)\n b.set_pixel(32, 13, c1)\n return b\n end",
"def test_alignBottomRight\n [@window, @sprite, @bitmap].each{|container|\n uc = UCIcon.new(container, Rect.new(0, 48, @window.contents.width, 72), 1, 2, 255, 2)\n uc.draw()\n }\n return true\n end",
"def crop(*args)\n with_command %(-crop \"#{Geometry.new(*args).to_s(true)}\")\n end",
"def bottom_panel\n FFI::NCurses.bottom_panel(@pointer)\n end",
"def crop_logo\n logo.recreate_versions! if crop_logo_x.present?\n end",
"def generate_white_spaces\n #Plain background\n if values_bits[Constants::V_Type_of_BG] > 4.5 \n if @vertical\n @white_space_w = @width - @sides_margin*2 \n @white_space_h = @height - (@main_image.height + @upper_img_margin + @upper_margin*2)\n @white_space_x = @sides_margin\n @white_space_y = values_bits[Constants::V_Image_position] < 4.5 ? @main_image.height+@upper_margin+@upper_img_margin : @upper_margin\n else\n @white_space_w = @width - (@main_image.width + @sides_img_margin + @sides_margin*2)\n @white_space_h = @height - @upper_margin*2\n @white_space_x = values_bits[Constants::V_Image_position] < 4.5 ? @main_image.width+2*@sides_margin : @sides_margin\n @white_space_y = @upper_margin\n end\n #Image as background\n else \n @white_space_w= @width - @sides_margin*2\n @white_space_h= @height - @upper_margin*2\n @white_space_x= @sides_margin\n @white_space_y= @upper_margin\n end\n \n @max_width = (@white_space_w.to_f * 0.60).to_i \n @max_width -= max_width%20 == 0 ? 0 : max_width%20\n # @groups.each do |g|\n # g.max_width = @max_width\n # end\n end",
"def calc_height; padding * 2 + base_height; end",
"def calc_height; padding * 2 + base_height; end",
"def crop(*args)\n @source = Cropper.new(@source, *args)\n self\n end",
"def pad_top(y)\n move_down(y)\n yield\n end",
"def clip_padding(val = nil)\n return @properties[\"clipPadding\"] if !val\n @properties[\"clipPadding\"] = val\n return self\n end",
"def split\n sw = (w / 2.0).round\n sh = (h / 2.0).round\n return Rect.new(x, y, sw, sh),\n Rect.new(x + sw, y, sw, sh),\n Rect.new(x, y + sh, sw, sh),\n Rect.new(x + sw, y + sh, sw, sh)\n end",
"def cut_image(source, width, height, dest = nil)\r\n dest ||= default_dest(source, \"cut\")\r\n image = MiniMagick::Image.from_file(source)\r\n image.crop \"#{width}x#{height}+0+0\"\r\n image.write dest\r\n dest\r\n end",
"def setup\n size 200, 200 \n no_stroke\n background 0 \n c = load_image \"cait.jpg\" \n xoff, yoff = 0, 0\n p = 2\n pix = p * 3 \n (c.width * c.height).times do |i| \n pixel = c.pixels[i] \n fill red( pixel ), 0, 0\n rect xoff, yoff, p, pix \n fill 0, green( pixel ), 0\n rect xoff+p, yoff, p, pix \n fill 0, 0, blue( pixel )\n rect xoff+p*2, yoff, p, pix \n xoff += pix\n if xoff >= (width-pix)\n xoff = 0\n yoff += pix\n end\n end \nend",
"def clip(rect)\n self.dup.clip!(rect)\n end",
"def add_border(size=3,r=0,g=0,b=0)\n width = @x_size+2*size\n height = @y_size+2*size\n resampled = image_create_true_color(width,height)\n image_filled_rectangle(resampled,0,0,width,height, r, g, b)\n image_copy(@picture,resampled,size,size,0,0,@x_size,@y_size)\n image_destroy(@picture)\n @x_size = width\n @y_size = height\n @picture = image_create_true_color(@x_size,@y_size)\n image_filled_rectangle(@picture,0,0,@x_size,@y_size,255,255,255)\n image_color_transparent(@picture,255,255,255)\n image_copy(resampled,@picture,0,0,0,0,@x_size,@y_size)\n end",
"def pad_image(image)\n\t\tdim = calc_side_length(image)\n\t\n\t\timage.background_color = @bg_color\n\t\t\n\t\tputs \"padding image\"\n\t\timage.extent(dim, dim)\n\tend",
"def cloud_top\n min, max = n, height - 2*n\n top = max\n top = rand(height - 2*n) + n until top < max\n top\n end",
"def _empty_hud_white_bar\n b = Bitmap.new(1, 12)\n (1..6).each {|i| b.fill_rect(0, i-1, 1, 14-i*2, Color.new(40*i/3, 40*i/3, 40*i/3))}\n return b\n end",
"def compose_slice_on_canvas(target, slice, x, y, width, height)\n source_canvas = slice[:canvas] || slice[:file][:canvas]\n source_width = slice[:sprite_slice_width]\n source_height = slice[:sprite_slice_height]\n\n top = 0\n left = 0\n\n # Repeat the pattern to fill the width/height.\n while top < height do\n left = 0\n\n while left < width do\n if target.respond_to?(:replace!)\n target.replace!(source_canvas, left + x, top + y)\n else\n target.composite!(source_canvas, left + x, top + y)\n end\n\n left += source_width\n end\n\n top += source_height\n end\n\n end",
"def cropping_mask\n return if crop_from.blank? || crop_size.blank?\n\n crop_from = point_from_string(read_attribute(:crop_from))\n crop_size = sizes_from_string(read_attribute(:crop_size))\n\n point_and_mask_to_points(crop_from, crop_size)\n end",
"def crop_to(width, height)\n # Checks that crop area is defined and crop should be done.\n if ((crop_args[0] == crop_args[2]) || (crop_args[1] == crop_args[3]))\n # If not creates default image and saves it's dimensions.\n resize_to_fill_and_save_dimensions(width, height)\n else\n args = crop_args + [width, height]\n crop_and_resize(*args)\n end\n end",
"def collage_canvas_styles\n styles = []\n styles << 'height: 0px'\n styles << \"padding-bottom: #{collage_height_ratio}%\"\n styles.join('; ')\n end",
"def crop_bgimg\n if crop_x.present?\n bgimg.cache_stored_file!\n bgimg.retrieve_from_cache!(bgimg.cache_name)\n bgimg.recreate_versions!\n end\n end",
"def vertically_striped(unstriped)\n output = unstriped.dup\n row_width = output[0].length\n\n # Zero out top and bottom 2 rows\n output[0] = [0] * row_width\n output[1] = [0] * row_width\n output[-1] = [0] * row_width\n output[-2] = [0] * row_width\n output\n end",
"def easy_crop(geometry, anchor)\n ow,oh = dimensions # Before crop\n \t w,h = geometry.strip.split('x').map{|n|n.to_i} # Target dimensions\n \t\tanchor_x, anchor_y = case anchor\n \t\t\twhen :tl\n \t\t\t\t[ 0 , 0 ]\n \t\t\twhen :tc\n \t\t\t\t[ ((ow - w) / 2.0).round , 0]\n \t\t\twhen :tr\n \t\t\t\t[ ow - w , 0 ]\n \t\t\twhen :ml\n \t\t\t\t[ 0 , ((oh - h) / 2.0).round ]\n \t\t\twhen :mc\n \t\t\t\t[ ((ow - w) / 2.0).round , ((oh - h) / 2.0).round ]\n \t\t\twhen :mr\n \t\t\t\t[ ow - w , ((oh - h) / 2.0).round ]\n \t\t\twhen :bl\n \t\t\t\t[ 0 , oh - h]\n \t\t\twhen :bc\n \t\t\t\t[ ((ow - w) / 2.0).round , oh - h ]\n \t\t\twhen :br\n \t\t\t\t[ ow - w , oh - h]\n \t\tend\n \t\tmanual_crop(geometry, anchor_x, anchor_y)\n\t end",
"def black_bitmap\n bitmap = Bitmap.new(80, 60)\n bitmap.fill_rect(0,0,80,60,Color.new(10,10,10))\n return bitmap\n end",
"def check_mouth\n\t\t\tx = @glabella_start_x_position + (@glabella_width / 2).round\n\t\t\ty = ((@glabella_start_y_position + @left_eye_width + @glabella_width + @right_eye_width) * 0.7).round\n\t\t\tmouth_pixel_color = @image.pixel_color(x, y)\n\t\t\t\n\t\t\tif mouth_pixel_color.red <= COLOR_THRESHOLD\n\t\t\t\tdebug_output(x, y)\n\t\t\t\twrite_to_image(x, y, '#f00')\n\t\t\t\treturn true\n\t\t\tend\n\t\t\treturn false\n\t\tend",
"def clip_off_wall\n if wall = clip then\n normal = NORMAL[wall]\n self.ga = (normal + random_turn(90)).degrees unless (normal - ga).abs < 45\n end\n end",
"def PcbSmartPad(x1, y1, x2, y2, thickness, name, number, flags)\n clearance = GetDim('clearance') * 2\n mask = GetDim('mask') * 2 + thickness\n PcbPad(x1, y1, x2, y2, thickness, clearance, mask, name, number, flags)\nend",
"def trim_box(x0, y0, x1, y1)\n @pages.trim_box = [ x0, y0, x1, y1 ]\n end",
"def bottom_left\n Point[x, y + height]\n end",
"def prepare!(max_side, watermark_img)\n if size == 1 and (columns > max_side or rows > max_side)\n resize_to_fit! max_side\n end\n\n watermark_mc watermark_img\n\n strip!\n end",
"def paper_white_area() barcode_bit_area -1 end",
"def padding; end",
"def padding; end",
"def height\n top - bottom\n end",
"def draw_borders\n if borders.top > 0 # TODO: :none\n options = translate( x: margins.left, y: margins.top ).merge( width: width + margins.width, height: borders.top, foreground: borders.foreground, background: Termbox::RED )\n \n pencil.draw_rectangle( options )\n end\n \n if borders.bottom > 0 # TODO: :none\n options = translate( x: margins.left, y: offsets.top + padding.bottom ).merge( width: width + margins.width, height: borders.bottom, foreground: borders.foreground, background: Termbox::RED )\n \n pencil.draw_rectangle( options )\n end\n end"
] |
[
"0.729578",
"0.7122948",
"0.59803075",
"0.57959604",
"0.5711049",
"0.5654403",
"0.5654206",
"0.5593234",
"0.5569859",
"0.55124867",
"0.54715115",
"0.5461746",
"0.54123026",
"0.53917235",
"0.5382463",
"0.53485173",
"0.5310281",
"0.53098184",
"0.5307977",
"0.53079116",
"0.530102",
"0.5298391",
"0.52685964",
"0.5232399",
"0.5198209",
"0.5190674",
"0.5172056",
"0.51699096",
"0.51134723",
"0.509952",
"0.50753605",
"0.5060912",
"0.50589585",
"0.5042628",
"0.50422007",
"0.503811",
"0.50223213",
"0.4992512",
"0.49909726",
"0.4965066",
"0.49637744",
"0.49635684",
"0.4908883",
"0.49029812",
"0.48987067",
"0.48966402",
"0.4896258",
"0.4895669",
"0.48849052",
"0.4884078",
"0.48826653",
"0.48776016",
"0.48747763",
"0.48647493",
"0.48632705",
"0.4858785",
"0.48536044",
"0.48439226",
"0.48368534",
"0.48306912",
"0.48029557",
"0.4801229",
"0.4796381",
"0.47927117",
"0.4779071",
"0.47776204",
"0.477136",
"0.47658005",
"0.47616673",
"0.47616673",
"0.47564328",
"0.47368655",
"0.4733683",
"0.4731128",
"0.47268933",
"0.47144726",
"0.47080022",
"0.4704396",
"0.4701592",
"0.47010303",
"0.468499",
"0.46767497",
"0.46752948",
"0.46728083",
"0.46711686",
"0.4670737",
"0.4670362",
"0.46691105",
"0.4658502",
"0.46442738",
"0.46347687",
"0.46347505",
"0.4621691",
"0.4620123",
"0.46104577",
"0.45979318",
"0.45943022",
"0.45943022",
"0.4589355",
"0.45882297"
] |
0.72931176
|
1
|
Merge the top and bottom part of the mouth to create the opened mouth.
|
def merge_top_and_bottom_of_mouth
Commander.run!("convert #{@dir}/top.miff #{@dir}/bottom.miff",
"-append #{@dir}/opened_mouth.miff")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def merge_opened_mouth_on_canvas(mouth)\n Commander.run!(\"composite\",\n \"#{@dir}/opened_mouth.miff #{@dir}/opened_mouths.miff\",\n \"-gravity northwest -geometry +#{mouth.x}+#{mouth.y}\",\n \"#{@dir}/opened_mouths.miff\")\n end",
"def create_mouth_bottom_crop(mouth)\n crop_size = \"#{mouth.width}x#{mouth.chin_height+mouth.opening_size}\"\n crop_location = \"+#{mouth.left_x}+#{mouth.middle}\"\n\n Commander.run!(\"convert #{@dir}/original.miff\",\n \"-fill black -stroke black\",\n\n \"-draw \\\"path '\",\n\n # Start line at the top left point\n \" M #{mouth.left}\",\n\n # Draw a curve to the right point\n \" C #{mouth.center_x},#{mouth.center_y+5}\",\n \" #{mouth.center_x},#{mouth.center_y+5}\",\n\n # Finish line at the right point.\n \" #{mouth.right}'\",\n \"\\\"\",\n\n # Add black padding to adjust how big the mouth opens.\n \"-gravity northwest -background black\",\n \"-splice 0x#{mouth.opening_size}+0+#{mouth.middle}\",\n\n # Crop to get the results.\n \"-crop #{crop_size}#{crop_location}\",\n\n \"#{@dir}/bottom.miff\")\n end",
"def create_mouth_top_crop(mouth)\n crop_size = \"#{mouth.width}x#{mouth.height+5}\"\n crop_location = \"+#{mouth.left_x}+#{mouth.top}\"\n\n Commander.run!(\"convert #{@dir}/original.miff\",\n \"-fill black -stroke black\",\n\n \"-draw \\\"path '\",\n # Start line at the top left point\n \" M #{mouth.left}\",\n\n # Draw a curve to the right point.\n \" C #{mouth.center_x},#{mouth.center_y+5}\",\n \" #{mouth.center_x},#{mouth.center_y+5}\",\n \" #{mouth.right}\",\n\n # Draw a straight line to a point below the right point.\n \" L #{mouth.right_x},#{mouth.bottom+5}\",\n\n # Draw a straight line to a point below the left point.\n \" L #{mouth.left_x},#{mouth.bottom+5}\",\n\n # Close the figure so it can be filled.\n \" Z\",\n \"'\\\"\",\n\n \"-crop #{crop_size}#{crop_location}\",\n\n \"#{@dir}/top.miff\")\n end",
"def mouth\n @mouth ||= Mouth.new self[:MOUTH_LEFT], self[:MOUTH_CENTER],\n self[:MOUTH_RIGHT]\n end",
"def bottom!\n self.ox = self.width/2\n self.oy = self.height\n end",
"def bottom\n self.ox = self.src_rect.width/2\n self.oy = self.src_rect.height\n end",
"def fit_pinning_top\n union_frame = frame_for_subviews\n \n # # balance horizontally - offset x based on diff between old and new widths.\n # width_change = union_frame.width - self.width \n # new_x = self.x - width_change / 2\n new_x = self.x\n\n # pin at the top - offset y based on original top location and new height.\n new_y = self.frame.top_y - union_frame.height\n\n # we need to apply a vertical offset to all subviews later.\n delta_y = (new_y - self.y)\n\n # set the frame (and pray)\n self.frame = new_rect new_x, new_y, union_frame.width, union_frame.height\n\n self.subviews.each do |subview|\n if delta_y > 0 # we need to grow - move subview y up.\n subview.y += delta_y\n else # we need to shrink - move subview y down.\n subview.y -= delta_y\n end\n end\n end",
"def bottomright=(bottomright)\n raise ArgumentError, \"Rect#bottomright= takes an Array of form [x, y].\" if bottomright.size != 2\n self.right, self.bottom = bottomright\n return bottomright\n end",
"def midbottom; return self.centerx, self.bottom; end",
"def display_both_bottoms\n\t\tdisplay_boards_separators(method(:display_bottom_separator))\n\tend",
"def move_party_horn\n\t\tif face_left?\n\t\t\t@party_horn.x = @x + \n\t\t\t\t\t\t\t(TILE_WIDTH/4 - PartyHorn::PARTY_HORN_TILE_WIDTH)\n\t\telse\n\t\t\t@party_horn.x = @x + 3 * TILE_WIDTH/4\n\t\tend\n\t\t@party_horn.y = @y + 3 * TILE_HEIGHT/5\n\t\t@party_horn.angle = @angle\n\tend",
"def pbBottomRight(window)\n window.x=Graphics.width-window.width\n window.y=Graphics.height-window.height\nend",
"def bottomright; return self.right, self.bottom; end",
"def set_mouth_shape\n @mouth_shape = MouthShape.find(params[:id])\n end",
"def bottom\n @ole.Bottom\n end",
"def bottom\n @ole.Bottom\n end",
"def midbottom=(midbottom)\n raise ArgumentError, \"Rect#midbottom= takes an Array of form [x, y].\" if midbottom.size != 2\n self.centerx, self.bottom = midbottom\n return midbottom\n end",
"def bottomleft=(bottomleft)\n raise ArgumentError, \"Rect#bottomleft= takes an Array of form [x, y].\" if bottomleft.size != 2\n self[0], self.bottom = bottomleft\n return bottomleft\n end",
"def with_crop(left, top, right, bottom); end",
"def fullmaze\n\t\ttopbottom = \"+-\" * @width + \"+\"\n\t\tmiddle = \"|\" + \" |\" * @width\n\t\treturn topbottom + (middle + topbottom) * @height\n\tend",
"def test_moveTo_Outside_Bottom\n w = Window_Base.new(200, 150, 100, 50)\n @windows.push(w)\n w.animationSpeed = 2000\n w.moveTo(200, 530)\n return true\n end",
"def current_youth\n requested_youth\n end",
"def test_bottom_wrap\n rover = MarsRover.new(0,0,'S', world=World.new(5,5))\n rover.command('F')\n assert_equal([0,4,'S'], rover.position)\n end",
"def add_to_bottom\n self.position = bottom + 1\n end",
"def extend!(envelope)\r\n lower_corner.x = [lower_corner.x,envelope.lower_corner.x].min\r\n lower_corner.y = [lower_corner.y,envelope.lower_corner.y].min\r\n upper_corner.x = [upper_corner.x,envelope.upper_corner.x].max\r\n upper_corner.y = [upper_corner.y,envelope.upper_corner.y].max\r\n self\r\n end",
"def divide_top_bottom(top_fraction = 0.7)\n if top_fraction >= 1\n raise \"Error: Invalid top_fraction for TCanvas.divide_top_bottom().\"\n end\n @@Minification = 0.95\n cd(0)\n self.Divide(1, 2)\n self.GetPad(1).SetPad(0, (1 - top_fraction) * @@Minification,\n 1 * @@Minification, 1 * @@Minification)\n self.GetPad(2).SetPad(0, 0,\n 1 * @@Minification, (1 - top_fraction) * @@Minification)\n self.GetPad(1).SetFillStyle(0)\n self.GetPad(2).SetFillStyle(0)\n self.GetPad(1).SetMargin(0.15, 0.03, 0, 0.00)\n self.GetPad(2).SetMargin(0.15, 0.03, 0.26, 0.04)\n end",
"def setup_anim_bottom\n # not sure if needed\n $game_temp.anim_top = (@acts[1] == true || @acts[1].nil? ? -1 : 0)\n end",
"def midtop=(midtop)\n raise ArgumentError, \"Rect#midtop= takes an Array of form [x, y].\" if midtop.size != 2\n self.centerx, self[1] = midtop\n return midtop\n end",
"def set_group_youth\n @group_youth = GroupYouth.find(params[:id])\n end",
"def display_both_tops\n\t\tdisplay_boards_separators(method(:display_top_separator))\n\tend",
"def bottomToTopWraparound(grid, width, height)\n\n strings = bottomToTop(grid, width, height)\n\n for string in strings do\n\n string << string\n\n end\n\n return strings\n\nend",
"def split\n sw = (w / 2.0).round\n sh = (h / 2.0).round\n return Rect.new(x, y, sw, sh),\n Rect.new(x + sw, y, sw, sh),\n Rect.new(x, y + sh, sw, sh),\n Rect.new(x + sw, y + sh, sw, sh)\n end",
"def bottom()\n return @top + @height\n end",
"def collapse\n @posx = 471\n for i in 0...@party_banners.size\n @party_banners[i].move(@posx,Banner::PosY[i],255,10)\n end\n @removed.reverse_each do |j|\n $game_party.remove_actor($game_party.members[j].id)\n end\n end",
"def setup_anim_bottom\n $game_temp.anim_top = (@acts[1] == true || @acts[1].nil? ? -1 : 0)\n end",
"def move_east\n # Each time we move_east we move the Robot 1 space to the left\n @east += 1\n end",
"def create_description_windows\n width = Graphics.width / 2\n @left_window = Window_PartyTitle.new(0, 0, width)\n @right_window = Window_PartyTitle.new(width, 0, width)\n @left_window.set_text(Vocab.active_members)\n @right_window.set_text(Vocab.standby_members)\n end",
"def midtop; return self.centerx, self[1]; end",
"def test_moveTo_Inside_Bottom\n w = Window_Base.new(200, 530, 100, 50)\n @windows.push(w)\n w.animationSpeed = 2000\n w.moveTo(200, 100)\n return true\n end",
"def draw(view)\r\n # Show the current input point\r\n if (@ip.valid? && @ip.display?)\r\n @ip.draw(view)\r\n @drawn = true\r\n end \r\n\r\n # draw the outline of the wall\r\n MM_HouseBuilder.draw_outline(view, @wall.origin, @wall.endpt, @wall.width, @wall.justify, \"gray\")\r\n vec = @end_pt - @start_pt\r\n # draw the outline of each door and window\r\n @wall.objects.each do |obj|\r\n vec.length = obj.center_offset - obj.width/2\r\n obj_start = @wall.origin + vec\r\n vec.length = obj.width\r\n obj_end = obj_start + vec\r\n MM_HouseBuilder.draw_outline(view, obj_start, obj_end, @wall.width, @wall.justify, \"gray\")\r\n end\r\n MM_HouseBuilder.draw_outline(view, @start_pt, @end_pt, @wall.width, @wall.justify, \"orange\", 2)\r\n @drawn = true\r\nend",
"def assume_bottom_position\n update_attribute(:position, bottom_position_in_list(self).to_i + 1)\n end",
"def assume_bottom_position\n pos = bottom_position_in_list(self).to_i + 1 \n set_my_position(pos)\n end",
"def assume_bottom_position\n pos = bottom_position_in_list(self).to_i + 1\n set_my_position(pos)\n end",
"def check_mouth\n\t\t\tx = @glabella_start_x_position + (@glabella_width / 2).round\n\t\t\ty = ((@glabella_start_y_position + @left_eye_width + @glabella_width + @right_eye_width) * 0.7).round\n\t\t\tmouth_pixel_color = @image.pixel_color(x, y)\n\t\t\t\n\t\t\tif mouth_pixel_color.red <= COLOR_THRESHOLD\n\t\t\t\tdebug_output(x, y)\n\t\t\t\twrite_to_image(x, y, '#f00')\n\t\t\t\treturn true\n\t\t\tend\n\t\t\treturn false\n\t\tend",
"def bottom=(bottom)\n @view__.bottom = bottom\n end",
"def reset_window\n if $game_temp.in_battle\n self.y = 16\n else\n case $game_system.message_position\n when 0 # up\n self.y = 16\n when 1 # middle\n self.y = 160\n when 2 # down\n self.y = 304\n end\n end\n if $game_system.message_frame == 0\n self.opacity = 255\n else\n self.opacity = 0\n end\n#------------------------------------------------------------------------------\n# Begin Multiple Message Windows Edit\n#------------------------------------------------------------------------------\n # transparent speech bubbles don't look right, so keep opacity at 255\n # self.back_opacity = 160\n @tail.opacity = 255\n#------------------------------------------------------------------------------\n# End Multiple Message Windows Edit\n#------------------------------------------------------------------------------\n end",
"def keep_top\n @pos_y = court.top_y\n end",
"def initialize\n @board = Array[]\n initializeTop\n initializeMiddle\n initializeBottom\n end",
"def bottom_panel\n FFI::NCurses.bottom_panel(@pointer)\n end",
"def topToBottomWraparound(grid, width, height)\n\n strings = topToBottom(grid, width, height)\n\n for string in strings do\n\n string << string\n\n end\n\n return strings\n\nend",
"def bottomleft; return self[0], self.bottom; end",
"def to_h\n { top: top.to_h, bottom: bottom.to_h }\n end",
"def draw(view)\r\n # show the wall base outline\r\n\r\n # draw the outline of the wall\r\n @corners = [] if not defined?(@corners)\r\n @corners[0] = @pts[0]\r\n @corners[1] = @pts[1]\r\n (a, b) = MM_HouseBuilder.draw_outline(view, @pts[0], @pts[1], @wall.width, @wall.justify, \"gray\")\r\n # puts \"a = \" + a.inspect\r\n @corners[2] = b\r\n @corners[3] = a\r\n @corners[4] = @pts[0]\r\n vec = @pts[1] - @pts[0]\r\n @wall.objects.each do |obj|\r\n vec.length = obj.center_offset - obj.width/2\r\n obj_start = @wall.origin + vec\r\n vec.length = obj.width\r\n obj_end = obj_start + vec\r\n if (defined?(@selected_obj) && (obj == @selected_obj))\r\n MM_HouseBuilder.draw_outline(view, obj_start, obj_end, @wall.width, @wall.justify, \"red\", 3)\r\n else\r\n MM_HouseBuilder.draw_outline(view, obj_start, obj_end, @wall.width, @wall.justify, \"gray\")\r\n end\r\n end\r\n \r\n if ((@state == STATE_PICK) || (@state == STATE_MOVING))\r\n if (@pt_to_move)\r\n view.draw_points(@pt_to_move, 10, 1, \"red\");\r\n end\r\n if (@state == STATE_MOVING)\r\n view.set_color_from_line(@start_input_point.position, @pt_to_move)\r\n view.line_stipple = \".\" # dotted line\r\n view.draw(GL_LINE_STRIP, @start_input_point.position, @pt_to_move)\r\n end\r\n end\r\n \r\n @drawn = true\r\nend",
"def create_side_by_side_example\n # Resize the original image to 40% of the size.\n Commander.run!(\"convert #{@dir}/original.miff\",\n \"-resize 40%\",\n \"#{@dir}/original_smaller.miff\")\n\n # Resize the singing image to 40% of the size.\n Commander.run!(\"convert\",\n Songster.output_folder.join(\"#{@fname}-singing.gif\").to_s,\n \"-resize 40%\",\n \"#{@dir}/singing_smaller.miff\")\n\n # Put two closed mouth side by side.\n Commander.run!(\"convert\",\n \"#{@dir}/original_smaller.miff #{@dir}/original_smaller.miff\",\n \"+append\",\n \"#{@dir}/sidebyside_closed.miff\")\n\n # Put a closed and opened mouth side by side.\n Commander.run!(\"convert\",\n \"#{@dir}/singing_smaller.miff\",\n \"+append\",\n \"#{@dir}/sidebyside_opened.miff\")\n\n Commander.run!(\"convert -loop 0 -delay 30\",\n \"#{@dir}/sidebyside_closed.miff #{@dir}/sidebyside_opened.miff\",\n Songster.debug_folder.join(\"#{@fname}-sidebyside.gif\").to_s)\n end",
"def assume_bottom_position\n set_list_position(bottom_position_in_list(self).to_i + 1)\n end",
"def deep_merge(bot, top)\n deep_merge!(deep_copy(bot), top)\nend",
"def insert_at_bottom\n assume_bottom_position\n end",
"def test_alignBottomRight\n [@window, @sprite, @bitmap].each{|container|\n uc = UCIcon.new(container, Rect.new(0, 48, @window.contents.width, 72), 1, 2, 255, 2)\n uc.draw()\n }\n return true\n end",
"def merge_outlines(old_data, new_data, position)\n old_data = actual_object(old_data)\n new_data = actual_object(new_data)\n if old_data.nil? || old_data.empty? || old_data[:First].nil?\n # old_data is a reference to the actual object,\n # so if we update old_data, we're done, no need to take any further action\n old_data.update new_data\n elsif new_data.nil? || new_data.empty? || new_data[:First].nil?\n return old_data\n else\n new_data = new_data.dup # avoid old data corruption\n # number of outline nodes, after the merge\n old_data[:Count] = old_data[:Count].to_i + new_data[:Count].to_i\n # walk the Hash here ...\n # I'm just using the start / end insert-position for now...\n # first - is going to be the start of the outline base node's :First, after the merge\n # last - is going to be the end of the outline base node's :Last, after the merge\n # median - the start of what will be appended to the end of the outline base node's :First\n # parent - the outline base node of the resulting merged outline\n # FIXME implement the possibility to insert somewhere in the middle of the outline\n prev = nil\n pos = first = actual_object((position.nonzero? ? old_data : new_data)[:First])\n last = actual_object((position.nonzero? ? new_data : old_data)[:Last])\n median = { is_reference_only: true, referenced_object: actual_object((position.nonzero? ? new_data : old_data)[:First]) }\n old_data[:First] = { is_reference_only: true, referenced_object: first }\n old_data[:Last] = { is_reference_only: true, referenced_object: last }\n parent = { is_reference_only: true, referenced_object: old_data }\n while pos\n # walking through old_data here and updating the :Parent as we go,\n # this updates the inserted new_data :Parent's as well once it is appended and the\n # loop keeps walking the appended data.\n pos[:Parent] = parent if pos[:Parent]\n # connect the two outlines\n # if there is no :Next, the end of the outline base node's :First is reached and this is\n # where the new data gets appended, the same way you would append to a two-way linked list.\n if pos[:Next].nil?\n median[:referenced_object][:Prev] = { is_reference_only: true, referenced_object: prev } if median\n pos[:Next] = median\n # midian becomes 'nil' because this loop keeps going after the appending is done,\n # to update the parents of the appended tree and we wouldn't want to keep appending it infinitely.\n median = nil\n end\n # iterating over the outlines main nodes (this is not going into subtrees)\n # while keeping every rotations previous node saved\n prev = pos\n pos = actual_object(pos[:Next])\n end\n # make sure the last object doesn't have the :Next and the first no :Prev property\n prev.delete :Next\n actual_object(old_data[:First]).delete :Prev\n end\n end",
"def underlay *others\n r = others.reverse.push self\n t = self.class.new(**r.shift)\n t.overlay!(*r)\n end",
"def make_dock\n\n lowest = @map.first\n @map.each do |tile|\n if more_south(tile, lowest)\n lowest = tile\n end\n end\n\n @map.push(Dock.create(:x => lowest.x, :y => (lowest.y + 1*@height) ))\n end",
"def test_alignBottomRight\n [@window, @sprite, @bitmap].each{|container|\n uc = UCCharacterGraphic.new(container, Rect.new(0, 80, @window.contents.width, 120), $data_actors[1], 2, 255, 2)\n uc.draw()\n }\n return true\n end",
"def union!(rect)\n self.normalize!\n rleft, rtop = self.topleft\n rright, rbottom = self.bottomright\n r2 = Rect.new_from_object(rect).normalize!\n\n rleft = [rleft, r2.left].min\n rtop = [rtop, r2.top].min\n rright = [rright, r2.right].max\n rbottom = [rbottom, r2.bottom].max\n\n self[0,4] = rleft, rtop, rright - rleft, rbottom - rtop\n return self\n end",
"def setup_blueprint_outdoor_farms(want)\n @fort_entrance.maptile.spiral_search([df.world.map.x_count, df.world.map.y_count].max, 9, 3) { |_t|\n next unless sf = surface_tile_at(_t)\n sd = sf.designation\n if (-1..1).all? { |dx| (-1..1).all? { |dy|\n tt = sf.offset(dx, dy) and\n td = tt.designation and\n ((sd.subterranean and td.subterranean) or\n (not sd.subterranean and not td.subterranean and\n sd.biome == td.biome)) and\n tt.shape_basic == :Floor and\n tt.designation.flow_size == 0 and\n [:GRASS_DARK, :GRASS_LIGHT, :SOIL].include?(tt.tilemat)\n } }\n @rooms << Room.new(:farmplot, [:food, :cloth][want % 2], sf.x-1, sf.x+1, sf.y-1, sf.y+1, sf.z)\n @rooms.last.misc[:users] = []\n @rooms.last.misc[:outdoor] = true\n want -= 1\n true if want == 0\n end\n }\n end",
"def draw(view)\r\n # show the wall base outline\r\n\r\n # draw the outline of the wall\r\n @corners[0] = @wall.origin\r\n @corners[1] = @wall.endpt\r\n (a, b) = MM_HouseBuilder.draw_outline(view, @corners[0], @corners[1], @wall.width, @wall.justify, \"gray\")\r\n # puts \"a = \" + a.inspect\r\n @corners[2] = b\r\n @corners[3] = a\r\n @corners[4] = @corners[0]\r\n vec = @corners[1] - @corners[0]\r\n @wall.objects.each do |obj|\r\n vec.length = obj.center_offset - obj.width/2\r\n obj_start = @wall.origin + vec\r\n vec.length = obj.width\r\n obj_end = obj_start + vec\r\n if (defined?(@selected_obj) && (obj == @selected_obj))\r\n if (@state != STATE_MOVING)\r\n MM_HouseBuilder.draw_outline(view, obj_start, obj_end, @wall.width, @wall.justify, \"red\", 3)\r\n end\r\n else\r\n MM_HouseBuilder.draw_outline(view, obj_start, obj_end, @wall.width, @wall.justify, \"gray\")\r\n end\r\n end\r\n if (@state == STATE_MOVING)\r\n MM_HouseBuilder.draw_outline(view, @start_pt, @end_pt, @wall.width, @wall.justify, \"red\", 2)\r\n end\r\n \r\n @drawn = true\r\nend",
"def copy_pad_to_win\n # check that we don't exceed other windows height/maxrow\n smr = smaxrow()\n # SHIT, this means the otherwin has to be a Pad, cannot be a window\n osw = @otherwin.width\n osh = @otherwin.height\n osh = @height if osh == 0 # root window has 0\n osw = @width if osw == 0 # root window has 0\n osmr = @otherwin.smaxrow() rescue osh # TRYING for windows\n osmc = @otherwin.smaxcol() rescue osw\n if smr >= osmr\n $log.debug \" adjusted smr from #{smr} to #{osmr} -1 causing issues in viewfooter\"\n smr = osmr-1 # XXX causing issues in viewport, wont print footer with this\n end\n if smr > @sheight + @top -1 -@pminrow # 2010-01-17 13:27 \n smr = @sheight + @top -1 -@pminrow \n $log.debug \" adjusted smr to #{smr} to prevent crash \"\n end\n smc = smaxcol()\n $log.debug \" SMC original = #{smc} \"\n if smc >= osmc\n smc = osmc-1\n smc = @width # XXX ??? THIS WAS WORKING< but throwing error in viewport case\n smc = [osmc-1, @width].min # yet another hack\n $log.debug \" SMC o-1 #{osmc-1} wdth #{@width}, smc #{smc} \"\n end\n ### XXX commented out since it doesn't let a comp print fully if widget expanded (splitpane)\n #smc = osw -1 if smc >= osw; # added 2009-11-02 17:01 for tabbedpanes\n\n # dang, this is coming up a lot. 2010-01-16 20:34 \n # the second scrollpane was one row too large in testsplit3a.rb\n if smr - @top > @padheight\n $log.debug \" fixing smr to padheight 2010-01-16 20:35 HOPE THIS DOESNT BREAK ANYTHING\"\n smr = @padheight\n end\n @pminrow = 0 if @pminrow < 0\n @pmincol = 0 if @pmincol < 0\n $log.debug \" COPYING #{self.name} to #{@otherwin.name} \"\n $log.debug \" calling copy pad #{@pminrow} #{@pmincol}, #{@top} #{@left}, #{smr} #{smc} self #{self.name} \"\n $log.debug \" calling copy pad H: #{@height} W: #{@width}, PH #{@padheight} PW #{@padwidth} WIN:#{@window} \"\n# $log.debug \" -otherwin target copy pad #{@otherwin.pminrow} #{@otherwin.pmincol}, #{@otherwin.top} #{@otherwin.left}, #{osmr} #{osmc} OTHERWIN:#{@otherwin.name} \"\n ret=\"-\"\n #if ret == -1\n#x XXX $log.debug \" #{ret} otherwin copy pad #{@otherwin.pminrow} #{@otherwin.pmincol}, #{@otherwin.top} #{@otherwin.left}, #{osmr} #{osmc} \"\n $log.debug \" #{ret} otherwin copy pad H: #{osh} W: #{osw}\"\n if @top >= osh\n $log.debug \" #{ret} ERROR top exceeds other ht #{@top} H: #{osh} \"\n end\n if @left >= osw\n $log.debug \" #{ret} ERROR left exceeds other wt #{@left} W: #{osw} \"\n end\n if smr >= osh\n $log.debug \" #{ret} ERROR smrow exceeds other ht #{smr} H: #{osh} \"\n smr = osh() -1 # testing 2010-01-31 21:47 , again 2010-02-05 20:22 \n end\n if smc >= osw\n $log.debug \" #{ret} ERROR smcol exceeds other wt #{smc} W: #{osw} \"\n end\n if smc - @left > @padwidth\n $log.debug \" #{ret} ERROR smcol - left exceeds padwidth #{smc}- #{@left} PW: #{@padwidth} \"\n end\n if smr - @top > @padheight\n $log.debug \" #{ret} ERROR smr - top exceeds padheight #{smr}- #{@top} PH: #{@padheight} \"\n end\n ret = @window.copywin(@otherwin.get_window,@pminrow,@pmincol, @top, @left, smr, smc, 0)\n $log.debug \" copywin ret #{ret} \"\n # 2010-01-11 19:42 one more cause of -1 coming is that padheight (actual height which never\n # changes unless pad increases) or padwidth is smaller than area being printed. Solution: increase \n # buffer by increasing widgets w or h. smc - left should not exceed padwidth. smr-top should not\n # exceed padheight\n #end\n @modified = false\n return ret\n end",
"def bottom(value)\n @ole.Bottom = value\n nil\n end",
"def bottom(value)\n @ole.Bottom = value\n nil\n end",
"def reset_window\n super \n position = $game_message.position\n case position\n when 0 # up\n self.y = 16\n when 1 # middle\n self.y = 160\n when 2 # down\n self.y = 304\n end \n end",
"def bottom=(value)\n @bottom = value\n end",
"def place_initial\n @party_banners = []\n @header_banner = BannerBG.new(384,0,@viewport)\n @header_banner.bitmap = Cache.banner(\"[TPX] Formation\")\n @header_banner.opacity = 0\n @header_banner.move(384,0,255,10)\n @posx = 471\n Banner::StartSound.play\n ind = 0\n $game_system.menu_disabled = true\n back = $game_party.members.count\n $game_party.members.each do |r|\n banner = BannerBG.new(@posx,205+40*ind,@viewport2)\n banner.bitmap = Cache.banner(\"[TPJ]#{r.id}\")\n banner.opacity = 0\n banner.z = 49-ind\n banner.move(@posx,Banner::PosY[ind],255,10)\n @party_banners.push(banner)\n ind+=1\n end\n #Step 3: Reveal and slide-up the banners of current party members (All Gold)\n end",
"def draw\n # clear the terminal\n system(\"clear\")\n # draw the top rail\n puts '-' * self.length\n # draw each horse in it's own lane\n self.horses.each do |horse|\n # draw .......all the way up to the position of the horse\n print '.' * horse.position + horse.print\n puts\n # draw the bottom rail\n puts '-' * self.length\n end\n end",
"def test_moveTo_Outside_Top\n w = Window_Base.new(100, 150, 100, 50)\n @windows.push(w)\n w.animationSpeed = 2000\n w.moveTo(100, -50)\n return true\n end",
"def assume_bottom_position\n update_attribute(position_column, bottom_position_in_list(self).to_i + 1)\n end",
"def triple_split(top_joker, bottom_joker)\n\t\t# everything above the top joker moves below the bottom joker\n\t\t# and everything below the bottom joker moves to above the top\n\t\t# joker\n\t\ttop_cards \t = @deck_of_cards[0...top_joker]\n\t\tmid_cards\t\t = @deck_of_cards[top_joker..bottom_joker]\n\t\tbottom_cards = @deck_of_cards[bottom_joker+1..53]\n\t\t@deck_of_cards.clear\n\t\t@deck_of_cards += (bottom_cards)+(mid_cards)+(top_cards)\n\tend",
"def bottom_panel\n Panel.bottom_panel(pointer)\n end",
"def initialize\r\n\t super(0,Graphics.height-WIN_HEIGHT,Graphics.width,WIN_HEIGHT)\r\n\t @x, @y, @i = 10, 50, 0\r\n\t @party_size = $game_party.all_members.size\r\n contents.font.size = FONT_SIZE\r\n\t self.back_opacity = WIN_OPACITY\r\n self.opacity = FRAME_OPACITY\r\n @actor_hp = []\r\n @actor_mp = []\r\n\t fhiz_hud\r\n\t check_visible\r\n end",
"def move_to_bottom\n return unless in_list?\n\n decrement_positions_on_lower_items\n assume_bottom_position \n end",
"def bottom_right\n @position + @dimensions\n end",
"def add_top_statements_to_object_scope\n temp = []\n combined_statements = []\n @statements.each do |stmt|\n if stmt.is_a?(TopStatement::Klass) || stmt.is_a?(TopStatement::CBindings)\n if !temp.empty?\n object_klass = TopStatement::Klass.new('Object', @scope, temp)\n combined_statements << object_klass\n end\n\n combined_statements << stmt\n temp = []\n else\n temp << stmt\n end\n end\n\n if !temp.empty?\n combined_statements << TopStatement::Klass.new('Object', @scope, temp)\n end\n\n @statements = combined_statements\n end",
"def border(top_or_bottom)\n if top_or_bottom == \"top\"\n puts \"\\n ╔═══ ☆ .·:·. ☽ ✧ † ✧ ☾ .·:·. ☆ ═══╗ \\n\"\n else\n puts \"\\n ╚═══ ☆ .·:·. ☽ ✧ † ✧ ☾ .·:·. ☆ ═══╝ \\n\"\n end\n end",
"def draw_blocks\n case view\n when :south_east\n size_y.times do |y|\n size_x.times do |x|\n size_z.times do |z|\n draw_block(x, y, z, x, y, z)\n end\n end\n end\n when :south_west\n size_x.times do |y|\n size_y.times do |x|\n size_z.times do |z|\n draw_block(x, y, z, size_x - 1 - y, x, z)\n end\n end\n end\n when :north_west\n size_y.times do |y|\n size_x.times do |x|\n size_z.times do |z|\n draw_block(x, y, z, size_x - 1 - x, size_y - 1 - y, z)\n end\n end\n end\n when :north_east\n size_x.times do |y|\n size_y.times do |x|\n size_z.times do |z|\n draw_block(x, y, z, y, size_y - 1 - x, z)\n end\n end\n end\n #end case\n end\n end",
"def update!(**args)\n @bottom = args[:bottom] if args.key?(:bottom)\n @left = args[:left] if args.key?(:left)\n @right = args[:right] if args.key?(:right)\n @top = args[:top] if args.key?(:top)\n end",
"def bottom()\n @view__.bottom\n end",
"def reset_window\n # This allows Tutorial Windows to be placed at the Top, Middle, and Bottom\n if $game_temp.in_battle and not @tutorial\n self.y = 16\n else\n case $game_system.message_position\n when 0 # up\n self.y = 16\n when 1 # middle\n self.y = 160\n when 2 # down\n self.y = 304\n end\n end\n if $game_system.message_frame == 0\n self.opacity = 255\n else\n self.opacity = 0\n end\n if @tutorial\n self.back_opacity = $game_system.tutorial_window_opacity\n else\n self.back_opacity = 160\n end\n end",
"def home\n pen_up\n self.xy = ORIGIN\n self.heading = 0.0\n end",
"def resize_and_move_holst(holst, frame_width, frame_height)\n photo = Image.read(URI.decode('public' + holst.image.url))[0]\n move = translation_holst(holst.positions, photo, frame_width, frame_height)\n photo = resize_to_fill_holst(photo, frame_width, frame_height)\n photo_done = Image.new(frame_width, frame_height).composite!(photo, move[0], move[1], OverCompositeOp)\n end",
"def move_to_bottom\n return unless in_list?\n\n decrement_positions_on_lower_items\n assume_bottom_position\n end",
"def north\n @north ||= south + SIZE\n end",
"def add_bbox(bbox)\n @north = [@north, bbox[\"north\"]].max\n @south = [@south, bbox[\"south\"]].min\n # we don't know whether to add the other_bbox \"to the left\"\n # or \"to the right\". So we do three and choose whichever has a\n # smaller result (by side length). The three are: as is, moved\n # right by 360 degrees and moved left by 360 degrees.\n other_east = bbox[\"east\"]\n other_west = bbox[\"west\"]\n if other_east < other_west\n other_east += 360\n end\n @east, @west = optimize_east_west_add(other_east, other_west)\n normalize\n end",
"def bottom_most_blocks\n width.times.map do |column_index|\n row_blocks_with_row_index = @blocks.each_with_index.to_a.reverse.detect do |row_blocks, row_index|\n !row_blocks[column_index].clear?\n end\n bottom_most_block = row_blocks_with_row_index[0][column_index]\n bottom_most_block_row = row_blocks_with_row_index[1]\n {\n block: bottom_most_block,\n row_index: bottom_most_block_row,\n column_index: column_index\n }\n end\n end",
"def bottom_right\n @bottom_right ||= Quadtree::Point.new(\n provinces.map { |province| province.bottom_right.x }.max,\n provinces.map { |province| province.bottom_right.y }.min\n )\n end",
"def snap_to_top( opts = { ref_view: self.superview } )\n new_y = opts[:ref_view].height - self.height\n self.frame = CGRectMake(self.frame.origin.x, new_y, self.width, self.height)\n end",
"def full_game_board\n\t\trows = []\n\t\t(0...$dimensions[:y]).each do |y|\n\t\t\tcols = []\n\t\t\t(0...$dimensions[:x]).each do |x|\n\t\t\t\tcols << board_status({:x => x, :y => y})\n\t\t\tend\n\t\t\trows << cols\n\t\tend\n\t\thunter_blob = captured_points\n\t\thunter_blob.each do |point|\n\t\t\trows[point[:y]][point[:x]] = \"-\" if rows[point[:y]][point[:x]] == '.'\n\t\tend\n\t\trows\n\tend",
"def add_maze_walls\n # add the left and right sides\n for wall_y in 0..@height-1 do\n @vertical_walls[wall_y].unshift :unhit\n @vertical_walls[wall_y].push :hit\n end\n # add the top\n @horizontal_walls.unshift Array.new(@width, :unhit)\n # open a hole for the start\n # starts on the top or bottom\n if(@start_y == 0 || @start_y == @height-1) then\n @horizontal_walls[@start_y == @height-1 ? @height : 0][@start_x] = :start\n end\n # starts on the left or right\n if(@start_x == 0 || @start_x == @width-1) then\n @vertical_walls[@start_y][@start_x == @width-1 ? @width : 0] = :start\n end\n # open a hole for the end\n # ends on the top or bottom\n if(@end_y == 0 || @end_y == @height-1) then\n @horizontal_walls[@end_y == @height-1 ? @height : 0][@end_x] = :end\n end\n # ends on the left or right\n if(@end_x == 0 || @end_x == @width-1) then\n @vertical_walls[@end_y][@end_x == @width-1 ? @width : 0] = :end\n end\n end",
"def middle_points(north_west_corner,south_east_corner,split_point)\n\t\tn_y,n_x=north_west_corner.position\n\t\ts_y,s_x=south_east_corner.position\n\t\tsp_y,sp_x=split_point.position\t\n\n\t\tnorth_middle=Point.new(n_y,sp_x,'wall')\n\t\tsouth_middle=Point.new(s_y,sp_x,'wall')\n\t\twest_middle=Point.new(sp_y,n_x,'wall')\n\t\teast_middle=Point.new(sp_y,s_x,'wall')\n\t\treturn [north_west_corner,split_point,north_middle,east_middle,west_middle,south_middle,split_point,south_east_corner]\n\tend",
"def test_top_wrap\n rover = MarsRover.new(0,4,'S', world=World.new(5,5))\n rover.command('B')\n assert_equal([0,0,'S'], rover.position)\n end",
"def move_up\n\t\t# if the horse isn't yet at the top of the screen move it up 20\n\t\tif @y > 0\n\t\t\t@y = @y -20\n\t\tend\n\tend",
"def index\n @mouth_shapes = MouthShape.all\n end",
"def screen_y\n n_split = [($game_party.actors.length * 0.5).ceil, 4].min\n case n_split\n when 1\n n_index = self.index * 2\n when 2\n if self.index < ($game_party.actors.length - 2)\n n_index = 0.5 + (2 * self.index)\n else\n if $game_party.actors.length == 3 then\n n_index = (self.index * 2) + 2\n elsif $game_party.actors.length == 4 then\n n_index = self.index * 2\n end\n end\n when 3\n n_index = self.index + (0.25 * (self.index + 1))\n if $game_party.actors.length == 5\n if self.index < 2\n n_index = self.index + (0.25 * (self.index + 1))\n else\n n_index = self.index + (0.25 * (self.index + 2)) + 1\n end\n end\n when 4\n n_index = self.index\n if $game_party.actors.length == 7\n if self.index < 3\n n_index = self.index\n else\n n_index = self.index + 1\n end\n end\n end\n return (n_index - ((n_index / 4).floor) * 4) * ((160 / (4)) * 1.6) + 270 - ((n_index / 4).floor * (110 - (4 * 20)))\nend"
] |
[
"0.756299",
"0.67998385",
"0.6741661",
"0.6539761",
"0.56384194",
"0.5429254",
"0.54279655",
"0.5200727",
"0.5188147",
"0.512879",
"0.5097356",
"0.5087007",
"0.5022179",
"0.5021614",
"0.4989712",
"0.4989712",
"0.4972248",
"0.49684033",
"0.48795733",
"0.48489606",
"0.4842336",
"0.48315802",
"0.48010173",
"0.478615",
"0.47844535",
"0.4784233",
"0.4783483",
"0.4782044",
"0.47197697",
"0.47084036",
"0.47082165",
"0.4690608",
"0.46885383",
"0.46874973",
"0.4669706",
"0.46619135",
"0.46584088",
"0.46391422",
"0.46336928",
"0.4626957",
"0.46190464",
"0.46186998",
"0.4617008",
"0.4616862",
"0.46150506",
"0.4610971",
"0.4604347",
"0.46036783",
"0.4601553",
"0.4598958",
"0.45978847",
"0.45946142",
"0.45900154",
"0.4588828",
"0.45876366",
"0.45814565",
"0.4570559",
"0.4564501",
"0.45564154",
"0.4555717",
"0.45452568",
"0.45414135",
"0.45399722",
"0.4537124",
"0.4535872",
"0.45262983",
"0.45174518",
"0.45174518",
"0.4496176",
"0.44833067",
"0.447507",
"0.4474475",
"0.4469018",
"0.446624",
"0.44659382",
"0.445869",
"0.44468018",
"0.44413874",
"0.44306242",
"0.44212323",
"0.44211453",
"0.44151136",
"0.44106722",
"0.44099545",
"0.4405515",
"0.44052577",
"0.43879253",
"0.4380629",
"0.43774146",
"0.43755686",
"0.43743116",
"0.43735728",
"0.43705288",
"0.43683717",
"0.43491924",
"0.43436697",
"0.43421942",
"0.43392384",
"0.433919",
"0.4338867"
] |
0.7797932
|
0
|
Put the opened mouth over the original image.
|
def merge_opened_mouth_on_canvas(mouth)
Commander.run!("composite",
"#{@dir}/opened_mouth.miff #{@dir}/opened_mouths.miff",
"-gravity northwest -geometry +#{mouth.x}+#{mouth.y}",
"#{@dir}/opened_mouths.miff")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def reset(window)\n\t\t# put the horse back in the center\n\t\t@x = window.width / 2 - @image.width / 2\n\t\t@y = window.height / 2 - @image.height / 2\n\tend",
"def move_party_horn\n\t\tif face_left?\n\t\t\t@party_horn.x = @x + \n\t\t\t\t\t\t\t(TILE_WIDTH/4 - PartyHorn::PARTY_HORN_TILE_WIDTH)\n\t\telse\n\t\t\t@party_horn.x = @x + 3 * TILE_WIDTH/4\n\t\tend\n\t\t@party_horn.y = @y + 3 * TILE_HEIGHT/5\n\t\t@party_horn.angle = @angle\n\tend",
"def create_mouth_top_crop(mouth)\n crop_size = \"#{mouth.width}x#{mouth.height+5}\"\n crop_location = \"+#{mouth.left_x}+#{mouth.top}\"\n\n Commander.run!(\"convert #{@dir}/original.miff\",\n \"-fill black -stroke black\",\n\n \"-draw \\\"path '\",\n # Start line at the top left point\n \" M #{mouth.left}\",\n\n # Draw a curve to the right point.\n \" C #{mouth.center_x},#{mouth.center_y+5}\",\n \" #{mouth.center_x},#{mouth.center_y+5}\",\n \" #{mouth.right}\",\n\n # Draw a straight line to a point below the right point.\n \" L #{mouth.right_x},#{mouth.bottom+5}\",\n\n # Draw a straight line to a point below the left point.\n \" L #{mouth.left_x},#{mouth.bottom+5}\",\n\n # Close the figure so it can be filled.\n \" Z\",\n \"'\\\"\",\n\n \"-crop #{crop_size}#{crop_location}\",\n\n \"#{@dir}/top.miff\")\n end",
"def merge_top_and_bottom_of_mouth\n Commander.run!(\"convert #{@dir}/top.miff #{@dir}/bottom.miff\",\n \"-append #{@dir}/opened_mouth.miff\")\n end",
"def create_mouth_bottom_crop(mouth)\n crop_size = \"#{mouth.width}x#{mouth.chin_height+mouth.opening_size}\"\n crop_location = \"+#{mouth.left_x}+#{mouth.middle}\"\n\n Commander.run!(\"convert #{@dir}/original.miff\",\n \"-fill black -stroke black\",\n\n \"-draw \\\"path '\",\n\n # Start line at the top left point\n \" M #{mouth.left}\",\n\n # Draw a curve to the right point\n \" C #{mouth.center_x},#{mouth.center_y+5}\",\n \" #{mouth.center_x},#{mouth.center_y+5}\",\n\n # Finish line at the right point.\n \" #{mouth.right}'\",\n \"\\\"\",\n\n # Add black padding to adjust how big the mouth opens.\n \"-gravity northwest -background black\",\n \"-splice 0x#{mouth.opening_size}+0+#{mouth.middle}\",\n\n # Crop to get the results.\n \"-crop #{crop_size}#{crop_location}\",\n\n \"#{@dir}/bottom.miff\")\n end",
"def mouth\n @mouth ||= Mouth.new self[:MOUTH_LEFT], self[:MOUTH_CENTER],\n self[:MOUTH_RIGHT]\n end",
"def overlay(dest_win)\n if dest_win.respond_to?(:win)\n Ncurses.overlay(pointer, dest_win.win)\n else\n Ncurses.overlay(pointer, dest_win)\n end\n end",
"def set_avatar\n @avatar_window.activate\n @avatar_window.x = 0 - @avatar_window.width unless @avatar_window.visible\n @avatar_window.visible = true\n @avatar_window.smooth_move(0, @avatar_window.y)\n end",
"def resize_and_move_holst(holst, frame_width, frame_height)\n photo = Image.read(URI.decode('public' + holst.image.url))[0]\n move = translation_holst(holst.positions, photo, frame_width, frame_height)\n photo = resize_to_fill_holst(photo, frame_width, frame_height)\n photo_done = Image.new(frame_width, frame_height).composite!(photo, move[0], move[1], OverCompositeOp)\n end",
"def move_picture picture\n end",
"def draw\n\t\t@party_horn.draw\n\t\tangle = draw_angle(face_left?)\n\t\tprawn_img = @@tiles[@tile_idx]\n\t\tprawn_img.draw_rot(@x+TILE_WIDTH/2, \n\t\t\t\t\t\t @y+TILE_HEIGHT/2, \n\t\t\t\t\t\t PRAWN_Z + @player.z, \n\t\t\t\t\t\t angle)\n\n\t\tprawn_skin = @@skins[@tile_idx] \n\t\tprawn_skin.draw_rot(@x + TILE_WIDTH/2, \n\t\t\t\t\t\t @y + TILE_HEIGHT/2, \n\t\t\t\t\t\t PRAWN_Z + @player.z, \n\t\t\t\t\t\t angle, \n\t\t\t\t\t\t 0.5, # Default center_x \n\t\t\t\t\t\t 0.5, # Default center_y\n\t\t\t\t\t\t 1, # Default scale_x\n\t\t\t\t\t\t 1, # Default scale_y\n\t\t\t\t\t\t @player.colour)\n\tend",
"def look_away()\r\n model = Sketchup.active_model\r\n camera = model.active_view.camera\r\n @eye = camera.eye\r\n @target = camera.target\r\n @up = camera.up\r\n bounds = model.bounds\r\n camera.set(bounds.corner(0), bounds.corner(0) - bounds.center, @up)\r\n end",
"def look_away()\r\n model = Sketchup.active_model\r\n camera = model.active_view.camera\r\n @eye = camera.eye\r\n @target = camera.target\r\n @up = camera.up\r\n bounds = model.bounds\r\n camera.set(bounds.corner(0), bounds.corner(0) - bounds.center, @up)\r\n end",
"def cover\n manipulate! do |frame, index|\n frame if index.zero?\n end\n end",
"def draw\n\t\tif @is_blown\n\t\t\tis_facing_left = face_left?\n\n\t\t\tangle = draw_angle(is_facing_left)\n\t\t\tidx = is_facing_left ? 0 : 1\n\n\t\t\timg = @@tiles[idx]\n\t\t\timg.draw_rot(@x + PARTY_HORN_TILE_WIDTH/2.0, \n\t\t\t\t\t\t @y + PARTY_HORN_TILE_HEIGHT/2.0, \n\t\t\t\t\t\t PARTY_HORN_Z + @player.z, \n\t\t\t\t\t\t angle)\n\t\tend\n\tend",
"def check_mouth\n\t\t\tx = @glabella_start_x_position + (@glabella_width / 2).round\n\t\t\ty = ((@glabella_start_y_position + @left_eye_width + @glabella_width + @right_eye_width) * 0.7).round\n\t\t\tmouth_pixel_color = @image.pixel_color(x, y)\n\t\t\t\n\t\t\tif mouth_pixel_color.red <= COLOR_THRESHOLD\n\t\t\t\tdebug_output(x, y)\n\t\t\t\twrite_to_image(x, y, '#f00')\n\t\t\t\treturn true\n\t\t\tend\n\t\t\treturn false\n\t\tend",
"def draw\n @image.drawAtPoint( @location,\n :fromRect, @image_rect,\n :operation, OSX::NSCompositeSourceOver,\n :fraction, 1.0\n )\n end",
"def blue_shift\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.blue_shift(2)\n img.write('public' + @photo.attachment_url)\n end",
"def draw_hadouken\n # left\n if @player.push_hadouken\n @hadouken_img.draw(@player.player_x - @mov, @center_y, 1, -1) if @player.player2?\n # right\n @hadouken_img.draw(@player.player_x + @mov, @center_y, 1) unless @player.player2?\n\n # calcula novamente o valor de X\n @center_x = @player.player_x - @mov if @player.player2?\n @center_x = @player.player_x + @mov unless @player.player2?\n end\n end",
"def draw\r\n @image_player.bmp.draw(@x, @y, ZOrder::TOP)\r\n end",
"def set_mouth_shape\n @mouth_shape = MouthShape.find(params[:id])\n end",
"def look_back()\r\n camera = Sketchup.active_model.active_view.camera.set(@eye, @target, @up)\r\n end",
"def look_back()\r\n camera = Sketchup.active_model.active_view.camera.set(@eye, @target, @up)\r\n end",
"def overlay(...)\n self.clone.overlay!(...)\n end",
"def displace_to_waste\n @areas[:waste].add_from(@pile, @card)\n end",
"def overwrite(dest_win)\n if dest_win.respond_to?(:win)\n Ncurses.overwrite(pointer, dest_win.win)\n else\n Ncurses.overwrite(pointer, dest_win)\n end\n end",
"def closeeye()\n\t\t@pintar = false\n\tend",
"def place_through(x, y, width_bound, height_bound, image, target)\n new_x = (width_bound - image.columns) / 2 + x\n new_y = (height_bound - image.rows) / 2 + y\n place_onto(new_x, new_y, image, target)\n end",
"def draw\n @image.draw(@x - @image.width/2.0, @y - @image.height/2.0, ZOrder::Player)\n end",
"def overlay(what, where=:marked)\n return if not_registered\n @mim.overlay what, where\n end",
"def reset\n @victory = false\n @win = false\n drawFromPixmap\n end",
"def place_onto(x, y, image, target)\n target.import_pixels(x, y, image.columns, image.rows, 'RGB', image.export_pixels)\n end",
"def draw\r\n @image.bmp.draw(@x, @y, ZOrder::TOP)\r\n end",
"def draw_bomb bomb\r\n bomb.cur_image.draw(bomb.x,bomb.y,2)\r\nend",
"def move_right(window)\n\t\t# if the horse isn't yet at the right edge move it right 20\n\t\tif @x < window.width - @image.width\n\t\t\t@x = @x +20\n\t\tend\n\tend",
"def update_bitmap\n @effectus_old_name = @picture.name\n if @effectus_old_name.empty?\n self.bitmap = nil\n else\n self.bitmap = Cache.picture(@effectus_old_name)\n @effectus_center_x = bitmap.width / 2\n @effectus_center_y = bitmap.height / 2\n end\n end",
"def representative_image(monograph, cover_noid)\n acquire_lock_for(monograph.id) do\n monograph.representative_id = cover_noid\n monograph.thumbnail_id = cover_noid\n monograph.save!\n end\n end",
"def game_over\n @scene.window.cursor = true\n x = 0\n y = @scene.height * 0.3\n x1 = 0\n x2 = @scene.width\n y1 = @scene.height * 0.3\n y2 = @scene.height * 0.6\n draw_window(x, y, x1, x2, y1, y2, @game_over_img)\n\n load_gm_btns unless @no_button && @yes_button\n\n @no_button.draw\n @yes_button.draw\n end",
"def set_upper_sprite\n return if @set_upper_area_sprite\n @upper_area_sprite ||= Sprite.new\n @upper_area_sprite.bitmap = Bitmap.new(self.width, self.height)\n props = [\"x\", \"y\", \"ox\", \"oy\", \"zoom_x\", \"zoom_y\", \"angle\", \"mirror\",\n \"bush_depth\", \"opacity\", \"blend_type\", \"color\", \"tone\", \"visible\",\n \"viewport\"]\n props.each do |meth|\n @upper_area_sprite.method(\"#{meth}=\").call(self.method(meth).call)\n end\n#~ @upper_area_sprite.x = @upper_area_sprite.y = 100\n @upper_area_sprite.z = 200\n @upper_area_sprite.viewport = @viewport1\n @set_upper_area_sprite = true\n old_bitmap, old_src_rect = self.bitmap, self.src_rect.clone\n self.bitmap = Bitmap.new(old_bitmap.width, old_bitmap.height)\n self.bitmap.blt(0, 0, old_bitmap, old_bitmap.rect)\n self.src_rect = old_src_rect\n end",
"def absorb other\n # Act only if there's not already an image in the absorber\n unless picref\n if otherpic = other.method(other.class.image_reference_name).call\n self.method(:\"#{self.class.image_reference_name}=\").call otherpic\n end\n end\n super if defined? super\n end",
"def rotate_180!\n pixels.reverse!\n self\n end",
"def update_bitmap\n ### The following commented lines may be used for animation frames ###\n # # Get the graphic that represents the current frame\n # sx = @unit.frame * @cw\n # # Take the square graphic from the rectangular picture\n # self.src_rect.set(sx, 0, @cw, @ch)\n self.src_rect.set(0, 0, @cw, @ch)\n end",
"def flip_vertically!\n @picture.flip_vertically!\n end",
"def flip\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.flip!\n img.write('public' + @photo.attachment_url)\n end",
"def main\n ImageManip::inspect_image(@image_path)\n dimensions = ImageManip::get_dimensions(@image_path)\n sharp_pixels = get_accidental_pixels(@sharp_path)\n flat_pixels = get_accidental_pixels(@flat_path)\n edits = Hash.new\n edits[:lower_left] = [dimensions[0] / 2, dimensions[1] / 2]\n edits[:rgb_array] = sharp_pixels\n ImageManip::draw_2D_object(@image_path, './new_staff.gif', edits)\n edits[:lower_left] = [dimensions[0] / 3, dimensions[1] / 3]\n edits[:rgb_array] = flat_pixels\n ImageManip::draw_2D_object('./new_staff.gif', './new_staff.gif', edits)\n end",
"def moveto(x, y)\n super\n # Centering\n center(x, y)\n # Make encounter count\n make_encounter_count\n end",
"def close_avatar\n @avatar_window.smooth_move(0 - @avatar_window.width, @avatar_window.y)\n @command_window.activate\n update_registration_ready\n end",
"def draw_custom_image\r\r\n bitmap = Cache.picture($game_map.ach_display.graphic)\r\r\n rect = Rect.new(0,0,bitmap.width,bitmap.height)\r\r\n target = Rect.new(0,0,contents.width,contents.height)\r\r\n contents.stretch_blt(target, bitmap, rect, 255)\r\r\n end",
"def sharpen\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.sharpen(0.0, 1.0)\n img.write('public' + @photo.attachment_url)\n end",
"def create_side_by_side_example\n # Resize the original image to 40% of the size.\n Commander.run!(\"convert #{@dir}/original.miff\",\n \"-resize 40%\",\n \"#{@dir}/original_smaller.miff\")\n\n # Resize the singing image to 40% of the size.\n Commander.run!(\"convert\",\n Songster.output_folder.join(\"#{@fname}-singing.gif\").to_s,\n \"-resize 40%\",\n \"#{@dir}/singing_smaller.miff\")\n\n # Put two closed mouth side by side.\n Commander.run!(\"convert\",\n \"#{@dir}/original_smaller.miff #{@dir}/original_smaller.miff\",\n \"+append\",\n \"#{@dir}/sidebyside_closed.miff\")\n\n # Put a closed and opened mouth side by side.\n Commander.run!(\"convert\",\n \"#{@dir}/singing_smaller.miff\",\n \"+append\",\n \"#{@dir}/sidebyside_opened.miff\")\n\n Commander.run!(\"convert -loop 0 -delay 30\",\n \"#{@dir}/sidebyside_closed.miff #{@dir}/sidebyside_opened.miff\",\n Songster.debug_folder.join(\"#{@fname}-sidebyside.gif\").to_s)\n end",
"def set_position\n self.position = institution.max_photo_position + 1\n end",
"def draw\n if @dir == :left\n @cur_image = @stand_r\n offs_x = -25\n @offset = :left\n # elsif @vy < 0\n # @cur_image = @jump\n else\n @cur_image = @stand\n offs_x = 25\n end\n @cur_image.draw(@x, @y, 1, 1.0)\n end",
"def set_group_youth\n @group_youth = GroupYouth.find(params[:id])\n end",
"def moveto(x, y)\n super\n center(x, y)\n make_encounter_count\n vehicle.refresh if vehicle\n @followers.synchronize(x, y, direction)\n end",
"def reboot\n img = ['blue_flower', 'red_flower', 'white_flower', 'pink_flower'].sample\n @image = Gosu::Image.new window, 'images/flowers/' + img +'.png', true\n @drawing = true\n end",
"def openeye()\n\t\t@pintar = true\n\tend",
"def check_out_of_world # swap size\n # y\n if @y < 0\n die\n elsif @y > WINDOW_SIZE_Y\n die\n end\n # x ( comment me out to add the glitch feature agian )\n if @x < 0\n @x = WINDOW_SIZE_X - TILE_SIZE - 2\n elsif @x > WINDOW_SIZE_X - TILE_SIZE - 1\n @x = 0\n end\n end",
"def setup\n size 640, 300, P3D\n @lens_d = 160\n @lens_list = []\n @xx, @yy, @dx, @dy = 0, 0, 3, 3\n \n # Create buffered image for lens effect.\n @lens_effect = create_graphics(width, height, P2D)\n \n # Load background image.\n @lens_effect.begin_draw\n @lens_effect.image(load_image('red_smoke.jpg'), 0, 0, width, height)\n @lens_effect.end_draw\n image(@lens_effect, 0, 0, width, height)\n \n # Create buffered image for warping.\n @lens_image = create_graphics(@lens_d, @lens_d, P2D)\n @lens_image2 = create_graphics(@lens_d, @lens_d, P2D)\n \n compute_lens_transformation\nend",
"def overwrite_window\n return @window.overwrite(@otherwin.get_window)\n end",
"def composing\n background = Image.read('test.png').first\n avatar = Image.read('499317.jpeg').first\n\n avatar_resized = avatar.resize_to_fit(40,40)\n avatar_resized.border!(1, 1, 'black')\n avatar_resized.shadow(2, 5, 3)\n\n marketing_image = background.composite(avatar_resized, 30, 58, OverCompositeOp)\n\n text = \"耀你的命 show me your lives!\"\n\n content = Magick::Draw.new\n content.annotate(marketing_image, 0, 0, 60, 550, text) do\n self.font = './ZuiYouTi-2.ttf'\n self.pointsize = 24\n self.font_weight = Magick::BoldWeight\n self.fill = 'black'\n self.gravity = Magick::SouthEastGravity\n end\n\n\n marketing_image.write(\"marketing_image.png\")\nend",
"def window_update(actor)\n if actor != nil\n bodyImg = MENU_CONFIG::BODY_IMAGES[actor.id]\n bitmap = Cache.picture(bodyImg.filename)\n @cBackCharImage.img_bitmap = bitmap\n @cBackCharImage.src_rect = Rect.new(bodyImg.src_rect.x, bodyImg.src_rect.y, \n bitmap.width, bitmap.height)\n end\n refresh()\n end",
"def orient_patch\n rotmat = CVFFI::CvMat.new CVFFI::cvCreateMat( 2,3, :CV_32F )\n CVFFI::cv2DRotationMatrix( CVFFI::CvPoint2D32f.new( [ @patch.width/2.0, @patch.height/2.0 ]), -@angle*180.0/Math::PI, 1.0, rotmat )\n\n dstimg = @patch.twin\n CVFFI::cvWarpAffine( @patch, dstimg, rotmat )\n\n dstimg \n end",
"def collapse\n @posx = 471\n for i in 0...@party_banners.size\n @party_banners[i].move(@posx,Banner::PosY[i],255,10)\n end\n @removed.reverse_each do |j|\n $game_party.remove_actor($game_party.members[j].id)\n end\n end",
"def current_youth\n requested_youth\n end",
"def move_down(window)\n\t\t# if the horse isn't yet at the bottom of the screen move it down 20\n\t\tif @y < window.height - @image.height\n\t\t\t@y = @y +20\n\t\tend\n\tend",
"def set_outline\r\n # - - - - - - - - - - - - - - - - - -\r\n @pocket_flag = false\r\n return self\r\n end",
"def reset(window)\n\t\t# create a new image using a random one from the candyList\n @image = Gosu::Image.new(window, candyList.sample)\n # set w,h based on image size\n @w = @image.width\n @h = @image.height\n # a random Y value so it starts at a random place\n\t @y = Random.rand(window.height - @h)\n\t # velocity of Y is random from -5 to 5\n\t # this changes the angle of the candy\n\t @vy = rand(-5..5)\n\t # x is set to the full width of the window so it starts on the right side\n\t @x = window.width\n\tend",
"def close_image\n @p.close_image(self)\n end",
"def draw\n\t\[email protected]_rot(@x, @y, ZOrder::Enemy, @angle)\n\tend",
"def center_origins\n return if !self.bitmap\n self.ox = self.bitmap.width / 2\n self.oy = self.bitmap.height / 2\n end",
"def revise_cover_status\n if self.cover?\n Plant.find(self.plant_id).pictures.each do |picture|\n if (picture.cover? && picture.id != self.id)\n picture.cover = false\n picture.save\n end\n end\n end\n end",
"def flip_horizontally!\n @picture.flip_horizontally!\n end",
"def reset_overwrites\n @position_overwrite = @windowskin_overwrite = @nameskin_overwrite = nil\n @line_number_overwrite = @width_overwrite = nil\n end",
"def attach_image_to_observation(image)\n @observation.add_image(image)\n image.log_reuse_for(@observation)\n if @observation.gps_hidden\n error = image.strip_gps!\n flash_error(:runtime_failed_to_strip_gps.t(msg: error)) if error\n end\n redirect_with_query(permanent_observation_path(id: @observation.id))\n # render(\"observations/show\",\n # location: permanent_observation_path(id: @observation.id,\n # q: get_query_param))\n end",
"def set_picture\n #load new picture\n @persona = Persona.find(:first, :conditions => { :screen_name => params[:persona_id] } )\n #@persona.avatar = File.open(Rails.root.to_s + '/public' + params[:selected_photo_path])\n @persona.avatar = Photo.find( params[:selected_photo_id]).avatar.medium\n @persona.save!\n\n #crop picture\n @persona.crop params[:x_coor].to_i, params[:y_coor].to_i, params[:h_coor].to_i, params[:w_coor].to_i\n\n respond_to do |format|\n format.html { redirect_to persona_path(@persona.screen_name), notice: 'Persona Picture Updated' } \n end\n end",
"def continue\n @victory = false\n @level += 1\n drawFromPixmap\n end",
"def draw_plank x, y, image\r\n image.draw(x,y,1) # 1 denotes the ZOrder \r\nend",
"def with_crop(left, top, right, bottom); end",
"def flip\n @facing_up = !@facing_up\n self\n end",
"def home\n pen_up\n self.xy = ORIGIN\n self.heading = 0.0\n end",
"def rotate_right!\n @picture.rotate_right!\n end",
"def closeeye()\n\t\t@opened_eye = false\n\tend",
"def put_in_foundation\n if can_put_in_foundation?\n add_to_pile_beneath(@card_to_drop)\n @pile.cards.last.face_up unless @pile.empty?\n else\n call_off\n end\n end",
"def reset_window\n if $game_temp.in_battle\n self.y = 16\n else\n case $game_system.message_position\n when 0 # up\n self.y = 16\n when 1 # middle\n self.y = 160\n when 2 # down\n self.y = 304\n end\n end\n if $game_system.message_frame == 0\n self.opacity = 255\n else\n self.opacity = 0\n end\n#------------------------------------------------------------------------------\n# Begin Multiple Message Windows Edit\n#------------------------------------------------------------------------------\n # transparent speech bubbles don't look right, so keep opacity at 255\n # self.back_opacity = 160\n @tail.opacity = 255\n#------------------------------------------------------------------------------\n# End Multiple Message Windows Edit\n#------------------------------------------------------------------------------\n end",
"def set_over\n @over = Over.find(params[:id])\n end",
"def flip_horizontally(params = {})\n params[:name] ||= @pictureName.gsub('.png', 'FlippedH.png')\n params[:save] ||= @picturePath\n \n flip_h = dup\n flip_h.flip_horizontally!\n \n flip_h.pictureName, picturePath = params[:name], params[:save]\n flip_h\n end",
"def rotate_left!\n @picture.rotate_left!\n end",
"def apply(image)\n image.view(0,0,image.columns,image.rows) do |view|\n eyes.each { |eye| do_redeye(eye,view) }\n end\n end",
"def create_target_picture\n @target = Sprite.new(@viewport)\n @target.bitmap = Cache.picture(MAP_TARGET)\n center(@target)\n @target.opacity = 0\n end",
"def reset_window (change_opacity = true)\n # x-coordinate depends on justification\n if $game_system.message_event == -1 and $game_system.train_actor == -1\n if $game_system.window_justification == RIGHT\n self.x = 640 - $game_system.window_width\n elsif $game_system.window_justification == LEFT\n self.x = 0\n else # center\n self.x = (640 - self.width) / 2\n end\n elsif $game_system.train_actor >= 0\n if $game_system.train_actor == 0 or $game_system.train_actor > $game_party.actors.size - 1\n # center on player\n event_x = $game_player.screen_x\n else\n # center on train actor\n event_x = $game_train.actors[$game_system.train_actor - 1].screen_x\n end\n self.x = event_x - self.width / 2\n @comic.x = self.x + (self.width / 2) + 4\n else\n if $game_system.message_event == 0 or $game_map.events[$game_system.message_event] == nil\n # center on player\n event_x = $game_player.screen_x\n else\n # center on the event specified\n event_x = $game_map.events[$game_system.message_event].screen_x\n end\n self.x = event_x - self.width / 2\n @comic.x = self.x + (self.width / 2) + 4\n end\n \n if $game_temp.in_battle\n self.y = 16\n else\n if $game_system.message_event == -1 and $game_system.train_actor == -1\n case $game_system.message_position\n when 0 # up\n self.y = 16\n when 1 # middle\n #self.y = (480 - $game_system.window_height) / 2\n self.y = (480 - self.height) / 2\n when 2 # down\n #self.y = 480 - $game_system.window_height - 24\n self.y = 480 - self.height - 24\n end\n elsif $game_system.train_actor >= 0\n if $game_system.train_actor == 0 or $game_system.train_actor > $game_party.actors.size - 1\n # center on player\n self.y = $game_player.screen_y - self.height - 48\n else\n # center on train actor\n self.y = $game_train.actors[$game_system.train_actor - 1].screen_y - self.height - 48\n end\n @comic.y = self.y + self.height - 2\n @comic.angle = 0\n else\n if $game_system.message_event == 0 or $game_map.events[$game_system.message_event] == nil\n # above player\n self.y = $game_player.screen_y - self.height - 48\n else\n # above event specified\n self.y = $game_map.events[$game_system.message_event].screen_y - self.height - 48\n end\n @comic.y = self.y + self.height - 2\n @comic.angle = 0\n end\n end\n if self.y < 0 + ($game_system.name == \"\" ? 0 : 16)\n if $game_system.comic_enabled\n if $game_system.message_event == 0 or $game_map.events[$game_system.message_event] == nil\n self.y = $game_player.screen_y - 16\n else\n self.y = $game_map.events[$game_system.message_event].screen_y - 16\n end\n @comic.angle = 180\n @comic.y = self.y + 2\n @comic.x = self.x + (self.width / 2) - 4\n else\n self.y = 0 + ($game_system.name == \"\" ? 0 : 16)\n end\n elsif self.y > 480 - self.height \n self.y = 480 - self.height\n end\n if self.x < 0 \n self.x = 0\n elsif self.x > 680 - self.width - 48\n self.x = 640 - self.width\n end\n \n if change_opacity\n if $game_system.message_frame == 0 and $game_temp.message_text != \"\"\n self.opacity = $game_system.opacity\n else\n self.opacity = 0\n end\n self.back_opacity = $game_system.back_opacity\n end\n \n # window back stuff\n if $game_system.window_image != nil\n @window_back.bitmap = RPG::Cache.windowskin($game_system.window_image)\n @window_back.x = self.x\n @window_back.y = self.y\n end\n \n # face stuff\n if $game_system.face_graphic != \"\" \n # the player has chosen to show a face graphic\n if @done and $game_system.resting_face != \"\"\n @face.bitmap = RPG::Cache.picture($game_system.face_graphic + $game_system.resting_face)\n if @face_frame * $game_system.face_frame_width >= @face.bitmap.width\n @face_frame = 0\n end\n else\n @face.bitmap = RPG::Cache.face($game_system.face_graphic) #RPG::Cache.picture($game_system.face_graphic)\n end\n \n # picture y-coordinate\n if $game_system.face_graphic_position == ABOVE\n @face.y = self.y - @face.bitmap.height\n @face_offset = 0\n elsif $game_system.face_graphic_position == CENTER\n delta = (@face.bitmap.height - self.height) / 2\n @face.y = self.y - delta\n if $game_system.animated_faces\n @face_offset = $game_system.face_frame_width + 16\n else\n @face_offset = @face.bitmap.width + 16\n end\n elsif $game_system.face_graphic_position == BOTTOM \n @face.y = self.y + self.height - @face.bitmap.height\n if $game_system.animated_faces\n @face_offset = $game_system.face_frame_width + 16\n else\n @face_offset = @face.bitmap.width + 16\n end\n else # side\n delta = (@face.bitmap.height - self.height) / 2\n @face.y = self.y - delta\n @face_offset = 0\n end\n \n # picture x-coordinate\n if $game_system.face_graphic_justification == LEFT\n if $game_system.face_graphic_position == SIDE\n @face.x = self.x - @face.bitmap.width\n else\n @face.x = self.x + 10\n end\n else # right side\n if $game_system.animated_faces\n offset = @face.bitmap.width - $game_system.face_frame_width\n else\n offset = 0\n end\n if $game_system.face_graphic_position == SIDE\n @face.x = self.x + self.width + offset\n else\n @face.x = self.x + self.width - @face.bitmap.width - 10 + offset\n @face_offset = 0\n end\n end\n \n if $game_system.animated_faces\n @face.src_rect = Rect.new(@face_frame * $game_system.face_frame_width, 0, $game_system.face_frame_width, @face.bitmap.height)\n if @done and $game_system.resting_face != \"\"\n pause = $game_system.resting_animation_pause\n else\n pause = $game_system.animation_pause\n end\n if Graphics.frame_count % pause == 0\n @animate_face = true\n end\n if @animate_face\n if Graphics.frame_count % 3 == 0\n @face_frame += 1\n if @face_frame * $game_system.face_frame_width >= @face.bitmap.width\n @face_frame = 0\n @animate_face = false\n end\n end\n end\n end\n end\n \n # name window\n if $game_system.name != \"\"\n @name_window.x = self.x\n @name_window.y = self.y - 36\n @name_window.set_name($game_system.name)\n end\n \n # If choice\n if $game_temp.choice_max > 0\n @choice_window.set_choices($game_temp.choices)\n # determine x and y coords for choice window\n if $game_system.choice_justification == LEFT\n @choice_window.x = self.x\n else\n @choice_window.x = self.x + self.width - @choice_window.width\n end\n if $game_system.choice_position == ABOVE\n # check to make sure there is enough room above the textbox\n if self.y < @choice_window.height\n # not enough room above, place below\n @choice_window.y = self.y + self.height\n else\n # draw above\n @choice_window.y = self.y - @choice_window.height\n end\n elsif $game_system.choice_position == BOTTOM\n # check to make sure there is enough room below the textbox\n if (480 - self.y - self.height) < @choice_window.height\n # not enough room below, place above\n @choice_window.y = self.y - @choice_window.height\n else\n # draw below \n @choice_window.y = self.y + self.height\n end\n else # side\n if $game_system.choice_justification == LEFT\n # check to make sure there's room on the left side\n if self.y < @choice_window.width\n # not enough room on the side, check to make sure there's room below\n if (480 - self.y - self.height) < @choice_window.height\n # not enough room below, place above\n @choice_window.y = self.y - @choice_window.height\n else\n # draw below \n @choice_window.y = self.y + self.height\n end\n else\n # place on the left side\n @choice_window.y = self.y\n @choice_window.x = self.x - @choice_window.width\n end\n else # right\n # check to make sure there's room on the right side\n if (680 - (self.y + self.width)) < @choice_window.width\n # not enough room on the side, check to make sure there's room below\n if (480 - self.y - self.height) < @choice_window.height\n # not enough room below, place above\n @choice_window.y = self.y - @choice_window.height\n else\n # draw below \n @choice_window.y = self.y + self.height\n end\n else\n # place on the left side\n @choice_window.y = self.y\n @choice_window.x = self.x + self.width\n end\n end\n end\n end\n \n # If number input\n if $game_temp.num_input_variable_id > 0\n if @input_number_window == nil\n digits_max = $game_temp.num_input_digits_max\n number = $game_variables[$game_temp.num_input_variable_id]\n @input_number_window = Window_InputNumber.new(digits_max)\n @input_number_window.number = number\n end\n # determine x and y coords for number input window\n if $game_system.choice_justification == LEFT\n @input_number_window.x = self.x\n else\n @input_number_window.x = self.x + self.width - @input_number_window.width\n end\n if $game_system.choice_position == ABOVE\n # check to make sure there is enough room above the textbox\n if self.y < @input_number_window.height\n # not enough room above, place below\n @input_number_window.y = self.y + self.height\n else\n # draw above\n @input_number_window.y = self.y - @choice_window.height\n end\n elsif $game_system.choice_position == BOTTOM\n # check to make sure there is enough room below the textbox\n if (480 - self.y - self.height) < @input_number_window.height\n # not enough room below, place above\n @input_number_window.y = self.y - @input_number_window.height\n else\n # draw below \n @input_number_window.y = self.y + self.height\n end\n else # side\n if $game_system.choice_justification == LEFT\n # check to make sure there's room on the left side\n if self.y < @input_number_window.width\n # not enough room on the side, check to make sure there's room below\n if (480 - self.y - self.height) < @input_number_window.height\n # not enough room below, place above\n @input_number_window.y = self.y - @input_number_window.height\n else\n # draw below \n @input_number_window.y = self.y + self.height\n end\n else\n # place on the left side\n @input_number_window.y = self.y\n @input_number_window.x = self.x - @choice_window.width\n end\n else # right\n # check to make sure there's room on the right side\n if (680 - (self.y + self.width)) < @input_number_window.width\n # not enough room on the side, check to make sure there's room below\n if (480 - self.y - self.height) < @input_number_window.height\n # not enough room below, place above\n @input_number_window.y = self.y - @input_number_window.height\n else\n # draw below \n @input_number_window.y = self.y + self.height\n end\n else\n # place on the left side\n @input_number_window.y = self.y\n @input_number_window.x = self.x + self.width\n end\n end\n end\n end\n end",
"def rotate!( *args )\n super( *args )\n reset_positions_inside\n end",
"def draw\n @image.draw(@x - @width / 2, @y - @height / 2, 1)\n end",
"def draw\n\t\tif !@flipped and !@matched then\n\t\t\[email protected](@xLocation, @yLocation, 0)\n\t\telsif @flipped and !@matched\n\t\t\[email protected](@xLocation, @yLocation, 0)\n\t\telse\n\t\t\[email protected](@xLocation, @yLocation, 0)\n\t\tend\n\tend",
"def update\n super\n update_bitmap # Update HP Graphic\n update_screen # Update the position the graphic should be displayed\n end",
"def blur!\r\n ones = get_ones\r\n ones.each do |found_row_number, found_col_number| \r\n @picture[found_row_number -1][found_col_number] = 1 unless found_row_number == 0 #up\r\n @picture[found_row_number +1][found_col_number] = 1 unless found_row_number == @picture.length-1 #down\r\n @picture[found_row_number][found_col_number -1] = 1 unless found_col_number == 0 #left\r\n @picture[found_row_number][found_col_number +1] = 1 unless found_col_number == @picture[found_row_number].length-1 #right\r\n end\r\n end",
"def paint(src=dup_src)\n yield src.graphics\n src.graphics.dispose\n ImageVoodoo.new src\n end",
"def create_map_picture\n @picture = Sprite.new(@viewport)\n @picture.bitmap = Cache.picture(MINIMAP_PICTURE)\n @picture.x = P_X; @picture.y = P_Y\n @picture.opacity = 0\n end",
"def draw_banner\n bmp = Cache.picture(@quest.banner) # Get Picture\n # Shift the hue if requested\n bmp.hue_change(@quest.banner_hue) unless @quest.banner_hue == 0\n x = (contents_width - bmp.rect.width) / 2\n if x < 0 # Stretch horizontally if the banner is too wide\n dest_rect = bmp.rect.dup\n dest_rect.width = contents_width\n contents.stretch_blt(dest_rect, bmp, bmp.rect)\n else\n contents.blt(x, @draw_y, bmp, bmp.rect)\n end\n bmp.dispose\n end",
"def update_src_rect\n mrts_qcksnd_update_src_rect \n self.src_rect.height -= @sunk\n end",
"def gameover\n op_hand.clear\n end"
] |
[
"0.62050015",
"0.5834073",
"0.58287716",
"0.55790573",
"0.5568584",
"0.5531366",
"0.5516264",
"0.54942805",
"0.5431468",
"0.54175085",
"0.537942",
"0.5318694",
"0.5318694",
"0.53106004",
"0.5254725",
"0.5225934",
"0.51849735",
"0.5170199",
"0.5152548",
"0.51484066",
"0.51230025",
"0.5105726",
"0.5105726",
"0.5089498",
"0.5072763",
"0.5057992",
"0.5005454",
"0.49906892",
"0.49870703",
"0.49713475",
"0.49636674",
"0.49605945",
"0.49396262",
"0.49362773",
"0.4924693",
"0.49180567",
"0.48873374",
"0.48762712",
"0.48686653",
"0.48592815",
"0.4848556",
"0.4838614",
"0.48363954",
"0.48150915",
"0.4813306",
"0.48065874",
"0.4804849",
"0.47947755",
"0.47786683",
"0.47762474",
"0.47502163",
"0.47465858",
"0.47397736",
"0.47320855",
"0.472785",
"0.47251382",
"0.47204995",
"0.47122222",
"0.4689783",
"0.46866316",
"0.4679656",
"0.46753758",
"0.46711004",
"0.46698996",
"0.46535856",
"0.46485028",
"0.4643087",
"0.46427825",
"0.4635614",
"0.46354863",
"0.4634239",
"0.4632362",
"0.4628831",
"0.46267062",
"0.46253708",
"0.462163",
"0.4618579",
"0.46184084",
"0.4617442",
"0.46169186",
"0.46085626",
"0.4605902",
"0.46014386",
"0.45991385",
"0.4588401",
"0.45876834",
"0.45803347",
"0.45790458",
"0.45777166",
"0.45730475",
"0.45722765",
"0.45531934",
"0.4552491",
"0.45478693",
"0.45466208",
"0.45439768",
"0.4543761",
"0.45382783",
"0.4535558",
"0.4534086"
] |
0.7124058
|
0
|
Build a gif of the original image and the image with opened mouths
|
def animate_into_gif
animate = Commander.new("convert -loop 0 -delay 30")
animate << "#{@dir}/original.miff #{@dir}/opened_mouths.miff"
animate << Songster.output_folder.join("#{@fname}-singing.gif").to_s
animate.run!
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def gifify\n\tframes = 50\n gif = ImageList.new\n\tframes.times do |i|\n\t gif.concat(ImageList.new(\"tempImages/image#{i}.png\"))\n\tend\n\tgif.delay = 20\n\tgif.ticks_per_second = 50 \n\tgif.write(\"DOORCAPTURE.gif\")\n end",
"def update_gif\r\n @gif_handle.update(bitmap)\r\n end",
"def images_to_gif(directory_name, gif_name)\n puts \"converting to gif\"\n sequence = Magick::ImageList.new\n Dir.glob(\"#{directory_name}/*.jpg\").each do |image|\n sequence << Magick::Image.read(\"#{image}\").first\n# Sets the delay between images. Lower number = less delay between image change\n sequence.cur_image.delay = 10\n end\n end",
"def animate() %x{convert -delay 20 -loop 1 #{base}*.png #{base}.gif} end",
"def gif\n size = FFI::MemoryPointer.new(:pointer)\n ptr = ::GD2::GD2FFI.send(:gdImageGifPtr, image_ptr, size)\n ptr.get_bytes(0, size.get_int(0))\n ensure\n ::GD2::GD2FFI.send(:gdFree, ptr)\n end",
"def rawimage_to_gif(rawimage, width, height, palette, image_path)\n image = Image.new width, height\n draw = Draw.new\n ii = 0\n (0...height).each do |yy|\n (0...width).step(2).each do |xx|\n c0 = PixelColor.from_coco3(palette[(rawimage[ii].ord & 0xf0) >> 4])\n draw.fill(c0.to_s())\n draw.point(xx, yy)\n c1 = PixelColor.from_coco3(palette[rawimage[ii].ord & 0xf])\n draw.fill(c1.to_s())\n draw.point(xx + 1, yy)\n ii = ii + 1\n end\n end\n draw.draw image\n image.write image_path\nend",
"def decompressGifs\n destination=\"./Convert/\"\n search_for=[\"*.gif\"]\n \n @files=readDirectoryFiles(destination,search_for)\n @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)\n @viewport.z=999999\n \n @bar=Sprite.new(@viewport)\n @bar.bitmap=Bitmap.new(Graphics.width,34)\n pbSetSystemFont(@bar.bitmap)\n \n for i in [email protected]\n @files[i]=@files[i].gsub(/.gif/) {\"\"}\n end\n \n return false if !Kernel.pbConfirmMessage(_INTL(\"There is a total of #{@files.length} GIF(s) available for conversion. Would you like to begin the process?\"))\n \n for i in [email protected]\n file=@files[i]\n \n width=((i*1.000)/@files.length)*Graphics.width\n @bar.bitmap.clear\n @bar.bitmap.fill_rect(0,0,Graphics.width,34,Color.new(255,255,255))\n @bar.bitmap.fill_rect(0,0,Graphics.width,32,Color.new(0,0,0))\n @bar.bitmap.fill_rect(0,0,width,32,Color.new(25*4,90*2,25*4))\n text=[[\"#{i}/#{@files.length}\",Graphics.width/2,2,2,Color.new(255,255,255),nil]]\n pbDrawTextPositions(@bar.bitmap,text)\n \n next if RTP.exists?(\"#{destination}#{file}.png\")\n \n sprite=GifExtra.new(\"#{destination}#{file}.gif\")\n frames=sprite.totalFrames\n width=sprite.bitmap.width\n height=sprite.bitmap.height\n sprite.visible=false \n \n if width < height\n size=height\n elsif height < width\n size=width\n else\n size=width\n end\n \n bitmap=Bitmap.new(size*frames,size)\n x=0\n ox=((size-width)/2)\n oy=((size-height)/2)\n rect=Rect.new(0,0,width,height)\n frames.times do\n bitmap.blt((x*size)+ox,0+oy,sprite.bitmap,rect)\n sprite.update\n x+=1\n end\n bitmap.saveToPng(\"#{destination}#{file}.png\")\n sprite.dispose\n pbWait(1)\n RPG::Cache.clear\n end\n @bar.dispose\n @viewport.dispose\n Kernel.pbMessage(_INTL(\"Done!\"))\nend",
"def create_modified_gif(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end",
"def main\n ImageManip::inspect_image(@image_path)\n dimensions = ImageManip::get_dimensions(@image_path)\n sharp_pixels = get_accidental_pixels(@sharp_path)\n flat_pixels = get_accidental_pixels(@flat_path)\n edits = Hash.new\n edits[:lower_left] = [dimensions[0] / 2, dimensions[1] / 2]\n edits[:rgb_array] = sharp_pixels\n ImageManip::draw_2D_object(@image_path, './new_staff.gif', edits)\n edits[:lower_left] = [dimensions[0] / 3, dimensions[1] / 3]\n edits[:rgb_array] = flat_pixels\n ImageManip::draw_2D_object('./new_staff.gif', './new_staff.gif', edits)\n end",
"def to_gif(*a)\n to_blob('gif', *a)\n end",
"def draw_gif(frames, value)\n\t#An image list to put all the frames in\n\tgif = ImageList.new()\n\n\t#generates the final value of the gif\n\tlast_value = value\n\tframes.times do\n\t\tlast_value = next_number(last_value)\n\tend\n\n\t#gets the color for the first frame\n\tr1, g1, b1 = get_colors(value)\n\t#gets the color for the final frame\n\tr2, g2, b2 = get_colors(last_value)\n\n\t#Repeats this process for every frame\n\tfor k in 0...frames\n\t\t#gets the next image\n\t\tvalue = next_number(value)\n\t\t#makes a new image to put it in\n\t\tgrid = Image.new(TM_SQUARE_SIZE*5, TM_SQUARE_SIZE*5) {self.background_color = \"white\"}\n\t\t#makes a new draw to hold everything we'll be drawing\n\t\tsquares = Magick::Draw.new\n\t\t#sets the color so that over the course of the gif it transitions from the starting coloring to the ending one\n\t\tr = tween(r1, r2, k.to_f/frames)\n\t\tg = tween(g1, g2, k.to_f/frames)\n\t\tb = tween(b1, b2, k.to_f/frames)\n\t\tsquares.fill(\"rgb(#{r},#{g},#{b})\")\n\n\t\t#checks each digit for being a one or zero, just like above\n\t\tfor i in 0...5\n\t\t\tfor j in 0...5\n\t\t\t\tif value & 2 ** (j + i*5) != 0\n\t\t\t\t\t#This image doesn't get scrambled because it looks better this way\n\t\t\t\t\tsquares.rectangle(TM_SQUARE_SIZE*i, TM_SQUARE_SIZE*j, TM_SQUARE_SIZE*(i+1), TM_SQUARE_SIZE*(j+1))\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t#puts all the drawings on the grid\n\t\tsquares.draw(grid)\n\t\t#saves it in the imageList\n\t\tgif << grid\n\tend\n\t#sets the gif delay\n\tgif.delay = FRAME_LENGTH\n\t#saves the gif\n\tgif.write(\"gif#{value}.gif\")\n\t#and we return the last value of this gif\n\treturn value\nend",
"def create_frame_and_thumbnail\n if (File.extname(self.image_sequence) == \".mha\")\n file_path = Rails.root.join(dir_path, self.image_sequence)\n result = system(Rails.root.join('scripts','mha_to_png','bin',\"MhaToPng #{file_path} 1\").to_s)\n base_name = File.basename(file_path, \".mha\")\n image = MiniMagick::Image.open(\"#{dir_path}/#{base_name}_frame.png\")\n image.resize \"200x200\"\n image.format \"png\"\n image.write \"#{dir_path}/#{base_name}_thumbnail.png\"\n File.chmod(0644, \"#{dir_path}/#{base_name}_thumbnail.png\")\n self.thumbnail = \"#{base_name}_thumbnail.png\"\n self.frame = \"#{base_name}_frame.png\"\n end\n end",
"def to_gif(*a)\n to_image(*a).to_blob{|i| i.format ='gif' }\n end",
"def generate_reference_gif_for_char(char)\n draw_image_for_char char\n end",
"def embed_image(src, label)\n id = \"img_#{@img_id}\"\n @img_id += 1\n if @io.respond_to?(:path) and File.file?(src)\n out_dir = Pathname.new(File.dirname(File.absolute_path(@io.path)))\n src = Pathname.new(File.absolute_path(src)).relative_path_from(out_dir)\n end\n # removing home dir\n src = URI::encode(src.gsub(\"#{Dir.home}\", ''))\n @builder.span(:class => 'embed') do |pre|\n pre << %{<a href=\"\" onclick=\"img=document.getElementById('#{id}'); img.style.display = (img.style.display == 'none' ? 'block' : 'none');return false\">#{label}</a><br> \n <img id=\"#{id}\" style=\"display: none\" src=\"#{src}\"/>}\n end\n end",
"def modify_gif(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end",
"def load_bitmap\r\n if @picture_name.empty?\r\n dispose_bitmap if @gif_handle\r\n return\r\n end\r\n # Test for gif loading\r\n if File.exist?(gif_name = format('graphics/pictures/%<filename>s.gif', filename: @picture_name))\r\n @gif_handle = Yuki::GifReader.new(gif_name)\r\n self.bitmap = Bitmap.new(@gif_handle.width, @gif_handle.height)\r\n else\r\n set_bitmap(@picture_name, :picture)\r\n end\r\n end",
"def load_bitmap(pokemon)\n unless @gif\n gif = pokemon.position < 0 ? pokemon.gif_face : pokemon.gif_back\n if gif\n @gif = gif\n self.bitmap = Bitmap.new(@gif.width, @gif.height)\n @gif.update(bitmap)\n else\n self.bitmap = pokemon.position < 0 ? pokemon.battler_face : pokemon.battler_back\n end\n end\n end",
"def plotGif(gp, sendcmd, ofname, xlabel, ylabel)\n [\n \"set terminal gif\" ,\n \"set output '#{ofname}'\",\n \"set xlabel '#{xlabel}'\",\n \"set ylabel '#{ylabel}'\",\n \"plot #{sendcmd}\"\n ].each{|cmd| gp.puts(cmd) }\n p ofname\nend",
"def extract_graphic\n if !Cache.screenshot(@save_number, header).nil?\n bitmap_screenshot = Cache.screenshot(@save_number, header)\n @screenshot.zoom_x = 2\n @screenshot.zoom_y = 2\n else @virtualb = DataManager.load_screenshot(@save_number)\n if @virtualb.nil?\n bitmap_screenshot = black_bitmap\n else\n bitmap_screenshot = @virtualb.get_bitmap\n @screenshot.zoom_x = 2\n @screenshot.zoom_y = 2\n Cache.add_screenshot(@save_number, bitmap_screenshot, header[:key])\n end\n end\n @screenshot.bitmap = bitmap_screenshot\n @screenshot_loaded = false\n @loading_bar.disappear\n end",
"def ImageTag(smiley, animated = false)\n if animated\n '<img src=\"/public/smileys/animated/'+smiley+'.gif\" title=\"('+smiley+')\" height=\"20px\" width=\"20px\" style=\"display:inline;margin:0;vertical-align:middle\"/>'\n else\n '<img src=\"/public/smileys/general/'+smiley+'.png\" title=\":'+smiley+':\" height=\"20px\" width=\"20px\" style=\"display:inline;margin:0;vertical-align:middle\"/>'\n end\n end",
"def show\n\n # Get random gif from Giphy (http://giphy.com)\n response = HTTParty.get('http://api.giphy.com/v1/gifs/search?' +\n 'q=' + @boolio.val.to_s +\n '&api_key=dc6zaTOxFJmzC' + # provided for public beta testing via (https://github.com/Giphy/GiphyAPI#public-beta-key)\n '&limit=1' + # only want 1\n '&offset=' + rand(30).to_s + # pull from the top 10 most relevant images\n '&rating=pg' + # afraid if this is any higher\n '&fmt=json' # seems to return JSON anyway, but just in case\n )\n\n if response.code == 200\n\n # conver to JSON\n json = JSON.parse response.body, object_class: OpenStruct\n\n # set image from returned results\n @image = json.data[0].images if json.data.count > 0\n end\n\n end",
"def image_manipulations(html_doc)\n html_doc.css('img').each do |img|\n # prepare image for lazy loading\n unless img['src'] == LOADING_IMAGE_GIF\n src = UrlNormalizer.normalize_entry_url img['src'], self\n img['src'] = LOADING_IMAGE_GIF\n img['data-src'] = src\n end\n end\n return html_doc\n end",
"def write_image id, name_suffix=\"\"\n m_begin \"write_image\"\n filename = \"./temp/\" +id.to_s+name_suffix+\".gif\"\n get_image(id).write(filename)\n m_end \"write_image\"\n end",
"def to_iruby\n gif_base64 = Base64.encode64(plot)\n ['text/html', \"<img src=\\\"data:image/gif;base64, #{gif_base64}\\\">\"]\n end",
"def icon action = 'ruby'\n loader = @main.get_class.get_class_loader\n stream = loader.get_resource_as_stream(\"/com/moneydance/modules/features/ruby/#{action}.gif\")\n bytes = stream.to_io.read.to_java_bytes\n java.awt.Toolkit.default_toolkit.create_image(bytes)\n end",
"def output_image\r\n @icon.each do |data|\r\n puts data.join\r\n end\r\n end",
"def animation(filename, _hue = 0)\n load_image(@animation_cache, filename, Animations_Path, @animation_data)\n end",
"def pbLoadPokemonIcon(pokemon)\n return AnimatedBitmap.new(pbPokemonIconFile(pokemon)).deanimate\nend",
"def show_image\n temp_floor_tile = Image.new('tiles\\tile_floor_1.png')\n hex_width = temp_floor_tile.width - 6\n hex_height = temp_floor_tile.width - 4\n temp_floor_tile.remove\n @hexArray.each_with_index do | line, x |\n bottom_y = hex_height * 11\n y_start = bottom_y - (11 - line.size) * (hex_height / 2)\n line.each_with_index do | hex, y |\n cur_x = x * hex_width\n cur_y = y_start - y * hex_height\n\n case hex.type\n when Hex::FLOOR_TYPE\n Image.new('tiles\\tile_floor_1.png', x:cur_x, y:cur_y)\n when Hex::LAVA_TYPE\n Image.new('tiles\\tile_liquid_1.png', x:cur_x, y:cur_y)\n when Hex::EXIT_TYPE\n Image.new('tiles\\tile_base.png', x:cur_x, y:cur_y)\n Image.new('tiles\\dung_ladderdown.png', x:cur_x, y:cur_y)\n else\n Image.new('tiles\\tile_base.png', x:cur_x, y:cur_y)\n end\n if hex.contained_object != nil && hex.contained_object.type == MovingObject::PLAYER_TYPE\n Image.new('tiles\\player.png', x:cur_x, y:cur_y)\n end\n end\n end\n end",
"def convert_gifs(text)\n text.tap do\n text.gsub!(/\\\\(includegraphics|image|imagebox)\\{(.*)\\.gif\\}/) do\n \"\\\\#{$1}{#{$2}.png}\"\n end\n end\n end",
"def setImage\n str = @pixbuf.pixels\n str.length.times do |i| str[i] = @image_test[@current][i/3] end\n @pixbuf.pixels = str\n @image.pixbuf = @pixbuf.scale(280,280,Gdk::Pixbuf::INTERP_NEAREST)\n set_title(\"MSI, img ##{@current} => #{@label_test[@current]}\")\n if @edge\n edgifyImage\n end\n end",
"def set_gif\n @gif = Gif.find(params[:id])\n end",
"def set_gif\n @gif = Gif.find(params[:id])\n end",
"def set_gif\n @gif = Gif.find(params[:id])\n end",
"def set_gif\n @gif = Gif.find(params[:id])\n end",
"def set_gif\n @gif = Gif.find(params[:id])\n end",
"def image\n MAIN_CDN + \"headshots/current/168x168/#{@id}.jpg\"\n end",
"def image(full_path, opts = {})\n image_name = template.add_image(full_path)\n output = '<draw:frame text:anchor-type=\"as-char\" '\n opts[:width] && output << %Q(svg:width=\"#{opts[:width]}cm\" )\n opts[:height] && output << %Q(svg:height=\"#{opts[:height]}cm\")\n output << '>'\n output << %Q(<draw:image xlink:href=\"Pictures/#{image_name}\" )\n output <<\n 'xlink:type=\"simple\" xlink:show=\"embed\" xlink:actuate=\"onLoad\"/>'\n output << '</draw:frame>'\n end",
"def image()\n\t\tActionController::Base.helpers.image_tag(\"holes/Hunter_H%02d\" % self.number + \".jpg\" \\\n\t\t\t, :alt => 'Hole ' % self.number \\\n\t\t\t, :class => 'holeImage'\n\t\t\t)\n\tend",
"def new\n # Add second slash to url that rails routing eats\n url = request.fullpath.gsub(/\\/http(s?)\\:/, 'http:/')\n\n gif = Gif.find_or_initialize_by(url: url){|g| g.remote_gif_url = url}\n\n if gif.new_record? && gif.save\n load_index_data\n flash.now[:success] = thumb_flash(gif, \"Created gif!\")\n else\n if gif.errors.include? :checksum\n found = Gif.where(checksum: gif.checksum).first\n flash.now[:notice] = thumb_flash(found, \"We've got that GIF!\")\n end\n end\n \n load_index_data\n render action: 'index'\n end",
"def process_gif(video, output_key, tmpdir)\n local_output_path = \"#{tmpdir}/#{File.basename output_key}\"\n\n video.gif(local_output_path)\n\n upload(local_output_path, output_key)\n\n local_output_path\n end",
"def generate_png\n command = \"python #{Rails.root}/lib/webkit2png --transparent -F -o #{id} -D #{Rails.root}/tmp #{url} \"\n system command\n return \"#{Rails.root}/tmp/#{id}-full.png\"\n end",
"def update\r\n super\r\n # Try to load the new file if the name is different\r\n if @picture_name != @picture.name\r\n @picture_name = @picture.name\r\n load_bitmap\r\n end\r\n # Don't update if the name is empty\r\n if @picture_name.empty?\r\n self.visible = false\r\n return\r\n end\r\n self.visible = true\r\n\r\n update_properties\r\n update_gif if @gif_handle\r\n end",
"def process_gif(data, filename)\n type = 'gif'\n x_dpi = 96\n y_dpi = 96\n\n width = data[6, 2].unpack1(\"v\")\n height = data[8, 2].unpack1(\"v\")\n\n raise \"#{filename}: no size data found in gif image.\\n\" if height.nil?\n\n [type, width, height, x_dpi, y_dpi]\n end",
"def show\n @gif = Gif.find(params[:id])\n render layout: false\n end",
"def new_image_markup(gallery)\n render_to_string(\n file: 'bootsy/images/_new',\n formats: [:html],\n locals: { gallery: gallery, image: gallery.images.new },\n layout: false\n )\n end",
"def logo\n rand_num = Random.rand(76) + 1\n \"http://www.biz-logo.com/examples/#{ rand_num < 10 ? \"00\" : \"0\" }#{rand_num}.gif\"\n end",
"def import_gifts_inst\n end",
"def loading_gif(id)\n image_tag(image_url('loading.gif'),\n class: 'loading_chart_gif', id: id,\n style: 'display: none;')\n end",
"def image(src, options = {})\n media = extract_media!(options)\n (@images ||= []) << IMAGE.new(src, media, options)\n\n # Do not render anything here!\n return \"\"\n end",
"def import_gifts_step_two\n end",
"def process_small_image\n small_image.encode!(:png).convert!('-resize 50x50 -gravity center -background none -extent 50x50')\n end",
"def generate_noise_gif_for_char(char)\n image = @reference_image_hash[char]\n\n #image = image.wave(10, 100)\n image = image.add_noise(Magick::PoissonNoise)\n #image = image.rotate(5)\n #image = image.resize_to_fit(@config.char_width, @config.char_height)\n\n image\n end",
"def start_load_screenshot\n show_loading_bar\n Thread.new{extract_graphic}\n end",
"def modify_gif_from_storage\n puts('Update parameters of a GIF image from cloud storage')\n\n upload_sample_image_to_cloud\n\n background_color_index = 5\n color_resolution = 4\n has_trailer = true\n interlaced = false\n is_palette_sorted = true\n pixel_aspect_ratio = 4\n from_scratch = nil\n folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage\n storage = nil # We are using default Cloud Storage\n\n request = AsposeImagingCloud::ModifyGifRequest.new(\n get_sample_image_file_name, background_color_index, color_resolution, has_trailer, interlaced,\n is_palette_sorted, pixel_aspect_ratio, from_scratch, folder, storage)\n\n puts(\"Call ModifyGif with params: background color index: #{background_color_index}, color resolution: \" +\n \"#{color_resolution}, has trailer: #{has_trailer}, interlaced: #{interlaced}}, is palette sorted: \" +\n \"#{is_palette_sorted}, pixel aspect ratio: #{pixel_aspect_ratio}\")\n\n updated_image = imaging_api.modify_gif(request)\n save_updated_sample_image_to_output(updated_image, false)\n puts\n end",
"def blue_shift\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.blue_shift(2)\n img.write('public' + @photo.attachment_url)\n end",
"def capture\n for i in 0..49\n\t open(\"tempImages/image#{i}.png\", 'wb') do |file|\n\t file << open('http://hq.cirrusmio.com:82/media/?action=snapshot', http_basic_authentication: [\"admin\", \"admin\"]).read\n\t sleep(0.2)\n\tend\n end\n end",
"def charcoal\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.charcoal(0.0, 1.0)\n img.write('public' + @photo.attachment_url)\n end",
"def write_gif_data(utm_url, time_stamp, visitor_id)\n header = {}\n\n header[\"Content-Type\"] = \"image/gif\"\n header[\"Cache-Control\"] = \"private, no-cache, no-cache=Set-Cookie, proxy-revalidate\"\n header[\"Pragma\"] = \"no-cache\"\n header[\"Expires\"] = \"Wed, 17 Sep 1975 21:32:10 GMT\"\n\n #If the debug parameter is on, add a header to the response that contains\n #the url that was used to contact Google Analytics.\n header[\"X-GA-MOBILE-URL\"] = utm_url if $cgi[\"utmdebug\"] != \"\"\n\n #Always try and add the cookie to the response.\n header[\"cookie\"] = CGI::Cookie.new({\n \"name\" => COOKIE_NAME,\n \"value\" => visitor_id,\n \"expire\" => time_stamp + COOKIE_USER_PERSISTENCE.to_s,\n 'path' => COOKIE_PATH\n })\n\n $cgi.out(header){GIF_DATA.pack(\"C35\")}\nend",
"def update_bitmap\n ### The following commented lines may be used for animation frames ###\n # # Get the graphic that represents the current frame\n # sx = @unit.frame * @cw\n # # Take the square graphic from the rectangular picture\n # self.src_rect.set(sx, 0, @cw, @ch)\n self.src_rect.set(0, 0, @cw, @ch)\n end",
"def get_haplotype_img(map_id)\n\n map = Map.find(map_id)\n @markers = []\n chromosome = params['chromosome'] || 1\n start = params['start'] || 20000000\n stop = params['end'] || 25000000\n\n # do the processing to get the data and create the image\n get_region_marker_data(chromosome, start, stop)\n # redirect output to the image file itself, thereby rendering the file\n redirect_to draw_haplotype_image(@markers, @strains, @genotypes, false, 'high', 'gif')\n\n end",
"def auto_image(html)\n return html.gsub(%r{http(s?):[a-z0-9/.\\-_%~/\\=\\?\\:]+(.gif|.jpg|.jpeg|.png|.bmp|.tif|.tiff)(?:\\?[\\w\\=\\.]+)?}i,\n '<img src=\"\\0\"/>')\n end",
"def set_img\n\n end",
"def image(local=1)\n unless cururl.index(Internet_path)\n fail \"You can only do this on a Researchr wikipage\"\n end\n wiki = cururl[22..-1]\n w,dummy = wiki.split(\"?\")\n wikipage = w.gsubs({:all_with => \"_\"}, \":\", \"%3A\", \"%20\").downcase\n\n if local==1\n curfile = File.last_added(\"#{Home_path}/Desktop/Screen*.png\") # this might be different between different OSX versions\n else\n dir = File.last_added_dir(Photostream_path) # this might be different between different OSX versions\n curfile = File.last_added(dir+\"*.JPG\")\n end\n if curfile == nil\n growl(\"No screenshots available\")\n exit\n end\n\n newfilename, pagenum = filename_in_series(\"#{Wiki_path}/data/media/pages/#{wikipage}\",\".png\")\n p newfilename\n if File.exists?(newfilename)\n pbcopy(\"\")\n fail(\"File already exists, aborting!\")\n end\n puts %Q(mv \"#{curfile.strip}\" \"#{newfilename}\")\n `mv \"#{curfile.strip}\" \"#{newfilename}\"`\n if defined?(dir) # if from iCloud\n `rm -rf \"#{dir}\"`\n `sips --resampleWidth 487 #{newfilename}`\n end\n `touch \"#{newfilename}\"` # to make sure it comes up as newest next time we run filename_in_series\n\n pbcopy(\"{{pages:#{wikipage}#{pagenum}.png}}\")\nend",
"def inspire_image\n head = satelliterepo.head.target\n parent = head.parents.first\n diff = head.diff parent\n # in some case diff is nil, which breaks image generation\n # with nilclass error <- TODO: Investivate this further\n return if diff.nil? || diff.deltas.empty?\n path = diff.deltas.last.new_file[:path]\n generate_inspire_image path\n end",
"def show_image\n if @wine.picture.attached?\n image_tag(@wine.picture.service_url, alt: \"your_image\", height: \"250\", style: \"border: 1px solid #220F24\")\n end\n end",
"def image\n if @notice.image?\n if(params[:style] == \"original\" || params[:style] == \"large\" || params[:style] == \"small\")\n send_file(@notice.image.path(params[:style]), filename:@notice.image_file_name, type: \"image/jpg\",disposition: 'inline',x_sendfile: true)\n else\n send_file(@notice.image.path(:large), filename:@notice.image_file_name, type: \"image/jpg\",disposition: 'inline',x_sendfile: true)\n end\n end\n end",
"def decorate_image\n if model.image_processed?\n return h.image_tag model.image_url(:thumb) if model.image?\n else\n return '<em>processing...</em>'\n end\n end",
"def paint(src=dup_src)\n yield src.graphics, src\n src.graphics.dispose\n ImageVoodoo.new(@io, src, @format)\n end",
"def make_badge( badge_text, deal )\n\n badge_text = badge_text.gsub('\"', \"\").gsub(\"'\", \"\").strip # take out single and double ticks\n badge_text = \"'\" << badge_text << \"'\" # enclose in single ticks\n badge_text = badge_text.gsub(\"$\", \"\\\\$\").gsub(\"/\", \"\") # take out forward and backslashes\n\n # img = MiniMagick::Image.open(\"public/images/yellow_starburst.jpg\")\n img = MiniMagick::Image.open(\"app/assets/images/yellow_starburst.jpg\")\n\n img.combine_options do |c|\n c.resize \"#{Victoria::Application::BADGE[0]}x#{Victoria::Application::BADGE[1]}\" # \"75x75\"\n c.gravity \"Center\"\n c.antialias\n c.font \"helvetica italic\"\n c.pointsize \"18\"\n c.draw \"text 0,0 #{badge_text}\" # 0,0 = x,y coords\n c.fill(\"#000000\")\n end\n # badge_path = \"badges/badge_#{deal.id}.jpg\"\n badge_path = \"badge_#{deal.id}.jpg\"\n deal.update_attribute(:badge_path, badge_path)\n # img.write(\"public/images/#{badge_path}\")\n img.write(\"app/assets/badges/#{badge_path}\")\n # returns \"app/assets/images/badges/badge_21.jpg JPEG 145x150 145x150+0+0 8-bit DirectClass 11.6KB 0.000u 0:00.010 \"\n end",
"def image\n assert_file!\n @image ||= ChunkyPNG::Image.from_file(@path)\n end",
"def create\n @gif = Gif.new(gif_params)\n @gif.avatar_remote_url(@gif.url)\n @gif.approved = false\n @gif.deleted = false\n @gif.upvotes = 0\n @gif.downvotes = 0\n @gif.ratio = 0\n @gif.views = 0\n\n respond_to do |format|\n if @gif.save\n format.html { redirect_to @gif, notice: 'Gif was successfully created.' }\n format.json { render action: 'show', status: :created, location: @gif }\n else\n format.html { render action: 'new' }\n format.json { render json: @gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def render_flex_image(img)\r\n img.to_jpg!\r\n send_data(img[img.class.binary_column], :type => 'image/jpeg', :disposition => 'inline')\r\n GC.start\r\n end",
"def image; end",
"def draw_custom_image\r\r\n bitmap = Cache.picture($game_map.ach_display.graphic)\r\r\n rect = Rect.new(0,0,bitmap.width,bitmap.height)\r\r\n target = Rect.new(0,0,contents.width,contents.height)\r\r\n contents.stretch_blt(target, bitmap, rect, 255)\r\r\n end",
"def put_image_extract_as_gif(name, image_id, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = put_image_extract_as_gif_with_http_info(name, image_id, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = put_image_extract_as_gif_with_http_info(name, image_id, opts)\n else\n raise\n end\n return data\n end",
"def load_images\n @@images[\"background\"] = Gosu::Image.new(self, \"media/ground.jpeg\", true)\n @@images[\"circle\"] = Gosu::Image.new(self, \"media/ground.jpeg\", true)\n @@images[\"creeps\"] = Gosu::Image.load_tiles(\"./media/pokemons.png\", 32, 32)\n end",
"def ImageStore(smiley, animated = false)\n if animated\n Net::HTTP.start(Animated_Smiley_URI) do |http|\n res = http.get('/images/Skype/'+smiley+'.gif')\n File.open('public/smileys/animated/'+smiley+'.gif', 'wb') { |file| file.write(res.body) }\n\tend\n else\n Net::HTTP.start(General_Smiley_URI) do |http|\n res = http.get('/graphics/emojis/'+smiley+'.png')\n File.open('public/smileys/general/'+smiley+'.png', 'wb') { |file| file.write(res.body) }\n\tend\n end\n end",
"def pure_jpg\n Jhead.call(\"-purejpg\", @match, @pattern)\n end",
"def figure_1 \n #file_path = File.join(Rails.root, \"public/images\", \"\")\n send_file(File.join(FILE_PATH, \"LgrNucDist.jpg\"), :type => 'image/png', :disposition => 'inline')\n end",
"def images; end",
"def proxy_image\n multiresimage = Multiresimage.find(params[:id])\n img_length = params[:image_length]\n\n begin\n if multiresimage.DELIV_OPS.svg_image.svg_width[0].to_i <= params[:image_length].to_i\n img_length = multiresimage.DELIV_OPS.svg_image.svg_width[0].to_i-1\n end\n rescue Exception\n #this is a fix so that smaller images get shown. Currently, they break since larger versions do not exist.\n end\n\n default_image = File.open(\"app/assets/images/site/missing2.png\", 'rb') do |f|\n f.read\n end\n filename = \"missing2.png\"\n resp = ''\n\n if can?(:read, multiresimage)\n\n Net::HTTP.start(DIL_CONFIG['dil_fedora_base_ip'], DIL_CONFIG['dil_fedora_port']) { |http|\n resp = http.get(\"#{DIL_CONFIG['dil_fedora_url']}#{params[:id]}#{DIL_CONFIG['dil_fedora_disseminator']}#{img_length}\")\n #open(\"/usr/local/proxy_images/#{params[:id]}.jpg\" ,\"wb\") { |new_file|\n #new_file.write(resp.body)\n #send_file(new_file, :type => \"image/jpeg\", :disposition=>\"inline\")\n #send data uses server memory instead of storage.\n if(resp.body.include? \"error\")\n image = default_image\n else\n image = resp.body\n filename = \"#{params[:id]}.jpg\"\n end\n send_data(image, :disposition=>'inline', :type=>'image/jpeg', :filename=>filename)\n }\n #}\n else\n send_data(default_image, :disposition=>'inline', :type=>'image/jpeg', :filename=>filename)\n end\n end",
"def render_image\n render_image_iterm2\n end",
"def paint(src=dup_src)\n yield src.graphics\n src.graphics.dispose\n ImageVoodoo.new src\n end",
"def generate_png\n img = IMGKit.new(url).to_png\n file = File.new(\"#{id}-full.png\", \"w\", :encoding => 'ascii-8bit')\n file.write(img)\n return file.path\n end",
"def show\n # require \"mini_magick\"\n #\n # @codeimage = @code.image\n # croppedcode = @codeimage.cropped\n # compositecode = @codeimage.composite\n # base = Base.last.image\n #\n # newimage = MiniMagick::Image.open(croppedcode.url)\n # baseimage = MiniMagick::Image.open(base.url)\n # newimage.rotate(\"-10\")\n #\n # newimage = baseimage.composite(newimage) do |c|\n # c.compose(\"Darken\")\n # c.geometry(\"200x200+215+70\")\n # c.gravity(\"southeast\")\n # end\n\n\n # newimage.write(@codeimage.composite.url)\n\n if Code.count > 1\n if Code.first.created_at < 7.days.ago\n Code.first.delete\n end\n end\n\n redirect_to root_url\n\n end",
"def get_gif_ref(word)\n word = word.gsub(/[\\^\\:']/,'')\n test_word = word.gsub(/[,.]/, '').downcase\n \"<img src='/images/stats/#{test_word}.gif' style='max-width: 30px;'></img>\"\nend",
"def show\n commontator_thread_show(@diff.new_image)\n end",
"def show_in_browser(lfile)\n htfile = \"/tmp/lyrics-out.html\"\n begin\n mp3info = Mp3Shell.new(@track.location.path)\n awfile = mp3info.get_artwork(\"/tmp/artwork\")\n if awfile && (awfile !~ /xxx$/) && (File.size(awfile) > 1024)\n background = \"background: url(#{awfile}) no-repeat center center fixed\"\n else\n Plog.info \"No image found for #{@track.name}. Use gradient\"\n background = \"background-image: -webkit-gradient(linear, left top, right bottom, color-stop(0, #FFFFFF), color-stop(1, #00A3EF))\"\n end\n rescue => errmsg\n p errmsg\n end\n File.open(htfile, \"w\") do |fod|\n fod.puts <<EOF\n<html><head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n<title>#{@track.name} - #{@track.artist}</title>\n<style type=\"text/css\">\n html { \n #{background};\n -webkit-background-size: cover;\n -moz-background-size: cover;\n -o-background-size: cover;\n background-size: cover;\n }\n .transbox {\n width:80%;\n margin:5% 10%;\n padding: 5px;\n background-color:#ffffff;\n border:1px solid #888888;\n opacity:0.7;\n filter:alpha(opacity=70); /* For IE8 and earlier */\n position: relative;\n }\n .info {\n font-size: 80%;\n color: #888;\n }\n .footer {\n position: relative;\n clear: both;\n margin-top: 20px;\n height: 20px;\n }\n</style>\n<script src=\"http://code.jquery.com/jquery.js\"></script>\n</head>\n<body>\n<div class=\"container\">\n<div class=\"transbox\">\nEOF\n fod.puts <<EOF\n<div class=info>\n<b>Artist:</b> #{@track.artist}\n<b>Author:</b> #{@track.composer}\n<b>Album:</b> #{@track.album}\n</div>\nEOF\n fod.puts \"<center><h2>#{@track.name}</h2>\"\n lines = File.read(lfile).split(/[\\r\\n][\\r\\n]+/)[1..-1]\n lines = lines.join(\"\\n\\n\").gsub(/[\\r\\n]/, \"\\n<br>\")\n\n fod.puts(lines)\n q0 = \"Lyrics #{@track.name} #{@track.artist}\"\n q = URI::escape(q0)\n href = \"http://www.google.com/search?q=#{q}&oq=#{q}ie=UTF-8\"\n fod.puts <<EOF\n</center>\n<a href=#{href}>#{q0}</a>\n<div class=\"info footer\">\n<b>Artist:</b> #{@track.artist}\n<b>Author:</b> #{@track.composer}\n<b>Album:</b> #{@track.album}\n</div>\n</div>\n</div>\n</body></html>\nEOF\n end\n browser = @options[:browser] || \"Safari\"\n Pf.system(\"open -a '#{browser}' #{htfile}\", 1)\n end",
"def icon\n pic = Paint.find(params[:id])\n send_data(Base64.decode64(pic.filedata), disposition: 'inline')\n end",
"def icon\n respond_to do |format|\n if @package.present?\n format.png do\n send_file @package.icon.photo.path, :url_based_filename => true, :type => \"image/png\", :disposition => \"inline\"\n fresh_when :etag => @package, :last_modified => @package.created_at.utc, :public => true\n end\n else\n render page_not_found\n end\n end\n end",
"def generate_images width=500, height=350\n # Base image with all territories shaded\n canvas = Magick::Image.new(width, height, Magick::TextureFill.new(@@map_bg))\n canvas.format = 'jpg'\n gc = Magick::Draw.new\n Territory.all.each do |t|\n gc.fill(\"transparent\")\n if t.clan\n gc.fill(\"rgb(#{t.clan.color_rgb.join(',')})\")\n gc.fill_opacity(0.25)\n end\n gc.stroke('rgb(64, 0, 0)')\n gc.stroke_width(1)\n if t.shape # uses svg-like shapes\n s = t.shape.split(',')\n path = \"M #{s[0]} #{s[1]} \"\n s[2..-1].each_slice(2) do |p|\n path << \"L #{p[0]} #{p[1]} \"\n end\n path << \"z\"\n gc.path(path)\n end\n\n if t.clan\n # draw the small icon for the clan if it exists\n if t.clan.image_filename 16\n gc.composite(t.position_x - 8, t.position_y - 8, 16, 16,\n Magick::Image.read(\"#{RAILS_ROOT}/public/images/#{t.clan.image_filename(16)}\").first)\n else # or draw a circle of their color\n gc.fill(\"rgb(#{t.clan.color_rgb.join(',')})\")\n gc.fill_opacity(1);\n gc.circle(t.position_x, t.position_y, t.position_x + 5, t.position_y)\n end\n else\n gc.circle(t.position_x, t.position_y, t.position_x + 5, t.position_y)\n end\n end\n gc.draw(canvas)\n canvas.write(\"#{RAILS_ROOT}/public/images/map/base.jpg\"){ self.quality = 95 } # TODO tweak the quality\n\n true\n end",
"def image_from_url(url)\n self.image.attach(io: URI.open(url), filename: 'generated-sketch.jpg')\n end",
"def end(args = {})\n \n if args[:file]\n file = args[:file]\n else\n if !args[:filename]\n file = \"#{@dir}/#{@name}.gif\"\n else\n file = \"#{@dir}/#{filename}\"\n end\n end\n \n rotate = args[:rotate] || 0\n step = args[:step] || 1\n max_width = args[:max_width] || Lava::DEFAULT_MAX_WIDTH\n max_height = args[:max_height] || Lava::DEFAULT_MAX_HEIGHT\n speed = args[:speed] || Lava::DEFAULT_SPEED\n \n \n rimages = Magick::ImageList.new\n (0 ... samples.count ).step(step).each do |i|\n s = samples[i]\n s.rimage.rotate! rotate\n s.rimage.resize_to_fit!(max_width, max_height)\n rimages << s.rimage\n end\n rimages.ticks_per_second = speed\n rimages.write(file)\n end",
"def image\n @image ||= MiniMagick::Image.open(source_path)\n end",
"def image_source_of( piece )\n \"/images/sets/default/#{piece.img_name}.gif\"\n session[:set] ||= 'default'\n path = \"/images/sets/#{session[:set]}/\"\n extension = gif_file_exists?(piece, path) ? \".gif\" : \".png\"\n path + piece.img_name + extension\n end",
"def test_gif_dispose(pokemon)\n return unless @pokemon && @gif\n if !pokemon || (@pokemon.id != pokemon.id) || (@pokemon.form != pokemon.form)\n bitmap.dispose\n @gif = nil\n end\n end",
"def img_path() \"#{$dir}/sprites.gif\"; end",
"def icon4share\r\n icon_path = self.display_icon.original\r\n icon4share_path = icon_path + \"4share.jpg\"\r\n unless File.exist?('public'+icon4share_path)\r\n back = Magick::Image.read('public/images/back4share.jpg').first\r\n icon = Magick::Image.read('public'+icon_path).first\r\n result = back.composite(icon, Magick::CenterGravity, Magick::OverCompositeOp)\r\n result.write('public'+icon4share_path)\r\n end\r\n icon4share_path\r\n end"
] |
[
"0.7335512",
"0.69443727",
"0.6922631",
"0.68361676",
"0.6663437",
"0.6235565",
"0.6148943",
"0.60807765",
"0.60747105",
"0.6072982",
"0.6059988",
"0.60149586",
"0.60052985",
"0.599802",
"0.595314",
"0.58922875",
"0.58846265",
"0.5877651",
"0.5875413",
"0.5846837",
"0.58395064",
"0.5740964",
"0.5738502",
"0.57087713",
"0.57014376",
"0.5685499",
"0.5627692",
"0.56229794",
"0.5620929",
"0.5619479",
"0.5600807",
"0.55990136",
"0.5593421",
"0.5593421",
"0.5593421",
"0.5593421",
"0.5593421",
"0.5587353",
"0.5586561",
"0.55863804",
"0.5580377",
"0.55715626",
"0.55704445",
"0.5553127",
"0.55436826",
"0.5525139",
"0.55230683",
"0.5519536",
"0.5502805",
"0.54996765",
"0.54787976",
"0.54785407",
"0.54775256",
"0.5464606",
"0.54314077",
"0.5422529",
"0.5417439",
"0.5412366",
"0.5404077",
"0.5403321",
"0.53980905",
"0.53950846",
"0.53915",
"0.5377639",
"0.53689355",
"0.5365798",
"0.53589153",
"0.5354811",
"0.5335359",
"0.5326626",
"0.5324627",
"0.532393",
"0.5322223",
"0.5305238",
"0.529188",
"0.52744454",
"0.5273009",
"0.52697563",
"0.52689093",
"0.5266091",
"0.5263515",
"0.5246671",
"0.5245849",
"0.5241391",
"0.52411664",
"0.52391845",
"0.52386713",
"0.52357304",
"0.5235243",
"0.52324295",
"0.52267516",
"0.5222892",
"0.5221829",
"0.521745",
"0.52096593",
"0.5208854",
"0.52011466",
"0.5191419",
"0.5186787",
"0.5186333"
] |
0.7667655
|
0
|
characterizes the file_node passed into this service Default options are: save: true
|
def characterize(save: true)
persister.save(resource: @file_node) if save
@file_node
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def characterize(save: true)\n new_file = original_file.new(file_characterization_attributes.to_h)\n @file_node.file_metadata = @file_node.file_metadata.select { |x| x.id != new_file.id } + [new_file]\n @persister.save(resource: @file_node) if save\n @file_node\n end",
"def characterize(save: true)\n @file_characterization_attributes = {\n width: image.width.to_s,\n height: image.height.to_s,\n mime_type: image.mime_type,\n checksum: MultiChecksum.for(file_object),\n size: image.size\n }\n new_file = original_file.new(@file_characterization_attributes.to_h)\n @file_node.file_metadata = @file_node.file_metadata.select { |x| x.id != new_file.id } + [new_file]\n @persister.save(resource: @file_node) if save\n @file_node\n end",
"def characterize(save: true)\n TikaFileCharacterizationService.new(file_node: file_node, persister: persister).characterize\n external_metadata_service.characterize if external_metadata_service.valid?\n end",
"def characterize(save: true)\n TikaFileCharacterizationService.new(file_set: file_set, persister: persister).characterize\n end",
"def characterize(save: true)\n [:original_file, :intermediate_file, :preservation_file].each do |type|\n target_file = @file_set.try(type)\n next unless target_file\n @file_object = Valkyrie::StorageAdapter.find_by(id: target_file.file_identifiers[0])\n new_file = target_file.new(file_characterization_attributes.to_h)\n @file_set.file_metadata = @file_set.file_metadata.select { |x| x.id != new_file.id } + [new_file]\n end\n @file_set = persister.save(resource: @file_set) if save\n @file_set\n end",
"def characterize(save: true)\n [:original_file, :intermediate_file, :preservation_file].each do |type|\n @target_file = @file_set.try(type)\n next unless @target_file\n @file_object = Valkyrie::StorageAdapter.find_by(id: @target_file.file_identifiers[0])\n @dataset_path = filename\n unzip_original_file if zip_file?\n new_file = @target_file.new(file_characterization_attributes.to_h)\n @file_set.file_metadata = @file_set.file_metadata.select { |x| x.id != new_file.id } + [new_file]\n clean_up_zip_directory if zip_file?\n end\n @file_set = persister.save(resource: @file_set) if save\n @file_set\n end",
"def characterize(save: true)\n [:original_file, :intermediate_file, :preservation_file].each do |type|\n target_file = @file_set.try(type)\n next unless target_file\n @file_object = Valkyrie::StorageAdapter.find_by(id: target_file.file_identifiers[0])\n next unless image_valid?\n new_file = target_file.new(file_characterization_attributes.to_h)\n @file_set.file_metadata = @file_set.file_metadata.select { |x| x.id != new_file.id } + [new_file]\n end\n @file_set = persister.save(resource: @file_set) if save\n @file_set\n end",
"def characterize\n metadata = content.extract_metadata\n characterization.ng_xml = metadata if metadata.present?\n append_metadata\n self.filename = [content.original_name]\n save\n end",
"def characterize\n self.characterization.ng_xml = self.content.extract_metadata\n fix_data_characterization!\n self.append_metadata\n self.filename = self.label\n save\n end",
"def characterize(save: true)\n unzip_original_file if zip_file?\n new_file = original_file.new(file_characterization_attributes.to_h)\n @file_set.file_metadata = @file_set.file_metadata.select { |x| x.id != new_file.id } + [new_file]\n @file_set = @persister.save(resource: @file_set) if save\n clean_up_zip_directory if zip_file?\n @file_set\n end",
"def characterize\n self.characterization.ng_xml = self.content.extract_metadata\n self.append_metadata\n self.filename = self.label\n save\n end",
"def characterize\n fits_xml, ffprobe_xml = self.content.extract_metadata\n self.characterization.ng_xml = fits_xml\n fix_mxf_characterization!\n self.ffprobe.ng_xml = ffprobe_xml if ffprobe_xml\n self.append_metadata\n self.filename = self.label\n save unless self.new_object?\n end",
"def file_options; end",
"def file_characterization_attributes\n {\n mime_type: mime_type\n }\n end",
"def uploaded_file=(file_field)\n self.filename = base_part_of(file_field.original_filename)\n\n f_str = Iconv.conv('utf-8', self.encoding, file_field.read)\n\n f = StringIO.new(f_str)\n\n if self.format == 'OBT'\n it = OBNOTextIterator.new(f, self.sentence_delimiter == 'delimiter')\n elsif self.format == 'VRT'\n it = VRTReader.new(f)\n else\n raise RuntimeError\n end\n\n it.each_sentence {|s| sentences << s}\n f.close()\n\n # add postamble stored in iterator after parsing last sentence\n # TODO add support for arbitrary data for OBT format\n if self.format = 'VRT'\n self.postamble = it.postamble\n end\n end",
"def update_upload_attributes\n if document.present? && document_changed?\n self.content_type = document.file.content_type\n self.file_size = document.file.size\n self.file_name = File.basename(document.url)\n end\n end",
"def file_characterization_attributes\n {\n geometry: info_service.geom,\n mime_type: mime_type\n }\n end",
"def file_characterization_attributes\n {\n geometry: info_service.geom,\n mime_type: mime_type\n }\n end",
"def file_characterization_attributes\n {\n bounds: info_service.bounds,\n mime_type: mime_type\n }\n end",
"def override_content_type_and_save_info\n case File.extname(file.file).delete('.').downcase.to_sym\n when :xlsx\n file.content_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'\n when :docx\n file.content_type = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'\n when :pptx\n file.content_type = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'\n when :rar\n file.content_type = 'application/vnd.rar'\n when :zip\n file.content_type = 'application/zip'\n when :bat\n file.content_type = 'application/x-msdos-program'\n when :cmd\n file.content_type = 'application/cmd'\n when :exe\n file.content_type = 'application/x-msdownload'\n when :msi\n file.content_type = 'application/x-msi'\n when :php\n file.content_type = 'application/x-php'\n when :py\n file.content_type = 'application/x-python'\n when :vbs\n file.content_type = 'application/x-vbs'\n end\n\n model.file_content_type = file.content_type if file.content_type\n model.file_size = number_to_human_size(file.size) if file.size\n end",
"def file_field; end",
"def save_content_type_and_size\n model.content_type = file.content_type if model.respond_to?(:content_type) && file.content_type\n model.file_size = file.size if model.respond_to?(:file_size)\n end",
"def fileable\n tr(' ', '_').downcase\n end",
"def update_file_info\n if self.path\n size = File.exists?(self.path) ? File.size(self.path) : nil\n end\n if size\n (value, units) = bits_to_human_readable(size)\n self.size = value unless value.nil? or value.empty?\n self.size_units = units unless units.nil? or units.empty?\n self.save if self.descMetadata.changed?\n end\n end",
"def add_file_characterization_to_all_basic_files\n logger = Logger.new(STDOUT)\n logger.level = Logger::INFO\n logger.datetime_format = \"%H:%M:%S\"\n bfs = BasicFile.all\n bfs.each do |bf|\n if bf.datastreams['fitsMetadata1'].nil?\n logger.info \"No FITS datastream found for #{bf.pid}, going to add one...\"\n #need to create a new temp file using the content from the datastream\n temp_file = File.new('temp_content_file', 'w+')\n begin\n temp_file.puts bf.content.content\n rescue StandardError => re\n logger.error 'Got error writing BasicFile contents to file'\n logger.error re.to_s\n if re.to_s.match 'from ASCII-8BIT to UTF-8'\n logger.info 'ASCII file detected'\n temp_file.puts bf.content.content.force_encoding('UTF-8')\n end\n end\n #temp_file.puts bf.content.content.force_encoding('UTF-8')\n\n f = ActionDispatch::Http::UploadedFile.new(filename: bf.content.label, type: bf.content.profile['dsMIME'], tempfile: temp_file)\n\n begin\n logger.info 'Generating FITS metadata XML'\n fitsMetadata = Hydra::FileCharacterization.characterize(f, f.original_filename, :fits)\n rescue Hydra::FileCharacterization::ToolNotFoundError => tnfe\n logger.error tnfe.to_s\n abort 'FITS tool not found, terminating, check FITS_HOME environment variable is set and FITS is installed'\n rescue RuntimeError => re\n logger.error 'Something went wrong with extraction of file metadata using FITS'\n logger.error re.to_s\n abort 'FITS tool not found, terminating, check FITS_HOME environment variable is set and FITS is installed'\n end\n fitsDatastream = ActiveFedora::OmDatastream.from_xml(fitsMetadata)\n fitsDatastream.digital_object = bf.inner_object\n\n bf.add_datastream(fitsDatastream, {:prefix => 'fitsMetadata'})\n bf.save\n logger.info 'FITS metadata datastream added, tidying up resources used'\n temp_file.close\n FileUtils.remove_file 'temp_content_file'\n logger.info \"Finished adding FITS metadata for #{bf.pid}\"\n logger.info '********************************************'\n end\n end\n end",
"def notest_should_remove_blank_char_from_filename\n\n document_field = CGI.new( :multipart => true )\n puts document_field.inspect\n document = Document.new(document_field)\n \n puts document.inspect\n \n \n end",
"def document=(document_field)\n self.name = base_part_of(document_field.original_filename)\n self.content_type = document_field.content_type.chomp\n self.data = document_field.read\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 seo_file_params\n params.require(:seo_file).permit(:filename, :domain, :targeturl, :valid_content)\n end",
"def save_character account, filename, data\n end",
"def uploaded_file=(file); write_attribute(:uploaded_file, file); end",
"def set_file_size\n write_attribute(:file_size, File.size(file_name)) if (file_size.blank? and !file_name.blank?)\n end",
"def transliterate_file_name\n\t\t\tfile_names = Array.new\n\t\t\[email protected] { |a| file_names << a if a.match(/_file_name{1}$/) }\n\t\t\tfile_names.each do |local_file_name|\n\t\t\t\tif self.send(local_file_name).present? && self.send(local_file_name+'_changed?')\n\t\t\t\t\textension = File.extname(send(local_file_name)).gsub(/^\\.+/, '')\n\t\t\t\t\tfilename = send(local_file_name).gsub(/\\.#{extension}$/, '')\n\t\t\t\t\tself.send(local_file_name.gsub(/_file_name{1}$/, '')).instance_write(:file_name, \"#{transliterate(filename)}.#{transliterate(extension)}\")\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def upload\n \tset_up_instances_variable\n \tuploaded_io = @tree.file\n \t@nome_arquivo = Rails.root.join('public', 'uploads', uploaded_io.original_filename)\n \tFile.open(Rails.root.join('public', 'uploads', uploaded_io.original_filename), 'wb') do |file|\n \t\tfile.write(uploaded_io.read)\n \tend\n \tler_texto @nome_arquivo\n end",
"def file_save file\n\t\tfields \t\t\t\t= {}\n \t\tfields[:uid] \t\t= file_uid\n\t\tfields[:fnum] \t\t= file_num_generate\n\t\tfields[:name] \t\t= file[:filename].split('.').first\n\t\tfields[:created]\t= Time.now\n\t\tfields[:type]\t\t= file[:type]\n \t\tfields[:path] \t\t= \"#{file_uid}-#{fields[:created].to_i}#{_random(3)}\"\n\n\t\t# allow these file type to save\n\t\tunless _var(:file_type).include? file[:type]\n\t\t\t_throw Sl[:'the file type isn`t allowed to save']\n\t\tend\n\n\t\t# allow the scope of file size\n\t\tfile_content = file[:tempfile].read\n\t\tif (fields[:size] = file_content.size) > _var(:file_size).to_i\n\t\t\t_throw Sl[:'the file size is too big']\n\t\tend\n\n\t\t# save the info of file\n\t\tSdb[:file_info].insert(fields)\n\n\t\t# save the body of file\n\t\tpath = Spath[:upload_dir] + fields[:path]\n\t\tSimrb.path_write path, file_content\n\t\t_msg :file_save, Sl['saved file successfully']\n\n# \t\t\tFile.open(Spath[:upload_dir] + fields[:path], 'w+') do | f |\n# \t\t\t\tf.write file_content\n# \t\t\tend\n\n# \n# \t\t# return the value\n# \t\tunless reval == nil\n# \t\t\tSdb[:file_info].filter(fields).get(reval)\n# \t\tend\n\tend",
"def uploaded_file=(field)\n if field != \"\"\n mt = field.content_type || \"application/binary\"\n self.filename = base_part_of(field.original_filename) \n self.mime_type = mt\n path = get_path\n data = field.read\n self.size = data.length\n if ! File::exist? path\n Dir::mkdir(path)\n else \n # delete old images\n Dir::new(path).each do |oldfile|\n if oldfile[0].chr != '.'\n File::unlink(path+\"/\"+oldfile)\n end\n end\n end\n f = File.new(path + \"/\" + self.filename,\"w\")\n f << data\n f.close\n end\n end",
"def internal_file_attributes; end",
"def save_file\n if self.file then\n self.file.save\n end\n end",
"def store_file\n # TODO\n # - kick BOM if present\n # - convert to UTF-8 if a different encoding is given\n # - we should check double encoding because the tempfile is always read as utf8\n\n # writes the file binary/raw without taking encodings into account.\n # If we want to convert incoming files this should be done before\n File.open(full_filename, 'wb') do |f| #w:UTF-8\n f.write @uploaded_file.read\n end\n end",
"def manipulate(options = {})\n if options[:path]\n options[:path] = berksfile.find(name).instance_variable_get(:@options)[:path] || options[:path]\n end\n options\n end",
"def save_attached_files; end",
"def save_attached_files; end",
"def save_file_entry\n @user.search_files.create!(file_path: uploaded_file_path.result, file_name: @file.original_filename, status: 'initialized')\n end",
"def filename_cleaner\n @options[:filename_cleaner] || FilenameCleaner.new(@options[:restricted_characters])\n end",
"def file name\n \n end",
"def uploadicon=(file)\n unless( file.blank? )\n logger.info(\"original_filename: \" + file.original_filename )\n self.content_type = file.content_type.chomp\n logger.info(\"content_type: \" + self.content_type )\n filename = base_part_of( file.original_filename ) \n \n if(file.length < 300000 )\n @uploadfile = file \n self.was_upload_successful = true\n else\n self.was_upload_successful = false\n end\n \n end\n end",
"def modify_file\n file_path = \"./app/views/hocr_files/_p#{self.filename}_hocr.html\"\n file = File.open(file_path, \"r\")\n data = file.read\n data = self.replace_bbox(data)\n data = self.add_image(data)\n File.open(file_path, 'w') {|f| f.write(data) }\n end",
"def before_save \n filename.strip!\n filename.gsub(/^(..)+/, \".\")\n filename.gsub(/[^\\s]/, \"\") # replace spaces with \n # replace all non alphanumeric, underscore or periods with underscore\n filename.gsub(/^[\\W]+$/, '_')\n end",
"def save_file\n\t\tif file\n\t\t\tdocuments.create({\n\t\t\t\t:uploaded_file => file,\n\t\t\t\t:user_id => user_id\n\t\t\t})\n\t\tend\n\t\t#`cp \"#{file.path}\" \"#{path}\"` if file\n\tend",
"def file_size\n number_to_human_size(super)\n end",
"def perform(file_set, file_id, filepath = nil, user = nil)\n @event_start = DateTime.current\n @relation = file_set.class.characterization_proxy\n file = file_set.characterization_proxy\n raise \"#{@relation} was not found for FileSet #{file_set.id}\" unless file_set.characterization_proxy?\n filepath = Hyrax::WorkingDirectory.find_or_retrieve(file_id, file_set.id) unless filepath && File.exist?(filepath)\n characterize(\n file: file,\n filepath: filepath,\n user: user,\n file_set: file_set\n )\n end",
"def update_content_type\n if file.present? && file_changed?\n self.content_type = file.file.content_type\n end\n end",
"def to_s\n @file_text\n end",
"def to_s\n @file_text\n end",
"def set_the_field_values\n fn = self.file_name\n unless self.file_ext && !self.file_ext.blank?\n self.file_ext = fn.split('.').last\n end\n ex = self.file_ext\n nm = self.name\n \n pic_name = fn.split('.')\n pic_name.delete(pic_name.last)\n \n pn = pic_name.join('_').to_s.to_go\n \n the_name = ( nm.blank? || nm.start_with?('dcfile_') ) ? pn.titleize : nm.to_s\n the_fname = !nm.blank? ? nm.to_s.to_go : pn\n \n self.name = the_name\n self.original_name = fn\n # => self.file_name = \"#{the_fname}.#{ex}\"\n self.file_name = \"#{ generate_dc_name }.#{ex}\"\n self.image = IMAGE_EXTS.include?( ex.to_s.downcase ) ? true : false\n self.save\n end",
"def file_name\n self.file_file_name\n end",
"def save(upload)\n uploadFile = upload['datafile']\n originalName = uploadFile.original_filename\n self.fileType = File.extname(originalName)\n\n create_or_update()\n\n # write the file\n File.open(self.filePath, \"wb\") { |f| f.write(uploadFile.read) }\n \n # write ID3 metadata to database, to avoid the expense of fetching\n # from the file every time - quite costly as more files are displayed at a time\n begin\n musicFile = TagLib::File.new(self.filePath())\n self.id3Title = musicFile.title\n self.id3Artist = musicFile.artist\n self.id3Length = musicFile.length\n rescue TagLib::BadFile => exc\n logger.error(\"Failed to id track: \\n #{exc}\")\n end\n\n if(self.fileType == '.mp3')\n convertToOGG();\n end\n create_or_update()\n\n end",
"def file_name\n @file_name\n end",
"def override_content_type_and_save_info\n case File.extname(file.file).delete('.').to_sym\n when :xlsx\n file.content_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'\n when :docx\n file.content_type = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'\n when :pptx\n file.content_type = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'\n end\n\n # if File.extname(file.file).delete('.').to_sym == :xlsx\n # file.content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'\n # end\n # if File.extname(file.file).delete('.').to_sym == :docx\n # file.content_type='application/vnd.openxmlformats-officedocument.wordprocessingml.document'\n # end\n # if File.extname(file.file).delete('.').to_sym == :pptx\n # file.content_type='application/vnd.openxmlformats-officedocument.presentationml.presentation'\n # end\n\n model.file_content_type = file.content_type if file.content_type\n model.file_size = number_to_human_size(file.size) if file.size\n\n tmp_file = file.path\n photo = MiniExiftool.new \"#{tmp_file}\"\n\n model.latitude = dms_to_float(photo.gpslatitude) if photo && photo.gpslatitude\n model.longitude = dms_to_float(photo.gpslongitude) if photo && photo.gpslongitude\n model.photo_created_at = photo.createdate if photo && photo.createdate\n end",
"def text_file_params\n params.require(:text_file).permit(:name, :content)\n end",
"def save\n # Nothing in base class. This should be used to persist settings in\n # subclasses that use files.\n end",
"def save_file\n if platinum_user_and_above?\n uid = current_user.id\n data_dir = Rails.root.join('shared','data')\n @file = data_dir.join('domains')\n file = File.open(@file, 'r')\n @restore = ''\n file.each_line { |line| @restore += line }\n file.close\n file = File.open(@file, 'w+')\n file.write(params[:file_content])\n file.close\n domain_table_reload(uid,data_dir.to_s)\n render json: { message: 'Saving successful.' }\n else\n render json: { message: 'Saving failed, please check your file again.' }\n end\n rescue Psych::SyntaxError\n file = File.open(@file, 'w+')\n file.write(@restore)\n file.close\n render json: { message: 'Saving failed, please check your file again.' }\n end",
"def employee_file_params\n params.require(:employee_file).permit(:employee_id, :title, :file, :filemime, :filesize)\n end",
"def encode_file(_file_suffix, _options = {})\n # convert to pdf\n self.class.encode(source_path, \"pdf\", Hydra::Derivatives.temp_file_base)\n pdf_file = File.join(Hydra::Derivatives.temp_file_base, [File.basename(source_path, \".*\"), 'pdf'].join('.'))\n\n # persist pdf original as access\n\n output_file_service.call(File.open(pdf_file, \"rb\"), url: directives.fetch(:access))\n\n # create thumbnails from the pdf using Hydra::Derivatives::Processors::Image\n Hydra::Derivatives::Processors::Image.new(pdf_file, thumbnail_directives).process\n Hydra::Derivatives::Processors::Image.new(pdf_file, citi_thumbnail_directives).process\n\n # clean up\n File.unlink(pdf_file)\n end",
"def full_filename (for_file = model.document.file)\n for_file\n end",
"def process_force_save(file_data, file_name, user_address) \n download_uri = file_data['url']\n if download_uri.eql?(nil)\n saved = 1\n return saved\n end\n\n download_ext = \".\"+file_data['filetype'] # get the extension of the downloaded file\n\n cur_ext = File.extname(file_name).downcase # get current file extension\n\n new_file_name = false\n\n # convert downloaded file to the file with the current extension if these extensions aren't equal\n unless cur_ext.eql?(download_ext)\n key = ServiceConverter.generate_revision_id(download_uri) # get the document key\n begin\n percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data(download_uri, download_ext.delete('.'), cur_ext.delete('.'), key, false, nil) # get the url of the converted file\n if new_file_uri == nil || new_file_uri.empty?\n new_file_name = true\n else\n download_uri = new_file_uri\n end\n rescue StandardError => msg\n new_file_name = true\n end\n end\n\n saved = 1\n\n data = download_file(download_uri) # download document file\n if data.eql?(nil)\n return saved\n end\n\n begin\n is_submit_form = file_data[\"forcesavetype\"].to_i == 3 # check if the forcesave type is equal to 3 (the form was submitted)\n\n if is_submit_form\n if new_file_name\n file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + \"-form\" + download_ext, user_address) # get the correct file name if it already exists\n else\n file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + \"-form\" + cur_ext, user_address)\n end\n forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file\n else\n if new_file_name\n file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address)\n end\n forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, false)\n if forcesave_path.eql?(\"\")\n forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, true) # if the path to the new file doesn't exist, create it\n end\n end\n\n save_file(data, forcesave_path) # save the downloaded file to the storage directory\n\n if is_submit_form\n uid = file_data['actions'][0]['userid']\n DocumentHelper.create_meta(file_name, uid, \"Filling Form\", user_address) # create file meta information with the Filling form tag instead of user name \n end\n\n saved = 0\n rescue StandardError => msg\n saved = 1\n end\n\n saved\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 update_after_conversion\n #update_attribute(:filename, \"#{filename}.flv\")\n #update_attribute(:content_type,\"video/x-flv\")\n end",
"def force_to_file\n if @data && ! (@file && File.exist?(@file.to_s))\n fh = Tempfile.new([ \"conconv_force_to_file\", @suffix.to_s ])\n @force_to_file = @file = Pathname.new(fh.path)\n fh.write @data\n fh.close\n $stderr.puts \" force_to_file wrote #{@data.size} => #{fh.path.inspect}\" if @verbose\n end\n @file\n end",
"def grid_fs_file_params\n params.require(:grid_fs_file).permit(:filename, :contentType, :author, :topic, :uploadDate, :length, :chunkSize, :md5, :contents)\n end",
"def file_type\r\n\t\t@file_type\r\n\tend",
"def filename\n \"#{options.filename}.#{options.filetype}\"\n end",
"def original_filename; end",
"def file_field(name = \"\", size = 20, maxlength = nil)\n attributes = if name.kind_of?(String)\n { \"TYPE\" => \"file\", \"NAME\" => name,\n \"SIZE\" => size.to_s }\n else\n name[\"TYPE\"] = \"file\"\n name\n end\n attributes[\"MAXLENGTH\"] = maxlength.to_s if maxlength\n input(attributes)\n end",
"def file_attributes\n {}\n end",
"def file_attributes\n {}\n end",
"def update_metadata\n @generic_file.destroy_existing_nested_nodes(params[:generic_file])\n super\n end",
"def document_file_params\n doc_params = params.require(:document_file).permit(:name, :document_file_type_id, :document_id, :content, properties: [:width, :height])\n if (doc_params.has_key?(:content))\n file_upload = doc_params.delete(:content)\n doc_params[:name] = sanitize_filename(file_upload.original_filename)\n doc_params[:document_file_type_id] = DocumentFileType.get_type_by_category(DocumentFileType::Logo, doc_params[:name]).id\n doc_params[:content] = file_upload.read\n dimensions = FastImage.size(file_upload.path)\n unless dimensions.nil?\n doc_params[:properties] = {width: \"#{dimensions[0]}px\", height: \"#{dimensions[1]}px\"}\n end\n end\n\n doc_params\n end",
"def edit_file\n @node = Node.new(:name => params[:name], :git_repo_id => params[:git_repo_id], :git_repo_path => params[:git_repo_path])\n end",
"def saveFile(filename)\n\t\tpretty = JSON.pretty_generate(filename)\n\t\tpretty_clean = Sanitize.clean(pretty)\n\t\tpretty_clean = pretty_clean.gsub(' \\n', \" <br/>\" )\n\t\tpretty_clean = pretty_clean.gsub(',', \" <br/> \")\n\t\tpretty_clean = pretty_clean.gsub('\"', \" <br/> \")\n\n\t\tFile.open(\"output.txt\", \"w\") do |f|\n\t\tf.write(pretty_clean)\n\tend\nend",
"def deco_file; end",
"def feature_upload(id, file)\r\n dir = \"home_features\"\r\n file.original_filename = id.to_s + (File.extname file.original_filename)\r\n return write(dir, file)\r\n end",
"def save\n create_file\n true\n end",
"def nthfile_params\n params.require(:nthfile).permit(:rename, :filesize, :count, :resize)\n end",
"def to_doc(file)\n return nil if file[\"size\"] == 0\n return {\n path: file[\"path\"] + \"/\" + file[\"name\"],\n size: file[\"size\"],\n name: file[\"name\"]\n }\n end",
"def characterize\n content = source_to_content\n extracted_md = extract_metadata(content)\n terms = parse_metadata(extracted_md)\n store_metadata(terms)\n end",
"def internal_file_attributes=(_arg0); end",
"def create\n @user = User.find(params[:user_id])\n @mycontact = Mycontact.find(params[:mycontact_id])\n @meeting = Meeting.find(params[:meeting_id])\n @userfile = @meeting.userfiles.new(userfile_params)\n\n uploadedIo = params[:userfile][:doc]\n @userfile.filename = uploadedIo.original_filename\n meetingId = @meeting.id\n tmpFileName = meetingId.to_s + \"_\" + [uploadedIo.original_filename.split(\".\").first.downcase.parameterize, \".\", uploadedIo.original_filename.split(\".\").last].join()\n @userfile.file_name_slug = tmpFileName\n\n\n fileName = Rails.root.join('public','uploads', tmpFileName)\n File.open(fileName, 'wb') do |file|\n file.write(uploadedIo.read)\n end\n\n respond_to do |format|\n if @userfile.save\n #format.html { redirect_to @userfile, notice: 'Userfile was successfully created.' }\n format.html { redirect_to user_mycontact_meeting_userfiles_path}\n format.json { render action: 'show', status: :created, location: @userfile }\n else\n format.html { render action: 'new' }\n format.json { render json: @userfile.errors, status: :unprocessable_entity }\n end\n end\n end",
"def content_type\n self.file_content_type\n end",
"def upload\n # connected to upload.html.haml form\n # looks for :zernike in params, existence means file is attached\n # significant help from \"http://www.tutorialspoint.com/ruby-on-rails/rails-file-uploading.htm\"\n if params[:zernike]\n uploaded_file = params[:zernike][:attachment]\n file_name = uploaded_file.original_filename\n jsonified_file = uploaded_file.as_json[\"tempfile\"]\n extract_data = coefficients_extractor(jsonified_file)\n @file = extract_data\n \n if @file.nil? or @file.empty?\n flash[:warning] = \"Unable to upload file\"\n # made it a \"warning\" instead of \"notice\" so we can change the colors/text\n else\n flash[:notice] = \"File successfully uploaded!\"\n end\n \n redirect_to zernikes_path\n end\n \n # if not @file.nil?\n # byebug\n # end\n # self.content = [TEXT INSIDE test.txt]\n # @file = params[:file]\n # byebug\n # @zernike = Zernike.\n # if @zernike.save\n # flash[:notice] = \"File successfully uploaded!\"\n # redirect_to \n # else \n # flash[:notice] = \"Unable to upload file\"\n \n # byebug\n # @file = params[:file]\n # if @file.nil? or @file.empty? \n # flash[:notice] = \"File is empty!\"\n # else \n # flash[:notice] = \"File successfully uploaded!\"\n # end\n \n end",
"def file_extension; end",
"def file_extension; end",
"def file_extension; end",
"def extract_text\n # check if we have a filter\n return if FILTERS[self.content_type].nil?\n\n # Create temporary working directory directory\n FileUtils.mkdir_p(File.join(RAILS_ROOT, 'tmp', 'documents'))\n\n # Find path to convert script\n convert_script = File.join(RAILS_ROOT, 'script', FILTERS[self.content_type])\n\n # Get paths to temp in/out file\n temp_file_in = self.create_temp_file.path\n temp_file_out = File.join(RAILS_ROOT, 'tmp', 'documents',\"#{self.id}.txt\")\n\n # Convert\n if system \"#{convert_script} #{temp_file_in} #{temp_file_out}\"\n self.content = File.read(temp_file_out)\n File.unlink(temp_file_out)\n else\n self.content = \"NO CONTENT\"\n end\n self.save\n end",
"def scrub_params\n params.require(:scrub).permit(:name, :file_type, :size)\n end",
"def upload_process\n # アップロードファイルを取得\n file = params[:upfile]\n\n # ファイルのベース名(パスを除いた部分)を取得\n name = file.original_filename\n\n # 許可する拡張子を定義\n permits = ['.jpg', '.jpeg', '.gif', '.png']\n\n # 配列 permits にアップロードファイルの拡張子に合致するものがあるか\n if ! permits.include?(File.extname(name).downcase)\n render :text => \"アップロードできるのは画像ファイルのみ( \" + permits.join(', ') + \" )です。\"\n elsif file.size > 1.megabyte\n render :text => 'ファイルサイズは1MBまでです。'\n else\n # utf8 to sjis\n name = name.kconv(Kconv::SJIS, Kconv::UTF8)\n\n # /public/doc フォルダ配下にアップロードファイルを保存\n File.open(\"public/docs/#{name}\", 'wb') { |f| f.write(file.read) }\n render :text => \"#{name.toutf8}をアップロードしました。\"\n end\n end",
"def external_file_attributes; end",
"def original_filename\n @file_representation[:filename]\n end",
"def create_document(file, file_type, object, comment, file_name=nil)\n if object.invoice_no.include?('/')\n file_obj=object.invoice_no.gsub('/','')\n else\n file_obj=object.invoice_no\n end\n filename = (file_name ? \"#{file_name}.#{file_type}\" : nil ) || \"InvoiceNo_#{file_obj}_#{Time.zone.now.to_i}_New.#{file_type}\"\n\n newfile=File.open(\"#{filename}\", \"w\") {|f| f.write(file) }\n\n root_file=File.open(\"#{RAILS_ROOT}/#{filename}\",'r')\n document={:name => \"Test\" ,:data=> root_file}\n document_home = {:document_attributes => document}\n document_home.merge!(:access_rights => 2, :created_by_user_id=>object.created_by_user_id,:company_id=>object.company_id,\n :mapable_id=>comment.id,:mapable_type=>'Comment', :owner_user_id=>object.owner_user_id)\n newdocument_home = comment.document_homes.new(document_home)\n newdocument = newdocument_home.documents.build(document.merge(:company_id=>object.company_id, :created_by_user_id=>object.created_by_user_id))\n newdocument_home.save\n if newdocument_home.save\n root_file.close\n File.delete(\"#{RAILS_ROOT}/#{filename}\")\n end\n end",
"def update_file_content(new_content)\n return false if new_content.nil?\n self.file_content = new_content\n return self.save\n end"
] |
[
"0.755723",
"0.746301",
"0.7454837",
"0.700791",
"0.68411684",
"0.6710213",
"0.66900915",
"0.65963703",
"0.65521705",
"0.64750093",
"0.64697015",
"0.6324699",
"0.5674666",
"0.5599572",
"0.5593694",
"0.547304",
"0.5461711",
"0.5461711",
"0.54408675",
"0.54296196",
"0.54084045",
"0.53126675",
"0.52699304",
"0.526685",
"0.52225167",
"0.52160585",
"0.5194721",
"0.5187774",
"0.5185723",
"0.5172508",
"0.51636916",
"0.5071482",
"0.5067044",
"0.5039391",
"0.5036836",
"0.50303143",
"0.5006718",
"0.50012624",
"0.49981505",
"0.49796703",
"0.4971316",
"0.4971316",
"0.4966039",
"0.49628615",
"0.4961671",
"0.49233305",
"0.4915334",
"0.4911695",
"0.4900569",
"0.48947504",
"0.4894435",
"0.48929775",
"0.4892223",
"0.4892223",
"0.4888801",
"0.4888489",
"0.48769778",
"0.48699296",
"0.48630783",
"0.48446375",
"0.48407102",
"0.48333308",
"0.48304853",
"0.48302323",
"0.48287666",
"0.48251396",
"0.4822901",
"0.48166302",
"0.48015687",
"0.48003685",
"0.47965127",
"0.47909787",
"0.4789996",
"0.47846654",
"0.4776221",
"0.4776221",
"0.47715038",
"0.47691286",
"0.47650194",
"0.47618118",
"0.4734899",
"0.47337475",
"0.47326398",
"0.4730516",
"0.47298443",
"0.47177222",
"0.47105327",
"0.47058505",
"0.4703304",
"0.4702319",
"0.4699037",
"0.4699037",
"0.4699037",
"0.46984962",
"0.46939576",
"0.4689005",
"0.46871638",
"0.46855235",
"0.46814632",
"0.4674837"
] |
0.81046796
|
0
|
Stub function that sets this service as valid for all FileNode types
|
def valid?
true
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def before_create_file(path, data, parent_node, modified)\n return true unless parent_node.is_a?(ICalendar)\n\n validate_i_calendar(\n data,\n path,\n modified,\n @server.http_request,\n @server.http_response,\n true\n )\n true\n end",
"def setup_class_info\n @file_model = nil\n @resource_assoc = :generic_files\n end",
"def file_field(method, options = T.unsafe(nil)); end",
"def internal_file_attributes=(_arg0); end",
"def filesystem_impl=(impl)\n @filesystem_impl = impl\n end",
"def test_file_filter\n raise Exception.new(\"Unimplemented\")\n end",
"def test_file_filter\n raise Exception.new(\"Unimplemented\")\n end",
"def before_create_file(_path, data, parent_node, modified)\n return true unless parent_node.is_a?(IAddressBook)\n\n validate_v_card(data, modified)\n true\n end",
"def internal_file_attributes; end",
"def set_filetypes\n #unless params[:id] == 'download' || params == :file\n @filetype = Filetype.find(params[:id])\n # end\n end",
"def initialize(env, tree_or_node = nil)\n super() # super without parenthesis would call initialize with our args\n\n @plugins = {}\n @protected_properties = [\n # RFC4918\n '{DAV:}getcontentlength',\n '{DAV:}getetag',\n '{DAV:}getlastmodified',\n '{DAV:}lockdiscovery',\n '{DAV:}supportedlock',\n\n # RFC4331\n '{DAV:}quota-available-bytes',\n '{DAV:}quota-used-bytes',\n\n # RFC3744\n '{DAV:}supported-privilege-set',\n '{DAV:}current-user-privilege-set',\n '{DAV:}acl',\n '{DAV:}acl-restrictions',\n '{DAV:}inherited-acl-set',\n\n # RFC3253\n '{DAV:}supported-method-set',\n '{DAV:}supported-report-set',\n\n # RFC6578\n '{DAV:}sync-token',\n\n # calendarserver.org extensions\n '{http://calendarserver.org/ns/}ctag',\n\n # sabredav extensions\n '{http://sabredav.org/ns}sync-token'\n ]\n @debug_exceptions = false\n @resource_type_mapping = {\n Tilia::Dav::ICollection => '{DAV:}collection'\n }\n @enable_propfind_depth_infinity = false\n\n if tree_or_node.is_a?(Tree)\n @tree = tree_or_node\n elsif tree_or_node.is_a?(INode)\n @tree = Tree.new(tree_or_node)\n elsif tree_or_node.is_a?(Array)\n # If it's an array, a list of nodes was passed, and we need to\n # create the root node.\n tree_or_node.each do |node|\n unless node.is_a?(INode)\n fail Exception, 'Invalid argument passed to constructor. If you\\'re passing an array, all the values must implement Tilia::Dav::INode'\n end\n end\n\n root = SimpleCollection.new('root', tree_or_node)\n @tree = Tree.new(root)\n elsif tree_or_node.nil?\n root = SimpleCollection.new('root')\n @tree = Tree.new(root)\n else\n fail Exception, 'Invalid argument passed to constructor. Argument must either be an instance of Tilia::Dav::Tree, Tilia::Dav::INode, an array or nil'\n end\n\n @xml = Xml::Service.new\n @sapi = Http::Sapi.new(env)\n @http_response = Http::Response.new\n @http_request = @sapi.request\n add_plugin(CorePlugin.new)\n end",
"def set_file\n if have_file?\n begin\n set_file_for_remote_storage\n rescue Errno::ENOENT\n set_file_for_local_storage\n rescue NoMethodError\n raise \"Original resource has no File\"\n end\n else\n raise \"Original resource has no File\"\n end\n end",
"def initialize()\n super\n @odata_type = \"#microsoft.graph.win32LobAppFileSystemRule\"\n end",
"def check_file\n super\n end",
"def perform_file_validation(_filename, _filehandle)\n raise NotImplementedError\n end",
"def file_utils; end",
"def set_file_input_files(files:, node_id: nil, backend_node_id: nil, object_id: nil)\n {\n method: \"DOM.setFileInputFiles\",\n params: { files: files, nodeId: node_id, backendNodeId: backend_node_id, objectId: object_id }.compact\n }\n end",
"def initialize\n TYPES.each do |type|\n transform_files!(Files.type_files(type), type)\n end\n end",
"def neofiles_mock(attrs, klass)\n Mongoid::Factory.from_db(klass, attrs).tap do |obj|\n neofiles_lazy_loadable obj\n end\n end",
"def setup\n fakefs_original_setup\n FakeFS.activate!\n FakeFS::FileSystem.clear\n end",
"def initialize(path)\n @path = path\n @intfs = @@intfs.dup\n @service = nil\n end",
"def file_field(object_name, method, options = T.unsafe(nil)); end",
"def set_file\n if have_file?\n case original_resource_mounter.send(:storage).class.name\n when 'CarrierWave::Storage::File'\n set_file_for_local_storage\n when 'CarrierWave::Storage::Fog', 'CarrierWave::Storage::AWS'\n set_file_for_remote_storage\n else\n raise UnknowStorage\n end\n else\n raise NoFileForOriginalResource\n end\n end",
"def validate(prefix = '/')\n ret = true\n\n scan(prefix, false).each do |name, data|\n begin\n # create type object and load\n pre_name = OneCfg::Config::Utils.prefixed(name, prefix)\n\n OneCfg::LOG.debug(\"Load '#{pre_name}' \" \\\n \"with #{data['ruby_class']}\")\n\n file = data['ruby_class'].new(pre_name)\n file.load\n\n # valid file and OneCfg code must evaluate file\n # as same, similar and without diff on self\n unless file.same?(file) &&\n file.similar?(file) &&\n file.diff(file).nil?\n raise OneCfg::Config::Exception::StructureError,\n 'Error when comparing file content with self'\n end\n\n # test save into temporary file\n Tempfile.open('validate') do |temp|\n OneCfg::LOG.debug(\"Save '#{pre_name}' \" \\\n \"into '#{temp.path}'\")\n\n temp.close\n file.save(temp.path)\n end\n\n OneCfg::LOG.info(\"File '#{pre_name}' - OK\")\n rescue StandardError => e\n ret = false\n\n # if any error, just print it and continue with the rest\n OneCfg::LOG.error('Unable to process file ' \\\n \"'#{name}' - #{e.message}\")\n end\n end\n\n ret\n end",
"def set(setPath)\r\n assert_exists\r\n \r\n setFileFieldValue(setPath)\r\n end",
"def test_file=(file) # :nodoc:\n self.test_files = [file]\n end",
"def type t\n @files = @files.select { |file| File.exist?(file) && File.ftype(file) == t}\n self\n end",
"def changeset\n raise NotImplementedError.new(\"changeset() must be implemented by subclasses of AbstractVersionedFile.\")\n end",
"def accepts_file_upload?\n true\n end",
"def accepts_file_upload?\n true\n end",
"def accepts_file_upload?\n true\n end",
"def accepts_file_upload?\n true\n end",
"def accepts_file_upload?\n true\n end",
"def accepts_file_upload?\n true\n end",
"def stub_file(path)\n double('stat', readable?: true, file?: true, directory?: false).tap do |double|\n allow(Bolt::Util).to receive(:file_stat).with(path).and_return(double)\n end\n end",
"def initialize()\n super\n @odata_type = \"#microsoft.graph.security.fileEvidence\"\n end",
"def create_file_set(file_node, file)\n attributes = {\n title: fileset_title(file_node.original_filename.first),\n file_metadata: [file_node],\n processing_status: \"in process\"\n }.merge(\n file.try(:container_attributes) || {}\n )\n file_set = FileSet.new(attributes)\n change_set = ChangeSet.for(file_set)\n change_set_persister.save(change_set: change_set)\n end",
"def file=(_); end",
"def initialize(path = \"\", no_validate = false, use_mock_file = false)\n @path = (use_mock_file == true ? mock_file_path : path)\n validate if no_validate == false\n end",
"def files_for(klass); end",
"def initialize(file_accessors, platform)\n @file_accessors = file_accessors\n super platform\n end",
"def file_field; end",
"def neofiles_mock_or_load(attrs_or_id, klass = ::Neofiles::File)\n if attrs_or_id.present?\n case attrs_or_id\n when ::String then klass.where(id: attrs_or_id).first\n when ::BSON::ObjectId then klass.where(id: attrs_or_id).first\n when ::Hash then neofiles_mock(attrs_or_id.with_indifferent_access, klass)\n end\n end\n end",
"def file_uploads; end",
"def validate_file(file)\n end",
"def set_check_file(opts)\n opts = check_params(opts,[:file_info])\n super(opts)\n end",
"def test_fileobject\n prov = mkprovider\n\n path = tempfile\n obj = nil\n assert_nothing_raised do\n obj = prov.target_object(path)\n end\n\n # The default filetype is 'ram'\n assert_instance_of(Puppet::Util::FileType.filetype(:ram), obj)\n\n newobj = nil\n assert_nothing_raised do\n newobj = prov.target_object(path)\n end\n\n assert_equal(obj, newobj, \"did not reuse file object\")\n\n # now make sure clear does the right thing\n assert_nothing_raised do\n prov.clear\n end\n assert_nothing_raised do\n newobj = prov.target_object(path)\n end\n\n assert(obj != newobj, \"did not reuse file object\")\n end",
"def set_file_operation\n @file_operation = FileOperation.find(params[:id])\n end",
"def set_storage_use_nfs(opts)\n opts = check_params(opts,[:usage])\n super(opts)\n end",
"def storage_use_nfs\n super\n end",
"def base_validate_parameters\n check_for_valid_filepath if (@repository.parameters[:file])\n validate_parameters\n nil\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 detect_catchall(d)\n d[:type] = :file\n d[:decl] = \"\"\n end",
"def require!(_file_)\n raise 'must implement'\n end",
"def test_no_file_uploaded_with_safari\n e = Resource.new\n assert_nothing_raised { e.file = \"\" }\n assert_equal nil, e.file\n end",
"def scan_files\n raise \"scan_files must be redefined in children classes\"\n end",
"def set_va_file(opts)\n opts = check_params(opts,[:va_files])\n super(opts)\n end",
"def allowFileOperations _obj, _args\n \"_obj allowFileOperations _args;\" \n end",
"def files\n fail \"Fetcher #{self} does not implement `files()`. This is required.\"\n end",
"def valid_options\n [:tempfile_base]\n end",
"def file_utils=(_arg0); end",
"def public_file_server=(_arg0); end",
"def public_file_server=(_arg0); end",
"def fs\n return @file_system if @file_system\n\n @file_system = Rosh::FileSystem.new(@name)\n @file_system.add_observer(self)\n\n @file_system\n end",
"def before_write_content(path, node, data, modified)\n return true unless node.is_a?(ICalendarObject)\n\n # We're onyl interested in ICalendarObject nodes that are inside of a\n # real calendar. This is to avoid triggering validation and scheduling\n # for non-calendars (such as an inbox).\n parent = Uri.split(path).first\n parent_node = @server.tree.node_for_path(parent)\n\n return true unless parent_node.is_a?(ICalendar)\n\n validate_i_calendar(\n data,\n path,\n modified,\n @server.http_request,\n @server.http_response,\n false\n )\n true\n end",
"def set_file_from_raw_data\n self.status = 'archived'\n self.file = ActionDispatch::Http::UploadedFile.new(filename: filename, tempfile: tempfile_for_filedata)\n end",
"def new_files; end",
"def default_mime_type=(value); end",
"def mock_file\n file = 'a_file.png'\n file.stubs(:size).returns(32)\n file.stubs(:original_filename).returns('a_file.png')\n file.stubs(:content_type).returns('image/png')\n file.stubs(:read).returns(false)\n file\nend",
"def set_fileset\n @fileset = Fileset.find(params[:id])\n authorize @fileset\n end",
"def initialize(node)\n self.name = node.content\n self.file_as = node.attribute('file-as').content rescue nil\n self.role = node.attribute('role').content rescue nil\n end",
"def file_watcher; end",
"def file_watcher; end",
"def test_files=(files) # :nodoc:\n @test_files = Array files\n end",
"def mime_type=(_); end",
"def control_files(node)\n files = []\n [Path.provider_base, @provider_dir].each do |provider_dir|\n [['services', :service_config], ['tags', :tag_config]].each do |attribute, path_sym|\n node[attribute].each do |attr_value|\n path = Path.named_path([path_sym, \"#{attr_value}.rb\"], provider_dir).sub(/\\.json$/,'')\n if File.exists?(path)\n files << path\n end\n end\n end\n end\n return files\n end",
"def test_em_watch_file_unsupported\n assert true\n end",
"def newobj(type, name, hash)\n transport = Puppet::TransObject.new(name, \"file\")\n transport[:path] = path\n transport[:ensure] = \"file\"\n assert_nothing_raised {\n file = transport.to_ral\n }\n end",
"def ensure_handle_is_valid\n\n end",
"def altered_files\n raise NotImplementedError.new(\"altered_files() must be implemented by subclasses of AbstractChangeset.\")\n end",
"def set(file)\n self.file = file\n end",
"def initialize(path, request, response, options)\n if path.nil? || path.empty? || path[0] != ?/\n raise ArgumentError, 'path must be present and start with a /'\n end\n @path = path\n\n @propstat_relative_path = !!options[:propstat_relative_path]\n @root_xml_attributes = options.delete(:root_xml_attributes) || {}\n @namespaces = (options[:namespaces] || {}).merge({DAV_NAMESPACE => DAV_NAMESPACE_NAME})\n @request = request\n @response = response\n unless(options.has_key?(:lock_class))\n @lock_class = LockStore\n else\n @lock_class = options[:lock_class]\n raise NameError.new(\"Unknown lock type constant provided: #{@lock_class}\") unless @lock_class.nil? || defined?(@lock_class)\n end\n @options = options\n @max_timeout = options[:max_timeout] || 86400\n @default_timeout = options[:default_timeout] || 60\n @user = @options[:user] || request.ip\n\n setup\n end",
"def file() nil; end",
"def create_file_set(file_node, file)\n attributes = {\n title: file_node.original_filename,\n file_metadata: [file_node],\n processing_status: \"in process\"\n }.merge(\n file.try(:container_attributes) || {}\n )\n persister.save(resource: FileSet.new(attributes))\n end",
"def file_field(method, **kwargs)\n without_field_error_wrapper do\n with_blueprint_file_input method, kwargs do |options|\n super(method, options)\n end\n end\n end",
"def get_files_to_upload(file_dir, dom)\n @log.info 'Figuring out which files to upload'\n\n uploaded_files = []\n\n # xpath variables\n premis_ns = { 'premis' => 'http://www.loc.gov/standards/premis' }\n mets_ns = { 'mets' => 'http://www.loc.gov/METS/' }\n checksum_xpath = 'premis:objectCharacteristics/premis:fixity/premis:messageDigest'\n original_name_xpath = 'premis:originalName'\n\n # loop over the files listed in the METS\n file_md5_list = dom.xpath('//premis:object', premis_ns)\n file_md5_list.each do |fptr|\n # file location info\n file_checksum = fptr.at_xpath(checksum_xpath, premis_ns).inner_html\n flocat_xpath = \"//mets:file[@CHECKSUM='\" + file_checksum + \"']/mets:FLocat\"\n file_location = dom.at_xpath(flocat_xpath, mets_ns)\n\n # the name of the file in the aip package and its original name\n aip_filename = file_location.attr('xlink:href')\n orig_filename = fptr.at_xpath(original_name_xpath, premis_ns).inner_html\n\n # type of file\n file_type = file_location.parent.parent.attr('USE')\n\n case file_type\n when 'THUMBNAIL'\n if @config['include_thumbnail']\n uploaded_file = upload_file(file_dir, orig_filename, aip_filename, 'thumbnail')\n uploaded_files.push(uploaded_file) unless uploaded_file.nil?\n end\n when 'ORIGINAL'\n uploaded_file = upload_file(file_dir, orig_filename, aip_filename, 'bitstream')\n uploaded_files.push(uploaded_file) unless uploaded_file.nil?\n end\n end\n\n uploaded_files\nend",
"def validate\n @errors = []\n methods.grep(/^validate_/).each { |m| method(m).call }\n @errors.each { |e| e.file = @file }\n valid?\n end",
"def initialize(filename, type, tempfile, options)\n @filename = File.basename(filename)\n @type = type\n @tempfile = tempfile\n @realfile = nil\n\n trait :options => options\n end",
"def file_field(name, identifier=nil, &block)\n define_method(\"#{name}=\") do |value|\n return platform.file_field_value_set(identifier.clone, value) unless block_given?\n self.send(\"#{name}_element\").value = value\n end\n define_method(\"#{name}_element\") do\n return call_block(&block) if block_given?\n platform.file_field_for(identifier.clone)\n end\n define_method(\"#{name}?\") do\n return call_block(&block).exists? if block_given?\n platform.file_field_for(identifier.clone).exists?\n end\n end",
"def should_validate_attachment_content_type name, options = {}\n klass = self.name.gsub(/Test$/, '').constantize\n valid = [options[:valid]].flatten\n invalid = [options[:invalid]].flatten\n context \"Class #{klass.name} validating content_types on #{name}\" do\n valid.each do |type|\n context \"being assigned a file with a content_type of #{type}\" do\n setup do\n @file = StringIO.new(\".\")\n class << @file; attr_accessor :content_type; end\n @file.content_type = type\n @attachment = klass.new.send(name)\n @attachment.assign(@file)\n end\n should \"not have a :content_type validation error\" do\n assert ! @attachment.errors[:content_type]\n end\n end\n end\n invalid.each do |type|\n context \"being assigned a file with a content_type of #{type}\" do\n setup do\n @file = StringIO.new(\".\")\n class << @file; attr_accessor :content_type; end\n @file.content_type = type\n @attachment = klass.new.send(name)\n @attachment.assign(@file)\n end\n should \"have a :content_type validation error\" do\n assert @attachment.errors[:content_type]\n end\n end\n end\n end\n end",
"def initialize\n @files = []\n end",
"def initialize()\n super\n @odata_type = \"#microsoft.graph.fileAssessmentRequest\"\n end",
"def initialize(filename)\n @valid = false\n @services = []\n @replace_wildcards = false\n load_from_file(filename)\n end",
"def file=(file)\n self.fileRef = file.uuid\n end",
"def file\n FileFactory.new(self)\n end",
"def initialize(*args)\n @options = {\n :access_level => 'public-read',\n :file_mapping => nil,\n :object => nil\n }\n @options.update(args.extract_options!)\n @options.stringify_keys!\n\n @raw_file = args.first\n @config = configuration\n @connection = Uv::Storage::Connection.new(self.config)\n @object = @options['object']\n\n debug \"Initializing new Uv::Storage::File\"\n debug \"Args First is a: #{args.first.class.to_s}\"\n debug \"Config loaded: #{config.present?}\"\n debug \"Connection loaded: #{connection.present?}\"\n debug \"Object given: #{object.present?}\"\n debug \"Raw File given: #{@raw_file.present?}\"\n debug \"Options given: #{options.present?}\"\n debug \"Identifier given: #{options['identifier'].present?}\"\n\n validate_object(@object) if @object.present?\n end",
"def test_set_method_types\n end",
"def initialize(test, file_path)\n # Needs the test object for accessing assertions.\n self.test = test\n self.file_path = file_path\n # Clean up after.\n ObjectSpace.define_finalizer(self, method(:finalize))\n File.open(file_path, 'r') do |file|\n self.root = REXML::Document.new(file).root\n end\n nil\n end",
"def should_validate?(_filename)\n raise NotImplementedError\n end",
"def file_upload(criteria = T.unsafe(nil)); end",
"def set_file_type\n if self.is_local?\n if self.attachment_content_type.blank?\n self.file_type = \"misc\"\n elsif self.attachment_content_type == 'application/pdf'\n self.file_type = \"pdf\"\n elsif self.attachment_content_type.include?('powerpoint')\n self.file_type = \"presentation\"\n elsif self.attachment_content_type == 'application/zip'\n self.file_type = \"zip\"\n elsif self.attachment_content_type == \"application/rtf\" || self.attachment_content_type == 'text/plain' || self.attachment_content_type == 'application/msword' || self.attachment_content_type.include?('wordprocessing')\n self.file_type = \"document\"\n elsif self.attachment_content_type.include?('spreadsheet') || self.attachment_content_type == 'ms-excel'\n self.file_type = \"spreadsheet\"\n elsif self.attachment_content_type.include?('image')\n self.file_type = \"image\"\n else\n self.file_type = \"misc\"\n end\n end\n end"
] |
[
"0.52635056",
"0.52221715",
"0.5153194",
"0.51494724",
"0.5107459",
"0.51017064",
"0.51017064",
"0.50477225",
"0.50262296",
"0.5017123",
"0.50135064",
"0.50090563",
"0.49955106",
"0.49599892",
"0.4921181",
"0.49167255",
"0.48984262",
"0.48855683",
"0.48624456",
"0.48543337",
"0.48509428",
"0.48397177",
"0.48390457",
"0.48242503",
"0.481662",
"0.48034793",
"0.48010737",
"0.47987068",
"0.47902355",
"0.47902355",
"0.47902355",
"0.47902355",
"0.47902355",
"0.47902355",
"0.4789589",
"0.4786344",
"0.47854665",
"0.47792172",
"0.4761854",
"0.47498423",
"0.47408018",
"0.47323045",
"0.4728353",
"0.47244537",
"0.47180417",
"0.47069314",
"0.47063068",
"0.470003",
"0.4698772",
"0.46963695",
"0.4693712",
"0.46935877",
"0.46861094",
"0.46788627",
"0.46726513",
"0.46663588",
"0.4665536",
"0.46637422",
"0.4662468",
"0.46569073",
"0.46568635",
"0.46567273",
"0.46567273",
"0.46535793",
"0.46535757",
"0.46487728",
"0.46437532",
"0.46437076",
"0.46415433",
"0.46410006",
"0.4631615",
"0.46235216",
"0.46235216",
"0.4621674",
"0.46181527",
"0.46181074",
"0.46120244",
"0.4606296",
"0.45941082",
"0.45768178",
"0.45753026",
"0.4574219",
"0.45723897",
"0.45689964",
"0.45655718",
"0.4559956",
"0.4553103",
"0.45526052",
"0.4552441",
"0.45485547",
"0.45456144",
"0.45326352",
"0.45296147",
"0.45209476",
"0.4520386",
"0.45170623",
"0.45038986",
"0.4497853",
"0.44924086",
"0.44903603",
"0.4489429"
] |
0.0
|
-1
|
Close tarantool connection. All active requests will be terminated.
|
def disconnect
mutex.synchronize do
_disconnect
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def close()\n @connection.disconnect\n @connection = nil\n end",
"def close\n @io.close\n @tar.close\n end",
"def close()\n\t\[email protected]\n\t\t@connection = nil\n\tend",
"def close_connection\n @connection.finish\n end",
"def close\n @connection_manager.close\n end",
"def close\n # Send close when going away only if we have been able to successfully connect\n if @close_req_subject\n req = STAN::Protocol::CloseRequest.new(clientID: @client_id)\n raw = nats.request(@close_req_subject, req.to_proto, timeout: options[:connect_timeout])\n\n resp = STAN::Protocol::CloseResponse.decode(raw.data)\n unless resp.error.empty?\n raise Error.new(resp.error)\n end\n end\n\n # If we do not even have a connection then return already...\n return unless @nats\n\n # TODO: If connection to nats was borrowed then we should\n # unsubscribe from all topics from STAN. If not borrowed\n # and we own the connection, then we just close.\n begin\n # Remove all related subscriptions for STAN\n @sub_map.each_pair do |_, sub|\n nats.unsubscribe(sub.sid)\n end\n\n # Finally, remove the core subscriptions for STAN\n nats.unsubscribe(@hb_inbox_sid)\n nats.unsubscribe(@ack_subject_sid)\n nats.flush(options[:connect_timeout])\n rescue NATS::IO::Timeout\n raise CloseReqTimeoutError.new(\"stan: close request timeout\")\n ensure\n if @borrowed_nats_connection\n @nats = nil\n else\n @nats.close\n end\n end\n end",
"def close_connection\n current_connection.logout if current_connection?\n current_connection = nil\n end",
"def close\n @transport.close\n @transport = nil\n @close_handler and @close_handler.call\n end",
"def closeServer()\n com = Sumo::Traci::Command_Close.new() ;\n execCommands(com) ;\n close() ;\n end",
"def close\n @connection.close\n end",
"def close\n @connection.close\n end",
"def close\n @update_manager.stop\n TD::Api.client_destroy(@td_client)\n end",
"def close_connection\n @connection.close\n end",
"def close\n @connection.close\n end",
"def close\n @connection.close\n end",
"def close\n conn.write(\"(api-quit)\") if connected?\n rescue Errno::ECONNRESET\n ensure\n self.conn = nil\n end",
"def close\n @conn.disconnect\n end",
"def close\n inactive!\n close_connections\n end",
"def __close_connections\n # to be implemented by specific transports\n end",
"def close\n connection.close\n end",
"def close\n @transport.close\n end",
"def close\n if self.conn && !self.conn.closed?\n self.conn.shutdown\n self.conn.close\n end\n\n self.conn = nil\n end",
"def close\n @io.close\n @tarreader.close\n end",
"def close\n connection.close if connection\n end",
"def close\n if @http && @http.started?\n @http.finish\n Log.info \"Closing HTTP connection for #{@host} from #{@connection_opened_at}\"\n end\n @http = nil\n end",
"def close_connection\n @connection.expunge\n @connection.logout\n @connection.disconnect\n end",
"def close\n @timer.detach if @timer.attached?\n @reqtable = {}\n @transport.close\n @seqid = 0\n self\n end",
"def close\n stop_monitoring_connection\n close_connection\n end",
"def close\n if @connection\n @connection.close unless @connection.closed?\n end\n @connection = nil\n end",
"def close\n return if @conn.nil?\n @conn.close\n @conn = nil\n end",
"def close\n @net_ssh.close\n @net_ssh = nil\n end",
"def thread_cleanup(th)\n tc = tconf(th)\n tc.connections.each { |conn| close_conn(conn) }\n tc.connections.clear\n tc.stack_size = 0\n tc.dbc = nil\n\n true\n end",
"def closeConnections()\n #N Without this, the connections won't be closed\n @sshAndScp.close()\n end",
"def close\n\t\[email protected]\n\tend",
"def close\n @mutex.synchronize { @conn.close }\n end",
"def close\n @mutex.synchronize { @conn.close }\n end",
"def cleanup\n\t\tputs \"Reconectando...\"\n\t\t@reconect = true\n\t\tcheck_ip_integrity\n\t\[email protected]\n\t\[email protected]\n\t\[email protected]\n\tend",
"def close(context)\n context.debug('Logout connection')\n @connection_info = nil\n @client.logout\n @client = nil\n @system = nil\n end",
"def close\n close_connection(CLOSED, true)\n end",
"def close\n @conn.close\n end",
"def terminate_connection\n @intentionally_closed = true\n close_connection\n end",
"def close_connection\r\n @ftp.close\r\n end",
"def close\n @work_queue.shutdown if @work_queue\n @connection.close\n end",
"def destroy\n connection.close\n end",
"def close\n log 'closing connection'\n @ssh.close\n end",
"def close\n self.client.close(self.file_id, self.tree_id)\n end",
"def close\r\n\t\[email protected]\r\n\tend",
"def close\n log \"Closing this request\"\n delete_sftp_files\n update_attribute(:ftp_password, nil)\n update_attribute(:closed_at, Time.now)\n end",
"def close_connection; end",
"def close\n info { \"closing connection\" }\n socket.shutdown\n end",
"def close\n @connection.close # Close the active mailbox\n @connection.logout # Send the logout command\n @connection.disconnect # Close the actual connection\n end",
"def close\n @logger.debug(@host) { 'Closing session' }\n @transport.close\n @transport = nil\n end",
"def close\n @mutex.synchronize do\n unless @closed\n @closed = true\n @htable_pool.close if use_table_pool?\n @connection.close\n\n # To be deprecated\n begin\n HConnectionManager.deleteConnection(@config)\n rescue ArgumentError\n # HBase 0.92 or below\n HConnectionManager.deleteConnection(@config, true)\n end if use_table_pool?\n end\n end\n\n thread_local.delete self\n\n nil\n end",
"def close\n @closing = true\n cancel_ping_timer\n cancel_reconnect_timer\n close_connection_after_writing if connected?\n process_disconnect if reconnecting?\n end",
"def close\n @conn.close if @conn && [email protected]?\n @conn = nil\n end",
"def shutdown\n @conn.shutdown\n end",
"def disconnect; @connection.close end",
"def close_connection\n @endpoint.close\n end",
"def shutdown\n @pool.shutdown do |connection|\n connection.quit\n end\n end",
"def shutdown\n @pool.shutdown do |connection|\n connection.quit\n end\n end",
"def shutdown\n @connection_manager.shutdown if @connection_manager\n @client = nil\n @connection_manager = nil\n end",
"def close #:nodoc:\n @server.shutdown\n end",
"def close\n statement = \"close #{@name}\"\n @connection.exec(statement)\n end",
"def force_close_connection\n destroy_transport\n connection.transition_state_machine :closed\n end",
"def close\n @http_client.reset_all\n end",
"def close\n @http_client.reset_all\n end",
"def shutdown_connection\n teardown_timers\n @conn.shutdown if @conn.respond_to? :shutdown\n @conn.terminate if @conn.respond_to? :terminate\n @conn = nil\n end",
"def finish\n @connections.each_value do |connection|\n begin\n connection.finish\n rescue Exception => e\n logger.error(\"Failed to close metadata http connection: #{e.backtrace.join(\"\\n\")}\")\n end\n end\n @connections = {}\n end",
"def close_and_shutdown\n handle_action_exceptions(__method__) do\n unload_toolshck\n shutdown\n unload_winrm_ps\n logger('debug', 'close') { 'done!' }\n @closed = true\n @json ? { 'result' => 'Success' } : true\n end\n end",
"def close(headers={})\n @connection.disconnect(headers)\n end",
"def tilt\n backend.proxy.halec_registry.delete_tctp_cookie(backend.client_connection.host, @tctp_cookie)\n backend.client_connection.close_connection(true)\n backend_connection.close_connection(true)\n end",
"def term(conn)\r\n if conn\r\n begin\r\n conn.quit\r\n ensure\r\n conn.close\r\n\t \r\n end\r\n end\r\n exit\r\nend",
"def close\n return unless @target\n\n target.reload\n target.close\n rescue *CONNECTION_CLEAR_ERRORS => e\n Karafka.monitor.notice_error(self.class, e)\n ensure\n @target = nil\n end",
"def release_transporter s\n s.close\n end",
"def disconnect\n super\n\n @transport.close rescue nil\n @transport = nil\n \n debug 'connections closed'\n end",
"def disconnect\n _logout\n @connection.close\n end",
"def close\n\n # nothing to do here.\n end",
"def close_all\n @connections.close_all\n end",
"def sftp_close_connection(connection)\n connection.close!(connection)\nend",
"def sftp_close_connection(connection)\n connection.close!(connection)\nend",
"def close\n\t\t\tKernel.exit 0\n\t\tend",
"def close\n # Close the HTTP client:\n @client.close if @client\n end",
"def close\n # Close the HTTP client:\n @client.close if @client\n end",
"def close\n @ftp.close\n end",
"def closeConnections\n #N Without this, cached SSH connections to the remote system won't get closed\n destinationLocation.closeConnections()\n end",
"def teardown_cleanup\n [reader, writer].each do |r_con|\n if(r_con && r_con.alive?)\n begin\n r_con.terminate\n rescue Celluloid::Task::TerminatedError\n warn 'Terminated task error when cleaning NSQ connections. Moving on.'\n end\n end\n end\n super\n end",
"def close!\n close(true)\n end",
"def close()\r\n _dprint(\"Closing Auth_WiKID connection ...\")\r\n unless $sslsocket.nil?\r\n unless $sslsocket.closed?\r\n $sslsocket.puts(\"QUIT\");\r\n $sslsocket.flush\r\n $sslsocket.close\r\n end\r\n $sslsocket = nil\r\n @socket.shutdown\r\n end\r\n @isConnected = false\r\n end",
"def close\n # by default do nothing - close any cached connections\n end",
"def close_connections\n @connections.values.each(&:close)\n end",
"def close\n tagged_response(\"CLOSE\")\n end",
"def close\n @registry[:transport][:session].close if @open\n @open = false\n end",
"def close # :nodoc:\n @tmp.close if @tmp\n @master.close if @master\n @to_io.close if @to_io\n end",
"def close\n lib.tcidbclose( @db ) || raise_error\n\n lib.tcidbdel( @db )\n\n @db = nil\n end",
"def shutdown\n @data_socket.close\n @ack_socket.close\n @client.disconnect! rescue nil\n end",
"def close\n @channel.close\n @conn.close\n end",
"def close\n parser_thread.kill if parser_thread # why if?\n poll_thread.kill\n socket.close if socket\n\n @status = DISCONNECTED\n end",
"def close\n flush\n\n @worker_thread[:should_exit] = true\n @worker_thread.join\n\n @ssl.close\n\n sleep 0.1\n @main_queue.drain!\n\n @socket = @ssl = @http = @main_queue = @work_queue = @requests = @exceptions = @worker_thread = nil\n end",
"def clean_up()\n puts \"Closing MQTT and DB connections\"\n closeMQTTConn()\n closeDBConn()\n end",
"def close\n self.disconnect\n end",
"def close\n @conn.close\n super\n end"
] |
[
"0.69550216",
"0.6894442",
"0.6847734",
"0.6729387",
"0.6703665",
"0.6670604",
"0.6650103",
"0.6587051",
"0.658403",
"0.6572945",
"0.6572945",
"0.65638936",
"0.6535572",
"0.65249056",
"0.65249056",
"0.65018827",
"0.6495419",
"0.6483082",
"0.6465666",
"0.6464458",
"0.64626133",
"0.6442564",
"0.6439623",
"0.64269763",
"0.6426866",
"0.64239526",
"0.64114416",
"0.6401997",
"0.636758",
"0.63480425",
"0.6344232",
"0.63439596",
"0.6322852",
"0.6286888",
"0.6238668",
"0.6238668",
"0.6230263",
"0.6225316",
"0.6221629",
"0.62215257",
"0.6220755",
"0.62133807",
"0.62090254",
"0.61939275",
"0.61841303",
"0.61693555",
"0.6168646",
"0.61589915",
"0.61403406",
"0.61342865",
"0.61188036",
"0.6099119",
"0.60965085",
"0.6091817",
"0.60908175",
"0.6090472",
"0.60841066",
"0.60817885",
"0.607462",
"0.607462",
"0.60573643",
"0.6047023",
"0.60373473",
"0.6034576",
"0.6032647",
"0.6032647",
"0.602116",
"0.6017407",
"0.6016674",
"0.60154855",
"0.60094315",
"0.60079944",
"0.6000865",
"0.59878194",
"0.59801453",
"0.5967023",
"0.5964765",
"0.5946903",
"0.5940388",
"0.5940388",
"0.59337676",
"0.5920376",
"0.5920376",
"0.59173954",
"0.59047174",
"0.5895121",
"0.58930486",
"0.5892832",
"0.58882093",
"0.5884082",
"0.58837914",
"0.5880952",
"0.5880638",
"0.5873579",
"0.58724755",
"0.5848046",
"0.5847965",
"0.5842894",
"0.582794",
"0.58246565",
"0.58241695"
] |
0.0
|
-1
|
list of challenges including open/closed status & pagination
|
def index
@challenges = Challenge.all params[:filters], params[:page]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def all\n challenges = Challenge.all(@oauth_token, params[:open], \n params[:technology] ||= nil, \n params[:platform] ||= nil, \n params[:category] ||= nil, \n enforce_order_by_params(params[:order_by], 'end_date__c'),\n params[:limit] ||= 50,\n params[:offset] ||= 0)\n # merge in the topcoder challenges\n Topcoder.challenges_open.each {|c| challenges << c } if params[:include_tc]\n expose challenges\n end",
"def index\n @challenges = Challenge.order(:id)\n .includes(:user)\n .page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end",
"def index\n @user_challenges = UserChallenge.all\n end",
"def index\n @teams = Team.order(:created_at)\n @challenges = Challenge.opened.order(:created_at)\n end",
"def challenges\n @limit = get_limit\n @offset = get_offset(params)\n if !params[:keyword].nil?\n @results_count = Challenge.count(:conditions => [ \"name like :kw or description like :kw\", { :kw => \"%\" + params[:keyword].to_s + \"%\" }])\n @challenges = Challenge.find(:all,\n :conditions => [ \"name like :kw or description like :kw\", { :kw => \"%\" + params[:keyword].to_s + \"%\" }],\n :limit => @limit,\n :offset => @offset)\n end\n @results_pages = @results_count.fdiv(@limit)\n respond_to do |format|\n format.html { render \"manage/challenges/index\" }\n format.xml { render :xml => @challenges }\n end\n end",
"def index\n @challenges = Challenge.all\n end",
"def index\n @challenges = Challenge.all\n end",
"def index\n @challenges = Challenge.all\n end",
"def index\n @challenges = Challenge.all\n end",
"def index\n @challenges = Challenge.all.order('difficulty ASC')\n end",
"def index\n @users = User.where(:listed => 1)\n if current_closed_challenge.present?\n @entries = Entry.where(:challenge_id => current_closed_challenge.id).limit(3)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Entry.all }\n end\n else\n respond_to do |format|\n format.html { render \"challenges/about\" }\n format.json { render json: Entry.all }\n end\n end\n end",
"def team_challenge_list\n @team_challenges = TeamChallenge.find_by_user(current_user.id)\n end",
"def index\n\t\tif params[:tag]\n\t\t\t@challenges = Challenge.tagged_with(params[:tag])\n\t\telse\n\t\t\t@challenges = Challenge.all\n\t\tend\n\tend",
"def mychallenges\n\t\tputs \"------------------\"\n\t\t# puts session[:users]\n\t\tputs current_user\n\t\t#puts current_user.id\n\t\tputs \"@@@@@@@@@@@@@@@@@@\"\n\n\t\t@challenges = Challenge.all(:limit => 10, :conditions => {:user_id => current_user.id})\n\tend",
"def index\n @weekly_challenges = WeeklyChallenge.all\n end",
"def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.haml\n format.json { render json: @challenges }\n end\n end",
"def index\n @challenge_instances = ChallengeInstance.all\n end",
"def index\n @challenge_instances = ChallengeInstance.all\n end",
"def index\n if @issuable\n if @issuable.class.to_s == 'Project'\n @pre_issues = @issuable.issues\n @pre_issues.concat(@issuable.lists.map{|l| l.studies.map{|s| s.issues }}.flatten)\n else\n @pre_issues = @issuable.issues.order('sequential_id DESC')\n end\n else\n @pre_issues = Issue.scoped\n end\n\n @issues = @pre_issues\n \n unless params[:state]\n params[:state] = 'open'\n end\n\n if params[:state] == 'open'\n @issues = @issues.where(closed: false)\n end\n if params[:state] == 'closed'\n @issues = @issues.where(closed: true)\n end\n if params[:creator]\n @issues = @issues.where(creator_id: params[:creator])\n end\n if params[:assignee]\n @issues = @issues.where(assigned_id: params[:assignee])\n end\n if params[:aspect]\n @project = Project.find(params[:aspect])\n @issues = @project.issues\n end\n\n respond_to do |format|\n format.html { render layout: 'fluid' }# index.html.erb\n format.json { render json: @issues }\n end\n end",
"def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end",
"def index\n @challenges = Challenge.user(current_user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end",
"def index\n @issue_histories = IssueHistory.paginate(page: params[:page], per_page: 50)\n end",
"def index\n @team_challenges = TeamChallenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @team_challenges }\n end\n end",
"def challenges; end",
"def index\n if params[:tickets] == 'closed'\n @tickets = Helpdesk::Ticket.where(:requester_id => helpdesk_user.id).closed.page(params[:page])\n else\n @tickets = Helpdesk::Ticket.where(:requester_id => helpdesk_user.id).active.page(params[:page])\n end\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tickets }\n end\n end",
"def index\n @challenge_participants = @challenge.challenge_participants.includes(:team, :user)\n end",
"def index\n @challenges = Challenge.all\n @users = User.all\n if params[:search]\n @challenges = Challenge.search(params[:search]).order(\"score DESC\")\n else\n @challenges = Challenge.all.order(\"created_at DESC\")\n end\n end",
"def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @challenges }\n end\n end",
"def index\n @problem_attempts = ProblemAttempt.all\n end",
"def index\n params[:problem_id] ?\n @problem_solutions = ProblemSolution.paginate(page: params[:page], per_page: 5).order('updated_at ASC').find_all_by_problem_id(params[:problem_id]) :\n @problem_solutions = ProblemSolution.accessible_by(current_ability).paginate(page: params[:page], per_page: 5).order('updated_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def index\n github = Github.new\n #@repo = github.repos.get(:user => \"rails\", :repo => \"rails\")\n @page = (params[:page].nil?) ? 1 : params[:page]\n @issues = github.issues.list(:user => 'rails', :repo => 'rails', :per_page => 25, :page => @page.to_i)\n\n @paging = {page: @page.to_i, totalpages: @issues.count_pages}\n\n respond_with(@issues, @paging)\n end",
"def all_issues()\n @endpoint = \"/issues.json?limit=100\"\n setup_get\n res = @http.request(@req)\n return JSON.load(res.body)[\"issues\"].sort_by { |issue| issue[\"id\"] }\n end",
"def generate_list\n if $game_temp.lbchll_last_index >= @challenges.size\n $game_temp.lbchll_last_index = 0\n else\n $game_temp.lbchll_last_index += 1\n end\n return @challenges[$game_temp.lbchll_last_index]\n end",
"def challenge_accepted_count\n self.challenges.where.not(status: \"pending\").order(updated_at: :desc).count\n end",
"def index\n @interview_decisions = InterviewDecision.all\n end",
"def index\n @challenge_types = ChallengeType.all\n end",
"def index\n @reqdifficulties = Reqdifficulty.all\n end",
"def issues\n if @issues.nil?\n @issues = {}\n max_result = 3\n jql = \"/rest/api/2/search?jql=project=\\\"#{name}\\\" AND issuetype NOT IN (Epic, Sub-task)&expand=changelog&maxResults=#{max_result}\"\n #r = nil\n #without_cache{ r = self.class.get(\"#{jql}&startAt=0\") }\n r = self.class.get(\"#{jql}&startAt=0\")\n pages = (r['total'] / max_result)\n (0..pages).each do |current_page|\n begin\n # If you can get the latest version of the last page, do so, otherwise load the cached version\n query = \"#{jql}&startAt=#{(current_page * max_result)}\"\n if current_page == pages\n #without_cache{ r = self.class.get(query) }\n # else\n r = self.class.get(query)\n end\n r['issues'].each do |issue|\n # Cast raw response to Issue(), passing project reference into constructor\n issue['project'] = self\n @issues[issue['key']] = Issue.new(issue)\n end\n # rescue => exception\n # puts \"#{exception.message} (#{exception.class})\"\n # pp exception.backtrace\n end\n end\n end\n @issues\n end",
"def index\n @problems = Problem.paginate(page: params[:page], per_page: 10 ).order('created_at DESC')\n\n respond_with @problems\n end",
"def index\n\t\t@tab = \"hist\"\n\t\n\t\t@problemas = current_user.attempts.select('numero_problema').group(:numero_problema).page(params[:page]).per(20)\n\t\n\t\t@attempts = current_user.attempts\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @attempts }\n\t\tend\n end",
"def index\n @tags = Tag.accessible_by(current_ability).sort_by{ | tag | tag.problems.count }.reverse\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def index\n @contraceptive_interactions = ContraceptiveInteraction.all\n end",
"def previous_contested_challenges\n user.challenges.where{id!=my{id}}.where{type==my{self.class.name}}.order(\"ends_on DESC\")\n end",
"def index\n \n last_modified = nil\n\n if params.has_key?(:character_id) # request using character_id \n \n state = Tutorial::State.find_by_character_id(params[:character_id])\n raise NotFoundError.new('No quests found for character id.') if state.nil?\n raise ForbiddenError.new('Access forbidden.') if state.owner != current_character && !staff? && !admin?\n \n @tutorial_quests = if api_request? # send only the relevant quests (those, that have not been finished yet)\n state.quests.non_closed \n else # display all quests in backend\n state.quests.paginate(:page => params[:page], :per_page => 50) \n end\n last_modified = state.updated_at.utc # the state is touched on changed on the quests\n \n else # request all \n raise ForbiddenError.new('Access forbidden.') if !staff? && !admin? \n @tutorial_quests = Tutorial::Quest.paginate(:page => params[:page], :per_page => 50)\n end\n \n if stale?(:last_modified => last_modified, :etag => @tutorial_quests)\n respond_to do |format|\n format.html \n format.json { render json: @tutorial_quests }\n end\n end\n end",
"def index\n @issues = Issue.all\n end",
"def index\n @issues = Issue.all\n end",
"def index\n @issues = Issue.all\n end",
"def index\n @issues = Issue.all\n end",
"def index\n @issues = Issue.all\n end",
"def get_issues_per_status(view_id, sprint_id, issue_count_array, issue_sp_count_array)\n current_start_at = 0\n\n begin\n response = get_response(\"/rest/agile/1.0/board/#{view_id}/sprint/#{sprint_id}/issue?startAt=#{current_start_at}\")\n page_result = JSON.parse(response.body)\n issue_array = page_result['issues']\n\n issue_array.each do |issue|\n accumulate_issue_information(issue, issue_count_array, issue_sp_count_array)\n end\n\n current_start_at = current_start_at + page_result['maxResults']\n end while current_start_at < page_result['total']\nend",
"def index\n @challenge_scores = ChallengeScore.all\n end",
"def index\n @issue_histories = IssueHistory.all\n end",
"def index\n @issues = current_user.issues\n end",
"def index\n @user_challenges = current_user.user_challenges.includes(:challenge)\n\n js progress: current_user.complete_challenges.count / Challenge.count.to_f * 100\n end",
"def scorecards\n expose Challenge.scorecards(@oauth_token, params[:challenge_id].strip)\n end",
"def index\n @health_cases = HealthCase.all.paginate(page: params[:page], :per_page => 10).order(\"created_at DESC\")\n end",
"def index\n @help_cases = HelpCase.all\n end",
"def send_challenges(event, page: nil)\n if event.channel.type != 1 && event.channel.id != CHANNEL_SECRETS\n mention = mention_channel(id: CHANNEL_SECRETS)\n raise OutteError.new \"No asking for challenges outside of #{mention} or DMs!\"\n end\n\n # Parse message parameters\n initial = page.nil?\n msg = fetch_message(event, initial)\n lvl = parse_highscoreable(msg, partial: true)\n\n # Multiple matches, send match list\n if lvl.is_a?(Array)\n format_level_matches(event, msg, page, initial, lvl, 'search')\n return\n end\n\n # Single match, send challenge list if it's a non-secret level\n raise OutteError.new \"#{lvl.class.to_s.pluralize.capitalize} don't have challenges!\" if lvl.class != Level\n raise OutteError.new \"#{lvl.tab.to_s} levels don't have challenges!\" if [\"SI\", \"SL\"].include?(lvl.tab.to_s)\n event << \"Challenges for #{lvl.longname} (#{lvl.name}):\\n#{format_block(lvl.format_challenges)}\"\nrescue => e\n lex(e, \"Error getting challenges.\", event: event)\nend",
"def show\n @solutions = @achievement.solutions.paginate(page: params[:page], per_page: 10).order('created_at DESC')\n add_breadcrumb @achievement.name, achievement_path(@achievement)\n respond_with @achievement\n end",
"def get_issues\n jira_issues = Hash.new\n # This is the REST URL that will be hit. Change the jql query if you want to adjust the query used here\n uri = URI(JIRA_BASE_URL + '/rest/api/2/search?jql=assignee+%3D+currentUser()+AND+status+not+in+(Closed,+Resolved)')\n\n Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') do |http|\n request = Net::HTTP::Get.new(uri)\n request.basic_auth USERNAME, PASSWORD\n response = http.request request\n # If the response was good, then grab the data\n if response.code =~ /20[0-9]{1}/\n data = JSON.parse(response.body)\n data[\"issues\"].each do |item|\n jira_id = item[\"key\"]\n jira_issues[jira_id] = item[\"fields\"][\"summary\"]\n end\n else\n raise StandardError, \"Unsuccessful response code \" + response.code + \" for issue \" + issue\n end\n end\n return jira_issues\nend",
"def fetch_closed_issues_and_pr\n print \"Fetching closed issues...\\r\" if @options[:verbose]\n issues = []\n page_i = 0\n count_pages = calculate_pages(@client, \"issues\", closed_pr_options)\n\n iterate_pages(@client, \"issues\", closed_pr_options) do |new_issues|\n page_i += PER_PAGE_NUMBER\n print_in_same_line(\"Fetching issues... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\")\n issues.concat(new_issues)\n break if @options[:max_issues] && issues.length >= @options[:max_issues]\n end\n print_empty_line\n Helper.log.info \"Received issues: #{issues.count}\"\n\n # separate arrays of issues and pull requests:\n issues.map { |issue| stringify_keys_deep(issue.to_hash) }\n .partition { |issue_or_pr| issue_or_pr[\"pull_request\"].nil? }\n end",
"def index\n @solutions = Solution.all.paginate(:page => params[:page])\n end",
"def issues\n @query = Query.new(:name => \"_\")\n @issues = @query.issues(:order => \"issues.created_on desc\", :limit => 50, :include => [:project, :author])\n res = Array.new\n @issues.each do |is|\n res << {:issue_id => is.id, :issue_title => is.subject, :issue_content => is.description, :project_name => is.project.name,\n :author_name => is.author.to_s, :author_email => is.author.mail, :issue_created_at => is.created_on, :issue_status => is.status.to_s }\n end\n render :json => res.to_json\n end",
"def index\n @judge_activities = JudgeActivity.all\n end",
"def index\n @challenge = Challenge.find(params[:challenge_id])\n @resources = @challenge.resources\n if params[:index]\n render :all\n else\n render :index\n end\n end",
"def index\n @defects = Defect.all.paginate :page => params[:page], :per_page => 5\n @defects_open = Defect.open_bug.paginate :page => params[:page], :per_page => 5\n @defects_new = Defect.new_bug.paginate :page => params[:page], :per_page => 5\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @defects }\n end\n end",
"def index\n @photo_challenges = PhotoChallenge.all.includes([:photos, :year, winning_photo: :photo]).reverse\n @grouped_challenges = @photo_challenges.group_by(&:year_id)\n end",
"def index\n @problems = Problem.all.order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 8)\n @problem = Problem.new\n end",
"def index\n @jira_issues = JiraIssue.all\n end",
"def index\n @discussions = @issue.discussions.all\n end",
"def index\n @problems = Problem.all\n end",
"def index\n @problems = Problem.all\n end",
"def index\n @problems = Problem.all\n end",
"def chapters_with_problems\n get_chapters.inject Hash.new do |chapters_with_sections,chapter|\n challenges = Dir[\"ch#{chapter}/challenge/*\"]\n chapters_with_sections[chapter] = challenges.map { |challenge| challenge[%r([^/]+?$)].to_i }.sort\n chapters_with_sections\n end\nend",
"def index\n @issues = Issue.search( params[:query]).order('created_at desc').page(params[:page]).per(64)\n end",
"def get_issues\n jira_issues = Hash.new\n # This is the REST URL that will be hit. Change the jql query if you want to adjust the query used here\n uri = URI(JIRA_BASE_URL + '/rest/api/2/search?jql=' + JQL)\n\n Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') do |http|\n request = Net::HTTP::Get.new(uri)\n request.basic_auth USERNAME, PASSWORD\n response = http.request request\n # If the response was good, then grab the data\n if response.code =~ /20[0-9]{1}/\n data = JSON.parse(response.body)\n data[\"issues\"].each do |item|\n jira_id = item[\"key\"]\n jira_issues[jira_id] = item[\"fields\"][\"summary\"]\n end\n else\n raise StandardError, \"Unsuccessful HTTP response code: \" + response.code\n end\n end\n return jira_issues\nend",
"def query_v3\n if params[:workflow]\n @collection = current_user.workflow_issues\n else\n raise \"not sure what to do here\"\n end\n\n @include_workflow_state = true\n @include_issue_team = true\n @include_issue_tracker = true\n\n render 'api/v2/issues/index'\n end",
"def index\n @problems = Problem.active.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @problems }\n end\n end",
"def index\n if params[:problems].blank?\n @cases = Case.all\n else\n @cases = Case.as(:c).where('c.stock <= 1').pluck(:c)\n @cases.map!{|c| {\n id: c.id,\n name: c.name,\n stock: c.stock\n }}\n\n @cases.sort_by! {:name}\n\n render json: @cases\n end\n end",
"def get_my_issues\n get_json( GITHUB_ISSUES_URL ).each do |item|\n puts \"#{ item[ 'repository' ][ 'full_name' ] }: ##{ item[ 'number' ] } #{ item[ 'title' ] } | href=#{ item[ 'html_url' ] }\"\n end\nend",
"def list_selfies\n user = User.friendly.find(params[:user_id])\n\n if current_user == user or current_user.is_following?(user)\n user_selfies = user.selfies.where(\"blocked = false and hidden = false\").order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 39)\n else\n user_selfies = user.selfies.where(\"private = false and blocked = false and hidden = false\").order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 39)\n end\n followers = user.followers(1)\n following = user.all_following\n #books = user.books\n number_selfie_approved = user.selfies.where(\"blocked = false and hidden = false and approval_status = 1\").count\n\n render json: user_selfies.includes(:challenge), meta: {number_selfies: user_selfies.count, number_following: following.count, number_followers: followers.count, number_approved: number_selfie_approved}\n end",
"def index\n @git_hub_issues = GitHubIssue.all\n end",
"def index\n @participants = Participant.includes(:responses, :participant_test_cases).order(created_at: :desc)\n .paginate(:page => params[:page])\n end",
"def index\n @contests = Manage::Contest.order(is_deleted: :desc,id: :desc).to_a\n @contests.sort! do |a,b|\n if a.current_compete != 0\n if b.current_compete != 0\n # 如果两个比赛都有对应的正在进行的赛事,就按比赛数量逆序排列\n b.competes_count <=> a.competes_count\n else\n # 如果只有a有,那么a排前面\n -1\n end\n else\n if b.current_compete != nil\n # 如果只有b有,那么b排前面\n 1\n else\n # 如果都没有,也按照比赛数量逆序排序\n b.competes_count <=> a.competes_count\n end\n end\n end\n\n @competes = @contests[0].competes.order(start_time: :desc)\n if params[:contest]\n current = @contests.find_all {|x| x.id == params[:contest].to_i}\n if current.length > 0\n @current = current[0]\n end\n end\n @current ||= @contests[0]\n end",
"def index\n @experiments = Experiment.where(pend_status: [0])\n @experiments_wait = Experiment.where(pend_status: [1])\n end",
"def index\n @book_issues = BookIssue.order(:issue_date).page(params[:page]).per(3)\n end",
"def index\n @help_session_requests = HelpSessionRequest.all\n end",
"def issues\n workspace_id = zenhub_workspace_id\n repo_id = zenhub_repo_id\n url = \"https://api.zenhub.io/p2/workspaces/#{workspace_id}/repositories/#{repo_id}/board\" \n issues = Array.new\n uri = URI(url)\n response = Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|\n request = Net::HTTP::Get.new(uri)\n request['Content-Type'] = 'application/json'\n request['X-Authentication-Token'] = ENV['TOKEN']\n\n http.request(request)\n end\n\n board = JSON.parse(response.body)\n board[\"pipelines\"].each do |columns|\n if columns[\"name\"] == COLUMN\n columns[\"issues\"].each do |issue|\n issues.push(issue['issue_number'])\n end\n end\n end\n issues\nend",
"def index\n @problems = Problem.all\n end",
"def index\n @groups = current_user.groups\n @contests = Contest.entered_by_user(current_user.id)\n @contests_explore = Contest.not_entered_by_user(current_user.id).order('created_at desc')\n render 'index'\n end",
"def index\n @sort_column = sort_column\n @requests = apply_scopes(Request).all\n\n if current_user.try(:admin?) || current_user.approver? || current_user.worker?\n # show all requests\n @requests = @requests.order(sort_column + \" \" + sort_direction)\n else\n # show only requests for this user\n @requests = @requests.where(\"email = ?\", current_user.email).order(sort_column + \" \" + sort_direction)\n end\n # pagination\n @requests = @requests.paginate(:page => params[:page], :per_page => 10)\n\n @issues = Issue.all\n end",
"def show\n # Get the current user\n @user = User.find(current_user.id)\n # Define arrays to hold open and closed tickets\n @open_tickets = []\n @closed_tickets = []\n # For each request the person has made:\n @user.help_requests.each do |request|\n # If the request is open...\n if request.open?\n # ...add it to the array of open tickets\n @open_tickets << request\n # Else if the ticket is closed...\n elsif !request.open?\n # Add it to the list of closed tickets\n @closed_tickets << request\n end\n end\n end",
"def index\n @slack_channels = SlackChannel.search_and_paginate(params)\n end",
"def index\n @difficulty_levels = DifficultyLevel.all\n end",
"def github_closed_issues(user, repo, milestone)\n issues = Github::Client::Issues.new(user: user, repo: repo)\n mid = github_milestone_for(issues, user, repo, milestone)\n\n return nil if mid == -1\n\n options = { user: user, repo: repo, milestone: mid.to_s, state: 'closed', per_page: 100 }\n\n full_list = []\n 1.upto(1_000_000) do |i|\n options[:page] = i\n page = issues.list(options).map do |issue|\n ['#' + issue.number.to_s, issue.title, issue.html_url]\n end\n return full_list if page.size == 0\n full_list.concat page\n end\n full_list\nend",
"def open_issues\n @open_issues = @github.issues.list user: APP_CONF['org'],\n repo: APP_CONF['repo'],\n state: 'all',\n # labels: 'Complete',\n assignee: params[:username]\n render json: @open_issues\n end",
"def index\n @course = Course.find(params[:course_id])\n @questions = @course.questions.current.due + @course.questions.current.pending.find(:all, :order => :next_datetime, :limit => 200)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @questions }\n end\n end",
"def index\n @icebreaker_answers = IcebreakerAnswer.all\n end",
"def index\n @chi_tiet_gio_hangs = ChiTietGioHang.all\n end",
"def index\n @contests = current_user.contests\n end"
] |
[
"0.69211173",
"0.6767194",
"0.67391765",
"0.6728214",
"0.67092866",
"0.6653258",
"0.6653258",
"0.6653258",
"0.6653258",
"0.6651063",
"0.66446704",
"0.65798146",
"0.63403565",
"0.62897265",
"0.6289674",
"0.6275492",
"0.6266861",
"0.6266861",
"0.61835396",
"0.6165022",
"0.61098385",
"0.608125",
"0.606032",
"0.6034103",
"0.59641135",
"0.5942169",
"0.59194577",
"0.5913639",
"0.58909494",
"0.5886613",
"0.58598715",
"0.585724",
"0.58453524",
"0.58451027",
"0.5831313",
"0.5823029",
"0.57839966",
"0.5777943",
"0.57736427",
"0.5765025",
"0.57455456",
"0.5745019",
"0.5737288",
"0.57231057",
"0.5715215",
"0.5715215",
"0.5715215",
"0.5715215",
"0.5715215",
"0.5708591",
"0.57019484",
"0.5690379",
"0.5679006",
"0.5670269",
"0.56614166",
"0.56592256",
"0.5623665",
"0.5615923",
"0.561212",
"0.5611997",
"0.5609611",
"0.56067973",
"0.55951834",
"0.5589139",
"0.55865073",
"0.5585789",
"0.5572315",
"0.5567709",
"0.55671406",
"0.55669886",
"0.55645156",
"0.55645156",
"0.55645156",
"0.55507994",
"0.5548644",
"0.55367625",
"0.55351245",
"0.5534403",
"0.55318344",
"0.5529677",
"0.5529526",
"0.55247164",
"0.5520683",
"0.55173975",
"0.5508232",
"0.5506061",
"0.5497965",
"0.54938626",
"0.5490972",
"0.54857934",
"0.5484584",
"0.54786134",
"0.5461864",
"0.54599035",
"0.5456214",
"0.5452642",
"0.5442581",
"0.5432426",
"0.54299855",
"0.54253155"
] |
0.6850811
|
1
|
rss feed based upon the selected platform, technology & category
|
def feed
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def rss\n @title = t('titles.news', brand: website.brand_name)\n @description = website.value_for(\"default_meta_tag_description\")\n @news = News.all_for_website(website)\n respond_to do |format|\n format.xml # render rss.xml.builder\n end\n end",
"def build_rss\n ::RSS::Maker.make('2.0') do |maker|\n maker.channel.link = @wiki.settings.url\n maker.channel.title = @wiki.settings.title\n maker.channel.description = @wiki.settings.description.to_s\n maker.channel.author = @wiki.settings.author.to_s\n maker.channel.updated = Time.now.to_s\n maker.items.do_sort = true\n\n posts.each do |post|\n html = post.content\n date = Time.parse(post.post_date)\n\n next if date > Time.now unless @wiki.settings.future\n\n if i = html.index('</p>')\n text = html[0..i+4]\n else\n text = html\n end\n\n maker.items.new_item do |item|\n item.title = post.title\n item.link = File.join(@wiki.settings.url, post.href)\n item.date = date\n item.description = text\n end\n end\n end\n end",
"def render_feed(type, tag_name)\n raise if !type.instance_of?(Symbol)\n raise if !tag_name.instance_of?(String)\n\n last_modified_date = Post.order(\"updated_at DESC\").first.try(:created_at).try(:to_datetime) || DateTime.now\n tag = Tag.where(:name => tag_name).first\n if !tag\n return render_404\n end\n posts = tag.posts.where(:is_public => true).order(\"sort_id DESC\")\n xml = \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" ?>\\r\\n\"\n case type\n when :rss\n xml << \"<rss version=\\\"2.0\\\" xmlns:atom=\\\"http://www.w3.org/2005/Atom\\\">\\r\\n\"\n xml << \" <channel>\\r\\n\"\n xml << \" <title>\" + APP_TITLE + \"</title>\\r\\n\"\n if tag.name == \"home\"\n xml << \" <description>\" + APP_DESCRIPTION.encode(:xml => :text) + \"</description>\\r\\n\"\n else\n xml << \" <description>\" + APP_DESCRIPTION.encode(:xml => :text) + \" Category: \" + tag.name + \".</description>\\r\\n\"\n end\n xml << \" <link>\" + (APP_PROTOCOL + APP_HOST).encode(:xml => :text) + \"</link>\\r\\n\"\n xml << \" <pubDate>\" + last_modified_date.to_formatted_s(:rfc822).encode(:xml => :text) + \"</pubDate>\\r\\n\"\n if tag.name == \"home\"\n xml << \" <atom:link href=\\\"\" + (APP_PROTOCOL + APP_HOST).encode(:xml => :text) + \"/rss\\\" rel=\\\"self\\\" type=\\\"application/rss+xml\\\" />\\r\\n\"\n else\n xml << \" <atom:link href=\\\"\" + (APP_PROTOCOL + APP_HOST).encode(:xml => :text) + \"/rss/\" + tag.name + \"\\\" rel=\\\"self\\\" type=\\\"application/rss+xml\\\" />\\r\\n\"\n end\n for post in posts\n xml << \" <item>\\r\\n\"\n xml << \" <title>\" + post.title.encode(:xml => :text) + \"</title>\\r\\n\"\n xml << \" <description>\" + post.summary.encode(:xml => :text) + \"</description>\\r\\n\"\n xml << \" <link>\" + (APP_PROTOCOL + APP_HOST).encode(:xml => :text) + post.canonical_uri.encode(:xml => :text) + \"</link>\\r\\n\"\n xml << \" <guid>\" + (APP_PROTOCOL + APP_HOST).encode(:xml => :text) + post.canonical_uri.encode(:xml => :text) + \"</guid>\\r\\n\"\n xml << \" <pubDate>\" + post.created_at.to_datetime.to_formatted_s(:rfc822).encode(:xml => :text) + \"</pubDate>\\r\\n\"\n xml << \" </item>\\r\\n\"\n end\n xml << \" </channel>\\r\\n\"\n xml << \"</rss>\\r\\n\"\n when :atom\n xml << \"<feed xmlns=\\\"http://www.w3.org/2005/Atom\\\">\\r\\n\"\n xml << \" <title>\" + APP_TITLE + \"</title>\\r\\n\"\n if tag.name == \"home\"\n xml << \" <subtitle>\" + APP_DESCRIPTION.encode(:xml => :text) + \"</subtitle>\\r\\n\"\n else\n xml << \" <subtitle>\" + APP_DESCRIPTION.encode(:xml => :text) + \" Category: \" + tag.name + \".</subtitle>\\r\\n\"\n end\n if tag.name == \"home\"\n xml << \" <link href=\\\"\" + (APP_PROTOCOL + APP_HOST).encode(:xml => :text) + \"/atom\\\" rel=\\\"self\\\" />\\r\\n\"\n else\n xml << \" <link href=\\\"\" + (APP_PROTOCOL + APP_HOST).encode(:xml => :text) + \"/atom/\" + tag.name + \"\\\" rel=\\\"self\\\" />\\r\\n\"\n end\n xml << \" <link href=\\\"\" + (APP_PROTOCOL + APP_HOST).encode(:xml => :text) + \"/\\\" />\\r\\n\"\n xml << \" <id>\" + (APP_PROTOCOL + APP_HOST).encode(:xml => :text) + \"/</id>\\r\\n\"\n xml << \" <updated>\" + last_modified_date.to_formatted_s(:rfc3339).encode(:xml => :text) + \"</updated>\\r\\n\"\n for post in posts\n xml << \" <entry>\\r\\n\"\n xml << \" <title>\" + post.title.encode(:xml => :text) + \"</title>\\r\\n\"\n xml << \" <link href=\\\"\" + (APP_PROTOCOL + APP_HOST).encode(:xml => :text) + post.canonical_uri.encode(:xml => :text) + \"\\\" />\\r\\n\"\n xml << \" <id>\" + (APP_PROTOCOL + APP_HOST).encode(:xml => :text) + post.canonical_uri.encode(:xml => :text) + \"</id>\\r\\n\"\n xml << \" <updated>\" + post.created_at.to_datetime.to_formatted_s(:rfc3339).encode(:xml => :text) + \"</updated>\\r\\n\"\n xml << \" <summary>\" + post.summary.encode(:xml => :text) + \"</summary>\\r\\n\"\n xml << \" <author>\\r\\n\"\n xml << \" <name>\" + APP_AUTHOR.encode(:xml => :text) + \"</name>\\r\\n\"\n xml << \" <email>\" + APP_EMAIL.encode(:xml => :text) + \"</email>\\r\\n\"\n xml << \" </author>\\r\\n\"\n xml << \" </entry>\\r\\n\"\n end\n xml << \"</feed>\\r\\n\"\n else\n return render_404\n end\n return render :xml => xml\n end",
"def parse_feed\n remove_previous_entries\n @items = @content[\"rss\"][\"channel\"][\"item\"]\n if [email protected]?\n for item in @items do\n item[\"pubDate\"] ||= \"\"\n item[\"creator\"] ||= \"\"\n item[\"guid\"] ||= \"\"\n item[\"title\"] ||= \"\"\n item[\"description\"] ||= \"\"\n clean_content(item[\"encoded\"] ||= \"\")\n item[\"link\"] ||= \"\"\n params = { \n :pubdate => item[\"pubDate\"], \n :creator => item[\"creator\"], \n :guid => relative_link(item[\"guid\"]), \n :title => item[\"title\"], \n :description => item[\"description\"], \n :content => @content, \n :link => relative_link(item[\"link\"])\n }\n insert_entry(params)\n end\n end\n end",
"def get_rss\n #version = \"1.0\" # [\"0.9\", \"1.0\", \"2.0\"]\n version = @version\n\n content = RSS::Maker.make(@version) do |m|\n m.channel.title = @title\n m.channel.description = @description \n m.channel.link = @link \n m.channel.language = @language\n m.channel.about = @about\n m.items.do_sort = true # sort items by date\n m.channel.updated = Time.now.to_s\n m.channel.author = NAME\n\n if @image != nil\n m.image.url = @image\n m.image.title = @title\n end\n\n for mp3 in @mp3s \n item = m.items.new_item\n item.title = mp3\n ## add a base url \n if base != ''\n link = base + '/' + URI::escape(mp3.path)\n else \n link = URI::escape(mp3.path)\n end\n item.link = link\n item.date = mp3.mtime\n item.enclosure.url = link\n item.enclosure.length = mp3.length\n item.enclosure.type = mp3.type\n end\n end\n\n return content\n end",
"def feed\n tag = params[:tag] || \"home\"\n return render_feed(params[:type].to_sym, tag)\n end",
"def xml\n xml = Builder::XmlMarkup.new(indent: 2)\n\n xml.instruct! :xml, encoding: 'UTF-8'\n xml.rss version: '2.0' do |rss|\n rss.channel do |channel|\n channel.title 'Haxpressen'\n\n last_ten_days.each do |day|\n summary = summary_for day\n\n if summary.present?\n channel.item do |item|\n item.title \"Sammanfattning för #{day}\"\n item.pubDate day\n item.description summary\n end\n end\n end\n end\n end\n end",
"def index\n # Load the latest full blog feed for Frank's blog as per \n @latest_blog_posts = load_blog_feed_for_url('http://blog.rietta.com/feeds/posts/default?alt=rss')\n \n # Load the latest posts for the Marketing label feed. Labels are case sensitive - Marketing != marketing\n # Please note that the example of the Google website has an error on its label example. The alt=rss comes after\n # the label in the feed URL\n @latest_marketing_posts = load_blog_feed_for_url('http://blog.rietta.com/feeds/posts/default/-/Marketing?alt=rss')\n \n # Load the latest posts for the SQL Converter label feed (space in the tag)\n @latest_sql_converter_posts = load_blog_feed_for_url('http://blog.rietta.com/feeds/posts/default/-/SQL%20Converter?alt=rss')\n end",
"def parse(str)\n # Dirty hack: some feeds contain the & char. It must be changed to &\n str.gsub!(/&(\\s+)/, '&\\1')\n doc = REXML::Document.new(str)\n @xml = doc.root\n # get feed info\n @encoding = doc.encoding\n @title,@link,@description,@creator = nil\n @items = []\n if doc.root.elements['channel'] || doc.root.elements['rss:channel']\n @type = \"rss\"\n # We have a RSS feed!\n # Title\n if (e = doc.root.elements['channel/title'] ||\n doc.root.elements['rss:channel/rss:title']) && e.text\n @title = e.text.unescape_html.toUTF8(@encoding).rmWhiteSpace!\n end\n # Link\n if (e = doc.root.elements['channel/link'] ||\n doc.root.elements['rss:channel/rss:link']) && e.text\n @link = e.text.rmWhiteSpace!\n end\n # Description\n if (e = doc.root.elements['channel/description'] || \n doc.root.elements['rss:channel/rss:description']) && e.text\n @description = e.text.toUTF8(@encoding).rmWhiteSpace!\n end\n # Creator\n if ((e = doc.root.elements['channel/dc:creator']) && e.text) ||\n ((e = doc.root.elements['channel/author'] ||\n doc.root.elements['rss:channel/rss:author']) && e.text)\n @creator = e.text.unescape_html.toUTF8(@encoding).rmWhiteSpace!\n end\n # Items\n if doc.root.elements['channel/item']\n query = 'channel/item'\n elsif doc.root.elements['item']\n query = 'item'\n elsif doc.root.elements['rss:channel/rss:item']\n query = 'rss:channel/rss:item'\n else\n query = 'rss:item'\n end\n doc.root.each_element(query) { |e| @items << RSSItem::new(e, self) }\n\n elsif doc.root.elements['/feed']\n # We have an ATOM feed!\n @type = \"atom\"\n # Title\n if (e = doc.root.elements['/feed/title']) && e.text\n @title = e.text.unescape_html.toUTF8(@encoding).rmWhiteSpace!\n end\n # Link\n doc.root.each_element('/feed/link') do |e|\n if e.attribute('type') and (\n e.attribute('type').value == 'text/html' or\n e.attribute('type').value == 'application/xhtml' or\n e.attribute('type').value == 'application/xhtml+xml')\n if (h = e.attribute('href')) && h\n @link = h.value.rmWhiteSpace!\n end\n end\n end\n # Description\n if e = doc.root.elements['/feed/info']\n e = e.elements['div'] || e\n @description = e.to_s.toUTF8(@encoding).rmWhiteSpace!\n end\n # Items\n doc.root.each_element('/feed/entry') do |e|\n @items << AtomItem::new(e, self)\n end\n else\n raise UnknownFeedTypeException::new\n end\n end",
"def feed_sorter\n\t\[email protected] do |url|\n\t\t\topen(url) do |rss|\n \t\t\tfeed = RSS::Parser.parse(rss)\n\t\t\t\n\t\t\t\tcase \n\t\t\t\twhen feed.feed_type == \"rss\"\n\t\t\t\t\trss_parser(feed)\n\t\t\t\twhen feed.feed_type == \"atom\"\n\t\t\t\t\tatom_parser(feed) \n\t\t\t\tend \n\t\t\tend \n\t\tend \n\tend",
"def isRss?\n self.category =~ /(rss)/i\n end",
"def fetch_data\n rss_provider = RssProvider.find(params[:format])\n unless rss_provider.rss_url.include?(\"indiatvnews\" ) || rss_provider.rss_url.include?(\"hindu\" ) || rss_provider.rss_url.include?(\"zee\" )\n xml = HTTParty.get(rss_provider.rss_url)\n ProviderContent.create(xml: xml, rss_provider_id: rss_provider.id)\n feeds = xml[\"rss\"][\"channel\"][\"item\"]\n feeds.each do |feed|\n if rss_provider.rss_url.include?(\"indiatoday\" )\n title = News.find_by(title: feed[\"title\"])\n unless title.present?\n\n\n index_of_summary = feed[\"description\"].index(\"</a>\")\n summary = feed[\"description\"][index_of_summary..].delete_prefix(\"</a> \")\n index_of_image = feed[\"description\"].index(\"src\")\n image_url = feed[\"description\"][(index_of_image+5)..(index_of_summary-4)]\n News.create(title: feed[\"title\"], summary: summary, \n published_on: feed[\"pubDate\"], url: feed[\"link\"], media_url: image_url,\n rss_provider_id: rss_provider.id, category_id: rss_provider.category.id, \n provider_id: rss_provider.provider.id, media_credit: rss_provider.provider.provider_name)\n rss_provider.update(news_updated_at: Time.now.localtime)\n\n end\n\n \n elsif rss_provider.rss_url.include?(\"news18\")\n title = News.find_by(title: feed[\"title\"])\n unless title.present?\n index_of_image = feed[\"description\"].index(\"https\")\n summary_index = feed[\"description\"].index(\" />\")\n last_index_of_image = feed[\"description\"].index(\"jpg\")\n image_url = feed[\"description\"][(index_of_image)..(last_index_of_image)] + \"pg\"\n summary = feed[\"description\"][(summary_index+3)..]\n News.create(title: feed[\"title\"], summary: summary,published_on: feed[\"pubDate\"], url: feed[\"link\"], media_url: image_url, rss_provider_id: rss_provider.id, category_id: rss_provider.category.id, \n provider_id: rss_provider.provider.id, media_credit: rss_provider.provider.provider_name)\n rss_provider.update(news_updated_at: Time.now.localtime)\n end\n\n\n elsif rss_provider.rss_url.include?(\"bbc\")\n title = News.find_by(title: feed[\"title\"])\n unless title.present?\n News.create(title: feed[\"title\"], summary: feed[\"description\"], \n published_on: feed[\"pubDate\"], url: feed[\"link\"], media_url: feed[\"fullimage\"], \n rss_provider_id: rss_provider.id, category_id: rss_provider.category.id, \n provider_id: rss_provider.provider.id, media_credit: rss_provider.provider.provider_name)\n rss_provider.update(news_updated_at: Time.now.localtime)\n end\n\n\n elsif rss_provider.rss_url.include?(\"ndtv\")\n title = News.find_by(title: feed[\"title\"])\n unless title.present?\n News.create!(title: feed[\"title\"], summary: feed[\"description\"], \n published_on: feed[\"updatedAt\"], url: feed[\"link\"], media_url: feed[\"fullimage\"], \n rss_provider_id: rss_provider.id, category_id: rss_provider.category.id,provider_id: rss_provider.provider.id, media_credit: rss_provider.provider.provider_name)\n rss_provider.update(news_updated_at: Time.now.localtime)\n end\n\n\n \n elsif rss_provider.rss_url.include?(\"timesofindia\")\n title = News.find_by(title: feed[\"title\"])\n\n unless title.present?\n\n if rss_provider.category.category_name == \"Top Story\" \n News.create(title: feed[\"title\"], summary: feed[\"description\"], \n published_on: feed[\"pubDate\"], url: feed[\"link\"], media_url: \"\", \n rss_provider_id: rss_provider.id,category_id: rss_provider.category.id, \n provider_id: rss_provider.provider.id, media_credit: rss_provider.provider.provider_name)\n rss_provider.update(news_updated_at: Time.now.localtime) \n else\n unless feed[\"description\"] == nil \n index_of_image = feed[\"description\"].index(\"src\")\n last_index_of_image = feed[\"description\"][index_of_image..].index(\"/>\")+index_of_image\n image_url = feed[\"description\"][(index_of_image+5)..(last_index_of_image-3)]\n summary_index = feed[\"description\"].index(\"</a>\")\n summary = feed[\"description\"][(summary_index+4)..]\n News.create(title: feed[\"title\"], summary: summary, \n published_on: feed[\"pubDate\"], url: feed[\"link\"], media_url: image_url, \n rss_provider_id: rss_provider.id, category_id: rss_provider.category.id, \n provider_id: rss_provider.provider.id, media_credit: rss_provider.provider.provider_name)\n rss_provider.update(news_updated_at: Time.now.localtime)\n end\n end\n end\n \n\n end\n\n end\n end\n\n unless rss_provider.rss_url.include?(\"timesofindia\" ) || rss_provider.rss_url.include?(\"ndtv\" ) || rss_provider.rss_url.include?(\"bbc\" ) ||\n rss_provider.rss_url.include?(\"news18\") || rss_provider.rss_url.include?(\"indiatoday\") \n\n\n if rss_provider.rss_url.include?(\"indiatvnews\" )\n xml = HTTParty.get(rss_provider.rss_url)\n ProviderContent.create(xml: xml, rss_provider_id: rss_provider.id)\n\n xml = xml.body\n feeds = Feedjira.parse(xml)\n feeds.entries.each do |feed|\n index_of_summary = feed.summary.index(\"</a>\")\n summary = feed.summary[index_of_summary+4..]\n index_of_image = feed.summary.index(\"src\")\n image_url = feed.summary[(index_of_image+5)..(index_of_summary-5)]\n title = News.find_by(title: feed.title)\n unless title.present?\n News.create(title: feed.title, summary: summary, \n published_on: feed.published, url: feed.url, media_url: image_url, \n rss_provider_id: rss_provider.id, category_id: rss_provider.category.id, \n provider_id: rss_provider.provider.id, media_credit: rss_provider.provider.provider_name)\n end\n\n end\n rss_provider.update(news_updated_at: Time.now.localtime)\n\n elsif rss_provider.rss_url.include?(\"thehindu\")\n xml = HTTParty.get(rss_provider.rss_url)\n ProviderContent.create(xml: xml, rss_provider_id: rss_provider.id)\n xml = xml.body\n feeds = Feedjira.parse(xml)\n feeds.entries.each do |feed|\n title = News.find_by(title: feed.title)\n unless title.present?\n News.create(title: feed.title, summary: feed.summary.strip, \n published_on: feed.published, url: feed.url,rss_provider_id: rss_provider.id, category_id: rss_provider.category.id, \n provider_id: rss_provider.provider.id, media_credit: rss_provider.provider.provider_name)\n end\n\n end\n rss_provider.update(news_updated_at: Time.now.localtime)\n\n elsif rss_provider.rss_url.include?(\"zee\")\n xml = HTTParty.get(rss_provider.rss_url)\n ProviderContent.create(xml: xml, rss_provider_id: rss_provider.id)\n xml = xml.body\n feeds = Feedjira.parse(xml)\n feeds.entries.each do |feed|\n title = News.find_by(title: feed.title)\n unless title.present?\n News.create(title: feed.title, summary: feed.summary.strip, \n published_on: feed.published, url: feed.url,rss_provider_id: rss_provider.id, category_id: rss_provider.category.id, \n provider_id: rss_provider.provider.id, media_credit: rss_provider.provider.provider_name)\n end\n\n end\n rss_provider.update(news_updated_at: Time.now.localtime)\n end\n\n end\n\n unless rss_provider.rss_url.include?(\"timesofindia\" ) || rss_provider.rss_url.include?(\"ndtv\" ) || rss_provider.rss_url.include?(\"bbc\" ) ||\n rss_provider.rss_url.include?(\"news18\") || rss_provider.rss_url.include?(\"indiatoday\") ||\n rss_provider.rss_url.include?(\"indiatvnews\") || rss_provider.rss_url.include?(\"thehindu\") ||\n rss_provider.rss_url.include?(\"zee\")\n\n xml = HTTParty.get(rss_provider.rss_url)\n ProviderContent.create(xml: xml, rss_provider_id: rss_provider.id)\n xml = xml.body\n feeds = Feedjira.parse(xml)\n feeds.entries.each do |feed|\n title = News.find_by(title: feed.title)\n unless title.present?\n News.create(title: feed.title, summary: feed.summary.strip, \n published_on: feed.published, url: feed.url,rss_provider_id: rss_provider.id, category_id: rss_provider.category.id, \n provider_id: rss_provider.provider.id, media_credit: rss_provider.provider.provider_name)\n end\n\n end\n rss_provider.update(news_updated_at: Time.now.localtime)\n\n end\n redirect_to admin_rss_providers_path, alert: \"Fetched Successfully \"\n\n end",
"def feed_type\n if @feed_type.nil?\n if self.root_node.nil?\n return nil\n end\n case self.root_node.name.downcase\n when \"feed\"\n @feed_type = \"atom\"\n when \"rdf:rdf\"\n @feed_type = \"rss\"\n when \"rdf\"\n @feed_type = \"rss\"\n when \"rss\"\n @feed_type = \"rss\"\n when \"channel\"\n if self.root_node.namespace == FEED_TOOLS_NAMESPACES['rss11']\n @feed_type = \"rss\"\n else\n @feed_type = \"cdf\"\n end\n end\n end\n return @feed_type\n end",
"def rss\n render_rss_feed_for Idea.find(:all, :order => 'created_at DESC',\n :limit => 10), {\n :feed => {\n :title => 'OpenMind New Ideas',\n :link => url_for(:controller => 'ideas', :action => 'list', :only_path => false),\n :pub_date => :created_at\n },\n :item => {\n :title => :title,\n :description => :formatted_description,\n :link => Proc.new{|idea| url_for(:controller => 'ideas',\n :action => 'show', :id => idea.id)}\n }\n }\n end",
"def make_rss(list, descr)\n out = ''\n my_time = Time.now.to_s\n\n out = RSS::Maker.make('atom') do |feed|\n feed.channel.author = @config[MYNAME]['author']\n feed.channel.updated = my_time\n feed.channel.about = @config[MYNAME]['rss']\n feed.channel.title = @config[MYNAME]['title']\n\n list.each_with_index do |book, idx|\n series = book['series']\n if series == ''\n title = book['title']\n else\n title = \"#{book['title']} (#{series}, ##{book['series_index']})\"\n end\n\n feed.items.new_item do |item|\n item.id = idx.to_s\n item.author = book['authors']\n item.link = @config[MYNAME]['where_uri']\n item.title = title\n item.updated = my_time\n end\n end\n end\n out\nend",
"def generate_feed(title='Rails 程序测试指南', link='http://guides.ruby-china.org/testing.html',\n source = 'http://guides.ruby-china.org/testing.html', author='MasterQiu')\n feed = Feed.new\n feed.title = title\n feed.link=link\n feed.source = source\n feed.author = author\n return feed\n end",
"def scrape\n\t\turl = 'http://www.wsj.com/xml/rss/3_7455.xml'\n open(url) do |rss|\n \tfeed = RSS::Parser.parse(rss, false)\n puts \" \"\n puts \"*********************************\"\n \tputs \"Title: #{feed.channel.title}\"\n puts \"--------------------------------\"\n feed.items.each do |item|\n tags = tag_article(item.title.to_s)\n \tarticle = Article.new(title: item.title.to_s, \n summary: item.description.to_s.gsub(/\\\"/,''), \n link: item.link, \n date: item.pubDate.to_s.gsub(/,/,''),\n tag_list: tags, \n source: \"Wall Street Journal\")\n article.save\n end\n end\n end",
"def discover\n # Look for rss link, e.g.\n # <link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\"\n # href=\"http://feeds.feedburner.com/TheRssBlog\">\n # Tricky: Hpricot CSS attribute selectors are written like XPath selectors\n [:atom, :rss].each do |flavor|\n if [email protected](\"head link[@type=application/#{flavor}+xml]\")\n return x[:href]\n end\n end\n if [email protected](\"head link[@type=text/xml]\")\n return x[:href]\n end\n return nil\n end",
"def feed\r\n @posts = Post.all(:order => \"created_at DESC\")\r\n respond_to do |format|\r\n format.rss\r\n end\r\n end",
"def scrape\r\n @article_arr = []\r\n\t\turl = 'http://feeds.news.com.au/heraldsun/rss/heraldsun_news_technology_2790.xml'\r\n open(url) do |rss|\r\n \tfeed = RSS::Parser.parse(rss, false)\r\n \tputs \"Title: #{feed.channel.title}\"\r\n puts \"*********************************\"\r\n puts \" \"\r\n feed.items.each do |item|\r\n \t@article_arr << HSArticle.new(author: \"nil\", title: item.title.to_s.gsub(/,/,' ').gsub(/\"/,' ').gsub(/'s/,'s').gsub(/'/, ''), \r\n summary: item.description.to_s.gsub(/,/,' ').gsub(/\\\"/,'\\'').gsub(/'s/,''), images: item.enclosure.url, source: item.link,\r\n date: item.pubDate.to_s.gsub(/,/,'').gsub(/\\\"/,'\\'').gsub(/'s/,''))\r\n end\r\n end\r\n @articles.concat(@article_arr)\r\n end",
"def retrieve_data\n # Define the url\n url = 'http://www.abc.net.au/radionational/feed/3771046/rss.xml'\n\n # Open the url and parse the rss feed\n open(url) do |rss|\n # Start parsing\n feed = RSS::Parser.parse(rss, false)\n\n # Iterate each item and scrape information\n feed.items.each do |item|\n # If the title of thie article matches the title of the last saved article,\n # stop scraping to avoid from saving duplicates in database\n break if !@last_title.nil? && @last_title.eql?(item.title.to_s)\n\n # If thie article is already stored then ignore\n next if Article.find_by(title: item.title.to_s)\n\n # Get the author\n regex_author = /<dc:creator>(.*)<\\/dc:creator>/\n regex_author.match(item.to_s)\n author = Regexp.last_match(1)\n\n author = nil if author.eql? ''\n\n # Get categories values\n regex_category = /<category>(.*)<\\/category>/\n\n categories = []\n item.categories.each do |category|\n regex_category.match(category.to_s)\n categories.push(Regexp.last_match(1))\n end\n\n # Make a template dictionary to put @articles\n temp = {\n author: author,\n title: item.title,\n summary: item.description.to_s,\n image: nil,\n date_time: DateTime.parse(item.pubDate.to_s),\n link: item.link,\n categories: categories.join(',')\n }\n\n # Put the object into articles array\n @articles << temp\n end\n end\n end",
"def feed_class(feed)\n return '' if feed.service.blank?\n \n if feed.service.photo?\n \"feed-photos\"\n elsif feed.service.bookmark?\n \"feed-bookmarks\"\n elsif feed.service.video?\n \"feed-videos\"\n elsif feed.service.music?\n \"feed-music\"\n end\n end",
"def feed_list_html(env)\n\tpage = \"\"\n\tpage << '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\t\t<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n\t\t\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n\t\t<html xmlns=\"http://www.w3.org/1999/xhtml\"\n\t\t xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xsi:schemaLocation=\"http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd\"\n\t\t xml:lang=\"en\" >\n\t\t\t<head>\n\t\t\t\t<title>WoC scrapped feed list for '+CONFIG[\"host\"].to_s+'</title>\n\t\t\t</head>\n\t\t\t<body>'\n\t\t\tpage << '<dl>'\n\t\t\tfor year in CONFIG[\"years\"] do\n\t\t\t\tpage << \"<dt>#{year[0]}:</dt>\"\n\t\t\t\tpage << '<dd>'\n\t\t\t\tpage << '<dl>'\n\t\t\t\tfor course in CONFIG[\"courses\"] do\n\t\t\t\t\tpage << \"<dt>#{CONFIG[\"course_names\"][course[1]]}</dt>\"\n\t\t\t\t\tpage << \"<dd>\"\n\t\t\t\t\tpage << \"<a href=\\\"http://#{env[\"HTTP_HOST\"]}/#{year[0]}/#{course[0]}/rss.xml\\\">http://#{env[\"HTTP_HOST\"]}/#{year[0]}/#{course[0]}/rss.xml</a>\"\n\t\t\t\t\tpage << \"</dd>\"\n\t\t\t\tend\n\t\t\t\tpage << '</dl>'\n\t\t\t\tpage << '</dd>'\n\t\t\tend\n\t\t\tpage << '</dl>'\n\t\tpage << \t\t\n\t\t\t'</body>\n\t\t</html>'\n\t\treturn page\nend",
"def scrape\n\t\topen(@url) do |rss|\n\t\t\tfeed = RSS::Parser.parse(rss)\n\t\t\t@source_name = feed.channel.title\n\t\t\tfeed.items.each do |item|\n\t\t\t\tif date_valid?(item.pubDate) and item.title\n\t\t\t\t\tcreate_article(item.dc_creator, item.title, item.description,\\\n\t\t\t\t\t\t\"\", @source_name, item.pubDate.to_date, item.link)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@articles\n\tend",
"def feed\n @feed ||= (parsed_feed('rss') || parsed_feed('atom'))\n end",
"def feed\n @feed ||= (parsed_feed('rss') || parsed_feed('atom'))\n end",
"def type\n return @type if @type\n @type = 'item' if rss.css('item').count > 0\n @type = 'entry' if rss.css('entry').count > 0\n return @type\n end",
"def xml_feed_entries(feed_url, locale, offset)\r\n p \"Feed #{feed_url}\"\r\n doc = Nokogiri::XML(open(feed_url))\r\n doc.xpath(\"//item\").count.times do |n|\r\n \r\n # process dates\r\n sdt = DateTime.parse(doc.xpath(\"//item//xCal:dtstart\")[n].text) rescue nil\r\n edt = doc.xpath(\"//item//xCal:dtend\")[n].text\r\n edt.blank? ? enddt = sdt.advance(:hours => 2) : enddt = DateTime.parse(edt)\r\n \r\n # get event title and url\r\n etitle = doc.xpath(\"//item//title\")[n].text.split(' at ')[0]\r\n url = doc.xpath(\"//item//link\")[n].text \r\n sid = doc.xpath(\"//item//id\")[n].text \r\n\r\n # get county based on coordinates\r\n lat = doc.xpath(\"//item//geo:lat\")[n].text\r\n lng = doc.xpath(\"//item//geo:long\")[n].text\r\n county = Schedule.chk_geocode(lat, lng) rescue nil\r\n \r\n # add only current events \r\n if sdt >= Date.today\r\n \r\n # find correct channel and location\r\n cid = LocalChannel.select_channel(etitle, county, locale).flatten 1\r\n# cid.map {|channel| p \"Channel: #{channel.channelID}\" }\r\n\r\n # add event to calendar\r\n cid.map {|channel| add_event(doc, n, sid, etitle[0..199], sdt, enddt, channel.channelID, url, offset)} if cid\r\n# add_event(doc, n, sid, etitle[0..199], sdt, enddt, cid[0].channelID, url, offset) if cid\r\n end\r\n end \r\n end",
"def rss # :nologin:\n @logs = RssLog.all(conditions: \"datediff(now(), updated_at) <= 31\",\n order: \"updated_at desc\", limit: 100,\n include: [:name,\n :species_list,\n { observation: :name }\n ])\n render_xml(layout: false)\n end",
"def rss\n @rss ||= build_rss\n end",
"def make_rss_feed\n require 'rss/maker'\n fname = Wiki_path + \"/rss-temp\"\n rss_entries = Marshal::load(File.read(fname))\n\n version = \"2.0\" # [\"0.9\", \"1.0\", \"2.0\"]\n\n content = RSS::Maker.make(version) do |m|\n m.channel.title = Wiki_title\n m.channel.link = Internet_path\n m.channel.description = Wiki_desc\n m.items.do_sort = true # sort items by date\n \n rss_entries.each do |entry|\n i = m.items.new_item\n i.title = entry[:title]\n i.link = entry[:link]\n i.date = entry[:date]\n i.description = entry[:description]\n end\n end\n\n File.write(Wiki_path + \"/data/media/pages.xml\", content) \nend",
"def create\n @feed = Feed.new(feed_params)\n\n\n\n @rss = RSS::Parser.parse(open(feed_params[:url]).read, false)\n\n @feed.title = @rss.channel.title\n @feed.link = @rss.channel.link\n @feed.pub_date = @rss.channel.pubDate\n @feed.description = @rss.channel.description\n @feed.author = @rss.channel.itunes_author\n @feed.language = @rss.channel.language\n\n \n if @rss.channel.itunes_image != nil\n @feed.image = @rss.channel.itunes_image.href\n else @rss.channel.image != nil\n @feed.image = @rss.channel.image.url\n end \n # @feed.keywords = @rss.channel.keywords\n unless @rss.channel.itunes_owner.blank?\n @feed.owner_name = @rss.channel.itunes_owner.itunes_name\n @feed.owner_email = @rss.channel.itunes_owner.itunes_email\n end\n unless @rss.channel.itunes_category.blank?\n @feed.category = @rss.channel.itunes_category.text\n end\n @feed.user_id = current_user.id\n\n\n respond_to do |format|\n if @feed.save\n format.html { redirect_to @feed, notice: 'Feed was successfully created.' }\n format.json { render :show, status: :created, location: @feed }\n else\n format.html { render :new }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def parse_feed\n feed = self.download_feed\n Nokogiri::XML(feed).xpath(\"//item\").map do |item|\n enclosure = item.xpath(\"enclosure\").first\n\n title = CGI::unescapeHTML(item.xpath(\"title\").text.chomp)\n publish_date = Time.parse(item.xpath(\"pubDate\").inner_html.chomp)\n type = enclosure ? enclosure[:type] : nil\n url = enclosure ? enclosure[:url] : nil\n Podcast.new title, publish_date, type, url, self\n end\n end",
"def parse_rss_alt(year, month, feed)\n file_paths = Array.new\n xbrlFilings = filter_feed_alt(Nokogiri::XML(feed), get_ciks)\n\n xbrlFilings.each do |xbrlFiling|\n cik = xbrlFiling.children[7].text\n xbrlFiles = xbrlFiling.children[23] != nil ? xbrlFiling.children[23].children : xbrlFiling.children[21].children\n file_path = Array.new\n\n (1..(xbrlFiles.length - 1)).step(2) do |j|\n url = xbrlFiles[j].attributes[\"url\"].value\n\n file_path << url if (url =~ /.(xml|xsd)$/) != nil\n end\n file_paths << [cik, [year.to_s, month.to_s], file_path]\n end\n file_paths\nend",
"def feed_for(name)\n find_articles(name) \n articles_to_list\n feed = @page.page_parts.where(name: 'feed').first\n process_with_filter(feed) \n end",
"def scrape\n open(@url) do |rss|\n feed = RSS::Parser.parse(rss)\n\n feed.items.each do |item|\n # Remove the p tag and retrieve image url from the description\n # if it exists\n p_tag = item.description[%r{<p>.*</p>}]\n if p_tag\n item.description.slice! p_tag\n img_url = p_tag.match(/src=\"(?<img>[^\"]*)\"/)[:img]\n else\n img_url = nil\n end\n\n # Sanitize HTML\n item.title = CGI.unescapeHTML(item.title)\n item.description = CGI.unescapeHTML(item.description)\n\n @articles.push(\n title: item.title,\n summary: item.description,\n image_url: img_url,\n source: @source,\n url: item.link,\n pub_date: item.pubDate.to_s,\n guid: item.guid.content\n )\n end\n end\n end",
"def feed_url\n blog_index_url(format: :rss)\n end",
"def rss\n @logs = RssLog.includes(:name, :species_list, observation: :name).\n where(\"datediff(now(), updated_at) <= 31\").\n order(updated_at: :desc).\n limit(100)\n\n render_xml(layout: false)\n end",
"def get_new_articles\n # Download the RSS feed and save to self.doc\n get_source\n \n # Keep track of which articles are in the feed \n articles = []\n \n article_links = (self.doc/'li.mjItemMain').collect do |mjItem|\n mjItem.at('a.mjLinkItem')\n end\n \n # For each item in the RSS feed \n article_links.each_with_index do |link, index|\n \n # Create or update the article in the db\n articles << Article.factory(\n :category => self.category,\n :description => '',\n :feed => self,\n :url => \"http://online.wsj.com#{link.attributes['href']}\",\n :priority => index\n )\n end\n \n articles\n end",
"def scrape\n\t\topen(@url) do |rss|\n\t\t\tfeed = RSS::Parser.parse(rss)\n\t\t\t@source_name = feed.channel.title\n\t\t\tfeed.items.each do |item|\n\t\t\t\tif date_valid?(item.pubDate) and item.title\n\t\t\t\t\tcreate_article(get_author(item), item.title, item.description,\\\n\t\t\t\t\t\tget_images(item), @source_name, item.pubDate.to_date,\\\n\t\t\t\t\t\titem.link, get_image_length(item))\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@articles\n\tend",
"def scrape\n @articles = []\n url = 'http://feeds.news.com.au/heraldsun/rss/heraldsun_news_technology_2790.xml'\n open(url) do |rss|\n feed = RSS::Parser.parse(rss, false)\n feed.items.each do |item|\n article = Article.create(title: item.title.to_s.tr('\"', '\\''),\n summary: item.description.to_s\n .gsub(/’/, '\\'').gsub(/\\\"/, '\\''),\n imageURL: item.enclosure.url,\n link: item.link,\n pubDate: DateTime.parse(item.pubDate.to_s),\n source: HSImporter.source_name)\n @articles << article\n end\n end\n @articles\n end",
"def parse_by_rss_feed(url,rss_link_id)\n feeds = RssFeed::RssFeed.parse_rss_url(url)\n feeds.entries.each do |item|\n params = {\n :title => item.title,\n :description => ActionController::Base.helpers.strip_tags(item.description),\n :link => item.link,\n :author => item.author,\n :publication_date => item.published,\n :media_contents => (item.media_image ? [{:url => item.media_image}] : []),\n :media_description => item.media_description,\n :media_credit => item.media_credit,\n :keywords => (item.categories.present? ? item.categories.join(\",\") : \"\"),\n :rss_link_id => rss_link_id\n }\n f = Feed.new(params)\n if f.save\n activity = Activity.new({:action => \"Create\", :parent_id => rss_link_id, :parent_type => \"RssLink\", :data => params}) \n activity.save\n puts \"*\" * 50\n puts \"Title: \" + f.title + \" parsed and saved\"\n end\n end if feeds && feeds.entries\n end",
"def feed\n @data.feed ||= parsed_document.xpath(\"//link\").select{ |link|\n link.attributes[\"type\"] && link.attributes[\"type\"].value =~ /(atom|rss)/\n }.map { |link|\n absolutify_url(link.attributes[\"href\"].value)\n }.first rescue nil\n end",
"def rss\r\n Nokogiri::XML(body)\r\n end",
"def feed(prefer = :rss)\n rss = rss_feed\n atom = atom_feed\n if rss && atom\n prefer == :rss ? rss : atom\n else\n rss || atom\n end\n end",
"def create_avail_category\n file = ::File.new(\"#{node['opennms']['conf']['home']}/etc/categories.xml\", \"r\")\n doc = REXML::Document.new file\n file.close\n cg_el = doc.elements[\"/catinfo/categorygroup[name[text()[contains(.,'#{new_resource.category_group}')]]]/categories\"]\n cat_el = cg_el.add_element 'category'\n label_el = cat_el.add_element 'label'\n label_el.add_text(REXML::CData.new(new_resource.label))\n comment_el = cat_el.add_element 'comment'\n comment_el.add_text new_resource.comment\n normal_el = cat_el.add_element 'normal'\n normal_el.add_text \"#{new_resource.normal}\" # really ruby? really?\n warning_el = cat_el.add_element 'warning'\n warning_el.add_text \"#{new_resource.warning}\"\n new_resource.services.each do |s|\n s_el = cat_el.add_element 'service'\n s_el.add_text s\n end\n rule_el = cat_el.add_element 'rule'\n rule_el.add_text(REXML::CData.new(new_resource.rule))\n out = \"\"\n formatter = REXML::Formatters::Pretty.new(2)\n formatter.compact = true\n formatter.write(doc, out)\n ::File.open(\"#{node['opennms']['conf']['home']}/etc/categories.xml\", \"w\"){ |file| file.puts(out) }\nend",
"def aviator \n aviator_output = {}\n source = \"Aviator-aero\"\n url = 'https://newsroom.aviator.aero/rss/'\n open(url) do |rss|\n feed = RSS::Parser.parse(rss)\n\n feed.items.each_with_index {|item, index|\n title = item.title\n description = item.description.gsub(/<\\/?[^>]*>/, \"\")\n category = item.category\n link = item.link \n \n aviator_output[index] = {\n :title => title,\n :description => description,\n :link => link,\n :source => source\n }\n }\n end\n aviator_output\n end",
"def feed\n\t\t\tpost = { \"token\" => @token }\n\t\t\tdocxml = nil\n\t\t\tdocxml = nessus_request('feed', post)\n\t\t\tif docxml.nil?\n\t\t\t\treturn\n\t\t\tend\n\t\t\tfeed = docxml.root.elements['contents'].elements['feed'].text\n\t\t\tversion = docxml.root.elements['contents'].elements['server_version'].text\n\t\t\tweb_version = docxml.root.elements['contents'].elements['web_server_version'].text\n\t\t\treturn feed, version, web_version\n\t\tend",
"def parse_rss\n parser = Parsers::RSS.new\n noko_sax = Nokogiri::XML::SAX::Parser.new(parser)\n noko_sax.parse(@data)\n parser.feed\n end",
"def feed_select(feed)\n selected_items = []\n case feed.feed_type\n when 'rss'\n items = feed.channel.items\n items.each do |item|\n selected_items.push(rss_select(item))\n end\n when 'atom'\n items = feed.entries\n items.each do |item|\n selected_items.push(atom_select(item))\n end\n end\n selected_items\n end",
"def parse_by_feedzirra(feed_text, src)\n if @src.uri =~ /citeulike/\n Feedzirra::Feed.add_common_feed_entry_element('dc:source', :as => :source)\n #Feedzirra::Feed.add_common_feed_entry_element('dc:creator', :as => :authors)\n Feedzirra::Feed.add_common_feed_entry_element('prism:publicationYear', :as => :pub_year)\n end\n feed_data = Feedzirra::Feed.parse feed_text\n #debugger\n feed_data.entries.map do|e|\n metadata = {}\n metadata[:author] = e.author if e.author\n #metadata[:author] = e.authors if e.respond_to?(:authors)\n metadata[:pub_year] = e.pub_year if e.respond_to?(:pub_year)\n metadata[:source] = e.source if e.respond_to?(:source)\n metadata[:tag_list] = e.categories.join(\",\") unless e.categories.blank?\n #debugger\n {:did=>(e.id || e.url), :title=>e.title,:content=>(e.content || e.summary),:basetime=>e.published, \n :metadata=>metadata, :uri=>e.url}\n end \n end",
"def build_xml(feed_type=(self.feed_type or \"atom\"), feed_version=nil,\n xml_builder=Builder::XmlMarkup.new(\n :indent => 2, :escape_attrs => false))\n \n if self.find_node(\"access:restriction/@relationship\").to_s == \"deny\"\n raise StandardError,\n \"Operation not permitted. This feed denies redistribution.\"\n elsif self.find_node(\"@indexing:index\").to_s == \"no\"\n raise StandardError,\n \"Operation not permitted. This feed denies redistribution.\"\n end\n \n self.full_parse()\n \n xml_builder.instruct! :xml, :version => \"1.0\",\n :encoding => (self.configurations[:output_encoding] or \"utf-8\")\n if feed_type.nil?\n feed_type = self.feed_type\n end\n if feed_version.nil?\n feed_version = self.feed_version\n end\n if feed_type == \"rss\" &&\n (feed_version == nil || feed_version <= 0.0)\n feed_version = 1.0\n elsif feed_type == \"atom\" &&\n (feed_version == nil || feed_version <= 0.0)\n feed_version = 1.0\n end\n if feed_type == \"rss\" &&\n (feed_version == 0.9 || feed_version == 1.0 || feed_version == 1.1)\n # RDF-based rss format\n return xml_builder.tag!(\"rdf:RDF\",\n \"xmlns\" => FEED_TOOLS_NAMESPACES['rss10'],\n \"xmlns:content\" => FEED_TOOLS_NAMESPACES['content'],\n \"xmlns:rdf\" => FEED_TOOLS_NAMESPACES['rdf'],\n \"xmlns:dc\" => FEED_TOOLS_NAMESPACES['dc'],\n \"xmlns:syn\" => FEED_TOOLS_NAMESPACES['syn'],\n \"xmlns:admin\" => FEED_TOOLS_NAMESPACES['admin'],\n \"xmlns:taxo\" => FEED_TOOLS_NAMESPACES['taxo'],\n \"xmlns:itunes\" => FEED_TOOLS_NAMESPACES['itunes'],\n \"xmlns:media\" => FEED_TOOLS_NAMESPACES['media']) do\n channel_attributes = {}\n unless self.link.nil?\n channel_attributes[\"rdf:about\"] =\n FeedTools::HtmlHelper.escape_entities(self.link)\n end\n xml_builder.channel(channel_attributes) do\n unless self.title.blank?\n xml_builder.title(\n FeedTools::HtmlHelper.strip_html_tags(self.title))\n else\n xml_builder.title\n end\n unless self.link.blank?\n xml_builder.link(self.link)\n else\n xml_builder.link\n end\n unless images.blank?\n xml_builder.image(\"rdf:resource\" =>\n FeedTools::HtmlHelper.escape_entities(\n images.first.url))\n end\n unless description.nil? || description == \"\"\n xml_builder.description(description)\n else\n xml_builder.description\n end\n unless self.language.blank?\n xml_builder.tag!(\"dc:language\", self.language)\n end\n unless self.rights.blank?\n xml_builder.tag!(\"dc:rights\", self.rights)\n end\n xml_builder.tag!(\"syn:updatePeriod\", \"hourly\")\n xml_builder.tag!(\"syn:updateFrequency\",\n (self.time_to_live / 1.hour).to_s)\n xml_builder.tag!(\"syn:updateBase\", Time.mktime(1970).iso8601)\n xml_builder.items do\n xml_builder.tag!(\"rdf:Seq\") do\n unless items.nil?\n for item in items\n if item.link.nil?\n raise \"Cannot generate an rdf-based feed with a nil \" +\n \"item link field.\"\n end\n xml_builder.tag!(\"rdf:li\", \"rdf:resource\" =>\n FeedTools::HtmlHelper.escape_entities(item.link))\n end\n end\n end\n end\n xml_builder.tag!(\n \"admin:generatorAgent\",\n \"rdf:resource\" => self.configurations[:generator_href])\n build_xml_hook(feed_type, feed_version, xml_builder)\n end\n unless self.images.blank?\n best_image = nil\n for image in self.images\n if image.link != nil\n best_image = image\n break\n end\n end\n best_image = self.images.first if best_image.nil?\n xml_builder.image(\"rdf:about\" =>\n FeedTools::HtmlHelper.escape_entities(best_image.url)) do\n if !best_image.title.blank?\n xml_builder.title(best_image.title)\n elsif !self.title.blank?\n xml_builder.title(self.title)\n else\n xml_builder.title\n end\n unless best_image.url.blank?\n xml_builder.url(best_image.url)\n end\n if !best_image.link.blank?\n xml_builder.link(best_image.link)\n elsif !self.link.blank?\n xml_builder.link(self.link)\n else\n xml_builder.link\n end\n end\n end\n unless items.nil?\n for item in items\n item.build_xml(feed_type, feed_version, xml_builder)\n end\n end\n end\n elsif feed_type == \"rss\"\n # normal rss format\n return xml_builder.rss(\"version\" => \"2.0\",\n \"xmlns:content\" => FEED_TOOLS_NAMESPACES['content'],\n \"xmlns:rdf\" => FEED_TOOLS_NAMESPACES['rdf'],\n \"xmlns:dc\" => FEED_TOOLS_NAMESPACES['dc'],\n \"xmlns:taxo\" => FEED_TOOLS_NAMESPACES['taxo'],\n \"xmlns:trackback\" => FEED_TOOLS_NAMESPACES['trackback'],\n \"xmlns:itunes\" => FEED_TOOLS_NAMESPACES['itunes'],\n \"xmlns:media\" => FEED_TOOLS_NAMESPACES['media']) do\n xml_builder.channel do\n unless self.title.blank?\n xml_builder.title(\n FeedTools::HtmlHelper.strip_html_tags(self.title))\n end\n unless self.link.blank?\n xml_builder.link(link)\n end\n unless self.description.blank?\n xml_builder.description(description)\n else\n xml_builder.description\n end\n unless self.author.email.blank?\n xml_builder.managingEditor(self.author.email)\n end\n unless self.publisher.email.blank?\n xml_builder.webMaster(self.publisher.email)\n end\n unless self.published.blank?\n xml_builder.pubDate(self.published.rfc822)\n end\n unless self.updated.blank?\n xml_builder.lastBuildDate(self.updated.rfc822)\n end\n unless self.copyright.blank?\n xml_builder.copyright(self.copyright)\n end\n unless self.language.blank?\n xml_builder.language(self.language)\n end\n xml_builder.ttl((time_to_live / 1.minute).to_s)\n xml_builder.generator(\n self.configurations[:generator_href])\n build_xml_hook(feed_type, feed_version, xml_builder)\n unless items.nil?\n for item in items\n item.build_xml(feed_type, feed_version, xml_builder)\n end\n end\n end\n end\n elsif feed_type == \"atom\" && feed_version == 0.3\n raise \"Atom 0.3 is obsolete.\"\n elsif feed_type == \"atom\" && feed_version == 1.0\n # normal atom format\n return xml_builder.feed(\"xmlns\" => FEED_TOOLS_NAMESPACES['atom10'],\n \"xml:lang\" => language) do\n unless title.blank?\n xml_builder.title(title,\n \"type\" => \"html\")\n end\n xml_builder.author do\n unless self.author.nil? || self.author.name.nil?\n xml_builder.name(self.author.name)\n else\n xml_builder.name(\"n/a\")\n end\n unless self.author.nil? || self.author.email.nil?\n xml_builder.email(self.author.email)\n end\n unless self.author.nil? || self.author.url.nil?\n xml_builder.uri(self.author.url)\n end\n end\n unless self.href.blank?\n xml_builder.link(\"href\" => self.href,\n \"rel\" => \"self\",\n \"type\" => \"application/atom+xml\")\n end\n unless self.link.blank?\n xml_builder.link(\n \"href\" =>\n FeedTools::HtmlHelper.escape_entities(self.link),\n \"rel\" => \"alternate\")\n end\n unless self.subtitle.blank?\n xml_builder.subtitle(self.subtitle,\n \"type\" => \"html\")\n end\n if self.updated != nil\n xml_builder.updated(self.updated.iso8601)\n elsif self.time != nil\n # Not technically correct, but a heck of a lot better\n # than the Time.now fall-back.\n xml_builder.updated(self.time.iso8601)\n else\n xml_builder.updated(Time.now.gmtime.iso8601)\n end\n unless self.rights.blank?\n xml_builder.rights(self.rights)\n end\n xml_builder.generator(self.configurations[:generator_name] +\n \" - \" + self.configurations[:generator_href])\n if self.id != nil\n unless FeedTools::UriHelper.is_uri? self.id\n if self.link != nil\n xml_builder.id(FeedTools::UriHelper.build_urn_uri(self.link))\n else\n raise \"The unique id must be a valid URI.\"\n end\n else\n xml_builder.id(self.id)\n end\n elsif self.link != nil\n xml_builder.id(FeedTools::UriHelper.build_urn_uri(self.link))\n elsif self.url != nil\n xml_builder.id(FeedTools::UriHelper.build_urn_uri(self.url))\n else\n raise \"Cannot build feed, missing feed unique id.\"\n end\n build_xml_hook(feed_type, feed_version, xml_builder)\n unless items.nil?\n for item in items\n item.build_xml(feed_type, feed_version, xml_builder)\n end\n end\n end\n else\n raise \"Unsupported feed format/version.\"\n end\n end",
"def data(boards, team, is_string)\n\n s1 = Set.new\n\n response = Net::HTTP.get(URI.parse('http://futisforum2.org/index.php?action=.xml;type=rss2;boards=' +\n boards +\n ';limit=255'))\n\n feed = RSS::Parser.parse response\n\n feed.items.each do |item|\n\n if item.title.include? team\n\n body = Net::HTTP.get(URI.parse(item.link)).to_s.gsub!('<br />', ' ').strip\n\n # Funny encoding hack...\n body.force_encoding('iso-8859-1')\n body = body.encode(\"UTF-16be\", :invalid=>:replace, :replace=>\"?\").encode('UTF-8')\n body.to_s.gsub!('', '€')\n\t\t\t\tbody.to_s.gsub!('', '\"')\n\n document = Oga.parse_html(body)\n\n document.css('div.post div.quote').each do |quote|\n quote.replace('\"' + quote.text.strip + '\" - ')\n end\n\n document.css('div.post div.quoteheader').each do |quote|\n quote.replace(\"\")\n end\n\n document.css('div.post a').each do |link|\n\t\t\t\t #puts link.attributes[0]\n\t\t\t\t\t#puts link.text\n link.replace(link.attributes[0].to_s)\t\t\t\t\t\n end\n\n document.css('div.post ul').each do |l|\n document.css('li').each do |x|\n x.replace(' ' + x.text + ', ')\n end\n end\n\n document.css('div.post').each do |person|\n\n if is_string == true\n s1.add(person.text + \" ||| \")\n else\n s1.add(person.text)\n end\n\n #puts '-' * 40\n end\n\n break\n\n else\n # DO SOMETHING LATER\n end\n\n end\n return s1\n end",
"def local_rss\n \"file:///\" + Rails.root.join(\"data\",\"cl-rss\", base_url.split(\"//\").last + \".rss\").to_s\n end",
"def retrieve_data\n # Define the url\n url = 'http://www.sbs.com.au/news/rss/news/science-technology.xml'\n\n # Open the url and parse the rss feed\n open(url) do |rss|\n # Start parsing\n feed = RSS::Parser.parse(rss, false)\n\n # Iterate each item and scrape information\n feed.items.each do |item|\n # If the title of thie article matches the title of the last saved article,\n # stop scraping to avoid from saving duplicates in database\n break if !@last_title.nil? && @last_title.eql?(item.title.to_s)\n\n # If thie article is already stored then ignore\n next if Article.find_by(title: item.title.to_s)\n\n # Make a template dictionary to put @articles\n temp = {\n author: nil,\n title: item.title,\n summary: item.description,\n image: nil,\n date_time: DateTime.parse(item.pubDate.to_s),\n link: item.link,\n categories: nil\n }\n\n # Put the object into articles array\n @articles << temp\n end\n end\n end",
"def generate_atom_feed\n xml = \"\"\n builder = Builder::XmlMarkup.new\n @articles_published.each do |article|\n content = process_with_filter(article)\n xml = builder.entry do |b|\n b.title(type: \"html\") { |t| t.cdata!(article.title) }\n unless article.authors.empty?\n b.author { |a| a.name(article.authors.first.full_name) }\n end\n b.link(rel: 'alternate', type: 'text/html', href: full_request(article.permalink))\n b.id(full_request(article.permalink))\n b.updated(article.updated_at.xmlschema)\n b.published(article.published_on.xmlschema)\n b.content(type: \"html\") { |c| c.cdata!(content) }\n end\n end\n { xml: xml }\n end",
"def initialize(data)\n @data = data\n @content_type = :rss # TODO: make this dynamic\n end",
"def get_feed(params)\n\n #Rails.logger.info(\" [RAILS] [LIB] [SCREEN_SCRAP] [GET_FEED] Entering\")\n\n url = process_node(params)\n\n if url && String === url && url !~ /^http/ && params[:url]\n url = URI.join(params[:url] , url).to_s\n elsif url && Array === url\n url.map! do |u|\n if u !~ /^http/ && params[:url]\n URI.join(params[:url], u).to_s\n else\n u\n end\n end\n url.uniq!\n end\n\n #Rails.logger.info(\" [RAILS] [LIB] [SCREEN_SCRAP] [GET_FEED] Leaving\")\n params[:output][\"feed\"] = url\n\n rescue => e\n Rails.logger.error(\"[RAILS] [LIB] [SCREEN_SCRAP] [GET_FEED] **** RESCUE **** #{e.message} \")\n nil\n end",
"def feed\n @blog_articles = BlogArticle.all\n respond_to do |format|\n format.rss { render layout: false }\n end\n end",
"def scrape\r\n @article_arr = []\r\n\t\turl = 'http://www.theage.com.au/rssheadlines/technology-news/article/rss.xml'\r\n open(url) do |rss|\r\n \tfeed = RSS::Parser.parse(rss, false)\r\n puts \" \"\r\n puts \"*********************************\"\r\n \tputs \"Title: #{feed.channel.title}\"\r\n puts \"--------------------------------\"\r\n feed.items.each do |item|\r\n \t@article_arr << AgeArticle.new(author: \"nil\", title: item.title.to_s.gsub(/,/,''), \r\n summary: (item.description).match(/\\<\\/p\\>[\\w ?,''\"\"]+/).to_s.gsub(/\\<\\/p\\>/,'').gsub(/,/,'').gsub(/\\\"/,''), \r\n images: (item.description).match(/http.+\\.(jpg|png)/), source: item.link, date: item.pubDate.to_s.gsub(/,/,''))\r\n end\r\n end\r\n @articles.concat(@article_arr)\r\n end",
"def create_worldcat_widely_held(request, xml)\n \n # try to prevent circular links\n top_holding_info = get_widely_held_info(xml) \n return nil if circular_link?(request, top_holding_info) \n \n # http://www.worldcat.org/links/\n most = top_holding_info['most']\n title = top_holding_info['title']\n oclcnum = top_holding_info['oclcnum']\n \n link = 'http://www.worldcat.org/oclc/' << oclcnum\n cover_image_link = extract_cover_image_link(request, most) \n notes = \"this author's most widely held work in WorldCat\"\n if cover_image_link \n display_text = '<img src=\"' << cover_image_link << '\" style=\"width:75px;\"/>' \n notes = title << ' is ' << notes\n else\n display_text = title\n end\n \n request.add_service_response( \n :service=>self, \n :url=>link,\n :display_text=> display_text,\n :notes => notes,\n :service_type_value => :highlighted_link) \n end",
"def main\n\n feedlist = File.foreach('parselist') do |wholeline|\n\n wholeline.strip!\n\n next if wholeline.empty?\n\n line = wholeline.split(\",\")\n url = line[0].strip\n tag = line[1].strip\n\n #parse each feed\n\n rss = SimpleRSS.parse(open(url).read)\n\n puts ' '\n puts rss.feed.title\n puts ' '\n\n rss.items[0..2].each do|i|\n puts \"Date: #{i.pubDate or i.published}\"\n puts \"Title: #{i.title}\"\n puts \"Link: #{i.link}\"\n puts \"=\" * 80\n end\n\n end\n\nend",
"def rss\n\t\theaders[\"Content-Type\"] = \"text/xml; charset=utf-8\"\n\t\trender :layout => false\n\tend",
"def feed_url\n if @tag\n \"#{tag_url(@tag)}feed/\"\n elsif @search\n \"#{search_url(@search)}feed/\"\n else\n '/feed/'\n end\n end",
"def initialize(feed, item)\n if (feed.feed_type == \"rss\")\n @feed_title = feed.channel.title\n @title = item.title\n @link = item.link\n @date = parse_time(item.date)\n @content = item.description\n @content = item.content_encoded if item.content_encoded\n @guid = item.guid.content\n @audio = nil\n if item.enclosure\n if item.enclosure.type == \"audio/mpeg\"\n @audio = item.enclosure.url\n elsif item.enclosure.type.start_with? \"image/\" # If there is an image in the enclosure\n unless @content.include? \"<img \" # and no images in the content\n # then include the enclosure image\n @content = \"<img src=\\\"#{item.enclosure.url}\\\" /><br/>\" + @content\n end\n end\n end\n elsif (feed.feed_type == \"atom\")\n @feed_title = feed.title.content\n @title = item.title.content\n @link = item.link.href\n if !item.published.nil?\n @date = parse_time(item.published.content)\n else\n @date = parse_time(item.updated.content)\n end\n if !item.content.nil?\n @content = CGI.unescapeHTML(item.content.to_s)\n else\n @content = CGI.unescapeHTML(item.summary.to_s)\n end\n @guid = item.id.to_s\n @audio = nil # TODO podcast support for Atom feeds?\n end\n end",
"def update_rss(id, body)\n doc = Nokogiri::XML(body)\n doc.xpath('rss/channel/item').each do |i|\n title = i.xpath('title').text\n link = i.xpath('link').text\n st = @sql.prepare \"select exists(select 1 from article_lists where article_url=?)\"\n st.execute(link).each_with_index do |res, index|\n insert_article_list(res, id, title, link) if index == 0\n end\n end\n end",
"def scrape\n\t\topen(@url) do |rss|\n\t\t\tfeed = RSS::Parser.parse(rss)\n\t\t\tfeed.items.each do |item|\n\t\t\t\tif date_valid?(item.pubDate) and item.title\n\t\t\t\t\tcreate_article(@default_author, item.title, item.description,\\\n\t\t\t\t\t\t\"\", @source_name, item.pubDate.to_date, item.link)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@articles\n\tend",
"def parse_feed_line line\n # Return [url, category, title]\n Feed.new(*line.split(' ', 3).map(&:strip))\nend",
"def get_blog_feed\n # fetching a single feed\n @feed = []# Feedzirra::Feed.fetch_and_parse(\"http://norastable.wordpress.com/feed/\")\n end",
"def feed_tag(mime, url, options={})\n full_mime = (mime == :atom) ? 'application/atom+xml' : 'application/rss+xml'\n tag(:link, { :rel => 'alternate', :type => full_mime, :title => mime, :href => url }.update(options))\n end",
"def rss \n @vote_topics = VoteTopic.rss\n respond_to do |format|\n format.rss\n end\n end",
"def rss\n forum = Forum.find(params[:id])\n comments = forum.comments_by_topic.find_all{|c| !c.private and forum.can_see? current_user}\n render_rss_feed_for comments, {\n :feed => {\n :title => \"New OpenMind Comments for Forum \\\"#{forum.name}\\\"\",\n :link => forum_url(forum.id),\n :pub_date => :created_at\n },\n :item => {\n :title => :rss_headline,\n :description => :rss_body,\n :link => Proc.new{|comment| \"#{topic_url(comment.topic.id, :anchor => comment.id)}\" }\n }\n }\n end",
"def get_rss\n all( :conditions => ['published_at IS NOT NULL'], :order => 'published_at DESC', :limit => per_page )\n end",
"def get_rss_feed( rss_url )\n\t\tfeed = false\n\t\tuntil feed.class == Feedzirra::Parser::RSS\n\t\t\tfeed = Feedzirra::Feed.fetch_and_parse( rss_url )\n\t\tend\n\t\tfeed\n\tend",
"def feed\n cached = Rails.cache.read(\"rss\")\n return cached unless cached.nil?\n\n resp = HTTParty.get(Rails.configuration.x.application.blog_rss)\n return [] unless resp.code == 200\n\n rss = RSS::Parser.parse(resp.body, false).items.first(5)\n cache_content(\"rss\", rss)\n rss\n rescue StandardError => e\n # If we were unable to connect to the blog rss\n logger.error(\"Caught exception RSS parse: #{e}.\")\n []\n end",
"def rss\n @headers[\"Content-Type\"] = \"application/xml\"\n @articles = Article.find(:all, \n :order => 'created_at DESC',\n :conditions => [\"articles.approved = ?\", true],\n :limit => 10\n )\n render :layout => false\n end",
"def add_to_rss\n require 'open-uri'\n require 'cgi'\n\n fname = Wiki_path + \"/rss-temp\"\n\n internalurl = cururl.split(\"/\").last\n url = \"#{Internet_path}/#{internalurl}\"\n\n # load existing holding file, or start form scratch\n if File.exists?(fname)\n rss_entries = Marshal::load(File.read(fname))\n else\n rss_entries = Array.new\n end\n\n page_contents = open(\"http://localhost/wiki/#{internalurl}?vecdo=print\").read\n contents = page_contents.scan(/<\\!\\-\\- start rendered wiki content \\-\\-\\>(.+?)\\<\\!\\-\\- end rendered wiki content \\-\\-\\>/m)[0][0]\n\n contents.gsub!(/\\<div class\\=\\\"hiddenGlobal(.+?)\\<div class\\=\\\"plugin_include_content/m, '<div ')\n\n # remove title (already given in metadata)\n contents.remove!(\n /\\<h1 class\\=\\\"sectionedit1\\\"\\>(.+?)\\<\\/a\\>\\<\\/h1\\>/,\n /\\<\\!\\-\\- TOC START \\-\\-\\>(.+?)\\<\\!\\-\\- TOC END \\-\\-\\>/m,\n /\\<span class\\=\\\"tip\\\"\\>(.+?)\\<\\/span\\>/, # remove citation tooltips\n /\\<div class\\=\\\"plugin\\_include\\_content\\ plugin\\_include\\_\\_clip(.+?)\\<\\/div\\>/m, # remove wiki clippings\n /\\<div class\\=\\\"plugin\\_include\\_content\\ plugin\\_include\\_\\_kindle(.+?)\\<\\/div\\>/m\n )\n\n title = page_contents.scan(/\\<h1(.+?)id(.+?)>(.+)\\<(.+?)\\<\\/h1\\>/)[0][2]\n title = CGI.unescapeHTML(title)\n\n entry_contents = {:title => title, :date => Time.now, :link => url, :description => contents}\n\n exists = false\n\n rss_entries.map! do |entry|\n if entry[:link] == url\n exists = true\n entry_contents\n else\n entry\n end\n end\n\n unless exists\n rss_entries << entry_contents\n end\n\n rss_entries = rss_entries.drop(1) if rss_entries.size > 15\n\n File.write(fname, Marshal::dump(rss_entries))\n\n if exists\n growl(\"Article updated\", \"Article #{title} updated\")\n else\n growl(\"Article added to feed\", \"'#{title}' added to RSS feed\")\n end\nend",
"def feed_item(list, title = @config[:title], identifier = '/feed/')\n Nanoc::Item.new(\n '<%= atom_feed(:articles => @item[:list]) %>',\n {:title => title, :extension => 'atom', :list => list},\n identifier\n )\nend",
"def streamlined_auto_discovery_link_tag()\n return if @syndication_type.nil? || @syndication_actions.nil?\n \n if @syndication_actions.include? params[:action]\n \"<link rel=\\\"alternate\\\" type=\\\"application/#{@syndication_type.downcase}+xml\\\" title=\\\"#{@syndication_type.upcase}\\\" href=\\\"#{params[:action]}/xml\\\" />\"\n end\n end",
"def process_feed(url, limit=200)\n rss = SimpleRSS.parse open(url)\n rss.items.each_with_index do |item, index|\n puts \"Parsing RSS item #{item.title}\"\n screenshoot(item.link, to_filename(item.title, IMG_FILENAME_SIZE))\n puts \"... donez\"\n puts \"\"\n break if index == limit-1\n end \nend",
"def feed\r\n # check for valid access key:\r\n user = User.find_by_rss_access_key(params[:access_key])\r\n @authorized = !user.blank?\r\n\r\n # get the folder\r\n @folder = Folder.find_by_id(folder_id)\r\n\r\n # set appriopriate instance variables,\r\n # so the feed can be created in folder.rxml\r\n if @authorized and not @folder.blank?\r\n if @folder.is_root or user.can_read(@folder.id)\r\n @folders = @folder.list_subfolders(user, 'name')\r\n @myfiles = @folder.list_files(user, 'filename')\r\n else\r\n @authorized = false\r\n end\r\n end\r\n\r\n # finally, set correct header\r\n if @authorized\r\n headers['Content-Type'] = 'text/xml'\r\n else\r\n headers['Content-Type'] = 'text/html'\r\n end\r\n end",
"def get_feed(url)\n source = URI.open(url, 'User-Agent' => 'Mozilla/5.0')\n feed = RSS::Parser.parse(source)\nend",
"def links_feed\n end",
"def display_rss_feed(limit = 10)\n\n # output = \"<div class='rss-entries'>\" \n # FeedEntry.all(:limit => limit).each do |entry|\n # output += \"<h4><a href='#{entry.url}'>#{entry.title}</a></h4>\"\n # output += \"<p>#{entry.content}</p>\"\n # end\n # output += \"</div>\"\n # output.html_safe\n end",
"def entries\n if @entries.nil?\n raw_entries = FeedTools::XmlHelper.select_not_blank([\n FeedTools::XmlHelper.try_xpaths_all(self.channel_node, [\n \"atom10:entry\",\n \"atom03:entry\",\n \"atom:entry\",\n \"entry\"\n ]),\n FeedTools::XmlHelper.try_xpaths_all(self.root_node, [\n \"rss10:item\",\n \"rss11:items/rss11:item\",\n \"rss11:items/item\",\n \"items/rss11:item\",\n \"items/item\",\n \"item\",\n \"atom10:entry\",\n \"atom03:entry\",\n \"atom:entry\",\n \"entry\",\n \"story\"\n ]),\n FeedTools::XmlHelper.try_xpaths_all(self.channel_node, [\n \"rss10:item\",\n \"rss11:items/rss11:item\",\n \"rss11:items/item\",\n \"items/rss11:item\",\n \"items/item\",\n \"item\",\n \"story\"\n ])\n ])\n\n # create the individual feed items\n @entries = []\n unless raw_entries.blank?\n for entry_node in raw_entries.reverse\n new_entry = FeedItem.new\n new_entry.feed_data = entry_node.to_s\n new_entry.feed_data_type = self.feed_data_type\n new_entry.root_node = entry_node\n if new_entry.root_node.namespace.blank?\n new_entry.root_node.add_namespace(self.root_node.namespace)\n end\n @entries << new_entry\n end\n end\n end\n \n # Sort the items\n if self.configurations[:entry_sorting_property] == \"time\"\n @entries = @entries.sort do |a, b|\n (b.time or Time.utc(1970)) <=> (a.time or Time.utc(1970))\n end\n elsif self.configurations[:entry_sorting_property] != nil\n sorting_property = self.configurations[:entry_sorting_property]\n @entries = @entries.sort do |a, b|\n eval(\"a.#{sorting_property}\") <=> eval(\"b.#{sorting_property}\")\n end\n else\n return @entries.reverse\n end\n return @entries\n end",
"def get_feed()\n feed_map = {\n '1019' => 'Technology',\n '1049' => 'Digital Life'\n }\n temp = ''\n feed = @params[:id].split(',')\n feed.each_with_index do |f, index|\n if index == 0\n temp = feed_map[f]\n else\n temp += '/'+feed_map[f]\n end\n end\n temp\n end",
"def rss_links \n\t\tdoc.xpath(\"//link[@type=\\\"application/rss+xml\\\"]\").map do |link|\n\t\t\tif link['href'] =~ /^http:\\/\\//\n\t\t\t\tlink['href']\n\t\t\telse\n\t\t\t\t\"#{@url}#{link['href']}\"\n\t\t\tend\n\t\tend\n\tend",
"def scrape\n articles = []\n url = 'http://feeds.news.com.au/heraldsun/rss/heraldsun_news_sport_2789.xml'\n\n open(url) do |rss|\n feed = RSS::Parser.parse(rss)\n feed.items.each do |item|\n articles << (interpret item)\n end\n end\n articles\n end",
"def loadRSSFeeds \n @raw_data = RSS::Parser.parse('http://www.nachrichten.at/storage/rss/rss/weltspiegel.xml', false)\n end",
"def create\n link = params[:link]\n @feed = Feed.find_by feed_link: link\n if [email protected]?\n respond_to do |format|\n format.html { redirect_to @feed, notice: 'Feed already subscribed.' }\n format.json { render :show, status: :ok, location: @feed }\n end\n return\n end\n\n feed_source = FeedsHelper.fetch_feed_source(link)\n\n @feed = Feed.new\n @feed.title = feed_source.title\n @feed.description = feed_source.description\n @feed.updated = feed_source.last_modified\n\n @feed.feed_link = feed_source.feed_url #TODO check if the link found in the xml doesn't match the url\n @feed.source_link = feed_source.url\n\n respond_to do |format|\n if @feed.save\n EntriesHelper.save_from(feed_source, @feed)\n format.html { redirect_to @feed, notice: 'Feed was successfully created.' }\n format.json { render :show, status: :created, location: @feed }\n else\n format.html { render :new }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end \n end",
"def meeting_feed_url\n \"#{@baseurl}/rss/rss.aspx\"\n end",
"def categories\n if nodes = @node.xpath(\"category\")\n nodes.map { |node| RSSCategory.new(node) }\n end\n end",
"def read_rss\n query = \"http://news.google.ru/news?hl=ru&topic=#{@topic}&output=rss&ned=ru_ru&num=30&&scoring=n\"\n feed = Feedjira::Feed.fetch_and_parse(query)\n feed.entries.map do |entry|\n {\n uuid: SecureRandom.uuid,\n title: entry.title,\n url: entry.url.match(GOOGLE_URI_REGEX)[0],\n published_datetime: entry.published,\n published_unixtime: entry.published.to_i\n }\n end\n end",
"def podcast\n respond_to do |format|\n format.html # podcast.html.haml\n format.rss # podcast.rss.builder\n end\n end",
"def generate_rss_feed tweets, old_items\n version = \"2.0\"\n long_url = nil\n\n @logger.info \"Generating RSS feed to #{@rss_outfile}.\"\n\n content = RSS::Maker.make(version) do |m|\n m.channel.title = \"tweetfeed RSS feed #{@hashtags}\"\n m.channel.link = \"http://github.com/madhatter/tweetfeed\"\n m.channel.description = \"Automatically generated news from Twitter hashtags\"\n m.items.do_sort = true # sort items by date\n\n tweets.each do |tweet|\n orig_url = tweet.urls[0].url\n expanded_url = tweet.urls[0].expanded_url\n @logger.debug \"URL to fetch: #{orig_url}\"\n @logger.debug \"Already expanded url: #{expanded_url}\"\n short_url = expanded_url\n title = tweet['text'].sub(/(#{orig_url})/, \"\")\n long_url = @url_parser.get_original_url short_url\n\n # TODO: Maybe some kind of domain filter would be nice here...\n i = m.items.new_item\n i.title = title.gsub(/\\n/,\"\")\n #i.link = tweet['attrs']['entities']['urls'][0]['url']\n unless long_url == nil\n i.link = long_url.gsub(/\\r/,\"\")\n else\n i.link = orig_url.gsub(/\\r/,\"\") unless orig_url == nil\n end\n i.date = tweet['created_at']\n end\n\n @logger.debug \"Adding the old stuff...:\"\n old_items.items.each do |item|\n i = m.items.new_item\n i.title = item.title\n @logger.debug \"Adding item '#{item.title}'\"\n i.link = item.link\n i.date = item.date\n end unless old_items.nil?\n end\n save_rss_feed(content)\n end",
"def parse\n products = []\n agent = WWW::Mechanize.new\n\n self.categories.each do |category|\n page = agent.get category.url\n page.search(\"//table[@class='OutBorder']\").each do |tr|\n unless (tr.children[0].text == 'Brand.') #ignore header <tr>'s\n p = Product.new\n p.name = tr.children[0].children[0].children[1].text\n p.image = tr.children[1].children[0].children[1].children[0]['src']\n p.brand = tr.children[0].text\n p.model = tr.children[2].text\n p.description = tr.children[4].text\n p.price = tr.children[10].text\n p.warranty = tr.children[6].text.gsub(/'/, '')\n p.stock = !tr.children[14].text.include?('(0)')\n tr.children[14].text =~ /\\d+/ #try get the numerical value inside this expression\n p.items_in_stock = $&\n p.tag = category.name\n products << p\n end\n end\n end\n\n products\n end",
"def news\n do_scrape\n @posts = UbuEntry.all(:order => \"id DESC\", :limit => 400)\n render :layout => false, :content_type => Mime::RSS\n end",
"def feed\n end",
"def items\n nodes = @doc.xpath(\"rss/channel/item\") || []\n nodes.map { |node| RSSChannelItem.new(node) }\n end",
"def streamlined_auto_discovery_link_tag\n # return if @syndication_type.nil? || @syndication_actions.nil?\n # \n # if @syndication_actions.include? params[:action]\n # \"<link rel=\\\"alternate\\\" type=\\\"application/#{@syndication_type.downcase}+xml\\\" title=\\\"#{@syndication_type.upcase}\\\" href=\\\"#{params[:action]}/xml\\\" />\"\n # end\n end"
] |
[
"0.6276439",
"0.6149912",
"0.6087195",
"0.60237586",
"0.5969577",
"0.59670365",
"0.5881391",
"0.5862641",
"0.58618206",
"0.5844047",
"0.5839787",
"0.5821244",
"0.5810483",
"0.57724756",
"0.57552576",
"0.57498163",
"0.57227665",
"0.57014585",
"0.56920326",
"0.56768554",
"0.5665711",
"0.5656716",
"0.56522036",
"0.5640405",
"0.56379855",
"0.56379855",
"0.56324697",
"0.56254774",
"0.56236374",
"0.5607845",
"0.55853504",
"0.55848134",
"0.5584633",
"0.55791646",
"0.5575557",
"0.5574744",
"0.55690116",
"0.5566993",
"0.5559697",
"0.5554206",
"0.55377823",
"0.5518315",
"0.5510195",
"0.54953426",
"0.5491732",
"0.54692036",
"0.5465699",
"0.54615885",
"0.5455734",
"0.5455569",
"0.544196",
"0.54414904",
"0.5435736",
"0.5424194",
"0.5422618",
"0.5386345",
"0.53848445",
"0.538013",
"0.53798956",
"0.5375954",
"0.53710055",
"0.5370905",
"0.53604794",
"0.5340853",
"0.53327143",
"0.53310907",
"0.5329425",
"0.532497",
"0.5324372",
"0.5305635",
"0.53055763",
"0.5293513",
"0.52885175",
"0.52833205",
"0.52797556",
"0.5278608",
"0.52752954",
"0.5274277",
"0.5266543",
"0.52638227",
"0.5254597",
"0.5252247",
"0.52499115",
"0.5242991",
"0.5240943",
"0.5237415",
"0.52354455",
"0.52230453",
"0.52226144",
"0.5221327",
"0.52154714",
"0.5197871",
"0.5196029",
"0.51923174",
"0.51918405",
"0.5191162",
"0.5186274",
"0.51810634",
"0.5174229",
"0.51616263"
] |
0.52250844
|
87
|
BEGIN Grant users administrative privileges
|
def manage_users
@users = User.all
respond_to do |format|
format.json {
render :json => @users.as_json(:only => [:id, :username, :firstname, :lastname, :email], :methods => [:avatar_url])
}
format.html {
render 'manage_users'
}
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def grant_system_admin_privileges(user)\n can :manage, AccountPlan\n end",
"def require_admin\n grant_access?(\"index\", \"users\")\n #position?('admin')\n end",
"def authorize_as_admin\n create_admin_user\n login_into_alchemy\n end",
"def grant_privileges(config)\n print \"Please provide the root password for your db installation\\n>\"\n postgres_password = $stdin.gets.strip\n\n create_db(config.merge('database' => config['database'], 'username' => 'postgres', 'password' => postgres_password))\n\n grant_statement = <<-SQL\nGRANT ALL ON DATABASE #{config['database']}\nTO \"#{config['username']}\" WITH GRANT OPTION;\nSQL\n\n ActiveRecord::Base.connection.execute grant_statement\n #ActiveRecord::Base.connection.drop_database config['database']\nend",
"def auto_elevate!\n add_role :superuser\n end",
"def setup_admin\n create_admin_user\n create_admin_organization\n update_admin_user_perms\nend",
"def require_admin_privileges\n\t\tredirect_to root_path unless is_global_admin?\n\tend",
"def upgrade_to_main_user\n self.is_main_user = true \n self.save \n \n admin_role = Role.find_by_name(USER_ROLE[:admin]) \n self.add_role_if_not_exists(admin_role ) \n end",
"def ensure_admin!\n # D: Send admin status to log\n logger.debug \"current_user.admin? => #{current_user.admin?}\"\n unless current_user.admin?\n flash[:notice] = 'You do not have sufficient privileges.'\n redirect_to root_path\n return false\n end \n end",
"def apply_privileges(app_name=nil)\n return if credentials(app_name).nil?\n if is_postgresql()\n cmd_acl=\"GRANT CREATE ON SCHEMA PUBLIC TO PUBLIC;\\\n GRANT ALL ON ALL TABLES IN SCHEMA PUBLIC TO PUBLIC;\\\n GRANT ALL ON ALL FUNCTIONS IN SCHEMA PUBLIC TO PUBLIC;\\\n GRANT ALL ON ALL SEQUENCES IN SCHEMA PUBLIC TO PUBLIC;\\\n ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO PUBLIC;\\\n ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO PUBLIC;\\\n ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON FUNCTIONS TO PUBLIC;\"\n# shell(cmd_acl,true)\n \n # reset the owner of the functions to the current user\n # when there is a 'privileged' app.\n app_name ||= @wrapped['director']['bound_app'] if @wrapped['director']\n if app_name\n cmd_select_fcts=\"SELECT pg_proc.proname FROM pg_catalog.pg_proc WHERE \\\n pg_proc.pronamespace=(SELECT pg_namespace.oid FROM pg_catalog.pg_namespace WHERE pg_namespace.nspname = 'public') \\\n AND pg_proc.proowner!=(SELECT oid FROM pg_roles WHERE rolname = 'postgres')\"\n current_owner=credentials()['username']\n unless current_owner\n STDERR.puts \"The application #{app_name} is not bound to the data-service #{name}; not applying the database privileges.\"\n return\n end\n fcts_name=shell(cmd_select_fcts,true,true)\n if fcts_name.empty?\n puts \"No need to re-assign the ownership of the functions in #{credentials()['name']}; the DB does not define its own functions.\" if VMC::Cli::Config.trace\n else\n fcts = fcts_name.split(\"\\n\").collect do |line|\n line.strip!\n \"'#{line}'\"\n end.join(',')\n cmd_change_fcts_owner=\"UPDATE pg_catalog.pg_proc \\\n SET proowner = (SELECT oid FROM pg_roles WHERE rolname = '#{current_owner}')\\\n WHERE pg_proc.proname IN (#{fcts})\"\n puts `sudo -u postgres psql --dbname #{credentials()['name']} -c \\\"#{cmd_change_fcts_owner}\\\" #{PSQL_RAW_RES_ARGS}`\n end\n end\n end\n end",
"def run_as_user(&block)\n run_command true, &block\n end",
"def make_first_user_admin\n return unless User.count.zero?\n\n self.is_admin = true\n self.approved = true\n end",
"def run_privileged *args\n args = if args.length > 1\n\t args.unshift \"start /b runas /savecred /env /user:Administrator \\\"\"\n\t args << '\"'\n\t else\n\t \"start /b runas /savecred /env /user:Administrator \\\"#{args.first}\\\"\"\n\t end\n end",
"def first_user_hook\n if User.with_role(:admin).count == 0\n self.grant :admin\n else # set editor as default role\n self.grant :editor if self.roles.empty?\n end\n end",
"def ensure_admin\n unless current_user && current_user.admin\n flash[:notice] = \"You are not authorized to perform this action\"\n redirect_back(fallback_location: root_path)\n end\n\n end",
"def authorize_admin\n\t\tauthorize( ADMIN_USER_LEVEL ) \n\tend",
"def authorize_user\n\t if !current_user.admin_user? then\n\t redirect_to '/', notice: 'You have attempted to access a function that is not available for basic users.'\n\t end\n\tend",
"def require_admin\n not_authorized(\"Invalid credentials.\") unless is_admin?\n end",
"def with_confirmation(&block)\n ApplicationRecord.transaction do\n CurrentUser.scoped(User.system, \"127.0.0.1\") do\n yield\n\n print \"Commit? (yes/no): \"\n raise \"abort\" unless STDIN.readline.chomp == \"yes\"\n end\n end\nend",
"def admin_user\n\t\t\tflash_text = \"Administrative privilege required to perform this action.\"\n\t\t\tflash[:danger] = flash_text unless current_user.admin?\n\t\t\tredirect_to(root_url) unless current_user.admin?\n\t\tend",
"def activate\n @user.activate! if @user.pending?\n redirect_to root_url\n end",
"def assign_administrator(user_id)\n add_user(user_id, true, true)\n end",
"def ensure_admin_user!\n redirect_to(region_templates_path, :alert => \"You may not perform this action on regions!\") and return unless current_user.admin?\n end",
"def be_admin\n if current_user.switch_to(\"admin\")\n flash[:notice] = \"You have now an 'admin' role\"\n else\n flash[:error] = \"You are not authorized to have a 'admin' role\"\n end\n redirect_to( request.env[\"HTTP_REFERER\"])\n end",
"def authorize_user\n if !current_user.admin_user? then\n redirect_to '/', notice: 'You have attempted to access a function that is not available for basic users.'\n end\n end",
"def authorize_user\n if !current_user.admin_user? then\n redirect_to '/', notice: 'You have attempted to access a function that is not available for basic users.'\n end\n end",
"def ensure_admin_user!\n redirect_to(news_path, :alert => \"You may not perform this action on News!\") and return unless user_signed_in? && current_user.admin?\n end",
"def authorise\n # checks can go here (is the application registered for example)\n grant = generate_grant\n valid_grants << grant\n grant\n end",
"def assign_administrator(user_id)\n\t\tadd_user(user_id, true, true)\n\tend",
"def approve_user\n # set the enabled flag to true for the user\n # send out approval notification\n end",
"def test_22_impersonate_permission()\n\t\t\n\t\tputs \"---------------------- START OF SCENARIO 22 ----------------------\"\n\t\tlogin($globaladmin_emailId, $globaladmin_password)\n\t\timpersonatePermission($admincon_url, $normal2_emailId, $normal2_firstname, $normal2_lastname)\n\t\tlogout()\n\t\tputs \"---------------------- END OF SCENARIO 22 ----------------------\"\n\t\n\tend",
"def require_correct_admin\n if current_user.user?\n raise ExceptionTypes::UnauthorizedError.new(\"Admin access only\")\n end\n if current_user.admin?\n raise ExceptionTypes::UnauthorizedError.new(\"You do not have permission to modify the program with ID #{@program.id}\") unless @program.admins.exists? current_user.id\n end\n end",
"def do_secure_accounts(instance)\n client = Client.open(instance, :no_password => true)\n q1 = \"UPDATE mysql.user SET Password = PASSWORD(\\'#{ROOT_PASSWORD}\\') where User = \\'root\\'\"\n q2 = \"UPDATE mysql.user SET Password = PASSWORD(\\'#{ROOT_PASSWORD}\\') where User = \\'\\'\"\n # q3 = \"CREATE USER \\'root\\'@\\'%.#{REPLICATION_DOMAIN}\\' IDENTIFIED BY \\'#{ROOT_PASSWORD}\\'\"\n # For testing with clients whose DHCP assigned IP address is not in DNS.\n q3 = \"CREATE USER \\'root\\'@\\'%' IDENTIFIED BY \\'#{ROOT_PASSWORD}\\'\"\n q4 = \"GRANT ALL PRIVILEGES ON *.* to \\'root\\'@\\'%\\' WITH GRANT OPTION\"\n q5 = \"FLUSH PRIVILEGES\"\n if client\n [q1, q2, q3, q4, q5].each do |query|\n puts query\n client.query(query)\n end\n end\n rescue Mysql2::Error => e\n puts e.message\n ensure\n client.close if client\n end",
"def set_user\n @user = User.find(params[:id])\n \tauthorize [:admin, @user]\n end",
"def activate\n # admin.tabs.add \"Ae Users Authenticator\", \"/admin/ae_users_authenticator\", :after => \"Layouts\", :visibility => [:all]\n User.send :include, AeUsersAuthenticator\n end",
"def require_admin_permission\n redirect_to tables_path, notice: 'Necesita permisos de administrador para visualizar la configuracion' unless current_user_admin?\n end",
"def make_admin\n authorize! @user\n @user.roles = @user.roles + ['admin']\n @user.save\n redirect_to @user, notice: t('user.made_admin', name: @user.username)\n end",
"def become\n return respond_with_status(401) unless current_user.admin? # double check\n login_as(resource)\n redirect_to user_url\n end",
"def grant_write_access(db, service)\n name = service.name\n db_connection = postgresql_connect(@postgresql_config[\"host\"],@postgresql_config[\"user\"],@postgresql_config[\"pass\"],@postgresql_config[\"port\"],name)\n service.bindusers.all.each do |binduser|\n user = binduser.user\n sys_user = binduser.sys_user\n sys_password = binduser.sys_password\n db_connection_sys_user = postgresql_connect(@postgresql_config[\"host\"],sys_user,sys_password,@postgresql_config[\"port\"],name)\n db_connection_sys_user.query(\"vacuum full\")\n db_connection_sys_user.close\n do_grant_query(db_connection,user,sys_user)\n end\n db_connection.query(\"grant create on schema public to public\")\n if get_postgres_version(db_connection) == '9'\n db_connection.query(\"grant all on all tables in schema public to public\")\n db_connection.query(\"grant all on all sequences in schema public to public\")\n db_connection.query(\"grant all on all functions in schema public to public\")\n else\n querys = db_connection.query(\"select 'grant all on '||tablename||' to public;' as query_to_do from pg_tables where schemaname = 'public'\")\n querys.each do |query_to_do|\n db_connection.query(query_to_do['query_to_do'].to_s)\n end\n querys = db_connection.query(\"select 'grant all on sequence '||relname||' to public;' as query_to_do from pg_class where relkind = 'S'\")\n querys.each do |query_to_do|\n db_connection.query(query_to_do['query_to_do'].to_s)\n end\n end\n db_connection.close\n service.quota_exceeded = false\n service.save\n rescue => e\n @logger.warn(\"PostgreSQL Node exception: #{e}\\n\" +\n e.backtrace.join(\"\\n\"))\n end",
"def enable_admin\n if current_user.admin?\n user = User.find(params[:id])\n user.update_attribute(\"admin\", true)\n redirect_to \"/users\"\n else\n redirect_to \"/home\"\n flash[:warning] = \"Only admins can perform that action.\"\n end\n end",
"def confirm\n if current_visitor && current_visitor.has_role?('admin', 'manager')\n user = User.find(params[:id]) unless params[:id].blank?\n if !params[:id].blank? && user && user.state != \"active\"\n user.confirm!\n user.make_user_a_member\n # assume this type of user just activated someone from somewhere else in the app\n flash[:notice] = \"Activation of #{user.name_and_login} complete.\"\n redirect_to(session[:return_to] || root_path)\n end\n else\n flash[:notice] = \"Please login as an administrator.\"\n redirect_to(root_path)\n end\n end",
"def grant_superuser(user, opts={})\n return false if self.superuser?(user, opts)\n unh = self._user_and_host(user, opts[:host])\n self.interpreter.log.info(PNOTE+\"Granted superuser rights to MySQL user: #{unh}\")\n sql = \"grant all privileges on *.* to #{unh}\"\n sql << \" identified by '#{opts[:password]}'\" if opts[:password]\n self.fetch(sql) if self.interpreter.writing?\n return true\n end",
"def require_admin\n deny_wrong_user if !admin?\n end",
"def ensure_user\n current_user? || deny_access('You must be logged in to perform this action.')\n end",
"def grant_privileges(role_name, privileges, options = nil)\n policy = create_policy(options, AdminPolicy, default_admin_policy)\n command = AdminCommand.new\n command.grant_privileges(@cluster, policy, role_name, privileges)\n end",
"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 enforce_permissions\n bounce unless is_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_barrier\n unless admin_access? || logged_in? && current_user == @user\n flash[:alert] = \"You must have admin access to do that.\"\n redirect_to :back\n end\n end",
"def authorization(*args, &block); end",
"def admin(&block)\n block.call if logged_in?\n end",
"def permit_user\n if (!current_user.lunches_admin?) \n flash[:alert] = 'You not allowed to see all orders.'\n respond_to do |format| \n format.html {redirect_to(root_url)}\n end\n end\n end",
"def change_owner!(user_changing, user_to_be_changed)\n if(!user_changing.persisted? || super_admin != user_changing)\n raise SecurityError.new \"No Permissions\"\n end \n exist_user?(user_to_be_changed)\n if(super_admin != user_changing)\n ActiveRecord::Base.transaction do\n remove_user!(user_changing, user_to_be_changed)\n participants.create(user_id: user_changing.id, member_type: Course.roles[\"admin\"])\n update(super_admin: user_to_be_changed)\n end\n end\n\nend",
"def admin_approve_user\n @user.update(approved: true)\n redirect_to admin_path, notice: \"User Approved\"\n end",
"def become\n return unless current_user.is_an_admin?\n sign_in(:user, User.find(params[:id]))\n redirect_to root_path\n end",
"def require_admin\n unless current_user.admin\n flash[:notice] = \"Need admin account.\"\n redirect_to(\"/login\")\n end\n end",
"def ensure_admin_user!\n redirect_to(enemy_templates_path, :alert => \"You may not perform this action on enemies!\") and return unless current_user.admin?\n end",
"def admin_user\n if user_signed_in? && current_user.adminrole?\n flash.now[:success] = \"Admin Access Granted\"\n else\n redirect_to root_path\n end\n end",
"def authorize_admin\n redirect_to root_path unless current.user.immortal?\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 initialize(user)\n define_global_privileges\n define_user_privileges(user) if user\n define_admin_privileges(user) if user and user.admin?\n end",
"def activate\n add_year_to_member_until_until\n ensure_member_role\n end",
"def require_admin \n\t \tif current_user && current_user.admin\n\t \telse\n\t \t\tredirect_to root_path\n\t\t\tflash.notice = \"You are not the admin!\"\n\t\tend\n\tend",
"def set_admin\n #puts \"called set_admin\"\n @admin = current_admin_credential\n end",
"def execute\n auth_user = create_or_find_auth_user(auth0_id_string, access_level)\n create_or_find_person(auth_user, email)\n end",
"def grant\n self.status = 'granted'\n save\n end",
"def grant(privileges) # rubocop:disable Metrics/AbcSize\n self.authorized_actions = privileges.map { |auth_tier, actions| [auth_tier.to_s, [actions].flatten.map(&:to_sym)] }.to_h\n\n tier_names = authorization_persona.authorization_tier_names\n extra_keys = authorized_actions.keys - authorization_persona.authorization_tier_names\n if extra_keys.present?\n raise AuthorizedPersona::Error, \"invalid grant: #{authorization_persona_class_name} \" \\\n \"has authorization tiers #{tier_names.join(', ')} but received extra keys: #{extra_keys.join(', ')}\"\n end\n end",
"def grantOrgAdminRights(admin_url, email_id, ein_number)\n\t\n\tputs \"************** START : Grant ORG Admin rights ****************\"\t\n\t$browser.open admin_url\n\t$browser.open \"admin/org_admins\"\n\t$browser.wait_for_page_to_load \n\t$browser.type \"email\", email_id\n\t$browser.type \"ein\", ein_number\n\t$browser.click \"commit\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Org Admin successfully created!\")\n\t\tputs \"Passed. Org Admin successfully created for #{email_id} user\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Failed. Org Admin has not created successfully for #{email_id} user\"\n\tend\n\t\n\tputs \"************** END : Grant ORG Admin rights ****************\"\t\n\t\nend",
"def authorize_admin\n return unless !current_user.admin?\n redirect_to root_path, alert: 'Admins only!'\n end",
"def authorize_admin\n return unless !current_user.admin?\n redirect_to root_path, alert: 'Admins only!'\n end",
"def notadmin\n\tprint_error(\"You need admin privs to run this!\")\n\tprint_error(\"Try using 'getsystem' or one of the many escalation scripts and try again.......\")\n\traise Rex::Script::Completed\nend",
"def setup_database_permissions(connection_string, db_name)\n # We tack on a space at the end to help regex matches\n connection_string += \" \"\n\n db_admin_user = connection_string.match db_string_regex('user')\n db_admin_user = db_admin_user[1]\n\n db_admin_password = connection_string.match db_string_regex('password')\n db_admin_password = db_admin_password[1]\n\n grant_sql = <<-SQL\n GRANT ALL PRIVILEGES ON #{db_name}.* TO #{db_admin_user}@localhost IDENTIFIED BY '#{db_admin_password}';\n SQL\n\n run \"#{connection_string} --execute=\\\"#{grant_sql}\\\"\"\nend",
"def grant(userid=nil, email=nil, download=true, upload=false, view=true, admin=false, delete=false, notifyupload=false, notifydownload=false) #(userid OR email) required\n end",
"def authorize_admin\n return unless current_user.admin?\n redirect_to root_path, alert: 'Admins only!'\n end",
"def ensure_admin_user!\n redirect_to(item_templates_path, :alert => \"You may not perform this action on items!\") and return unless current_user.admin?\n end",
"def grantOrgAdminRights(admin_url, email_id, ein_number)\n\t\n\tputs \"************** START : Grant ORG Admin rights ****************\"\t\n\t$browser.open admin_url\n\t$browser.click \"link=Manage Org Admins\"\n\t$browser.wait_for_page_to_load \n\t$browser.type \"email\", email_id\n\t$browser.type \"ein\", ein_number\n\t$browser.click \"commit\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Org Admin successfully created!\")\n\t\tputs \"Passed. Org Admin successfully created for #{email_id} user\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Failed. Org Admin has not created successfully for #{email_id} user\"\n\tend\n\t\n\tputs \"************** END : Grant ORG Admin rights ****************\"\t\n\t\nend",
"def grantOrgAdminRights(admin_url, email_id, ein_number)\n\t\n\tputs \"************** START : Grant ORG Admin rights ****************\"\t\n\t$browser.open admin_url\n\t$browser.click \"link=Manage Org Admins\"\n\t$browser.wait_for_page_to_load \n\t$browser.type \"email\", email_id\n\t$browser.type \"ein\", ein_number\n\t$browser.click \"commit\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Org Admin successfully created!\")\n\t\tputs \"Passed. Org Admin successfully created for #{email_id} user\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Failed. Org Admin has not created successfully for #{email_id} user\"\n\tend\n\t\n\tputs \"************** END : Grant ORG Admin rights ****************\"\t\n\t\nend",
"def allow_if_admin\n unless is_admin?\n flash[:danger] = \"Administration permissions needed to access to this page\"\n redirect_to new_user_session_path\n end\n end",
"def ensure_user_is_admin\n bounce_user unless current_user and current_user.admin?\n end",
"def grant(userid=nil, email=nil, download=true, upload=false, view=true, admin=false, delete=false, notifyupload=false, notifydownload=false) #(userid OR email) required\n end",
"def authorize_admin\n return unless !current_admin\n redirect_to root_path, alert: 'Admins only!'\n end",
"def require_admin\n #byebug\n redirect_to user_path(current_user) unless current_user.role === \"Admin\"\n end",
"def require_user\n end",
"def alteration_approve\n UserNotifier.deliver_in_process(self, user)\n end",
"def authorize_user\n redirect_to restrooms_path, flash: {message: \"You don't have permission to make changes to another user's profile.\"} unless current_user.admin? || @user == current_user\n end",
"def confirm_admin\n @confirm_admin = true if session[:role_name] == 'Administrator'\n end",
"def set_as_admin\n self.role = USER_ROLES[:admin]\n end",
"def run_with_admin_privileges(file, *args)\n require 'win32ole'\n shell = WIN32OLE.new('Shell.Application')\n shell.ShellExecute('ruby', \"#{file} #{args.join(' ')}\", nil, 'runas', 1)\n end",
"def require_admin!\n authenticate_user!\n\n if current_user && !current_user.admin?\n redirect_to root_path\n end\n end",
"def require_admin!\n authenticate_user!\n\n if current_user && !current_user.admin?\n redirect_to root_path\n end\n end",
"def require_admin!\n authenticate_user!\n\n if current_user && !current_user.admin?\n redirect_to root_path\n end\n end",
"def require_admin!\n authenticate_user!\n\n if current_user && !current_user.admin?\n redirect_to root_path\n end\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n self.make_admin_if_first_user\n save(false)\n end",
"def ensure_admin!\n authorize! :read, :admin_dashboard\n end",
"def ensure_admin!\n authorize! :read, :admin_dashboard\n end",
"def require_admin\n unless @current_user.is_admin?\n set_notification_messages(\"authentication.permission_denied\", :error)\n redirect_or_popup_to_default_sign_in_page\n return\n end\n end",
"def autenticathe_admin!\n unless someone_is_logged_in? && is_admin_user?(current_user)\n redirect_to root_path\n end\n end",
"def change_privilege(user, group=user)\n puts \">> Changing process privilege to #{user}:#{group}\"\n\n uid, gid = Process.euid, Process.egid\n target_uid = Etc.getpwnam(user).uid\n target_gid = Etc.getgrnam(group).gid\n\n if uid != target_uid || gid != target_gid\n # Change process ownership\n Process.initgroups(user, target_gid)\n Process::GID.change_privilege(target_gid)\n Process::UID.change_privilege(target_uid)\n end\nrescue Errno::EPERM => e\n puts \"Couldn't change user and group to #{user}:#{group}: #{e}\"\nend",
"def authorize_admin\n redirect_to root_path, flash: {:error => \"User don't have admin privileges\"} unless isAdmin?\n end",
"def require_privilege(scope)\n # check if client has the required scope\n doorkeeper_authorize! scope\n return if performed?\n\n # check if user has heightened privileges\n case scope\n when :admin_all\n if not current_user.administrator?\n raise ApiError.new(\"User does not have admin privileges\", :forbidden)\n end\n when :instructor_all\n # @cud must have been set if the before_action order is correct\n if not @cud.instructor\n raise ApiError.new(\"User does not have instructor privileges for this course\", :forbidden)\n end\n end\n end",
"def create_user\n user new_resource.user do\n comment \"Service user for #{new_resource.name}\"\n gid new_resource.group if new_resource.group\n home new_resource.home\n shell '/bin/false'\n system true\n uid new_resource.uid\n end\n end"
] |
[
"0.6232591",
"0.6229489",
"0.62078214",
"0.6202992",
"0.61756426",
"0.59826195",
"0.59616613",
"0.5947145",
"0.5887757",
"0.5880907",
"0.5848691",
"0.58329165",
"0.5822338",
"0.5817",
"0.5815245",
"0.5802619",
"0.57931274",
"0.57920265",
"0.57896996",
"0.577335",
"0.57626075",
"0.57605976",
"0.5756307",
"0.57410175",
"0.5731975",
"0.5731975",
"0.56922865",
"0.56889194",
"0.56874996",
"0.5687014",
"0.5682498",
"0.5669257",
"0.5662713",
"0.56430554",
"0.5641285",
"0.5638614",
"0.5623705",
"0.5615476",
"0.5613578",
"0.561106",
"0.5604993",
"0.55998975",
"0.55957127",
"0.5594287",
"0.55808103",
"0.5573445",
"0.5570281",
"0.55680805",
"0.55614704",
"0.55515426",
"0.5531107",
"0.55233216",
"0.5522923",
"0.55218375",
"0.55128455",
"0.55088115",
"0.5506423",
"0.550297",
"0.5500304",
"0.55001414",
"0.5497225",
"0.5489153",
"0.54865605",
"0.5485267",
"0.54846025",
"0.54803383",
"0.5479952",
"0.5479768",
"0.5478569",
"0.5478569",
"0.5459493",
"0.5459266",
"0.5454666",
"0.54532224",
"0.54505587",
"0.54505336",
"0.54505336",
"0.54454815",
"0.5444825",
"0.5442661",
"0.5439547",
"0.54371876",
"0.54355425",
"0.54330075",
"0.5431138",
"0.5430505",
"0.5426138",
"0.5409339",
"0.54058653",
"0.54055583",
"0.5404846",
"0.5404846",
"0.54009014",
"0.53994304",
"0.53994304",
"0.5398321",
"0.5394995",
"0.5394969",
"0.53902406",
"0.5389341",
"0.538608"
] |
0.0
|
-1
|
END Grant users administrative privileges
|
def become_user
return unless current_user.admin?
respond_to do |format|
format.html
format.js {
# Check if user to become is an admin. If so, then redirect.
render :js => "window.location.href='" + api_admin_home_path + "'" and return if User.find_by_email(params[:email]).admin?
# Sign in as user and redirect
sign_in(:user, User.find_by_email(params[:email]), { :bypass => true })
render :js => "window.location.href='" + home_index_path + "'"
}
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def auto_elevate!\n add_role :superuser\n end",
"def require_admin\n grant_access?(\"index\", \"users\")\n #position?('admin')\n end",
"def require_admin_privileges\n\t\tredirect_to root_path unless is_global_admin?\n\tend",
"def notadmin\n\tprint_error(\"You need admin privs to run this!\")\n\tprint_error(\"Try using 'getsystem' or one of the many escalation scripts and try again.......\")\n\traise Rex::Script::Completed\nend",
"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 ensure_an_admin_remains\n if User.count.zero?\n raise \"Can't delete last user\"\n end\n end",
"def grant_system_admin_privileges(user)\n can :manage, AccountPlan\n end",
"def ensure_admin!\n # D: Send admin status to log\n logger.debug \"current_user.admin? => #{current_user.admin?}\"\n unless current_user.admin?\n flash[:notice] = 'You do not have sufficient privileges.'\n redirect_to root_path\n return false\n end \n end",
"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\t\t\tflash_text = \"Administrative privilege required to perform this action.\"\n\t\t\tflash[:danger] = flash_text unless current_user.admin?\n\t\t\tredirect_to(root_url) unless current_user.admin?\n\t\tend",
"def administrate!\n\tif current_user.admin == false \n\t\tredirect \"/home\"\n\tend\nend",
"def ensure_an_admin_remains\n if User.count.zero?\n raise \"Can't delete last user\"\n end\n end",
"def upgrade_to_main_user\n self.is_main_user = true \n self.save \n \n admin_role = Role.find_by_name(USER_ROLE[:admin]) \n self.add_role_if_not_exists(admin_role ) \n end",
"def be_admin\n if current_user.switch_to(\"admin\")\n flash[:notice] = \"You have now an 'admin' role\"\n else\n flash[:error] = \"You are not authorized to have a 'admin' role\"\n end\n redirect_to( request.env[\"HTTP_REFERER\"])\n end",
"def ensure_admin_user!\n redirect_to(enemy_templates_path, :alert => \"You may not perform this action on enemies!\") and return unless current_user.admin?\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 ensure_if_admin_remains\n raise \"Can't delete last admin user.\" if User.count.zero?\n end",
"def ensure_if_admin_remains\n raise \"Can't delete last admin user.\" if User.count.zero?\n end",
"def require_correct_admin\n if current_user.user?\n raise ExceptionTypes::UnauthorizedError.new(\"Admin access only\")\n end\n if current_user.admin?\n raise ExceptionTypes::UnauthorizedError.new(\"You do not have permission to modify the program with ID #{@program.id}\") unless @program.admins.exists? current_user.id\n end\n end",
"def authorize_as_admin\n create_admin_user\n login_into_alchemy\n end",
"def ensure_admin_user!\n redirect_to(news_path, :alert => \"You may not perform this action on News!\") and return unless user_signed_in? && current_user.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 setup_admin\n create_admin_user\n create_admin_organization\n update_admin_user_perms\nend",
"def require_admin\n not_authorized(\"Invalid credentials.\") unless is_admin?\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 require_admin\n deny_wrong_user if !admin?\n end",
"def make_first_user_admin\n return unless User.count.zero?\n\n self.is_admin = true\n self.approved = true\n end",
"def test_22_impersonate_permission()\n\t\t\n\t\tputs \"---------------------- START OF SCENARIO 22 ----------------------\"\n\t\tlogin($globaladmin_emailId, $globaladmin_password)\n\t\timpersonatePermission($admincon_url, $normal2_emailId, $normal2_firstname, $normal2_lastname)\n\t\tlogout()\n\t\tputs \"---------------------- END OF SCENARIO 22 ----------------------\"\n\t\n\tend",
"def apply_privileges(app_name=nil)\n return if credentials(app_name).nil?\n if is_postgresql()\n cmd_acl=\"GRANT CREATE ON SCHEMA PUBLIC TO PUBLIC;\\\n GRANT ALL ON ALL TABLES IN SCHEMA PUBLIC TO PUBLIC;\\\n GRANT ALL ON ALL FUNCTIONS IN SCHEMA PUBLIC TO PUBLIC;\\\n GRANT ALL ON ALL SEQUENCES IN SCHEMA PUBLIC TO PUBLIC;\\\n ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO PUBLIC;\\\n ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO PUBLIC;\\\n ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON FUNCTIONS TO PUBLIC;\"\n# shell(cmd_acl,true)\n \n # reset the owner of the functions to the current user\n # when there is a 'privileged' app.\n app_name ||= @wrapped['director']['bound_app'] if @wrapped['director']\n if app_name\n cmd_select_fcts=\"SELECT pg_proc.proname FROM pg_catalog.pg_proc WHERE \\\n pg_proc.pronamespace=(SELECT pg_namespace.oid FROM pg_catalog.pg_namespace WHERE pg_namespace.nspname = 'public') \\\n AND pg_proc.proowner!=(SELECT oid FROM pg_roles WHERE rolname = 'postgres')\"\n current_owner=credentials()['username']\n unless current_owner\n STDERR.puts \"The application #{app_name} is not bound to the data-service #{name}; not applying the database privileges.\"\n return\n end\n fcts_name=shell(cmd_select_fcts,true,true)\n if fcts_name.empty?\n puts \"No need to re-assign the ownership of the functions in #{credentials()['name']}; the DB does not define its own functions.\" if VMC::Cli::Config.trace\n else\n fcts = fcts_name.split(\"\\n\").collect do |line|\n line.strip!\n \"'#{line}'\"\n end.join(',')\n cmd_change_fcts_owner=\"UPDATE pg_catalog.pg_proc \\\n SET proowner = (SELECT oid FROM pg_roles WHERE rolname = '#{current_owner}')\\\n WHERE pg_proc.proname IN (#{fcts})\"\n puts `sudo -u postgres psql --dbname #{credentials()['name']} -c \\\"#{cmd_change_fcts_owner}\\\" #{PSQL_RAW_RES_ARGS}`\n end\n end\n end\n end",
"def allow_if_admin\n unless is_admin?\n flash[:danger] = \"Administration permissions needed to access to this page\"\n redirect_to new_user_session_path\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 administrate!\r\n\tif !current_user.administrator\r\n\t\tredirect \"/dashboard\"\r\n\tend\r\nend",
"def admin_actions\n unless @current_admin.is_super_admin\n flash[:error]=\"You are not authorized to navigate to this page \"\n redirect_to admin_index_path\n return\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 make_admin\n authorize! @user\n @user.roles = @user.roles + ['admin']\n @user.save\n redirect_to @user, notice: t('user.made_admin', name: @user.username)\n end",
"def ensure_admin\n unless current_user && current_user.admin\n flash[:notice] = \"You are not authorized to perform this action\"\n redirect_back(fallback_location: root_path)\n end\n\n end",
"def enforce_permissions\n bounce unless is_admin?\n end",
"def run_privileged *args\n args = if args.length > 1\n\t args.unshift \"start /b runas /savecred /env /user:Administrator \\\"\"\n\t args << '\"'\n\t else\n\t \"start /b runas /savecred /env /user:Administrator \\\"#{args.first}\\\"\"\n\t end\n end",
"def grantOrgAdminRights(admin_url, email_id, ein_number)\n\t\n\tputs \"************** START : Grant ORG Admin rights ****************\"\t\n\t$browser.open admin_url\n\t$browser.open \"admin/org_admins\"\n\t$browser.wait_for_page_to_load \n\t$browser.type \"email\", email_id\n\t$browser.type \"ein\", ein_number\n\t$browser.click \"commit\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Org Admin successfully created!\")\n\t\tputs \"Passed. Org Admin successfully created for #{email_id} user\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Failed. Org Admin has not created successfully for #{email_id} user\"\n\tend\n\t\n\tputs \"************** END : Grant ORG Admin rights ****************\"\t\n\t\nend",
"def authorize_admin\n\t\tauthorize( ADMIN_USER_LEVEL ) \n\tend",
"def grantOrgAdminRights(admin_url, email_id, ein_number)\n\t\n\tputs \"************** START : Grant ORG Admin rights ****************\"\t\n\t$browser.open admin_url\n\t$browser.click \"link=Manage Org Admins\"\n\t$browser.wait_for_page_to_load \n\t$browser.type \"email\", email_id\n\t$browser.type \"ein\", ein_number\n\t$browser.click \"commit\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Org Admin successfully created!\")\n\t\tputs \"Passed. Org Admin successfully created for #{email_id} user\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Failed. Org Admin has not created successfully for #{email_id} user\"\n\tend\n\t\n\tputs \"************** END : Grant ORG Admin rights ****************\"\t\n\t\nend",
"def grantOrgAdminRights(admin_url, email_id, ein_number)\n\t\n\tputs \"************** START : Grant ORG Admin rights ****************\"\t\n\t$browser.open admin_url\n\t$browser.click \"link=Manage Org Admins\"\n\t$browser.wait_for_page_to_load \n\t$browser.type \"email\", email_id\n\t$browser.type \"ein\", ein_number\n\t$browser.click \"commit\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Org Admin successfully created!\")\n\t\tputs \"Passed. Org Admin successfully created for #{email_id} user\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Failed. Org Admin has not created successfully for #{email_id} user\"\n\tend\n\t\n\tputs \"************** END : Grant ORG Admin rights ****************\"\t\n\t\nend",
"def admin_auth\n\t\tif signed_out?\n deny_access \"You must sign in first.\"\t\t\t\n\t\telse\n\t deny_access \"You must be an admin to perform that action.\" unless current_user.admin\n\t\tend\n end",
"def must_be_admin\n if current_user.is? \"EA\"\n return true\n else\n redirect_to root_path,:notice =>\"Access Denied...\"\n end\n end",
"def ensure_an_admin_remains\n if user_type_id == UserType::vendor_admin_id\n if User.where({user_type_id: UserType::vendor_admin_id, company_id: company_id}).count.zero?\n raise \"Cannot delete last vendor admin.\"\n end\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.admin? || current_user.super_admin?\n end",
"def ensure_user_is_admin\n bounce_user unless current_user and current_user.admin?\n end",
"def authorize_admin\n redirect_to root_path unless current.user.immortal?\n end",
"def admin_user\n if user_signed_in? && current_user.adminrole?\n flash.now[:success] = \"Admin Access Granted\"\n else\n redirect_to root_path\n end\n end",
"def authorize_admin\n return unless !current_user.admin?\n redirect_to root_path, alert: 'Admins only!'\n end",
"def authorize_admin\n return unless !current_user.admin?\n redirect_to root_path, alert: 'Admins only!'\n end",
"def do_secure_accounts(instance)\n client = Client.open(instance, :no_password => true)\n q1 = \"UPDATE mysql.user SET Password = PASSWORD(\\'#{ROOT_PASSWORD}\\') where User = \\'root\\'\"\n q2 = \"UPDATE mysql.user SET Password = PASSWORD(\\'#{ROOT_PASSWORD}\\') where User = \\'\\'\"\n # q3 = \"CREATE USER \\'root\\'@\\'%.#{REPLICATION_DOMAIN}\\' IDENTIFIED BY \\'#{ROOT_PASSWORD}\\'\"\n # For testing with clients whose DHCP assigned IP address is not in DNS.\n q3 = \"CREATE USER \\'root\\'@\\'%' IDENTIFIED BY \\'#{ROOT_PASSWORD}\\'\"\n q4 = \"GRANT ALL PRIVILEGES ON *.* to \\'root\\'@\\'%\\' WITH GRANT OPTION\"\n q5 = \"FLUSH PRIVILEGES\"\n if client\n [q1, q2, q3, q4, q5].each do |query|\n puts query\n client.query(query)\n end\n end\n rescue Mysql2::Error => e\n puts e.message\n ensure\n client.close if client\n end",
"def adminprotected!\n if authorized? == true and isuseradmin? == true\n return\n else redirect '/denied'\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 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_barrier\n unless admin_access? || logged_in? && current_user == @user\n flash[:alert] = \"You must have admin access to do that.\"\n redirect_to :back\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 first_user_hook\n if User.with_role(:admin).count == 0\n self.grant :admin\n else # set editor as default role\n self.grant :editor if self.roles.empty?\n end\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 require_admin_permission\n redirect_to tables_path, notice: 'Necesita permisos de administrador para visualizar la configuracion' unless current_user_admin?\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 @group = Group.find(by_id)\n redirect_to @group unless @group.has_admin?(current_user)\n end",
"def authorize_admin\n return unless current_user.admin?\n redirect_to root_path, alert: 'Admins only!'\n end",
"def ensure_admin_user!\n redirect_to(region_templates_path, :alert => \"You may not perform this action on regions!\") and return unless current_user.admin?\n end",
"def admin_in!\n access_denied! unless current_user.admin?\n end",
"def _admin_or_self\n not_authorizaed unless current_user.admin? || current_user == @user\n end",
"def set_admin\n #puts \"called set_admin\"\n @admin = current_admin_credential\n end",
"def authorize_admin\n return unless !current_admin\n redirect_to root_path, alert: 'Admins only!'\n end",
"def authorize_user\n\t if !current_user.admin_user? then\n\t redirect_to '/', notice: 'You have attempted to access a function that is not available for basic users.'\n\t end\n\tend",
"def check_manager_or_admin\n unless current_user && (current_user.privilege_manager? || 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\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 give_admin!\n self.admin = true\n save\n puts \"Felicitation vous etes admin!\"\n true\n end",
"def authorize_admin\n redirect_to root_path, flash: {:error => \"User don't have admin privileges\"} unless isAdmin?\n end",
"def authorise_admin\n redirect_to root_path, alert: \"You are not authorised to access that page\" if current_user.try(:admin?) != true\n end",
"def admin_user\n redirect_to(root_path) unless is_admin?\n end",
"def admin_user\n redirect_to(root_path) unless (current_user != nil && current_user.admin == true)\n end",
"def require_admin\n unless @current_user.is_admin?\n set_notification_messages(\"authentication.permission_denied\", :error)\n redirect_or_popup_to_default_sign_in_page\n return\n end\n end",
"def admin_user\n\t\tredirect_to(root_path) unless current_user.admin?\n\tend",
"def authorize_admin_manage_users\n unless current_user.permission.manage_users\n redirect_back fallback_location: root_path\n end\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 main_admin\n @@_cache_admin ||= (User.where(email: '[email protected]').take || User.create!(first_name: 'Loverealm', last_name: 'Administrator', email: '[email protected]', password: ENV['LR_SUPER_USERS_PASSWORD'], password_confirmation: ENV['LR_SUPER_USERS_PASSWORD'], roles: [:admin]))\n end",
"def admin_only\n unless current_user.admin?\n redirect_to :back, :alert => \"Access denied.\"\n end\n end",
"def authorize_admin\n redirect_to '/librarians/denied' unless current_user && current_user.admin?\n end",
"def set_as_admin\n self.role = USER_ROLES[:admin]\n end",
"def change_privilege\n if Merb::Config[:user] && Merb::Config[:group]\n Merb.logger.verbose! \"About to change privilege to group \" \\\n \"#{Merb::Config[:group]} and user #{Merb::Config[:user]}\"\n _change_privilege(Merb::Config[:user], Merb::Config[:group])\n elsif Merb::Config[:user]\n Merb.logger.verbose! \"About to change privilege to user \" \\\n \"#{Merb::Config[:user]}\"\n _change_privilege(Merb::Config[:user])\n else\n return true\n end\n end",
"def grant_privileges(config)\n print \"Please provide the root password for your db installation\\n>\"\n postgres_password = $stdin.gets.strip\n\n create_db(config.merge('database' => config['database'], 'username' => 'postgres', 'password' => postgres_password))\n\n grant_statement = <<-SQL\nGRANT ALL ON DATABASE #{config['database']}\nTO \"#{config['username']}\" WITH GRANT OPTION;\nSQL\n\n ActiveRecord::Base.connection.execute grant_statement\n #ActiveRecord::Base.connection.drop_database config['database']\nend",
"def admin_only\n return if admin_user?\n\n add_message 'Insufficient permission to view page'\n redirect_to '/'\n end",
"def enable_admin\n if current_user.admin?\n user = User.find(params[:id])\n user.update_attribute(\"admin\", true)\n redirect_to \"/users\"\n else\n redirect_to \"/home\"\n flash[:warning] = \"Only admins can perform that action.\"\n end\n end",
"def assign_administrator(user_id)\n add_user(user_id, true, true)\n end",
"def permit_user\n if (!current_user.lunches_admin?) \n flash[:alert] = 'You not allowed to see all orders.'\n respond_to do |format| \n format.html {redirect_to(root_url)}\n end\n end\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 administrator_user\n unless current_user.administrator?\n flash[:danger] = \"Only an administrator can do that.\"\n redirect_to(root_path)\n end\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 must_be_admin!\n access_denied! unless current_admin?\n end",
"def authorize_admin\n redirect_to :login unless current_user.permission.manage_app ||\n current_user.permission.manage_attrs ||\n current_user.permission.manage_achievement_categories ||\n current_user.permission.manage_talent_trees ||\n current_user.permission.manage_talents ||\n current_user.permission.manage_quests ||\n current_user.permission.manage_skills ||\n current_user.permission.manage_achievements ||\n current_user.permission.manage_items ||\n current_user.permission.manage_titles\n end"
] |
[
"0.6656823",
"0.6646341",
"0.6579562",
"0.65202165",
"0.6469432",
"0.6466289",
"0.6462393",
"0.64079165",
"0.6405331",
"0.6405331",
"0.639928",
"0.63782775",
"0.63649017",
"0.63567185",
"0.632375",
"0.6320614",
"0.62797403",
"0.62760764",
"0.62760764",
"0.62734944",
"0.62714857",
"0.6256784",
"0.6251982",
"0.6250482",
"0.6231751",
"0.62275815",
"0.6226086",
"0.62120706",
"0.62063193",
"0.6205148",
"0.61994505",
"0.6198324",
"0.619419",
"0.61931276",
"0.61896396",
"0.6184163",
"0.6179769",
"0.6176409",
"0.6174164",
"0.6167652",
"0.6156108",
"0.6148389",
"0.6148389",
"0.61474943",
"0.61315894",
"0.61306393",
"0.6124728",
"0.6106856",
"0.61025435",
"0.6096454",
"0.6083168",
"0.60794234",
"0.60794234",
"0.6074572",
"0.60739875",
"0.60730124",
"0.60730124",
"0.6069816",
"0.6068128",
"0.6067209",
"0.60600895",
"0.6055264",
"0.6052352",
"0.60511243",
"0.60455453",
"0.6043865",
"0.60430926",
"0.603889",
"0.6036489",
"0.6033864",
"0.60324967",
"0.60312253",
"0.6031136",
"0.6031136",
"0.60304683",
"0.60233295",
"0.60222673",
"0.60108507",
"0.6009952",
"0.600703",
"0.6005189",
"0.6003942",
"0.6003777",
"0.6002883",
"0.59955686",
"0.59886146",
"0.5988156",
"0.5984812",
"0.5980955",
"0.5973531",
"0.5967035",
"0.59662634",
"0.59646374",
"0.59634155",
"0.59634155",
"0.5960413",
"0.595904",
"0.595904",
"0.595904",
"0.59574324",
"0.5953243"
] |
0.0
|
-1
|
we would arrive here if there is a second step in the reserve process, only for issn enabled listings
|
def update
@reserver = @reservation.reserver
@billing = @reserver.billing_info || @reserver.billing_infos.create
@billing.update_attributes params[:billing_info]
@response = @reservation.process_new_tenant @billing
if IssnAdapter.no_fatal_error?(@response['sErrorMessage']) && @reserver.save
@reservation.update_attribute :status, 'paid' if @response['sErrorMessage'].blank?
send_notices
render :json => { :success => true, :data => render_to_string(:partial => 'reservations/step3') }
else
render :json => { :success => false, :data => (@response['sErrorMessage'].blank? ? model_errors(@reserver) : @response['sErrorMessage']) }
end
#rescue => e
# render :json => { :success => false, :data => e.message }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def reserve(req)\n # Check the services priority\n match = @svcList.select{|s| s.name == req.service}\n if match == nil || match[0] == nil\n $Logger.error \"Unable to find service #{req.service}\"\n return\n end\n service = match[0]\n svcpri = service.priclass\n # CHeck if service limits will be exceeded\n vcpusallocated = service.vcpusallocated.to_i + req.vcpus.to_i\n memallocated = service.memallocated.to_i + req.mem.to_i\n if vcpusallocated > service.maxcpus.to_i || memallocated > service.maxmemory.to_i\n $Logger.debug \"Request #{req.reqid} would exceed limits for #{req.service}\"\n return\n end\n \n if SHAREDPOOLS[req.pool] == nil\n $Logger.error \"Pool in request #{req.reqid} is #{req.pool} not known\"\n return\n end\n # Find all pools with a equal or better class than the request\n # We look for pools in the same zone as the pool in which the\n # environment was originall created in.\n targetZone = SHAREDPOOLS[req.pool][:zone]\n match = @poolList.select {|p|\n priclass2Index(p.priclass) >= priclass2Index(svcpri) && \n p.zone == targetZone &&\n p.availvcpus.to_i >= req.vcpus &&\n p.availmem.to_i >= req.mem\n }\n if match == nil || match[0] == nil\n $Logger.info \"No matching pool found for #{req.reqid}. Adding req to preemptee list\"\n @preempteeList.push(req)\n return\n end\n\n $Logger.info \"Number of matching pools found for req #{req.reqid} is #{match.length()}\"\n \n \n match.sort!{ |a,b| a.availvcpus.to_i <=> b.availvcpus.to_i }\n pool = match[0]\n if pool == nil\n $Logger.error \"No pools found #{req.service}\"\n return\n end\n $Logger.info \"Pool info: #{pool.availvcpus} #{pool.availmem}\"\n $Logger.info \"Req info: #{req.vcpus} #{req.mem}\"\n \n $Logger.info \"Assigning #{req.reqid} to pool #{pool.name}\"\n pool.availvcpus = pool.availvcpus.to_i - req.vcpus.to_i\n pool.availmem = pool.availmem.to_i - req.mem.to_i\n service.vcpusallocated = service.vcpusallocated.to_i + req.vcpus.to_i\n service.memallocated = service.memallocated.to_i + req.mem.to_i\n req.status = \"ALLOCATED\" \n req.pool = pool.name\n $eventProcessor.updateRequest(req)\n # Send m GRANT essage to the client\n g=Grant.new(\"GRANT\",req.zone, req.service, pool.name, req.envid, req.reqid)\n g.vcpus = req.vcpus\n g.mem = req.mem\n $eventProcessor.notifyclient(req.service + \"-\" + req.zone, g.to_json) \n return\n end",
"def reserve_for(desired_showdate, processor, new_comments='')\n if reserved?\n errors.add :base,\"This ticket is already holding a reservation for #{reserved_date}.\" and return nil\n raise ReservationError\n end\n redemption = valid_voucher_adjusted_for processor,desired_showdate\n if processor.is_boxoffice || redemption.max_sales_for_this_patron > 0\n reserve!(desired_showdate, new_comments)\n else\n errors.add :base,redemption.explanation\n raise ReservationError\n end\n end",
"def try_allocate_next\n while not @waiting_list.empty? and @waiting_list.first[1] <= @free do\n first = @waiting_list.shift\n first[0].req(self, first[1])\n first[0].ready\n end\n end",
"def available\n self.listing.reservations.each do |r|\n if self.checkin.nil? || !(r.checkin && r.checkin < self.checkin)\n errors.add(:checkin, \"checkin and checkout unavailable\")\n # elsif (r.checkin && r.checkin < self.checkin) == false\n # errors.add(:checkin, \"checkin and checkout unavailable\")\n end\n end\n end",
"def waitlist_allocation\n if capacity.changed? or new_record?\n selected_for_allocation = event.waitlist.limit(capacity - candidates.count)\n if selected_for_allocation and candidates.count < capacity\n waitlist_update(selected_for_allocation)\n end\n end\n end",
"def enroll_from_waitlist_as_needed\n\n # Very dumb lock\n @@currently_enrolling = true\n\n # Get tour that some booking was just destroyed for\n tour = self.tour\n\n # We can possibly enroll if there are available seats, and waitlisted seats\n if Booking.get_available_seats_for_tour(tour).positive? && Waitlist.get_waitlisted_seats_for_tour(tour).positive?\n # Iterate over all waitlists for this tour\n Waitlist.get_waitlists_for_tour_first_come_first_served(tour).each do |waitlist|\n\n # Since we are in a loop, re-check some stuff each time\n # Available seats in the tour may have been modified so check that again\n # Waitlist may have been destroyed (but not quite totally 100% gone yet)\n # Honestly I don't understand how a \"destroyed\" waitlist can be returned\n # from get_waitlists_for_tour_first_come_first_served,\n # but I am seeing behavior that makes me pretty sure this is happening\n # Here we have multiple levels of trying to NOT see a waitlist we have destroyed\n if waitlist.num_seats <= Booking.get_available_seats_for_tour(tour)\n\n # We can book all of these seats\n # We need a booking\n # If there was a booking already, update it\n # If there was not a booking already, create it\n # We do not need a waitlist (destroy it)\n associated_booking = waitlist.booking_same_user_same_tour\n if associated_booking\n already_booked = associated_booking.num_seats\n associated_booking.update(\n num_seats: already_booked + waitlist.num_seats\n )\n else\n associated_booking = Booking.new(\n num_seats: waitlist.num_seats,\n user_id: waitlist.user_id,\n tour_id: waitlist.tour_id\n )\n end\n\n # FIRST destroy the waitlist THEN save the new or updated booking\n # to help protect against seats from a waitlist being added to booking more than once\n waitlist.destroy\n associated_booking.save\n\n end\n end\n\n end\n\n # Very dumb lock\n @@currently_enrolling = false\n\n end",
"def review_assigned_stock\n\n automatic_assignation = SystemConfiguration::Variable.get_value('booking.assignation.automatic_resource_assignation', 'false').to_bool\n\n # Search availability\n product_search = ::Yito::Model::Booking::BookingCategory.search(self.rental_location_code,\n self.date_from,\n self.time_from,\n self.date_to,\n self.time_to,\n self.days,\n {\n locale: self.customer_language,\n full_information: true,\n product_code: nil,\n web_public: false,\n sales_channel_code: self.sales_channel_code,\n apply_promotion_code: self.promotion_code.nil? ? false : true,\n promotion_code: self.promotion_code,\n include_stock: true,\n ignore_urge: {origin: 'booking', id: self.id}\n })\n free_resources = product_search.inject([]) do |result, item|\n result.concat(item.resources)\n end\n\n p \"free_resources: #{free_resources}\"\n\n self.booking_line_resources.each do |booking_line_resource|\n\n if !booking_line_resource.booking_item_reference.nil? # Assigned resource\n if free_resources.index(booking_line_resource.booking_item_reference).nil? # Not found\n if product = product_search.select { |item| item.code == booking_line_resource.booking_line.item_id }.first\n if product.availability and product.resources.size > 0\n if automatic_assignation\n p \"booking : #{self.id} reassigned #{product.resources.first} instead of #{booking_line_resource.booking_item_reference}\"\n booking_line_resource.assign_resource(product.resources.first)\n product.resources.delete_at(0)\n end\n else\n booking_line_resource.clear_assignation\n p \"booking : #{self.id} clear assignation #{booking_line_resource.booking_item_reference} -- not free resources\"\n end\n else\n p \"booking : #{self.id} #{booking_line_resource.booking_item_reference} product #{booking_line_resource.booking_line.item_id} not found\"\n end\n else\n p \"booking: #{self.id} kept: #{booking_line_resource.booking_item_reference}\"\n end\n else # Not assigned resource\n if automatic_assignation\n if product = product_search.select { |item| item.code == booking_line_resource.booking_line.item_id }.first\n if product.availability and product.resources.size > 0\n p \"booking : #{self.id} assigned #{product.resources.first}\"\n booking_line_resource.assign_resource(product.resources.first)\n product.resources.delete_at(0)\n end\n end\n end\n end\n end\n end",
"def reclaim()\n if @preempteeList.empty?\n $Logger.info \"No one requiring preemption\"\n return\n end\n # Look for low priority requests using resources of a higher class\n @preemptableList.clear\n @reqList.each do |req|\n if req.status == \"ALLOCATED\"\n match1 = @poolList.select {|p| p.name == req.pool}\n match2 = @svcList.select {|s| s.name == req.service}\n poolpri = match1[0].priclass \n svcpri = match2[0].priclass\n if priclass2Index(poolpri) > priclass2Index(svcpri) \n $Logger.info \"Adding req #{req.reqid} as preemption candidate\"\n @preemptableList.push(req)\n end\n end\n end\n $Logger.info \"The size of the preemptable list is #{@preemptableList.length}\"\n # Try and match preemptable with preemptee\n @preempteeList.each do |target|\n targetPriClass = getPriClass(target)\n $Logger.info \" Trying to find a match for #{target.reqid} with class #{targetPriClass}\"\n match = @preemptableList.select { |r|\n candPoolPriClass = getReqPoolPriClass(r)\n targetPriClass == candPoolPriClass}\n if match == nil or match[0] == nil\n $Logger.info \"No match found for #{target.reqid}\"\n next\n end\n # Check if we have already sent a reclaim request for this\n # environment recently\n r = match[0]\n ekey = r.service + \"-\" + r.zone + \"-\" + r.envid\n if @reclaimOutstanding.has_key?(ekey)\n if Time.now - @reclaimOutstanding.fetch(ekey) < 60\n $Logger.info \"Environment has recent reclaim request #{r.envid}\"\n next\n end\n end\n\n # Send a reclaim message to the target client which we are\n # preempting. The reclaim will cause a release of the resource\n # which should be assigned to the target\n \n $Logger.info \" Sending a reclaim for #{r.reqid}\"\n rec = Reclaim.new(\"RECLAIM\", r.reqid, r.envid)\n \n $eventProcessor.notifyclient(r.service + \"-\" + r.zone, rec.to_json) \n @reclaimOutstanding.store(ekey, Time.now) \n end\n\n end",
"def reserve_for(key)\n reserves.fetch(key)\n end",
"def enter_pending; end",
"def check_rbs_availability!; end",
"def reserve_with_restriction\n @job_in_progress = reserve_without_restriction\n return @job_in_progress\n end",
"def create\n @reservation = Reservation.new(reservation_params)\n @reservation.teacher_id = current_user.id\n authorize! :create, @reservation\n\n if(session[:rental_category_id].nil?)\n redirect_to shopping_path\n end\n \n \n reservation_category = ItemCategory.find(session[:rental_category_id])\n \n #Nasty race condition if multiple ppl grab same kit\n @@semaphore.synchronize {\n kit_pool = Kit.available_for_item_category(reservation_category)\n \n test_kit = kit_pool.sample\n if(!test_kit.nil?)\n test_kit.set_reserved\n test_kit.reload\n @reservation.kit_id = test_kit.id\n end\n \n respond_to do |format|\n if @reservation.save\n session[:rental_category_id] = nil\n session[:start_date] = nil\n session[:end_date] = nil\n session[:pickup_date] = nil\n session[:return_date] = nil\n\n format.html { redirect_to rental_history_path(current_user), notice: 'Thank you for supporting the STEAM Kit rental program.' }\n else\n if(!test_kit.nil?)\n test_kit.unset_reserved\n test_kit.reload\n end\n format.html { redirect_to reservation_error_path }\n end\n end\n }\n end",
"def reserve vlan_id, vn = nil\n unless (start...(start + size)).include? vlan_id then\n raise StandardError.new(\"Requested VLAN ID isn't a part of this Pool(#{id})\")\n end\n\n lease =\n if vn.nil? then\n VLANLease.where(id: vlan_id, pool_id: id).first\n else\n VLANLease.where(vn: vn, id: vlan_id, pool_id: id).first\n end\n\n unless lease.nil? then\n raise StandardError.new(\"Requested VLAN ID is already leased\")\n end\n\n unless vn.nil? then\n VLANLease.insert(vn: vn, id: vlan_id, pool_id: id)\n else\n VLANLease.insert(id: vlan_id, pool_id: id)\n end\n true\n end",
"def reserve_and_run_one_job; end",
"def prepare_guest_lists\n confirmed = []\n waitlist = []\n num_total = 0\n\n reservations.order(:created_at).each do |r|\n if num_total >= show.seats\n # We're already past capacity. All people join the waitlist.\n waitlist << r\n num_total += r.num\n elsif (num_total + r.num) > show.seats\n # This group puts us past capacity. Split it and waitlist the excess #.\n seats_available = (show.seats - num_total)\n r_waitlisted = r.dup\n r.num = seats_available\n r_waitlisted.id = r.id # having the same id referent is important\n r_waitlisted.num -= seats_available\n\n confirmed << r\n waitlist << r_waitlisted\n num_total += (r.num + r_waitlisted.num)\n else\n # We're still within capacity.\n confirmed << r\n num_total += r.num\n end\n end\n\n [\n confirmed.sort_by{ |r| r.lname.downcase },\n waitlist # waitlist stays in order reserved\n ]\n end",
"def index\n @suggestions = policy_scope(Item).order(expiration: :desc)\n\n Reservation.joins(:item)\n .where('items.pickup_time < ?', Time.now)\n .destroy_all\n\n @reservations = policy_scope(Reservation).order(created_at: :desc)\n @reservation = Reservation.new\n authorize @reservation\n\n # CAROUSEL: OTHER UNIQUE ITEMS BY SAME SUPPLIER\n @my_owned_items = Item.all.where(user: current_user)\n @same_supplier_items = []\n @in_cart = []\n @reservations.each do |reservation|\n @same_supplier_items |= reservation.item.user.items\n @in_cart << reservation.item\n end\n @same_supplier_items.select! { |item| item.pickup_time.to_datetime > DateTime.now }\n @same_supplier_items -= @in_cart\n @same_supplier_items -= @my_owned_items\n\n # CAROUSEL: OTHERS WITH SAME ITEMS IN CART ALSO HAVE THESE IN CART\n @other_reserved_items = []\n @my_reserved_items = []\n @reservations.each do |my_reservation|\n my_reservation.item.reservations.each do |same_reservation|\n same_reservation.user.reservations.each do |other_reservation|\n if other_reservation.user_id == current_user.id\n @my_reserved_items |= [other_reservation.item]\n else\n @other_reserved_items |= [other_reservation.item]\n end\n end\n end\n end\n @other_reserved_items.uniq!\n\n @other_reserved_items.select! { |item| item.pickup_time.to_datetime > DateTime.now }\n @other_reserved_items -= @my_reserved_items\n @other_reserved_items -= @my_owned_items\n\n # CAROUSEL: OTHERS WHO BOUGHT WHAT YOU'VE BOUGHT ALSO BOUGHT\n if @others_purchased_items = Order.all\n .where(state: 'paid')\n .where.not(user_id: current_user.id)\n .map(&:purchased_items)\n .flatten\n .map(&:item)\n .uniq!\n @others_purchased_items.select! { |item| item.pickup_time.to_datetime > DateTime.now }\n\n if @my_purchased_items = Order.all\n .where(state: 'paid')\n .where(user_id: current_user.id)\n .map(&:purchased_items)\n .flatten\n .map(&:item)\n .uniq!\n @others_purchased_items -= @my_purchased_items\n @others_purchased_items -= @my_owned_items\n end\n end\n\n # SHOPPING CART: SEPARATE ITEMS BY SELLER\n @reservations_suppliers = []\n @reservations.each do |reservation|\n supplier = reservation.item.user\n @reservations_suppliers |= [supplier]\n end\n @reservations_suppliers_with_reserved = @reservations_suppliers.map { |supplier|\n [\n supplier,\n @reservations\n .joins(:item)\n .where(items: { user_id: supplier.id })\n ]\n }\n\n if user_signed_in?\n @purchased_item = PurchasedItem.new\n @subtotal_price = 0\n @total_price = 0\n @total_items = 0\n @reservations.each do |reservation|\n @subtotal_price += reservation.item.price * reservation.quantity\n @total_items += reservation.quantity\n end\n @percent = 5.0\n @amount = @subtotal_price\n @subtotal_price = @subtotal_price * (1 / (1 + (@percent/100)))\n @commission = @amount - @subtotal_price\n else\n redirect_to reservations_error_path\n end\n end",
"def reserve_inventory\n begin\n @product_reserved_stock = @product.reserved_stock_availabilty_in_distribution_center(\n @distribution_center.id, inventory_stock_params[:items_count]).first\n unless @product_reserved_stock.present?\n @product_reserved_stock = @product.stock_inventories.create!(available: false,\n items_count: 0,\n distribution_center_id:\n @distribution_center.id)\n end\n if @product_available_stock.update_attribute(:items_count,\n @product_available_stock.items_count -\n inventory_stock_params[:items_count]) &&\n @product_reserved_stock.update_attribute(:items_count,\n @product_reserved_stock.items_count +\n inventory_stock_params[:items_count])\n\n response = {message: 'Inventory has been reserved of particular product stock in specified distribution center.'}\n status_code = 200\n else\n response = {errors:\n [{detail: \"We can't apply this operation at this time, please try later.\"}]}\n status_code = 403\n end\n rescue => ex\n response = {errors: [{detail: ex.message}]}\n status_code = 403\n end\n render json: response, status: status_code\n end",
"def reserve(*args)\n @reservations << Reservation.new(self, *args)\n end",
"def confirm_reservations\n puts \"Auta einai ta params\"\n puts params[:user_slice]\n puts params[:reservations].inspect\n\n params[:reservation]\n\n reservations = []\n params[:reservations].each do |element|\n reservations << eval(element) \n end\n\n old_timeslot = false\n reservations.each do |reservation|\n if reservation[\"valid_from\"] <= Time.zone.now.to_s\n old_timeslot = true\n break\n end\n end\n \n if old_timeslot == true\n redirect_to :back\n flash[:danger] = \"Your time is old. Please make a new request.\" \n else\n array_with_reservations = []\n reservations.each do |element|\n\n h = Hash.new\n h = {\"valid_from\" => element[\"valid_from\"], \"valid_until\"=> element[\"valid_until\"], \"resources\"=> [element[\"uuid\"]] }\n if array_with_reservations.length == 0\n array_with_reservations << h\n else\n flag = 0\n array_with_reservations.each do |reservation|\n if reservation[\"valid_from\"] == element[\"valid_from\"] && reservation[\"valid_until\"] == element[\"valid_until\"] && !reservation[\"resources\"].include?(element[\"uuid\"])\n reservation[\"resources\"] << element[\"uuid\"]\n flag =1\n break \n end \n end\n end\n if flag == 0\n array_with_reservations << h\n end\n end\n\n puts array_with_reservations\n\n results_of_reservations = []\n array_with_reservations.each do |reservation|\n results_of_reservations << reserveNode(reservation[\"resources\"],params[:user_slice],reservation[\"valid_from\"],reservation[\"valid_until\"])\n end\n\n flash_msg = []\n results_of_reservations.each do |result|\n if !result.to_s.include?(\"OK\") \n flash_msg << result.to_s \n end\n end \n if flash_msg.length !=0\n flash[:danger] = flash_msg\n else\n flash[:success] = \"Successful reservation!\"\n end\n redirect_to unbound_requests_path\n end \n end",
"def no_other_reservations_on_this_time_period\n item_reservations.each do |ir|\n item = ir.item\n amount_available = item.get_availability(pick_up_time.to_datetime, return_time.to_datetime, id)\n if ir.amount > amount_available\n if amount_available > 0\n errors.add(:items, errors.generate_message(:items, :too_few_available, { :item_title => item.title, :count => amount_available.to_s }))\n else\n errors.add(:items, errors.generate_message(:items, :none_available, { :item_title => item.title }))\n end \n end\n end \n end",
"def reserve\n queue_names = params[:queue_names].split(\",\")\n reservation_details = params[:reservation_details]\n \n Worker.identify( reservation_details, queue_names )\n \n job = JobCommands::JobReservation.new(queue_names: queue_names, reservation_details: reservation_details).perform\n if job.present?\n render_job_as_message(job)\n else\n head status: :not_found\n end\n end",
"def try_to_free_token(tkn, slt)\n\n if slt.reservation_token_id == tkn.id\n slt.reservation_token_id = nil\n slt.save\n\n write_log_entry(\"VAPAUTUS: \", tkn, slt)\n\n return 1\n end\nend",
"def reserveNode(node_ids,account_name,valid_from,valid_until)\n cert_path = APP_CONFIG['cert_path']\n # resernation_name: we set a random name for every reservation constructing by the name of the slice and a random number ex user1/12341234 \n resernation_name =account_name+ \"/\" + (1000 + Random.rand(10000000)).to_s\n puts resernation_name\n \n broker_url = APP_CONFIG['broker_ip'] + ':' + APP_CONFIG['broker_port'].to_s\n\n node_ids.map!{|r| {uuid: r}}\n\n header = {\"Content-Type\" => \"application/json\"}\n options ={\n name: resernation_name,\n valid_from: valid_from,\n valid_until: valid_until,\n account: \n { \n name: account_name\n },\n components: node_ids\n }\n\n #puts options.to_json \n uri = URI.parse(broker_url+\"/resources/leases\")\n pem = File.read(cert_path)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.cert = OpenSSL::X509::Certificate.new(pem)\n http.key = OpenSSL::PKey::RSA.new(pem)\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Post.new(uri.request_uri, header)\n request.body = options.to_json\n\n response = http.request(request)\n \n res = JSON.parse(response.body)\n \n if response.header.code != '200'\n puts \"Something went wrong\"\n puts response \n puts res[\"exception\"][\"reason\"]\n return res[\"exception\"][\"reason\"]\n else\n return \"OK\"\n end\n \n end",
"def instance_unreserve\n if reserve? && instance\n n = reader.update( <<-SQL )\n UPDATE urls\n SET reserved = NULL\n WHERE reserved IS NOT NULL AND\n instance = '#{instance}'\n SQL\n @log.info { \"Unreserved #{n} orders for instance #{instance}\" }\n n\n end\n rescue SQLException => x\n @log.error( \"On instance_unreserve: \", x )\n end",
"def check_guest_into_room(guest)\n if @guests.length < @capacity\n @guests.push(guest)\n # if this was in the bar class would call allocate_excess_guests method at this point\n end\n end",
"def no_own_reservations\n if guest == listing.host\n errors.add(:guest, \"Please select a listing that is not your own\")\n end\n end",
"def reservation_available\n if timeslot_contains_reservations?\n errors.add(:base, I18n.t('reservation.reservation_available'))\n end\n end",
"def test_waiting_list_order\n # @todo don't know yet how to list waiting list\n # @todo original plan was just to have a waitinglist queue and only next is available to view\n puts \"Test under construction: waiting_list_order\"\n end",
"def assign_available_stock\n\n stock_detail, category_occupation = BookingDataSystem::Booking.categories_availability(self.rental_location_code,\n self.date_from,\n self.time_from,\n self.date_to,\n self.time_to,\n nil,\n {\n origin: 'booking',\n id: self.id\n })\n\n #p \"stock_detail: #{stock_detail.inspect}\"\n #p \"category_occupation: #{category_occupation.inspect}\"\n\n transaction do\n booking_lines.each do |booking_line|\n booking_line.booking_line_resources.each do |booking_line_resource|\n if booking_line_resource.booking_item_reference.nil?\n p \"assign_available_stock -- #{booking_line_resource.booking_item_reference} -- available: #{category_occupation[booking_line.item_id][:available_stock].inspect} -- available_assignable: #{category_occupation[booking_line.item_id][:available_assignable_stock].inspect}\"\n if booking_item_reference = category_occupation[booking_line.item_id][:available_assignable_stock].first and !booking_item_reference.nil?\n booking_line_resource.assign_resource(booking_item_reference)\n category_occupation[booking_line.item_id][:available_assignable_stock].delete_at(0)\n end\n end\n end\n end\n\n end\n\n end",
"def existing_reservations?\n !existing_reservations.empty?\n end",
"def fix_train_availables(tlist)\n phase_list = %w[1 2 3]\n phase_list << '3a' if @units[2] && !@kits[3]\n phase_list.concat(%w[4 4a]) if @kits[3]\n tlist.each do |h|\n h.delete(:available_on) if h[:available_on] && !phase_list.include?(h[:available_on])\n end\n end",
"def reservations_exist_in_block\n if timeslot_contains_reservations?\n errors.add(:base, I18n.t('reservation.reservations_exist_in_block'))\n end\n end",
"def slots_available\r\n begin\r\n serverinfo = $ts.command('serverinfo')\r\n res_slots = serverinfo['virtualserver_reserved_slots']\r\n max_clients = serverinfo['virtualserver_maxclients']\r\n clients_online = serverinfo['virtualserver_clientsonline']\r\n max_clients - (res_slots + clients_online)\r\n rescue\r\n puts '[ERROR] problem getting available slots'\r\n raise 'slots_available'\r\n end\r\nend",
"def available; end",
"def available; end",
"def start_accepting\n @res = []\n @in_list_entry = []\n @list = []\n end",
"def avail\n updatePool\n @pool\n end",
"def reserve\n db.transaction do\n if job = waiting.order(:id).last # asc\n job[:started_working_at] = Time.now\n update_job!(job)\n payload = job[:payload].nil? ? nil : Marshal.load(job[:payload])\n EQ::Job.new(job[:id], job[:queue], payload)\n end\n end\n rescue ::Sequel::DatabaseError => e\n retry if on_error e\n end",
"def reserve_room(check_in, check_out)\n dates = date_range(check_in, check_out)\n new_reservation = nil\n @rooms.each do |room|\n if is_available?(room, dates) && is_not_blocked?(room, dates)\n new_reservation = Reservation.new(room, check_in, check_out)\n new_reservation.id = assign_res_id\n @reservations << new_reservation\n break\n end\n end\n if new_reservation != nil\n return new_reservation\n else\n raise StandardError, 'no rooms available in date range'\n end\n end",
"def reserve\n if @submission.followings.count > 0 && @submission.followings.first.user != current_user.sk # Already reserved by somebody else\n f = @submission.followings.first\n @correct_name = f.user.name\n @reservation_date = f.created_at\n @what = 2\n else\n if @submission.followings.count == 0 # Avoid adding two times the same Following\n f = Following.create(:user => current_user.sk,\n :submission => @submission,\n :read => true,\n :kind => 0)\n end\n @what = 3\n end\n \n respond_to do |format|\n format.js\n end\n end",
"def reserve_copies\n copies.count(&:on_reserve?)\n end",
"def process_pending_requests\n puts \"Processing pending requests...\"\n pending_requests = @calendar_network.ricart_agrawala.pending_requests.dup\n pending_requests.each do |pending_request|\n puts \"Processing pending request: \" + pending_request.to_s\n # get earliest local request that has same action on same appointment with\n # with pending request\n earliest_similar_local_request = @calendar_network.ricart_agrawala.earliest_similar_local_request_for(pending_request)\n puts \"Earliest similar local request is: #{earliest_similar_local_request.inspect}\"\n if earliest_similar_local_request == nil ||\n\t pending_request < earliest_similar_local_request\n\t# if no local request exists or pending request initiated before local request\n\t# confirm pending request\n remote_server = xml_rpc_client(pending_request.node.address, @calendar_network.config[\"path\"], \n\t\t\t\t pending_request.node.port)\n\tremote_server.call(\"calendar_network.confirm_request\", pending_request.action, \n\t\t\t pending_request.appointment_id, pending_request.timestamp)\n\t# remove pending request from the list\n\tputs \"Removing the pending_request from the list...\"\n\t@calendar_network.ricart_agrawala.pending_requests.delete(pending_request)\n end\n end\n true\n end",
"def handle_reserve_pressed(room, events)\n # check if should extend reso or make new\n if room.next_start && room.next_end && room.next_start < Time.now && room.next_end > Time.now\n # extend endtime of current event\n puts \"Room #{room.room_name}: Extending current reso\"\n #TODO may wish to extend the event for all attendees as well\n cur_event = events.find{|event| event.start_time == room.next_start && event.title == room.next_desc}\n if cur_event\n cur_event.end_time = get_end_time(cur_event.end_time, room.next_next_start)\n save(cur_event, @cal_service)\n else\n #TODO Unexpected Error\n puts \"Room #{room.room_name}: Couldn't find event #{room.next_desc} at #{room.next_start} reserved by #{room.next_reserved_by}\"\n end\n else\n puts \"Room #{room.room_name}: Creating new reso\"\n # create new reservation\n event = GCal4Ruby::Event.new(@cal_service)\n event.calendar = @roominator_cal\n event.title = Room::EVENT_TITLE\n event.where = room.room_name\n event.start_time = Time.now\n event.end_time = get_end_time(event.start_time, room.next_start)\n event.attendees = [{:name => room.room_name, :email => room.calendar_id, :role => \"Attendee\", :status => \"Attending\"}]\n event.save\n \n events.unshift(event)\n end\n end",
"def create\n @reservation = Reservation.new(reservation_params)\n \n @emailroom = Room.all.find(@reservation.room_id)\n @emaillibrary = Library.select(\"name\").find(@emailroom.library_id)\n @emailemailid = User.all.find(session[:user_id])\n @emailslot = Slot.all.find(@reservation.slot_id)\n if (@emailslot.id >= 4 && @emailslot.id <=45)\n checkslot = [(@emailslot.id - 3),(@emailslot.id - 2),(@emailslot.id - 1),(@emailslot.id),(@emailslot.id + 1),(@emailslot.id + 2), (@emailslot.id + 3)]\n else if (@emailslot.id == 1)\n checkslot = [1, 2, 3, 4, 48, 47, 46]\n else if (@emailslot.id == 2)\n checkslot = [1, 2, 3, 4, 48, 47, 5]\n if (@emailslot.id == 3)\n checkslot = [1, 2, 3, 4, 48, 6, 5]\n if (@emailslot.id == 48)\n checkslot = [1, 2, 3, 45, 48, 47, 46]\n if (@emailslot.id == 47)\n checkslot = [1, 2, 44, 45, 48, 47, 46]\n if (@emailslot.id == 46)\n checkslot = [1, 43, 44, 45, 48, 47, 46]\n end\n end\n end\n end\n end\n end\n end\n if logged_student?\n @anyres = Reservation.select('id').where('reservation_date=?', @reservation.reservation_date).where('user_id=?',@reservation.user_id)\n if (@anyres.count > 0)\n flash[:danger] = \"You already have a booking for #{@reservation.reservation_date}\"\n redirect_to new_reservation_path and return\n end\n end\n @availres = Reservation.select('id').where('room_id=?', @emailroom.id).where('reservation_date=?', @reservation.reservation_date).where(slot_id: checkslot)\n if (@availres.count > 0)\n flash[:danger] = \"room is not available for requested time\"\n redirect_to new_reservation_path\n else\n respond_to do |format|\n if @reservation.save\n \n ReservationMailer.notify_email(@emailroom.room_number, @emaillibrary.name, @emailemailid.email,\n @reservation.reservation_date,\n @emailslot.start_time).deliver_now!\n \n emails=params[:emails]\n values=emails.split(\",\")\n values.each do |value|\n ReservationMailer.notify_email(@emailroom.room_number, @emaillibrary.name, value,\n @reservation.reservation_date,\n @emailslot.start_time).deliver_now!\n end\n \n format.html { redirect_to afterlogin_path, notice: 'Reservation was successfully created.' }\n #format.json { render :show, status: :created, location: @reservation }\n else\n format.html { render :new }\n format.json { render json: @reservation.errors, status: :unprocessable_entity }\n end\n end\n \n end\n end",
"def adapted_scheduling_initial!(partitions)\n bin_index = 0\n full_bins = 0\n partitions.size.times do\n if @list[bin_index].size + partitions.first.size <= @operations_lower_bound\n @list[bin_index].add!([partitions.first])\n partitions.drop!(1)\n\n # Edge case handling for perfect fit\n if @list[bin_index].size == @operations_lower_bound\n full_bins += 1\n @operations_lower_bound -= 1 if full_bins == @list.size - @operations_rounding_adjustment\n end\n\n else\n break\n end\n\n bin_index = (bin_index + 1) % @list.size\n end\n @list = @list.sort\n\n partitions\n end",
"def next_assigned_or_reserved\n Ip.find(:first, :conditions => \n ['address_i > ? AND service = ? and (network_id is not null OR reserved_until is not null)', \n self.address_i, self.service], :order => 'address_i asc')\n end",
"def sitemaps; end",
"def check_in_guest(guest)\n if @guest.count < @capacity\n @guest.push(guest)\n else\n return \"fail no availability try another room\"\n end\n end",
"def create\n @event = Event.find(params[:event_id])\n @user = current_user\n\n if params[:waiting_list]\n # add user to waiting_list\n @reservation = Reservation.new(reservation_params)\n @reservation.status = \"Waiting_List\"\n @reservation.save\n flash[:notice] = \"You will be notified by email if a seat becomes available!\"\n redirect_to event_path @event\n else\n begin\n if params[\"stored_card\"]\n result = Braintree::Transaction.sale(\n amount: params[\"amount\"],\n customer_id: @user.braintree_customer_id\n )\n else\n result = Braintree::Transaction.sale(\n amount: params[\"amount\"],\n credit_card: {\n number: params[\"number\"],\n cvv: params[\"cvv\"],\n expiration_month: params[\"month\"],\n expiration_year: params[\"year\"]\n },\n options: {\n submit_for_settlement: true\n }\n )\n end\n rescue SocketError => e\n logger.info(e)\n end\n\n if result.success?\n @reservation = Reservation.new(reservation_params)\n @reservation.transaction_number = result.transaction.id\n @reservation.update_attribute(:status, \"Completed\")\n @event.update_number_of_available_seats\n @event.save\n flash[:notice] = \"Reservation was successfully created. Transaction ID: #{result.transaction.id}\"\n redirect_to event_path @event\n else\n flash[:notice] = \"Error while processing payment: #{result.message}\"\n redirect_to event_path @event\n end\n end\n end",
"def make_reservation\n \n node_obj = Nodes.new\n hash_details_of_resources = node_obj.get_details_of_resources\n \n # finds which resources are for reservation\n ids = []\n reservations = []\n reservations = params[:reservations]\n # puts \"Autes einai oi krathseis pou thelw na kanw\"\n # puts reservations\n\n # control for empty request for reservation\n reservation_table = []\n if reservations == nil \n redirect_to :back\n flash[:danger] = \"You must select a timeslot to make a reservation. Please try again\" \n else\n\n #control for up to 8 timeslots reservation \n\n hash_num_limition = Hash.new\n reservations.each do |element|\n hash_num_limition[element.split('/')[0]] = 0 \n end\n\n reservations.each do |element|\n hash_num_limition[element.split('/')[0]] = hash_num_limition[element.split('/')[0]]+1\n end\n\n flag_limit = false\n hash_num_limition.each_value do |value|\n if value>8\n flag_limit = true\n break\n end\n end\n\n if flag_limit == true\n redirect_to :back\n flash[:danger] = \"Please choose at most 8 timeslots for every resource.\" \n else\n #control for forgotten timeslots \n old_timeslot = false\n reservations.each do |reservation|\n if reservation.split('/')[1] <= Time.zone.now.to_s[0...-9]\n old_timeslot = true\n break\n end\n end\n \n if old_timeslot == true\n redirect_to :back\n flash[:danger] = \"Please select a time from now on\" \n else\n\n \n # Checks if there is two different dates of reservations (case of 24hours schedule) and keeps the shorter\n reservation_date_num = 0\n reservation_date = \"\"\n reservations.each do |reservation|\n date = reservation.split('/')[1][0...-6]\n if date != reservation_date\n if date < reservation_date && reservation_date != \"\"\n reservation_date = date\n reservation_date_num +=1\n elsif reservation_date == \"\"\n reservation_date = date\n reservation_date_num +=1\n end\n \n end\n end\n\n reservations.each do |reservation|\n if !ids.include?(reservation.split('/')[0])\n ids << reservation.split('/')[0]\n end\n end\n\n puts \"reservation_date_num\"\n puts reservation_date_num\n\n # constructs a table with the reservations. 1 for selected timeslot and 0 for non-selected\n if reservation_date_num >= 2 || reservation_date == Time.zone.today.to_s\n\n today = Time.zone.today.to_s\n tomorrow = (Time.zone.today + 1.day).to_s\n time_now = Time.zone.now.to_s.split(\" \")[1][0...-3]\n\n #Upologismos gia sthles\n columns = Array.new(48)\n columns[0]= \"Name\"\n (0..47).each do |n|\n if (n % 2 == 0) \n columns[n+1] = \"#{n<20 ? \"0#{n / 2}\" : n / 2}:00\"\n else\n columns[n+1] = \"#{n<20 ? \"0#{n / 2}\" : n / 2}:30\"\n end\n end\n\n today_and_tommorow_columns = []\n today_and_tommorow_columns << \"Name\"\n\n columns.each do |element|\n if element > time_now && element != \"Name\"\n today_and_tommorow_columns << today + \" \" + element \n end\n end\n\n columns.each do |element|\n if element <= time_now && element != \"Name\" \n today_and_tommorow_columns << tomorrow + \" \" + element\n end\n end\n\n #Upologismos gia rows\n rows = Array.new(ids.length){Array.new(49,0)}\n rows.each_index do |i|\n rows[i][0] = ids[i]\n end\n\n reservation_table = rows.map{|r| Hash[ *today_and_tommorow_columns.zip(r).flatten ] }\n else\n ids.each_index do |i|\n h = Hash.new\n r_name = ids[i]\n h[\"Name\"] = r_name\n (0..47).each do |n|\n if (n % 2 == 0) \n h[\"#{reservation_date}#{n<20 ? \" 0#{n / 2}\" : \" #{n / 2}\"}:00\"] = 0\n else\n h[\"#{reservation_date}#{n<20 ? \" 0#{n / 2}\" : \" #{n / 2}\"}:30\"] = 0\n end\n end\n #if the last half hour of a day selected, we reserve a node until \"23:59\" \n h[reservation_date + \" 23:59\"] = 0\n reservation_table << h\n end\n end\n #Sumplhrwnw o kathe hash me tis krathseis \n reservation_table.each do |element|\n reservations.each do |reservation|\n if reservation.split('/')[0] == element[\"Name\"]\n element[reservation.split('/')[1]] =1\n end\n end\n end\n puts ids\n\n \n # array_with_reservations: table filled with hashes of the reservations to be done \n array_with_reservations = []\n num = 0\n #Compute valid_from and valid_until for each reservation request \n valid_from = \"\"\n valid_until = \"\"\n puts \"Auto einai to reservation table afou to gemisw\"\n puts reservation_table.inspect\n reservation_table.each do |element|\n element.each do |key,value|\n #puts key\n #puts value\n if num ==0\n if value ==1\n #puts \"mpika \"\n valid_from = key\n #puts valid_from\n num += 1\n end\n else \n if value ==0\n valid_until = key\n #stelnw krathsh \n #element[\"Name\"]\n\n valid_from = valid_from + \":00 \" #+ Time.zone.now.to_s.split(' ')[2]\n valid_from = Time.zone.parse(valid_from)\n valid_until = valid_until + \":00 \" #+ Time.zone.now.to_s.split(' ')[2]\n valid_until = Time.zone.parse(valid_until)\n #reserveNode(node_list_uuids[element[\"Name\"]],params[:user_slice],valid_from,valid_until)\n \n h = Hash.new\n h = {\"valid_from\" => valid_from, \"valid_until\"=> valid_until, \"resources\"=> [hash_details_of_resources[element[\"Name\"]][\"uuid\"]] }\n if array_with_reservations.length == 0\n array_with_reservations << h\n else\n flag = 0\n array_with_reservations.each do |reservation|\n if reservation[\"valid_from\"] == valid_from && reservation[\"valid_until\"] == valid_until && !reservation[\"resources\"].include?(hash_details_of_resources[element[\"Name\"]][\"uuid\"])\n reservation[\"resources\"] << hash_details_of_resources[element[\"Name\"]][\"uuid\"]\n flag =1\n break \n end\n end\n if flag == 0\n array_with_reservations << h\n end\n end\n puts \"Tha kanw krathsh me valid_from\"\n puts valid_from\n puts \"kai valid_until\"\n puts valid_until\n # puts \"Gia ton \"+element[\"Name\"] + \"me uuid=\" + @node_list_uuids[element[\"Name\"]]\n num = 0\n end\n end\n end\n end\n puts \"\"\n puts \"Auto einai to array me ta reservation pou prepei na ginoun\"\n puts array_with_reservations\n\n # Making reservations\n results_of_reservations = []\n array_with_reservations.each do |reservation|\n results_of_reservations << reserveNode(reservation[\"resources\"],params[:user_slice],reservation[\"valid_from\"],reservation[\"valid_until\"])\n end\n \n flash_msg = []\n results_of_reservations.each do |result|\n if !result.to_s.include?(\"OK\") \n flash_msg << result.to_s \n end\n end \n if flash_msg.length !=0\n flash[:danger] = flash_msg\n else\n flash[:success] = \"Successful reservation!\"\n end\n redirect_to :back \n end\n\n end\n\n \n end \n end",
"def reserved; end",
"def free_slots_bikes\n uPos = params[:pos]\n foundSt = false\n destStation = \"\"\n if params[:query] == \"slot\"\n #what to search for like slots or bikes on a station\n what = \"empty_slots\"\n else\n what = \"free_bikes\"\n end\n stationList = get_stationList(uPos)\n for station in stationList\n if station[what] != 0\n destStation = station[\"name\"]\n foundSt = true\n break\n end\n end\n response = {:success => foundSt, :destStation => destStation}\n respond_to do |format|\n format.json {render :json => response, status: 200}\n end\n end",
"def process_listing_nodes(listings)\n listings.each_with_index do |hash, index|\n id = hash[:vendor_id]\n sku = hash[:vebdor_sku]\n vendor_sku = hash[:vendor_sku]\n vendor_url = hash[:vendor_url]\n next if Listing.data_present?(vendor_sku, 'wayfair')\n puts \"=== starting id: #{id} \\\n | sku: #{sku} \\\n | iteration: #{index}\"\n Listing.append_wayfair_url(\n vendor_sku,\n vendor_url)\n Listing.append_vendor_attrs(\n vendor_sku,\n hash)\n end\n end",
"def allocateBySATforEachDemand(demand)\n selfDefnWeightsArray = Array.new();\n nofBus = @simulator.savList.size();\n acceptedSizeArray = Array.new();\n allPairsHashArray = Array.new();\n deadlineArray = Array.new();\n # Anonymous1 04/02 -> extension for the case of (one demand n-passengers) via 'pickDropArray'\n pickDropArray = Array.new();\n # Anonymous1 04/09 -> number of carried\n nofCarried = Array.new();\n newDemandSize = 1;\n capacityArray = Array.new();\n tmpArray = Array.new();\n tmpHash = Hash.new();\n # for dealing with the capacity's inconsistency of dummyPoint\n busIDArrayWhoseBusIncludeDummy = Array.new();\n @simulator.savList.each{|sav|\n #sav.clearDummyViaPointsInTail();\n if sav.viaPointList.size()-1 > sav.viaPointIndex && sav.viaPointList.size() >= 2\n for i in sav.viaPointIndex..sav.viaPointList.size()-2\n if sav.viaPointList[sav.viaPointIndex].mode != :dummy && sav.viaPointList[i].mode == :dummy\n puts \"caught you!\";\n sav.viaPointList.delete_at(i);\n end\n end\n end\n for i in sav.viaPointIndex..sav.viaPointList.size()-1\n if sav.viaPointList[i].mode == :dummy\n busIDArrayWhoseBusIncludeDummy.push(1);\n break;\n elsif i == sav.viaPointList.size()-1 && sav.viaPointList[i].mode != :dummy\n busIDArrayWhoseBusIncludeDummy.push(0);\n end\n end\n tmpArray.clear();\n tmpArray.push(sav.fetchPosition());\n acceptedSizeArray.push(sav.viaPointList.size()-sav.viaPointIndex);\n for i in sav.viaPointIndex..sav.viaPointList.size()-1\n tmpArray.push(sav.viaPointList[i]);\n end\n tmpHash.clear();\n for i in 1..tmpArray.size()-1\n if tmpArray[i].mode == :pickUp\n for j in i+1..tmpArray.size()-1\n if tmpArray[i].demand == tmpArray[j].demand && tmpArray[j].mode == :dropOff\n tmpHash.store(j-1, i-1);\n break;\n end\n end\n end\n end\n allPairsHashArray.push(tmpHash.clone());\n tmpArray.push(demand.tripViaPoint.pickUp);\n tmpArray.push(demand.tripViaPoint.dropOff);\n for i in 1..tmpArray.size()-1\n if tmpArray[i].mode == :dropOff\n deadlineArray.push((1*(tmpArray[i].demand.tripRequiredTime.dropOff)).to_i);\n pickDropArray.push((-1*(tmpArray[i].demand.numPassenger)).to_i);\n elsif tmpArray[i].mode == :pickUp\n deadlineArray.push(0);\n pickDropArray.push((1*(tmpArray[i].demand.numPassenger)).to_i);\n elsif tmpArray[i].mode == :dummy\n deadlineArray.push(0);\n pickDropArray.push(0);\n end\n end\n nofCarried.push(sav.countNumOnBoard());\n for i in 1..tmpArray.size()-1\n for j in 0..tmpArray.size()-1\n selfDefnWeightsArray.push((1+1*(estimateTime(tmpArray[j], tmpArray[i], sav, :averageManhattan))).to_i);\n end\n end\n capacityArray.push(sav.capacity);\n if sav.countNumOnBoard() > sav.capacity\n #puts \"error numOnBorad: #{sav.countNumOnBoard()}\";\n #exit;\n end\n }\n #puts \"selfDefnWeightsArray: #{selfDefnWeightsArray}\";\n #puts \"nofBus: #{nofBus}\";\n #puts \"acceptedSizeArray: #{acceptedSizeArray}\";\n #puts \"allPairsHashArray: #{allPairsHashArray}\";\n #puts \"deadlineArray: #{deadlineArray}\";\n #puts \"pickDropArray: #{pickDropArray}\";\n #puts \"newDemandSize: #{newDemandSize}\";\n #puts \"capacityArray: #{capacityArray}\";\n encodingDone = false;\n if (nofBus * newDemandSize != 0) \n #wcnfGen(selfDefnWeightsArray, nofBus, acceptedSizeArray, allPairsHashArray, deadlineArray, newDemandSize, capacityArray);\n #runMaxSATSolver = \"../../encodedProblem/qmaxsat_g3 -cpu-lim=10 -card=mrwto -pmodel=0 -incr=1 ../../encodedProblem/test.wcnf ../../encodedProblem/externality.txt ../../encodedProblem/answer.txt > ../../encodedProblem/log.txt\";\n # for NCC\n encodingDone = wcnfGenNcc(selfDefnWeightsArray, nofBus, acceptedSizeArray, allPairsHashArray, deadlineArray, newDemandSize, capacityArray, busIDArrayWhoseBusIncludeDummy,pickDropArray,nofCarried);\n runMaxSATSolver = \"../../encodedProblem/qmaxsatNcc_g3 -cpu-lim=10 -card=mrwto -pmodel=0 -incr=1 ../../encodedProblem/test.wcnf ../../encodedProblem/externality.txt ../../encodedProblem/answer.txt > ../../encodedProblem/log.txt\";\n clearPreviousAns = \"rm ../../encodedProblem/answer.txt\";\n if encodingDone \n system(runMaxSATSolver);\n else\n system(clearPreviousAns);\n end\n end\n \n if encodingDone\n maxSATans = IO.readlines(\"../../encodedProblem/answer.txt\");\n else\n maxSATans = Array.new();\n maxSATans.push(\"UNSAT\");\n maxSATans.push(\"noEncodedProblem\");\n end\n if encodingDone && maxSATans[0].include?(\"OPT\") && maxSATans[1] != nil\n allocatedViaPointList = Array.new();\n tmpAnsReadLine = Array.new();\n busID = maxSATans[1].to_i;\n updateFlag = false;\n sav = @simulator.savList[busID-1];\n tmpAnsReadLine = maxSATans[2].split(\" \").map{|str| str.to_i};\n if sav.viaPointIndex == sav.viaPointList.size()\n for i in 0..sav.viaPointList.size()-1\n allocatedViaPointList.push(sav.viaPointList[i]);\n end\n for i in 1..tmpAnsReadLine.size()-1\n updateFlag = true;\n if ( (tmpAnsReadLine[i]-(acceptedSizeArray[busID-1]))%2 == 0 ) # pickUp\n allocatedViaPointList.push( demand.tripViaPoint.pickUp );\n else # dropOff\n allocatedViaPointList.push( demand.tripViaPoint.dropOff );\n end\n end\n elsif acceptedSizeArray[busID-1]+1 < tmpAnsReadLine.size()\n for i in 0..sav.viaPointIndex\n allocatedViaPointList.push(sav.viaPointList[i]);\n end\n for i in 2..tmpAnsReadLine.size()-1\n updateFlag = true;\n if (tmpAnsReadLine[i] > acceptedSizeArray[busID-1]+1)\n if ( (tmpAnsReadLine[i]-(acceptedSizeArray[busID-1]+1))%2 == 1 ) # pickUp\n allocatedViaPointList.push( demand.tripViaPoint.pickUp );\n else # dropOff\n allocatedViaPointList.push( demand.tripViaPoint.dropOff );\n end\n else\n allocatedViaPointList.push(sav.viaPointList[ sav.viaPointIndex+tmpAnsReadLine[i]-2 ]);\n end\n end\n end\n if ( updateFlag )\n tmpViaPointIndex = sav.viaPointIndex;\n sav.viaPointList.clear();\n #for i in 0..allocatedViaPointList.size()-1\n # sav.viaPointList.push(allocatedViaPointList[i]);\n #end\n for i in 0..allocatedViaPointList.size()-1\n if i <= tmpViaPointIndex || allocatedViaPointList[i].mode != :dummy\n sav.viaPointList.push(allocatedViaPointList[i]);\n else\n puts \"planned route includes dummyViaPoint (NOT FIRST POINT)!\";\n end\n end\n \n viaPointIndex = sav.viaPointIndex ;\n prevPos = sav.fetchPosition() ;\n currentTime = @simulator.currentTime ;\n (viaPointIndex...sav.viaPointList.size).each{|idx|\n viaPoint = sav.viaPointList[idx] ;\n diffTime = estimateTime(prevPos, viaPoint, sav, :averageManhattan) ;\n currentTime += diffTime ;\n\n # store new plan\n if(true) then\n if(viaPoint.mode == :pickUp) then\n viaPoint.demand.updatePlannedPickUpTime(currentTime) ;\n elsif(viaPoint.mode == :dropOff) then\n viaPoint.demand.updatePlannedDropOffTime(currentTime) ;\n end\n end\n\n prevPos = viaPoint.pos ;\n }\n \n sav.assignedDemandList.push(demand) ;\n sav.clearDummyViaPointsInTail();\n demand.sav = sav ;\n \n #@simulator.savList[busID-1] = sav;\n\n pushAllocatedDemand( demand ) ;\n end\n\n else #if maxSATans[0].include?(\"UNSAT\") || !encodingDone\n if maxSATans[1] != nil\n if maxSATans[1].include?(\"exceeDeadline\")\n puts \"UNSAT (reason: exceeDeadline)\";\n demand.cancel(@simulator, :exceedDropOffTime);\n elsif maxSATans[1].include?(\"exceedCapacity\")\n puts \"UNSAT (reason: exceedCapacity)\";\n demand.cancel(@simulator, :exceedCapacity);\n elsif maxSATans[1].include?(\"noEncodedProblem\")\n puts \"UNSAT (reason: noEncodedProblem)\";\n demand.cancel(@simulator, :notAssigned);\n else\n puts \"UNSAT (reason: searchTimeout)\";\n demand.cancel(@simulator, :notAssigned);\n end\n else\n puts \"Unknown reason\";\n demand.cancel(@simulator, :notAssigned);\n #exit;\n end\n pushCancelledDemand( demand ) ;\n end\n \n sumOFinished = 0;\n @simulator.savList.each{|sav|\n for i in 0..sav.viaPointIndex-1\n if sav.viaPointList[i] != nil && sav.viaPointList[i].mode == :dropOff\n sumOFinished += 1;\n end\n end\n }\n puts \"sumOFinished : #{sumOFinished} | timeCost : #{@simulator.currentTime}\";\n if @simulator.currentTime >= 44000\n puts \"Finished time : #{@simulator.currentTime}\";\n exit;\n end\n \n end",
"def original_scheduling_initial!(partitions)\n # Phase 1: Sort partitions by sites.size\n partitions.sort_by_sites!\n\n # Phase 2: Initial filling\n bin_assigner = 0\n full_bins = 0\n partitions.size.times do\n if @list[bin_assigner].total_sites + partitions.first.sites.size <= @sites_lower_bound\n @list[bin_assigner].add!([partitions.first])\n partitions.drop!(1)\n\n # Edge case handling for perfect fit\n if @list[bin_assigner].total_sites == @sites_lower_bound\n full_bins += 1\n @sites_lower_bound -= 1 if full_bins == @list.size - @sites_rounding_adjustment\n end\n\n else\n break\n end\n\n bin_assigner = (bin_assigner + 1) % @list.size\n end\n partitions\n end",
"def ensure_seat_is_free\n\t\tseat=Seat.find(seat_id)\n\t \tunless(seat.reservation==nil)\n\t \t\tself.errors.add(:alert, \"Seat is already taken!\")\n\t \tend\n\tend",
"def reserve(requirements)\t\t\n\t\t#Check if we have a non-kosher floor and revert to default\n\t\trequirements['floor'] = \"\" if !(requirements['floor'].nil?) and \n\t\t\t!([\"\", \"F\", \"G\", \"2\", \"3\"].include? requirements['floor'])\n\t\t\n\t\t#Default args\n\t\tdefault_options = {'floor' => \"\", 'start_time' => Time.now, 'duration' => 90}\n\t\targs = default_options.merge(requirements)\n\t\t\n\t\t#Convert start_date and start_time from date and time to correct form format\n\t\tstart_time = args['start_time'].format_start_time\n\t\tstart_date = args['start_time'].format_start_date\n\t\t\n\t\t#Duration logic - round to 30, 60, or 90 (nearest)\n\t\tunless requirements['duration'].nil?\n\t\t\tif args['duration'] <= 30\n\t\t\t\targs['duration'] = 30\n\t\t\telsif args['duration'] <= 60\n\t\t\t\targs['duration'] = 60\n\t\t\telse\n\t\t\t\targs['duration'] = 90\n\t\t\tend\n\t\tend\n\t\t\n\t\tagent = spike_login()['agent'] # Mechanize agent at successful login page\n\t\tgsr = spike_login()['gsr'] # Mechanize page = successful login page\n\t\tgsrform = gsr.form_with(:action => 'https://spike.wharton.upenn.edu/m/gsr.cfm') #Select GSR form\n\n\t\t#Input GSR info\n\t\tgsrform.preferred_floor = args['floor']\n\t\tgsrform.start_date = start_date\n\t\tgsrform.start_time = start_time\n\t\tgsrform.duration = args['duration']\n\t\t\n\t\t#Submit reservation\n\t\tsubmit = agent.submit(gsrform, gsrform.buttons.first)\n\t\t\n\t\t#Check if successful\n\t\traise \"Error reserving GSR. Check supplied parameters.\" if submit.link_with(:text => 'Cancel').nil?\n\t\t\n\tend",
"def freeup(req)\n if req.status != \"ALLOCATED\"\n $Logger.error \"Internal error. Trying to release unallocated request for #{req.reqid}\"\n return\n end\n \n # Find the pool and restore the capacity\n match = @poolList.select{|p| p.name == req.pool }\n if match == nil || match[0] == nil\n $Logger.error \"Internal error. No matching pool found for #{req.reqid}\"\n return\n end\n pool = match[0]\n pool.availvcpus = pool.availvcpus.to_i + req.vcpus.to_i\n pool.availmem = pool.availmem.to_i + req.mem.to_i\n # Adjust the limit counters for the service\n match = @svcList.select{|s| s.name == req.service}\n if match == nil || match[0] == nil\n $Logger.error \" No matching service #{req.service} found for #{req.reqid}\"\n end\n service = match[0]\n service.vcpusallocated = service.vcpusallocated.to_i - req.vcpus.to_i\n service.memallocated = service.memallocated.to_i - req.mem.to_i\n req.status = \"RELEASED\"\n $eventProcessor.updateRequest(req)\n end",
"def scan_in(passenger)\n raise \"Not enough credit\" if passenger.credit < 2\n raise \"The station is full\" if passenger_count == DEFAULT_CAPACITY_PASSENGERS\n passengers << passenger \n end",
"def reserve_room(start_date, end_date) \n \n current_room = ()\n if @reservation_list.empty? == true\n current_room = rooms.shift\n elsif @reservation_list.empty? == false\n @reservation_list.include?(start_date)\n count = @reservation_list.count(start_date)\n current_room = rooms[count - 1]\n end\n \n \n room = current_room\n range = Hotel::DateRange.new(start_date, end_date)\n start_date = range.start_date\n end_date = range.end_date\n nights = range.nights\n \n # if the range has overlapping dates, then it will return true\n # if the range returns true \n \n reservation = Reservation.new(start_date, end_date, nights, room)\n \n # if @reservations_list.overlap?(range)\n # raise ArgumentError.new\n # end\n \n @reservation_list << reservation\n return reservation\n end",
"def return_to_reserve()\n for i in @actors\n if i != nil && !$game_actors[i].party_locked\n $game_faction.add_reserve_actor(i)\n end\n end\n @actors = []\n @actor_positions = []\n end",
"def start_accepting\n @res = \"\"\n @in_list_entry = []\n end",
"def create\n @tool = Tool.friendly.find(params[:tool_id])\n @booking = @tool.bookings.build(booking_params)\n if @booking.save\n cont = 0 #this variable and the following loop have the same purpose that in 'avaiable' method\n @tool.bookings.where('end_date >= ? AND confirmed = ? AND lab_id = ?', Time.now, true, @booking.lab_id).each do |b| # for simplify the procedure, the system check only reservations that are already confirmed\n if (@[email protected]_date).overlaps?(b.start_date..b.end_date)\n cont = cont + b.quantity\n end\n end\n cont = cont + @booking.quantity\n quantity_tool = @tool.labs_tools.where(\"lab_id = ?\", @booking.lab_id).first.quantity\n if cont > quantity_tool\n max = quantity_tool - cont + @booking.quantity\n if max == 1\n flash[:danger]=\"#{t('.looking')} #{max} #{t('bookings.avaiable.tool')}\"\n else\n flash[:danger]=\"#{t('.lookings')} #{max} #{t('bookings.avaiable.tools')}\"\n end\n @booking.destroy\n redirect_to tool_path(@tool)\n else #if the booking are not in conflict with other confirmated resarvations, the system create a new booking entity\n\n BookingControlJob.set(wait_until: @booking.start_date.to_datetime).perform_later(@booking) #if the booking are not confirmed before the start date, is unuseful store it in the database\n if @tool.fast_booking == true\n flash[:success]=t('.fast_booking_true')\n @booking.confirmed = true\n @booking.save\n LabMailer.new_booking(@booking).deliver_now #this email notify at the prof that his booking was confirmed\n ProfMailer.confirmed_booking(@booking.prof, @booking).deliver_later\n else\n flash[:success]=t('.fast_booking_false')\n AdminMailer.with(booking: @booking, prof: @booking.prof).new_booking.deliver_later #this email notify at the admin that a new booking was created\n end\n redirect_to tool_path(@tool)\n end\n else\n flash[:danger] = @booking.errors.full_messages\n redirect_to tool_path(@tool)\n end\n end",
"def starting_status\n if entry_limit && status == 'Open'\n 'Requested'\n else\n if entry_limit &&\n entries_entered.size + entries_requested.size + entries_to_be_confirmed.size >= entry_limit\n 'Waiting List'\n else\n 'Entered'\n end\n end\n end",
"def prepare_all\n reservations = []\n @items.each do |id, quantity|\n quantity.times do\n reservations << Reservation.new(reserver: reserver,\n start_date: @start_date,\n due_date: @due_date,\n equipment_model_id: id)\n end\n end\n reservations\n end",
"def sell_pending\n end",
"def next_availability\n if job = jobs.detect { |k, v| v['reserved_at'].nil? }\n job.first\n end\n end",
"def available?(reservations = [])\n return true if self.class == Reservation && self.status != 'reserved'\n all_res = reservations.dup\n all_res << self if self.class != Reservation\n all_res.uniq!\n eq_objects_needed = same_model_count(all_res)\n if equipment_model.num_available(start_date, due_date) < eq_objects_needed\n errors.add(:base, equipment_model.name + \" is not available for the full time period requested.\\n\")\n return false\n end\n return true\n end",
"def print_reservations\n puts \"We do not share our clients info!\"\n puts \"At least for free....\"\n end",
"def available_time_slot date_of_booking\n\t\tif date_of_booking.gsub(/[-]+/,\"\").to_i != Time.zone.now.strftime(\"%Y%m%d\").to_i\n\t\t\tresource_slot = self.timeslots\n\t\t\tif self.bookings.where(date_of_booking:date_of_booking).where(status:1)\n\t\t\t\tbookings_of_day = self.bookings.where(date_of_booking: date_of_booking).where(status:1)\n\t\t\t\tbookings_of_day.each do |x|\n\t\t\t\t\tresource_slot.delete_at(x.slot)\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tresource_slot = next_time_slots\n\t\tend\n\t\tresource_slot\n\tend",
"def reserved?\n status == Status::RESERVED\n end",
"def allocateOne(demand, savList)\n bestSav = nil ;\n bestTripIndex = nil ;\n bestAllocScore = nil ;\n violateReason = [] ;\n #counter = 0; # Anonymous1 20190114\n #bestSavIdx = 0; # Anonymous1 20190114\n start_time = Time.now();\n\n savList.each{|sav|\n savViolateReason = [] ;\n currentIndex = sav.viaPointIndex ;\n maxIndex = sav.viaPointList.size() ;\n (currentIndex..maxIndex).each{ |i|\n pickUpIndex = i - currentIndex ;\n (i..maxIndex).each{ |j|\n dropOffIndex = j - currentIndex ;\n tripIndex = Trip.new(pickUpIndex, dropOffIndex) ;\n allocScore =\n estimateTimeForNewRoute(sav, demand, tripIndex, false) ;\n\n ## collect violate reason\n if(allocScore[:violateReason].nil?) then\n savViolateReason = nil ;\n elsif(!savViolateReason.nil?) then\n reason = allocScore[:violateReason] ;\n if(!savViolateReason.include?(reason)) then\n savViolateReason.push(reason)\n end\n end\n \n if(compareScore(bestAllocScore, allocScore)) then\n #bestSavIdx = counter; # Anonymous1 20190114\n bestSav = sav ;\n bestTripIndex = tripIndex ;\n bestAllocScore = allocScore ;\n end\n }\n }\n if(savViolateReason) then\n savViolateReason.each{|reason|\n violateReason.push(reason) if(!violateReason.include?(reason));\n }\n end\n \n #counter += 1; # Anonymous1 20190114\n if Time.now() - start_time >= 10\n break;\n end\n }\n \n allocateDemandToSav(demand, bestSav, bestTripIndex, violateReason) ;\n \n # Anonymous1 20190128\n nofMax = 65534;\n nofInst = 1;\n for i in 2..nofMax+1\n if File.exist?(\"../../expDir/seqOpTime/test_#{nofInst}.time\")\n if i == nofMax+1\n exit\n end\n nofInst = i;\n end\n end\n timeFile = File.new(\"../../expDir/seqOpTime/test_#{nofInst}.time\", \"w+\");\n timeFile.syswrite(\"seqOpTime #{nofInst} : #{Time.now() - start_time}\");\n \n sumOFinished = 0;\n @simulator.savList.each{|sav|\n for i in 0..sav.viaPointIndex-1\n if sav.viaPointList[i] != nil && sav.viaPointList[i].mode == :dropOff\n sumOFinished += 1;\n end\n end\n }\n puts \"sumOFinished : #{sumOFinished} | timeCost : #{@simulator.currentTime}\";\n if @simulator.currentTime >= 44000\n puts \"Finished time : #{@simulator.currentTime}\";\n exit;\n end\n \n return bestSav ;\n end",
"def mark_for_hot_list\n if self.is_available_for_hot_list\n return self.update_attribute(:added_to_hot_list, Time.now)\n end\n return false\n end",
"def reserve!\n memory_map.transform_values! { |_| RESERVED }\n end",
"def provision!; end",
"def my_reservations\n @slices = []\n @slices = getSlices\n puts @slices.inspect\n @my_reservations = Hash.new\n if @slices.length != 0 \n @slices.each do |slice|\n this_slice_leases = []\n this_slice_leases = getLeasesBySlice(slice) \n #Sort my slices by valid_from\n this_slice_leases = this_slice_leases.sort_by{|hsh| hsh[\"valid_from\"]}\n @my_reservations[slice] = this_slice_leases \n # puts \"my reservations \"\n # puts @my_reservations.inspect\n end\n end\n end",
"def blocklisted_response; end",
"def select_reservation\n end",
"def reserveRoom(date, time, scheduleTable)\n j=0\n reservedRooms = []\n while j < scheduleTable.size\n if date == scheduleTable[j][\"Date\"] && time == scheduleTable[j][\"Time\"] && self.building == scheduleTable[j][\"Building\"] && self.roomNum == scheduleTable[j][\"Room\"]\n scheduleTable[j][\"Available\"] = \"false\"\n end\n j+=1\n end\n end",
"def planning_work\n self.planned_at = Time.now\n self.unfreeze_request! if self.frozen?\n self.push_msg\n end",
"def allocate_drench\n return if authorise_for_web(program_name?, 'delivery_edit')==false\n\n #test if drenching is allowed\n @del_track = DeliveryTrackIndicator.find_by_sql(\"select * from delivery_track_indicators where delivery_id=#{session[:new_delivery].id} order by id ASC\")[0] #delivery_id_and_track_indicator_type_code(session[:new_delivery].id, \"LOB\")\n if @del_track && @del_track.track_variable_1 == true\n #test for drench allocation\n @drench_route_step = DeliveryRouteStep.find_by_route_step_code_and_delivery_id(\"drench_allocation_complete\", session[:new_delivery].id)\n @dry_route_step = DeliveryRouteStep.find_by_route_step_code_and_delivery_id(\"dry_line_allocated\", session[:new_delivery].id)\n if @drench_route_step\n if (!@dry_route_step)\n flash[:error]= \"dry_line_allocated route step is missing for this delivery\"\n @freeze_flash = false\n render_existing_new_delivery\n elsif (@drench_route_step.date_completed==nil && @dry_route_step.date_completed==nil)\n session[:drench_delivery] = nil if session[:drench_delivery]!= nil\n session[:drench_delivery] = Hash.new\n session[:drench_delivery][:delivery_id] = session[:new_delivery].id\n @drench_line_codes = DrenchLine.find_by_sql(\"select distinct drench_line_code from drench_lines\").map { |g| [g.drench_line_code] }\n @drench_line_codes.unshift([\"<empty>\"])\n render :template => 'rmt_processing/delivery/allocate_drench.rhtml', :layout => 'content'\n #render_allocate_drench\n else\n flash[:error]= \"Drench allocation was already done for this delivery\"\n @freeze_flash = false\n render_existing_new_delivery\n end\n else\n flash[:error]= \"drench_allocation_complete route step is missing for this delivery\" #\"Delivery has not been set for drenching!\"\n @freeze_flash = false\n render_list_deliveries\n end\n else\n flash[:error]= \"Drenching is not allowed for this delivery. Check Track_Variable_1 of LOB indicator!\"\n @freeze_flash = false\n# render_list_deliveries\n redirect_to_index()\n end\n end",
"def reserve # Start Ride\n return render json: { error: \"This bike is not available to reserve\" }, status: :forbidden unless @bike.available?\n begin\n ActiveRecord::Base.transaction do\n @bike.current_ride = Ride.build_from_user_bike(@user, @bike)\n @bike.reserved!\n case params[:payment_type]\n when \"subscription\"\n render json: { error: \"Subscription has not been implemented yet\" }, status: :bad_request\n raise ActiveRecord::Rollback\n when \"prepay\"\n @user.validates_payment_and_good_standing\n @bike.current_ride.trans = Transaction.charge_user_for_ride(@user, @bike.current_ride, \"prepay\")\n else # :per_minute\n # put pay_per_minute logic here\n end\n @bike.save!\n\n print \"Reserved Bike #{@bike.id} - scheduling bike-reserved-email\"\n puts Time.now\n minutes = 5\n delay = \"#{minutes}m\"\n Rufus::Scheduler.singleton.in delay do\n if (Ride.find(@bike.current_ride.id).progress?)\n ApplicationMailer.bikes_been_reserved_for(minutes, @user, @bike.id).deliver_now\n print \"Sent email \"\n puts Time.now\n end\n end\n\n end\n rescue User::PaymentMethodException, User::BraintreeException => e\n render json: { error: e.message }, \n status: :payment_required, \n location: api_new_payment_path\n rescue User::NotInGoodStandingException => e\n render json: { error: e.message }, \n status: :forbidden, \n location: api_collections_path\n rescue ActiveRecord::RecordInvalid => e\n render :json => { :error => e.message }, \n status: :unprocessable_entity\n rescue Transaction::Rejected => e\n render :json => { :error => e.message }, \n status: :bad_request\n else\n render json: {bike: @bike.to_json({methods: :code}), transction: @bike.current_ride.trans}\n end\n end",
"def reserved_items=(reserved_items)\n reserved_items.each do |id, amount|\n item_reservations.build(:item_id => id, :amount => amount)\n end\n end",
"def touch_in(station)\n deduct(PENALTYFARE) if @in_joureny == true\n min_balance? ? (fail \"insufficent funds\") : @the_journey.start(station)\n @in_journey = true\n end",
"def start_accepting\n @res = \"\"\n @in_list_entry = []\n end",
"def initial_hiring\n 6.times do\n @people_currently_working << @waiting_list.shift\n end\n puts \"Congratulations to those who were hired from our waiting list pool! In three months, we will determine who gets to move into a job and who needs to (temporarily) leave! Here is the starting list of workers!\"\n ap @people_currently_working\n end",
"def start_special_list(list_type)\n end",
"def set_reserved\n @reserved = Reserved.find(params[:id])\n end",
"def reserve_within_block(block_id)\n selected_block = @room_blocks.find { |block| block.id == block_id}\n new_reservation = nil\n dates = date_range(\"#{selected_block.check_in_date}\", \"#{selected_block.check_out_date}\")\n\n selected_block.collection_rooms.each do |room_blocked|\n check_room = @rooms.find { |room| room == room_blocked }\n if is_available?(check_room, dates)\n new_reservation = Reservation.new(check_room, \"#{selected_block.check_in_date}\", \"#{selected_block.check_out_date}\")\n new_reservation.id = assign_res_id\n @reservations << new_reservation\n break\n end\n end\n\n if new_reservation != nil\n return new_reservation\n else\n raise StandardError, 'no rooms available in block'\n end\n end",
"def check_allocation\n if marked_for_destruction? and !candidates.count.zero?\n errors.add(:base, \"CANNOT DELETE BATCH\")\n end\n end",
"def create_starting_restrictions\n restrictions << BeforeOpenRestriction.create(:offering => self)\n restrictions << PastDeadlineRestriction.create(:offering => self)\n end",
"def bookEvent userid, eventid, qty\n spec = EventSpecificationCatalogue.instance.getByID(eventid)\n \n qty = qty.to_i\n \n p spec \n\n if spec.Capacity < qty\n @SocketHandle.puts \"Not enough spaces\" \n else\n @SocketHandle.puts \"Booked event\"\n BookingCatalogue.instance.createBooking(userid,eventid,qty)\n spec.Capacity -= qty\n end\n\n @SocketHandle.puts \"safeguard\" \n end",
"def assign_available_slots(teams_bidding_info)\n teams_bidding_info.each do |tb|\n tb[:bids].each do |bid|\n topic_id = bid[:topic_id]\n num_of_signed_up_teams = SignedUpTeam.where(topic_id: topic_id).count\n max_choosers = SignUpTopic.find(bid[:topic_id]).try(:max_choosers)\n if num_of_signed_up_teams < max_choosers\n SignedUpTeam.create(team_id: tb[:team_id], topic_id: bid[:topic_id])\n break\n end\n end\n end\n end",
"def process_included\n @snps.each_with_index do |snp, index|\n if @included_snps_hash[snp.name]\n @included_snps << index\n @index_of_included_snps[snp.name] = @included_snps.length-1\n end\n end\n end",
"def mark_reserved(reservation)\n blocks = @venues[reservation.venue][reservation.day_id]\n\n for block_index in reservation.start_block...reservation.end_block\n blocks[block_index] = true\n end\n\n nil\n end",
"def index\n #approve_request\n @resource_transportation_bookings = ResourceTransportationBooking.where(:requester_id => \"#{current_user.id}\").order.page(params[:page]).per(5)\n end",
"def allocate_users\n @vehicle = Vehicle.where(:id => params[:id])\n @users = get_available_users @vehicle #getting users who are not working on selected vehicle.\n get_list\n\n if params[:vehicle_id] #Allocating vehicles to users.\n users = Array.new\n params.each do |key,value|\n users << value if key.starts_with?'check'\n end\n\n users.each do |user|\n UserAccess.create(:user_id => user,:vehicle_id => params[:vehicle_id], :shared_by => params[:shared_by], :appointment_date => Time.now)\n redirect_to vehicles_path \n flash[:notice] = \"Vehicle alotted successfully.\"\n end\n end\n \tend",
"def supports_shipment_auto_booking?\n return false\n end",
"def is_slot_alloted?\n\t\tif self.company.bookings.find_by_date_of_booking(self.date_of_booking)\n\t\t\tif self.new_record?\n\t\t\t\tdays_booking = self.company.bookings.where(date_of_booking: self.date_of_booking)\n\t\t\telse\n\t\t\t\tdays_booking = self.company.bookings.where(date_of_booking: self.date_of_booking).where.not(id: self.id)\n\t\t\tend\n\t\t\tdays_booking.each do |x|\n\t\t\t\tunless x.slot != self.slot\n\t\t\t\t\tself.errors[:allocated_slot] << \"=> This slot is already alloted\"\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def reserve_job! to=10\n begin qjob = job_queue.reserve(to)\n rescue Beanstalk::TimedOut => e ; Log.info e.to_s ; sleep 0.4 ; return ;\n rescue StandardError => e ; Log.warn e.to_s ; sleep 1 ; return ; end\n qjob\n end"
] |
[
"0.6252134",
"0.59533507",
"0.5916143",
"0.5832942",
"0.58034635",
"0.5744903",
"0.57438976",
"0.57395625",
"0.5625031",
"0.5606467",
"0.5595131",
"0.5583125",
"0.55628395",
"0.5554263",
"0.55448586",
"0.55231",
"0.5518247",
"0.550055",
"0.5492148",
"0.54594415",
"0.54423594",
"0.5413993",
"0.5389681",
"0.53803545",
"0.5368746",
"0.5368016",
"0.53622895",
"0.5355225",
"0.535368",
"0.532739",
"0.5322846",
"0.5296759",
"0.5293481",
"0.5274265",
"0.5268694",
"0.5268694",
"0.5267692",
"0.52666813",
"0.52559036",
"0.52461886",
"0.52438277",
"0.5214399",
"0.52112186",
"0.5209469",
"0.5208816",
"0.5204085",
"0.5192899",
"0.5191102",
"0.5176383",
"0.51638544",
"0.51609904",
"0.5159861",
"0.5158238",
"0.5152463",
"0.5150324",
"0.5146633",
"0.51444334",
"0.514137",
"0.51406324",
"0.5137706",
"0.51353467",
"0.5126798",
"0.5122473",
"0.5116227",
"0.50991064",
"0.5098762",
"0.50890356",
"0.5084819",
"0.50732416",
"0.5071938",
"0.5070357",
"0.50492746",
"0.50413716",
"0.5041281",
"0.50357217",
"0.5032324",
"0.5031639",
"0.5018905",
"0.501059",
"0.50025064",
"0.50019884",
"0.500103",
"0.50001585",
"0.49847233",
"0.49846035",
"0.49843094",
"0.49790096",
"0.49710733",
"0.49656853",
"0.49571037",
"0.4954099",
"0.4953157",
"0.49459922",
"0.49454814",
"0.494274",
"0.49415472",
"0.49301416",
"0.49266842",
"0.49254146",
"0.49241585",
"0.49152973"
] |
0.0
|
-1
|
Required for letting ERB know of the existence of variables.
|
def get_binding
binding
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def validate_variable_definitions!\n return unless grafana_dashboard[:dashboard][:templating]\n\n return if grafana_dashboard[:dashboard][:templating][:list].all? do |variable|\n query_params[:\"var-#{variable[:name]}\"].present?\n end\n\n raise_error 'All Grafana variables must be defined in the query parameters.'\n end",
"def is_variable_available\n super\n end",
"def check_vars\n @to_load.each do |hash|\n assert_not_nil(instance_variable_get(hash[:name]))\n end\n end",
"def invariable?\n false\n end",
"def prep_variables\n end",
"def variable?\n not constant?\n end",
"def include_variable?\n return VariableTable.check_include_variable(@content)\n end",
"def variable_definition?\n @variable\n end",
"def existential_vars\n @existentials ||= vars.select(&:existential?)\n end",
"def variable?\n !@variable_id.nil?\n end",
"def variables\n {}\n end",
"def local_variables() end",
"def variables; end",
"def variables; end",
"def include_variable?\n VariableTable.check_include_variable(@value)\n end",
"def unbound?\n !variables.empty? && variables.values.all?(&:unbound?)\n end",
"def render_variable(context); end",
"def hasVar?( name )\n\t\t\t\tArgTest::type( \"name\", name, String )\n\t\t\t\tname.strip!()\n\t\t\t\tArgTest::stringLength( \"name\", name, 1 )\n\t\t\t\treturn @vars.has_key?( name )\n\t\t\tend",
"def validate_vars\n errors = instance_variables.map do |var|\n next unless instance_variable_get(var).to_s.empty?\n \"Cannot find #{var} key, check your YAML config file.\"\n end.compact\n puts errors.join(\"\\n\") if errors\n errors.empty?\n end",
"def include_variable?\n @blocks.values.any?{|block| block.include_variable?}\n end",
"def active_locals; end",
"def include_variable?\n @elements.any?{|elt| elt.include_variable?}\n end",
"def instance_variable_defined?(p0) end",
"def render_variable(context)\n Liquid::Template.parse(@file).render(context) if @file =~ VARIABLE_SYNTAX\n end",
"def render_variable(context)\n if @file.match(VARIABLE_SYNTAX)\n partial = context.registers[:site]\n .liquid_renderer\n .file(\"(variable)\")\n .parse(@file)\n partial.render!(context)\n end\n end",
"def __in_erb_template;\n end",
"def __in_erb_template;\n end",
"def strict_variables; end",
"def locals; end",
"def locals; end",
"def locals; end",
"def is_variable(element)\n !(@cfg.variables.index(element) == nil)\n end",
"def local_variable_defined_for_node?(node, name); end",
"def variable_name; end",
"def variable_name; end",
"def include_variable?\n @expr.include_variable?\n end",
"def variables\n context.variables.keys - context.allowed_variables\n end",
"def get_template_variable_hash\n # Some variables are handled specially with their own UI elements, omit these here.\n excludes = ['date', 'server', 'servers']\n cmd_vars = extract_template_vars\n cmd_vars.reject!{|v| excludes.include? v}\n cmd_vars.map!{|c| {c => CommandTemplateVar.get_saved_values(self, c) }}\n end",
"def validate_template_variables(data)\n variables = (data[:template_variables] || []).map { |v| \"$#{v.fetch(:name)}\" }\n return if variables.empty?\n\n queries = data[:widgets].flat_map do |widget|\n ([widget] + (widget.dig(:definition, :widgets) || [])).flat_map { |w| widget_queries(w) }\n end.compact\n\n matches = variables.map { |v| Regexp.new \"#{Regexp.escape(v)}\\\\b\" }\n queries.reject! { |q| matches.all? { |m| q.match? m } }\n return if queries.empty?\n\n invalid!(\n \"queries #{queries.join(\", \")} must use the template variables #{variables.join(\", \")}\\n\" \\\n \"If that is not possible, add `validate: -> { false } # query foo in bar does not have baz tag`\"\n )\n end",
"def inspect_people_loaded\n if instance_variable_defined?(:@people_loaded) \n then puts @people_loaded.inspect\n else \n puts \"No existe la variable buscada\"\n end\n end",
"def template(_template_name)\n \"This is a dummy template! <%= dummy %> \\n \"\\\n 'Here is a global value <%= dummy_global %>'\n end",
"def validate\r\n self.variables.each do |key, value|\r\n self.errors.add(\r\n :variables,\r\n \"<tt>#{key}</tt> can't be blank\"\r\n ) if value.blank?\r\n end\r\n end",
"def variables\r\n if self.template.nil?\r\n template_variables = Template.detect_variables( self.get_template )\r\n else\r\n template_variables = self.template.variables\r\n end\r\n original_variables = self.attributes[\"variables\"] || {}\r\n original_variables.each do |key, value|\r\n template_variables[key] = value if template_variables.keys.include?( key )\r\n end\r\n return template_variables\r\n end",
"def foo\n local_variables = 10\n puts \"local variables: #{local_variables}\"\n puts defined?(local_variables)\nend",
"def partial?; @unbound_fields.any?; end",
"def variable; end",
"def variable; end",
"def built_in_variables\n {\n template_id: self.template.try(:to_param),\n recipient: {\n full_name: self.recipient.full_name,\n first_name: self.recipient.first_name,\n last_name: self.recipient.last_name,\n email: self.recipient.email\n },\n sender: {\n full_name: self.sender.full_name,\n first_name: self.sender.first_name,\n last_name: self.sender.last_name,\n email: self.sender.email\n }\n }\n end",
"def _variables\n _uri_template.variables\n end",
"def variable_exists?(id) #method\n @variables.key?(id)\n end",
"def fetch_variable(var_name, required: false)\n raise \"#{var_name} is a required variable\" if ENV[var_name].nil? && required\n\n return false if ENV[var_name] && ENV[var_name].downcase == 'false'\n ENV[var_name]\nend",
"def strict_locals?\n strict_locals!\n end",
"def node_context_vars(finder)\n # do nothing (this is a hook for other modules like QueryBuilder and RubyLess)\n {}\n end",
"def variable_checker(variable)\n $user_variables[variable.upcase.ord - 65]\n end",
"def maybe_directives?; end",
"def include_variable?\n # FIXME\n @table.values.any?{|val| val.include_variable?}\n end",
"def get_variable( var_name)\n\t\tvar = Vim::evaluate(\n\t\t\t\"exists(\\\"#{var_name}\\\") ? #{var_name} : \\\"__NIL__\\\"\"\n\t\t)\n\n\t\tvar == '__NIL__' ? nil : var\n\tend",
"def get_vars(instruction)\n dictionary = {\n 'definition' => ['os_type_id','iso_file','boot_cmd_sequence','postinstall_files'],\n 'kickstart' => ['reponame','pkgs'],\n 'preseed' => ['suite','pkgs'],\n 'autoinst' => ['pkgs']\n }\n # 'kickstart_file' option in definition.rb is deprecated\n # erb_vars = ['os_type_id','iso_file','boot_cmd_sequence','kickstart_file','postinstall_files']\n return dictionary[instruction]\n end",
"def method_missing( sym, *args, &block )\n\t\t\treturn super unless sym =~ /^\\w+$/\n\t\t\treturn @locals[ sym ].nil? ? @fragments[ sym ] : @locals[ sym ]\n\t\tend",
"def vars\n variables.values\n end",
"def vars\n variables.values\n end",
"def erb!(vars = {})\n ERBResolve.new(vars).resolve!(self)\n end",
"def erb!(vars = {})\n ERBResolve.new(vars).resolve!(self)\n end",
"def erb!(vars = {})\n ERBResolve.new(vars).resolve!(self)\n end",
"def all_instance_variables_set?\n self.class.instance_variables_required.to_a.all? do |instance_variable|\n !instance_variable_get(instance_variable.to_s).nil?\n end\n end",
"def get_variables\n get_siteinfo('variables')['query']['variables']\n end",
"def find_variable(key, raise_on_not_found: T.unsafe(nil)); end",
"def check_var(varname,var=nil)\n var.nil? and fail \"Requires #{varname} be set!\"\n var\nend",
"def build_vars\n\n end",
"def validate\n\n r = validate_template_name\n return r unless r.success?\n\n validate_template_vars\n\n end",
"def variable_name_expr; end",
"def locals; list_all :local_variables; end",
"def unbound?(aContext)\n vr = aContext.lookup(name)\n raise StandardError, \"Unknown variable #{name}\" unless vr\n\n bindings = aContext.associations_for(name)\n bindings.empty? || (bindings.size == 1 && bindings[0].kind_of?(Fusion))\n end",
"def handle_variables(activity, line_num)\n variables = get_variables(activity)\n variables.each do |variable|\n if variable_checker(variable).nil?\n puts \"Line #{line_num}: Variable #{variable} is not initialized\"\n return -1\n end\n end\n 3\n end",
"def variables\n EMPTY_ARRAY\n end",
"def use_implicit_variables; CurrentParser[:implicit_variables]=true; end",
"def each_uninstantiated_variable \n @variables.each { |variable|\n yield variable unless variable.instantiated?\n }\n end",
"def extract_template_vars\n return self.command.scan(/{{([a-z0-9\\-_]+?)}}/i).flatten\n end",
"def uninstantiated_variables\n @variables.select {|v| not v.instantiated?}\n end",
"def immediate?; @unbound_fields.empty?; end",
"def vars\n variable? ? [self] : []\n end",
"def show\n setup_variables(params)\n\n end",
"def var_present?(var)\n !ENV[var].nil? && !ENV[var].empty?\n end",
"def locals\n variables - parameters - hidden\n end",
"def gather_vars(executor, tconf, message)\n\n # try to return before a potentially costly call to executor.vars(nid)\n\n return nil if (tconf.keys & %w[ include_vars exclude_vars ]).empty?\n # default behaviour, don't pass variables to taskers\n\n iv = expand_filter(tconf['include_vars'])\n return nil if iv == false\n\n ev = expand_filter(tconf['exclude_vars'])\n return {} if ev == true\n\n vars = executor.vars(message['nid'])\n\n return vars if iv == true\n\n vars = vars.select { |k, v| var_match(k, iv) } if iv\n vars = vars.reject { |k, v| var_match(k, ev) } if ev\n\n vars\n end",
"def say_my_name\n\t# my_name is a local variable\n\t# variable is not initialized!\n\t# doesn't have any value!\n\t# And doesn't have a type \n\tputs my_name\nend",
"def global_variables() end",
"def class_variable_defined?(sym) end",
"def bound_variables\n @context.bound_variables\n end",
"def is_namevar?\n @is_namevar\n end",
"def is_undefined()\n res = super(context,self)\n return res\n end",
"def thread_variable?(key)\n _locals.has_key?(key.to_sym)\n end",
"def setup_template_variables(rid)\n @rid = rid\n @request_data = JSON.parse @rid.request_data\n @response_data = JSON.parse @rid.response_data\n end",
"def value_loaded?(name)\n !self.instance_variable_get(\"@#{name}\").nil?\n end",
"def universal_vars\n @universals ||= vars.reject(&:existential?).uniq\n end",
"def strict_variables=(_arg0); end",
"def variable_exists(name)\n assert_type name, :String, :name\n bool(environment.caller.var(name.value))\n end",
"def template() false end",
"def variable?\n any? {|op| op.respond_to?(:variable?) && op.variable?}\n end",
"def variable\n @variable ||= \"@#{@name}\"\n end",
"def test_required\n required = true\n if @subject.nil? || @subject.empty?\n WhoToWho.log.warn 'you need define a subject'\n required = false\n end\n\n if @content.nil? || @content.empty?\n WhoToWho.log.warn 'you need define a file or a file not empty for you mail template'\n required = false\n end\n\n if @list_link.nil? || @list_link.empty? || @list_link.size < 2\n WhoToWho.log.warn 'The list of data need define by a file. This file can\\'t be empty or only one data'\n required = false\n end\n\n if ActionMailer::Base.smtp_settings.empty?\n WhoToWho.log.warn 'The configuration of your SMTP account can\\'t be empty'\n required = false\n end\n\n if @from.nil? || @from.empty?\n WhoToWho.log.warn 'You need define a from in your mail settings.'\n required = false\n end\n\n unless required\n puts @full_print\n exit\n end\n end"
] |
[
"0.63035524",
"0.62274516",
"0.61799663",
"0.61141264",
"0.5984898",
"0.5958079",
"0.59247535",
"0.5900749",
"0.5898745",
"0.58501303",
"0.58456445",
"0.5814581",
"0.5805446",
"0.5805446",
"0.5730663",
"0.5726861",
"0.5700144",
"0.5683919",
"0.5661244",
"0.565974",
"0.5641687",
"0.56406146",
"0.5624594",
"0.5596344",
"0.559101",
"0.5585085",
"0.5585085",
"0.5554978",
"0.55527794",
"0.55527794",
"0.55527794",
"0.55485195",
"0.5501641",
"0.549933",
"0.549933",
"0.5489813",
"0.54860616",
"0.5484689",
"0.54673064",
"0.5447489",
"0.5442196",
"0.53923863",
"0.5380425",
"0.53676724",
"0.5357051",
"0.5350797",
"0.5350797",
"0.5348418",
"0.53277916",
"0.5321311",
"0.5318573",
"0.5304255",
"0.5303944",
"0.5301533",
"0.5234665",
"0.52261394",
"0.5217088",
"0.52143127",
"0.5203455",
"0.51959497",
"0.51959497",
"0.51928526",
"0.51928526",
"0.51928526",
"0.51858294",
"0.5183638",
"0.51769686",
"0.51764315",
"0.5169345",
"0.51675445",
"0.51670015",
"0.5164913",
"0.51592094",
"0.5155133",
"0.5152721",
"0.5148294",
"0.51463693",
"0.5143557",
"0.51433164",
"0.51303095",
"0.5129786",
"0.5129087",
"0.51279026",
"0.5123622",
"0.51108325",
"0.5106298",
"0.5105479",
"0.50980514",
"0.50946045",
"0.50883174",
"0.5084308",
"0.5083939",
"0.5071592",
"0.5071229",
"0.50672174",
"0.50658333",
"0.50644535",
"0.5062703",
"0.5050645",
"0.5048614",
"0.5043956"
] |
0.0
|
-1
|
Parses and assigns variables from config.yaml
|
def information_generator()
# We need the config.yaml file. Load it in.
File.exist?(@relative_path + '/config.yaml') ?
config = YAML.load_file(@relative_path + '/config.yaml') :
logger.fatal("Could not locate config file: #{config}") && abort
# Do the variable jig.
@access_key = config['keys']['access']
@secret_key = config['keys']['secret']
@def_region = config['region']
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def load config_file\n YAML.load_file(config_file).each do |parameter,value|\n instance_variable_set( \"@#{parameter}\", value )\n end\n end",
"def load_vars\n config = YAML.load_file(@config_file)\n @dev_port = config[\"development\"][\"port\"] ||= @default_dev_port\n @dev_pid = config[\"development\"][\"pid\"] ||= @default_dev_pid\n @dev_log = config[\"development\"][\"log\"] ||= @default_dev_log\n @prod_port = config[\"production\"][\"port\"] ||= @default_prod_port\n @prod_pid = config[\"production\"][\"pid\"] ||= @default_prod_pid\n @prod_log = config[\"production\"][\"log\"] ||= @default_prod_log\nend",
"def parse_config \n path = \"#{Rails.root}/config/mebla.yml\"\n return unless File.exists?(path)\n \n conf = YAML::load(ERB.new(IO.read(path)).result)[Rails.env]\n \n conf.each do |key,value|\n self.send(\"#{key}=\", value) if self.respond_to?(\"#{key}=\")\n end unless conf.nil?\n end",
"def load_configuration (key)\n configuration = YAML.load_file 'variables.yml'\n configuration['vars'][key].map do |package|\n package.kind_of?(Hash) ? package['name'] : package\n end\nend",
"def load_config(configfile)\n config = YAML.load_file(configfile)\n config.each { |key, value|\n instance_variable_set(\"@#{key}\", value) \n }\n end",
"def parse_config(\n config_file=File.expand_path(File.join(File.dirname(__FILE__), 'config.yml'))\n)\n require 'yaml'\n config = {\n 'sites' => \"sites\",\n 'webroot_subdir' => \"\",\n 'databases' => \"databases\",\n 'memory' => '2048',\n 'cpus' => '1',\n 'use_nfs' => true,\n 'with_gui' => false,\n 'ip' => \"192.168.50.4\",\n 'box_name' => 'Parrot-Trusty',\n 'varnish_enabled' => false,\n 'local_user_uid' => Process.uid,\n 'local_user_gid' => Process.gid,\n 'forward_solr' => true,\n 'forward_mysql' => true,\n 'forward_varnish' => true,\n 'forward_apache' => true,\n 'forward_https' => true,\n 'forward_dovecot' => true,\n 'solr_port' => 8983,\n 'mysql_port' => 3306,\n 'varnish_port' => 8181,\n 'apache_port' => 8080,\n 'https_port' => 1443,\n 'dovecot_port' => 1143,\n 'drush_version' => 'drush/drush',\n }\n if File.exists?(config_file)\n overrides = YAML.load_file(config_file)\n config.merge!(overrides)\n end\n config\nend",
"def import_config()\n # The config is top down.. anything after a [group] gets added as part\n # of that group until a new [group] is found. \n group = nil\n open(self.config_file).each do |line| \n line.strip!\n unless (/^\\#/.match(line))\n if(/\\s*=\\s*/.match(line))\n param, value = line.split(/\\s*=\\s*/, 2) \n var_name = \"#{param}\".chomp.strip\n value = value.chomp.strip\n new_value = ''\n if (value)\n if value =~ /^['\"](.*)['\"]$/\n new_value = $1\n else\n new_value = value\n end\n else\n new_value = ''\n end \n\n if group\n self.add_to_group(group, var_name, new_value)\n else\n self.add(var_name, new_value)\n end\n \n elsif(/^\\[(.+)\\]$/.match(line).to_a != [])\n group = /^\\[(.+)\\]$/.match(line).to_a[1]\n self.add(group, {})\n \n end\n end\n end \n end",
"def parse_config(config)\n @config = YAML.load_file(config)\n debug_msg(\"CONFIG: #{@config.inspect}\")\nend",
"def set_args_from_yaml(yaml_path)\n yaml = YAML::load( File.open(yaml_path) )\n @login = yaml['login']\n @password = yaml['password']\n @client = yaml['client']\n @project = yaml['project']\n @application = yaml['application']\n @environment = yaml['environment']\n @mmd_url = yaml['mmd_url']\nend",
"def get_vars\n\t\tvars_hash = {}\n\n\t\tparsed_config = begin\n\t\t\tYAML.load(File.open(@path_to_var_yml))\n\t\trescue ArgumentError => e\n \t\t\tputs \"Could not parse YAML: #{e.message}\"\n\t\tend\n\n\t\tparsed_config['template_variables'].each do |n|\n\t\t\tvars_hash[n[0]] = n[1]\n\t\tend\n\n\t\tvars_hash\n\tend",
"def local_yaml\n parse_yaml_string(yaml_string(local_config_file), local_config_file)\n end",
"def parse_config(config); end",
"def yaml\n parse_yaml_string(yaml_string(config_file), config_file)\n end",
"def initialize()\n @config = YAML.load_file('config.yaml')\n @puppetdb = @config['puppetdb']\n @servicenow = @config['servicenoe']\n @syslog = @config['syslog']\n end",
"def parse_config\n %w(/etc/steel/steel.yml steel.yml).each do |cfg|\n if File.exist?(cfg)\n begin\n y = YAML.load_file(cfg)\n rescue Psych::SyntaxError => e\n error \"[#{e.class}] Failed to parse '#{cfg}'!!\"\n error e.message\n exit 1\n end\n # Merge the contents of the config into @config.\n config.merge!(y)\n end\n end\n end",
"def read_config\n db_config = YAML.load_file('config/database.yml.production')\n set :db_user, db_config[rails_env][\"username\"]\n set :db_password, db_config[rails_env][\"password\"] \n set :db_name, db_config[rails_env][\"database\"]\nend",
"def read_config\n db_config = YAML.load_file('config/database.yml.production')\n set :db_user, db_config[rails_env][\"username\"]\n set :db_password, db_config[rails_env][\"password\"] \n set :db_name, db_config[rails_env][\"database\"]\nend",
"def config_for name\n yaml = SpaceScrape.root.join 'config', \"#{ name }.yml\"\n\n unless yaml.exist?\n raise \"Could not load configuration. No such file - #{ yaml }\"\n end\n\n erb = ERB.new(yaml.read).result\n erbd_yaml = YAML.load erb\n\n erbd_yaml[SpaceScrape.environment.to_s] || {}\n rescue YAML::SyntaxError => e\n raise \"YAML syntax error occurred while parsing #{ yaml }. \" \\\n \"Please note that YAML must be consistently indented using spaces. Tabs are not allowed. \" \\\n \"Error: #{ e.message }\"\n end",
"def load_variables\n options = ActiveSupport::HashWithIndifferentAccess.new(@options.dup)\n options[:blueprint] = @blueprint\n options[:stack] ||= @blueprint\n location = Lono::ConfigLocation.new(\"variables\", options, Lono.env)\n evaluate_variables_file(location.lookup_base) if location.lookup_base\n evaluate_variables_file(location.lookup) if location.lookup # config file\n end",
"def parse_yaml(filename)\n @config_file = filename\n begin\n @configuration = YAML::load_file(filename)\n rescue => ex\n STDERR.puts \"Couldn't find config file #{filename}\"\n STDERR.puts ex\n STDERR.puts ex.backtrace\n exit(1)\n end\n end",
"def read_config\n info(\"reading config.yml\")\n AIPP.config.read! config_file\n @aixm.namespace = AIPP.config.namespace\n end",
"def parse_config_file(path)\n return unless File.exists?(path)\n \n conf = YAML::load(ERB.new(IO.read(path)).result)[Rails.env]\n \n conf.each do |key,value|\n self.send(\"#{key}=\", value) if self.respond_to?(\"#{key}=\")\n end unless conf.nil?\n end",
"def loadConfigs()\n fh = File.open(@fileName_vars, \"r\")\n\n fh.each do |line| \n line.gsub!(/[\\s]/, '') # removes white spaces \n\n if(!(/^\\#/.match(line)) && /:/.match(line)) # only considers lines not begining with #\n line.sub!(/\\#.*$/, '') # removes all trailing comments\n line.upcase!\n arr_configs = line.split(/:/)\n case arr_configs[0] \n when FOLDER_DATA\n @folder_data = arr_configs[1]\n when FOLDER_DB\n @folder_db = arr_configs[1]\n when FOLDER_BLASTRES\n @folder_blastRes = arr_configs[1]\n when FOLDER_FINALRES\n @folder_finalRes = arr_configs[1]\n end \n #puts arr[0] + \"\\t\" + arr[1]\n #puts line\n end \n\n end \n\n fh.close\n end",
"def parse_cloud_config\n cloud_config = YAML.load(File.read('config/cloud.yml'))\n check_cloud_config(cloud_config)\n\n cloud_config\n end",
"def load config\n \n # TODO better place for this?\n if config['log4r_config']\n ycfg = Log4r::YamlConfigurator\n # ycfg['foo'] = bar # replaces instances of #{foo} in the YAML with bar\n ycfg.load_yaml_string(YAML.dump(config))\n end\n \n # gah - log4r expects strings, so only convert to symbols here\n config.keys_to_symbols!\n \n # load all scrapers, and mix all shared fields into them\n config[:scrapers].each_pair do |group, included|\n \n shared_setup = {}\n scraper_setups = {}\n \n # load setups\n included.each_pair do |key, value|\n target = if is_scraper?(key)\n logger.info \"Loading scraper #{group}::#{key}\"\n scraper_setups\n else\n shared_setup\n end\n\n target[key] = value\n end\n \n # create each scraper when whole setup is present\n scrapers[group] = setup_scrapers(scraper_setups, shared_setup);\n end if config[:scrapers]\n end",
"def load_settings\n begin\n save = YAML.load_file('settings.yaml')\n unless save\n # the file is empty.. well, not valid YAML\n raise(ArgumentError)\n end\n \n # do something with the loaded values\n @maildirpath = save['maildirpath']\n @known = save['known']\n @ignore = save['ignore']\n @mailers = save['mailers']\n \n rescue Errno::ENOENT, ArgumentError => e\n # file not found or not valid\n # so create a valid one\n File.open('settings.yaml', 'w' ) do |out|\n save = {'maildirpath' => '/path/to/mh/',\n 'known' => {'Firstname Lastname' => ['[email protected]']},\n 'ignore' => ['[email protected]'],\n 'mailers' => {'Mailername' => ['RegEx']}\n }\n YAML.dump(save, out)\n end\n raise(ArgumentError, 'You should check settings.yaml before re-running this program')\n end\n end",
"def prepare_from_yaml\n set(:db_backup_path) { \"#{shared_path}/backup/\" }\n\n set(:db_local_file) { \"tmp/\" }\n set(:db_user) { db_config[rails_env.to_s][\"username\"] }\n set(:db_pass) { db_config[rails_env.to_s][\"password\"] }\n set(:db_host) { db_config[rails_env.to_s][\"host\"] }\n set(:db_port) { db_config[rails_env.to_s][\"port\"] }\n set(:db_name) { db_config[rails_env.to_s][\"database\"] }\n\n set(:db_remote_backup) { \"#{db_backup_path}/#{db_name}\" }\n end",
"def load_settings\n attributes = YAML.load_file(\"defaults.yml\")\n begin\n custom_attributes = YAML.load_file(\"config.yml\")\n attributes = simple_deep_merge(attributes, custom_attributes)\n rescue\n end\n attributes\nend",
"def global_yaml\n parse_yaml_string(yaml_string(global_config_file), global_config_file)\n end",
"def load_preconfig\n\t\tbegin\n\t\t\tconf = Msf::Config.load\n\t\trescue\n\t\t\twlog(\"Failed to load configuration: #{$!}\")\n\t\t\treturn\n\t\tend\n\n\t\tif (conf.group?(ConfigCore))\n\t\t\tconf[ConfigCore].each_pair { |k, v|\n\t\t\t\ton_variable_set(true, k, v)\n\t\t\t}\n\t\tend\n\tend",
"def parse\n\n values = {}\n\n # Items are defined in the config file\n paths = YAML.load_file('config/paths.yml')\n\n paths.each do |key, item|\n values[key] = parse_item(item)\n end\n\n # Additional values\n values['account'].merge!({\n world: @world,\n username: @username,\n profile_url: PublicProfile.profile_url(@world, @username)\n })\n\n values\n end",
"def load_config\n @config = YAML.safe_load(ERB.new(File.read(config_path)).result)\n @queue_ahead = @config[\"queue_ahead\"] || Task::DEFAULT_QUEUE_AHEAD_MINUTES\n @queue_name = @config[\"queue_name\"] || \"default\"\n @time_zone = @config[\"tz\"] || Time.zone.tzinfo.name\n @config.delete(\"queue_ahead\")\n @config.delete(\"queue_name\")\n @config.delete(\"tz\")\n end",
"def config\n\tYAML.load(File.open(\"config.yaml\"))\nend",
"def config_load(config); end",
"def fetch_config\n Rails.logger.debug \"Loading #{@file}::#{@env}\" if Object.const_defined?('Rails') && Rails.logger.present?\n YAML::load_file(@file)[@env.to_s]\n end",
"def update_config\n if File.directory?(yolo_dir) and File.exist?(yaml_path)\n @yaml = YAML::load_file yaml_path\n update_yaml_setting(@yaml, \"deployment\", \"api_token\", \"example\")\n update_yaml_setting(@yaml, \"deployment\", \"team_token\", \"example\")\n end\n end",
"def data\n YAML::load_file(files[:config])\n end",
"def load_from_file(path)\n YAML.load_file(path).each { |n,v| instance_variable_set(n, v) }\n end",
"def load_config(files)\n vconfig = {}\n files.each do |config_file|\n if File.exist?(config_file)\n optional_config = YAML.load_file(config_file)\n vconfig.merge!(optional_config) if optional_config\n end\n end\n resolve_jinja_variables(vconfig)\n end",
"def setup\n preference_file = \"#{defaults[:root_dir]}/config.yml\"\n preferences = {}\n if File.exists? preference_file\n require 'yaml'\n File.open(preference_file) { |file| preferences = YAML.load(file) }\n end\n base_file_variations(absolute_paths(defaults.merge(preferences)))\n end",
"def load_config(filename)\n yml = YAML.load_file(filename)\n yml.each do |key, value| \n next if key == 'Templates'\n\n if key == 'PackageDirs'\n # PackageDirs.register value\n elsif key == 'AppDirs' \n # ApplicationDirMatcher.register value\n else\n app_matcher.register value\n end \n end\n end",
"def load(path, env)\n yaml_safe_load(File.open(path).read)[env].each do |section, settings|\n section = instance_variable_get(\"@#{section}\")\n next unless section\n settings.each do |setting, value|\n unless section == @index || section == @source\n value = interpolate_string(value, nil)\n end\n setter(section, setting, value)\n end\n end\n end",
"def load_from_yaml(yaml_file)\n y = Psych.load_file(yaml_file)\n properties_map = { \n \"hostname\" => :@hostname,\n \"dns_server\" => :@dns_server,\n \"dns_port\" => :@dns_port,\n \"dnssec_key_name\" => :@dnssec_key_name,\n \"dnssec_key_hmac\" => :@dnssec_key_value,\n \"zone\" => :@zone,\n \"ttl\" => :@ttl,\n \"srv_priority\" => :@priority,\n \"srv_weight\" => :@weight,\n \"sleep_time\" => :@sleep_time,\n \"transport\" => :@transport,\n \"max_dns_response_time\" => :@max_dns_response_time,\n }\n properties_map.each { |k,v|\n if (y.has_key?(k))\n self.instance_variable_set(v, y[k])\n end\n }\n end",
"def load_yaml(filename); end",
"def read_defaults(config_file)\n begin\n defaults = YAML.load_file(config_file)\n\n unless defaults == false\n defaults.each do |k, v|\n if self.respond_to?(k.to_sym)\n self.instance_variable_set((\"@\" + k.to_s).to_sym, v)\n end\n end\n end\n rescue Exception => e\n puts e.message\n puts e.backtrace\n raise e\n end\n end",
"def fill_from_yaml(yaml)\n fill_from_hash(Psych.load(yaml))\n end",
"def config_from_hash(data = {})\n data.each do |param, value|\n if Pkg::Params::BUILD_PARAMS.include?(param.to_sym)\n self.instance_variable_set(\"@#{param}\", value)\n else\n warn \"Warning - No build data parameter found for '#{param}'. Perhaps you have an erroneous entry in your yaml file?\"\n end\n end\n end",
"def load_yaml(yaml_path, variables = nil)\n #puts \"load_yaml #{yaml_path}\"\n if variables\n YAML.load(ERB.new(File.read(yaml_path)).result(OpenStruct.new(variables).instance_eval { binding })) \n else\n YAML.load(ERB.new(File.read(yaml_path)).result)\n end\nend",
"def load_config( filename )\n\n fullname = \"#{Rails.application.root}/config/#{filename}\"\n begin\n config_erb = ERB.new( IO.read( fullname ) ).result( binding )\n rescue StandardError => ex\n raise( \"#{filename} could not be parsed with ERB. \\n#{ex.inspect}\" )\n end\n\n begin\n yml = YAML.load( config_erb )\n rescue Psych::SyntaxError => ex\n raise \"#{filename} could not be parsed as YAML. \\nError #{ex.message}\"\n end\n\n config = yml.symbolize_keys\n @configuration = config[ Rails.env.to_sym ].symbolize_keys || {}\n end",
"def load(file, schemasdir)\n schemafile = File.join(schemasdir, 'variables.yaml')\n schema = Kwalify::Yaml.load_file(schemafile)\n validator = Kwalify::Validator.new(schema)\n parser = Kwalify::Yaml::Parser.new(validator)\n serialized_vars = parser.parse_file(file)\n parser.errors.push(Kwalify::ValidationError.new(\"No variables defined\")) unless serialized_vars\n if parser.errors.empty?\n serialized_vars.each { |v| vars[v['name']] = v['value'] }\n else\n Log.warn(\"Error loading variables from '#{file}': #{KwalifyHelper.parser_error(parser)}\")\n end\n end",
"def example_env_vars\n Parser.call(read)\n rescue Errno::ENOENT, FormatError\n {}\n end",
"def ansible_default_vars\n auth = authentications.first\n\n {\n 'lxca_user' => auth.userid,\n 'lxca_password' => auth.password,\n 'lxca_url' => \"https://#{hostname}\",\n }\n end",
"def load_yaml(file, env_vars, my = nil)\n\n yaml = YAML.load_file(file)\n eval_map_values(yaml, env_vars, file, my || yaml)\n end",
"def load_yaml(base=ENV['PWD'], env=\"active\")\n env = \"dev\" if env == \"active\" and not File.exist? \"#{base}/opt/active\"\n @data = ::YAML.load_file(\"#{base}/opt/#{env}/config.yaml\")\n end",
"def config(name, &block)\n config = ConfigVariable.new(name)\n if block\n config.instance_eval(&block)\n end\n variables[name] = config\n end",
"def load_config_from_yaml(path)\n config = load_config(path)\n\n # validate loaded yaml data\n validate_config config\n\n config.each do |key, value|\n Mihari.config.send(\"#{key.downcase}=\".to_sym, value)\n end\n end",
"def load_config\n $config = YAML.load_file(CONFIG)[DATABASE]\n $config['discord_client'] = (TEST ? ENV['DISCORD_CLIENT_TEST'] : ENV['DISCORD_CLIENT']).to_i\n $config['discord_secret'] = TEST ? ENV['DISCORD_TOKEN_TEST'] : ENV['DISCORD_TOKEN']\n $config['twitch_client'] = ENV['TWITCH_CLIENT']\n $config['twitch_secret'] = ENV['TWITCH_SECRET']\n log(\"Loaded config\")\nrescue => e\n fatal(\"Failed to load config: #{e}\")\n exit\nend",
"def parse_config\n raw_config.split(\"\\n\").each do |line|\n match = CONFIG_MATCH_EXPRESSION.match(line)\n\n next unless match\n\n key, value = match[1], match[2]\n\n if key.include?('.')\n metric_name, metric_parameter = key.split('.')\n\n metrics[metric_name] ||= {}\n metrics[metric_name][metric_parameter] = value\n else\n parameters[key] = value\n end\n end\n end",
"def initialize_from_yaml(path)\n # FIXME: It would be a lot cleaner if the YAML library would raise an\n # exception if it fails to read the file. We'll handle it like this for now\n # load_file just returns \"false\" if it fails\n yaml_data = YAML.load_file(path)\n\n unless yaml_data.nil?\n raise InitializationError.new(\"Bad YAML format, key/value pairs expected\") unless yaml_data.kind_of?(Hash)\n\n yaml_data.each do |variable, value|\n self.store(variable, value)\n end\n end\n\n after_initialize\n dump\n end",
"def load_yml(yml_file)\n if File.exist?(yml_file)\n yml_cfg = OpenStruct.new(YAML.load_file(yml_file))\n yml_cfg.jira_properties.each do |k, v|\n instance_variable_set(\"@#{k}\", v)\n end\n else\n raise StandardError, \"unable to find yml config file\"\n end\n end",
"def parse_people_config\n people_config_path = \"config/people/#{Etc.getlogin}.yml\"\n @people_config = ( YAML.load_file(people_config_path) if File.exist?(people_config_path) ) || YAML.load_file(\"config/people/roderik.yml\")\n end",
"def load_config\n cfg = File.open(CONFIG) { |yf| YAML::load( yf ) } if File.exists?(CONFIG)\n # => Ensure loaded data is a hash. ie: YAML load was OK\n if cfg.class != Hash\n raise \"ERROR: Configuration - invalid format or parsing error.\"\n else\n if cfg['login'].nil?\n raise \"ERROR: Configuration: login not defined.\"\n end\n end\n\n return cfg\nend",
"def from_yaml(text)\n if config = YAML.load(text)\n return config\n end\n end",
"def load_config\n if @type == :upload\n config_file = \"ul_config.xml\"\n else\n config_file = \"dl_config.xml\"\n end\n doc = Nokogiri::XML(open(\"config/#{config_file}\"))\n doc.search(@type.to_s).each do |config|\n @config_map[:ip] = get_content config, \"ip\"\n @config_map[:port] = get_content config, \"port\"\n @config_map[:user] = get_content config, \"user\"\n @config_map[:password] = get_content config, \"password\"\n @config_map[:remotedir] = get_content config, \"remotedir\"\n @config_map[:localdir] = get_content config, \"localdir\"\n\n @localfile = get_content config, \"localfile\"\n @remotefile = get_content config, \"remotefile\"\n\n @thread_num = get_content(config, \"thread_num\").to_i\n @sleep = get_content(config, \"sleep\").to_i\n @test = get_content(config, \"test\")\n end\n\n if @type == :upload\n @thread_num = @thread_num >= 10 ? @thread_num : 10\n end\n end",
"def load\n yaml = YAML.load_file(@file_path)\n yaml.each {|k, v| interpolate_setting(yaml, v)}\n settings = OpenStruct.new\n add_hash(settings, yaml)\n\n @lock.synchronize do\n @yaml = yaml\n @settings = settings\n end\n rescue\n puts \"Failed to load file: #{@file_path}\\n#{$!}\"\n end",
"def load_config\n if !File.exists?('config.yml')\n raise \"The config.yml file is not present in the current directory. Run -setup to configure this file.\"\n end\n\n # Load the config.yml configuration file.\n config = YAML::load_file('config.yml')\n\n # Create the ars models context given values from the config.yml file.\n context = ArsModels::Context.new({\n :username => config['username'],\n :password => config['password'],\n :server => config['server'],\n :port => config['port']\n })\n context\nend",
"def config\n @config ||= YAML.load_file(BASE_PATH + '/local.config.yml')\nend",
"def load_user(filepath)\n $user = load_yaml(filepath)\nend",
"def load_config(filename)\n\t\t\tconfig = read_config(filename)\n\t\t\t@servers = config[:servers]\n\t\t\t@email_addr = config[:email][:addr]\n\t\t\t@email_sender = config[:email][:sender]\n\t\tend",
"def take_yaml(yml)\n @data = YAML.load(yml)\n end",
"def take_yaml(yml)\n @data = YAML.load(yml)\n end",
"def load_env_variables(project)\r\n @project = project\r\n puts(\"project = #{project}\")\r\n\r\n if project.nil? then\r\n raise \"#{msg_prefix} > No project defined.\\n\"\\\r\n \"Call SET PROJECT=prj, replacing prj with your project.\"\r\n elsif !File.exist?(File.join(SAF::PROJECTS, project)) then\r\n raise \"#{msg_prefix} > Project not found: #{project}.\"\r\n end\r\n\r\n load_yml_config(project)\r\n\r\n @enable_remote_logging = load_boolean(\"ENABLE_REMOTE_LOGGING\", true)\r\n @logstash_host = load_var(\"LOGSTASH_HOST\", \"showinpoc01.fbfs.com\")\r\n @logstash_port = load_var(\"LOGSTASH_PORT\", 5514).to_i\r\n\r\n @aut_host = load_var(\"HOST\")\r\n @test_slave_host = load_var('REMOTE_HOST', 'showinpoc01.fbfs.com')\r\n @test_slave_port = load_var('REMOTE_PORT', 4444).to_i\r\n\r\n @in_browser = load_boolean(\"IN_BROWSER\", true)\r\n\r\n @browser = load_var('BROWSER', 'ie')\r\n\r\n @log_level = load_var(\"LOG_LEVEL\", \"Logger::INFO\")\r\n\r\n @screenshots = load_boolean(\"TAKE_SCREEN_SHOT\", true) # Was ist das?\r\n @screenshots_on_fail = load_boolean(\"TAKE_SCREEN_SHOT_ON_FAIL\", true)\r\n @screenshots_on_warning = load_boolean(\"TAKE_SCREEN_SHOT_ON_WARNING\",\r\n true)\r\n\r\n @yml_config.delete(\"project\")\r\n\r\n unless @yml_config.empty? then\r\n # TODO: Error class\r\n raise \"#{msg_prefix} > Unknown keys in \"\\\r\n \"#{project}'s #{SAF::PROJECT_ENV_YAML}:\\n\"\\\r\n \" #{@yml_config.keys.join(', ')}\"\r\n end\r\n end",
"def pets\n load_yaml('personaje/pets')\nend",
"def prepare_from_yaml\n set(:db_file) { \"#{application}-dump.sql.bz2\" }\n set(:db_remote_file) { \"#{shared_path}/backup/#{db_file}\" }\n set(:db_local_file) { \"tmp/#{db_file}\" }\n set(:db_user) { db_config[rails_env][\"username\"] }\n set(:db_password) { db_config[rails_env][\"password\"] }\n set(:db_host) { db_config[rails_env][\"host\"] }\n set(:db_name) { db_config[rails_env][\"database\"] }\n end",
"def read_cfg\n config = Config.new\n File.open(\"#{$work_dir}/#{filename}\") do |file|\n while line = file.gets\n #next if /^#/\n if /^(PMASTER):\\w+:(\\S+)/ =~ line then\n config.host_list[$2] = $1\n puts \"Puppet Master: #{$2}\"\n end\n if /^(AGENT):\\w+:(\\S+)/ =~ line then\n config.host_list[$2] = $1\n puts \"Puppet Agent: #{$2}\"\n end\n end\n end\n return config\n end",
"def _load_env\n require 'yaml'\n r_var = _open_sefile('env3.yml') { |f| YAML.load(f) }\n @var.delete :file_open_raised\n r_var.each { |k,v| @var[k] = v } if r_var\nend",
"def prepare_from_yaml\n set(:db_file) { \"#{application}-dump.sql.bz2\" }\n set(:db_remote_file) { \"#{shared_path}/backup/#{db_file}\" }\n set(:db_local_file) { \"tmp/#{db_file}\" }\n set(:db_user) { db_config[rails_env][\"username\"] }\n set(:db_pass) { db_config[rails_env][\"password\"] }\n set(:db_host) { db_config[rails_env][\"host\"] }\n set(:db_name) { db_config[rails_env][\"database\"] }\n end",
"def read_yaml(base, name)\n self.content = File.read(File.join(base, name))\n\n if self.content =~ /^(---\\s*\\n.*?\\n?)^(---\\s*$\\n?)/m\n self.content = $POSTMATCH\n\n begin\n self.data = YAML.load($1)\n rescue => e\n puts \"YAML Exception reading #{name}: #{e.message}\"\n end\n end\n\n self.data ||= {}\n end",
"def load_config\n conf = YAML.load_file(File.expand_path('../config.yml', File.dirname(__FILE__)))\n\n unless %w[basedir master filesync_cert filesync_cert_key filesync_ca_cert].all? { |s| conf.key?(s) && !conf[s].nil? }\n Pem.log_error('Missing required settings in config.yml', @logger)\n raise\n end\n\n conf['envdir'] = \"#{conf['basedir']}/environments\"\n conf['mod_dir'] = \"#{conf['basedir']}/modules\"\n\n return conf\n rescue StandardError\n err = 'Missing config file, or required configuration values - check config.yml'\n Pem.log_error(err, @logger)\n raise(err)\n end",
"def load_config(config_file)\n YAML.load(File.open(config_file))\nend",
"def from_config\n config ||= YAML::load(File.open((File.join(File.dirname(__FILE__), 'config.yml'))))\nend",
"def load_config(config_file)\n conf = File.read(config_file).lines\n .map(&:strip)\n .delete_if { |l| l.empty? || l.start_with?('#') }\n .each_with_object({}) do |line, config|\n parameter, value = line.split('=', 2)\n config[parameter.to_sym] = value\n config\n end\n conf\n end",
"def read_config!\n @config = YAML.load_file(CONFIG_FILE)\n end",
"def config_from_raw(raw_config)\n config = Hash.new\n\n raw_config.split(\"\\n\").select { |line| line.match(/:\\s/) }.each do |line|\n key, value = line.split(/:\\s+/)\n config[key] = value\n end\n\n config\nend",
"def load_config_file( filename )\n\n begin\n config_erb = ERB.new( IO.read( filename ) ).result( binding )\n rescue StandardError => ex\n raise( \"#{filename} could not be parsed with ERB. \\n#{ex.inspect}\" )\n end\n\n begin\n yml = YAML.load( config_erb )\n rescue Psych::SyntaxError => ex\n raise \"#{filename} could not be parsed as YAML. \\nError #{ex.message}\"\n end\n\n config = yml.symbolize_keys\n return config.symbolize_keys || {}\n end",
"def prepare_from_yaml\n set(:db_file) { \"#{application}-dump.sql.bz2\" }\n set(:db_remote_file) { \"#{current_path}/backup/#{db_file}\" }\n set(:db_local_file) { \"tmp/#{db_file}\" }\n set(:db_user) { db_config[rails_env][\"username\"] }\n set(:db_pass) { db_config[rails_env][\"password\"] }\n set(:db_host) { db_config[rails_env][\"host\"] }\n set(:db_name) { db_config[rails_env][\"database\"] }\n end",
"def load_config_from_database\n @params.each do |p|\n p['value_db'] = @bot_dbaccess.read_parameter_with_default(p['name'], p['default'])\n end\n end",
"def load_config_from_database\n @params.each do |p|\n p['value_db'] = @bot_dbaccess.read_parameter_with_default(p['name'], p['default'])\n end\n end",
"def load_yml_config(project)\r\n @saf_env = ENV[\"SAF_ENV\"] || \"default\"\r\n puts(\"SAF_ENV = #{@saf_env}\")\r\n\r\n env_yml_path = File.join(SAF::PROJECTS, project, SAF::PROJECT_ENV_YAML)\r\n\r\n unless File.exist?(env_yml_path) then\r\n # TODO: File not found error class\r\n raise \"#{msg_prefix} > Could not find #{env_yml_path}\"\r\n end\r\n\r\n all_yml_config = YAML.load(File.read(env_yml_path))\r\n # Throw an error if they specified an illegal install key.\r\n unless all_yml_config.key?(@saf_env) then\r\n raise ArgumentError.new(\"#{caller.first}\\n\"\\\r\n \"SAF env #{@saf_env} not found in project \"\\\r\n \"#{project}.\")\r\n end\r\n @yml_config = all_yml_config[@saf_env]\r\n end",
"def load_config(config_file)\n begin\n $test_config=YAML::load(YAML::load_file(config_file))\n rescue Exception => e\n puts \"Error: #{e} while loading the configuration file, please specify valid yaml file\"\n end\n end",
"def initialize(defaults,cmd_opts)\n @fields = defaults\n if !cmd_opts[:config_file].nil?\n path = cmd_opts[:config_file]\n else\n path = defaults[:config_file]\n end\n data = YAML.load_file(path)\n # Now combine data:\n # defaults, config file, command line (low->high priority)\n data.each do |k,v|\n if EXPECTED.include? k.to_sym\n @fields[k.to_sym] = v\n else\n STDERR.puts \"Warning: unknown section '#{k}' in config file\"\n end\n end\n cmd_opts.each do |k,v|\n @fields[k] = v\n end\n end",
"def config_file_template_variables\n init_config_template unless config_template_exist?\n find_resource!(:template, ::File.join(new_resource.config_file)).variables[:config]\n end",
"def params\n begin\n YAML::load(File.open(@config))\n rescue\n {}\n end\n end",
"def load_credentials\n yml = YAML.load(File.read(credentials_file)) || {}\n @uuid, @token = yml[:uuid], yml[:token]\n yml\n end",
"def load_config_from_file\n # Useful for testing or embedding credentials - although as always \n # it is not recommended to embed any kind of credentials in source code for security reasons\n return { :piwik_url => PIWIK_URL, :auth_token => PIWIK_TOKEN } if PIWIK_URL.present? and PIWIK_TOKEN.present?\n config = {}\n if defined?(RAILS_ROOT) and RAILS_ROOT != nil\n home = RAILS_ROOT\n filename = \"config/piwik.yml\"\n else\n home = ENV['HOME'] || ENV['USERPROFILE'] || ENV['HOMEPATH'] || \".\"\n filename = \".piwik\"\n end\n temp_config = if File.exists?(File.join(home,filename))\n YAML::load(open(File.join(home,filename)))\n else\n open(File.join(home,filename),'w') { |f| f.puts @@template }\n YAML::load(@@template)\n end\n temp_config.each { |k,v| config[k.to_sym] = v } if temp_config\n if config[:piwik_url] == nil || config[:auth_token] == nil\n if defined?(RAILS_ROOT) and RAILS_ROOT != nil\n raise MissingConfiguration, \"Please edit ./config/piwik.yml to include your piwik url and auth_key\"\n else\n raise MissingConfiguration, \"Please edit ~/.piwik to include your piwik url and auth_key\"\n end\n\n end\n config\n end",
"def read_config\n begin\n config = YAML.load_file('config/config.yml')\n puts config['address']\n puts config['port']\n rescue YAML::LoadError => e\n # If config file is not found or valid, return with errors\n logger.error \"read config error: #{e}\"\n end\n\n [config['address'], config['port']]\n end",
"def parse_config_file\n if !File.exist?(options[:config_file])\n puts \"Configuration file is not found\"\n exit 1\n end\n\n configs = YAML.load_file(options[:config_file]).deep_symbolize_keys\n options.reverse_merge!(configs[environment.to_sym] || {})\n end",
"def load_config\n config_file = File.join(Dir.home, \".assemblotron\")\n if File.exists? config_file\n @log.debug \"config file found at #{config_file}\"\n config = YAML::load_file(config_file)\n if config.nil?\n @log.warn \"config file malformed or empty\"\n return\n end\n @config = config.deep_symbolize\n end\n end",
"def config\n fail(SlashDeploy::NoConfig) unless config?\n SlashDeploy::Config.from_yaml(raw_config)\n end",
"def mongo_settings(yaml)\n @mongo = YAML.load(yaml)\n end",
"def process_configuration\n self.configuration = YAML::load(File.read('.codecom.yml'))\n end"
] |
[
"0.72689384",
"0.7165393",
"0.7107731",
"0.68241304",
"0.6692438",
"0.666565",
"0.65412366",
"0.6505321",
"0.6492628",
"0.63593924",
"0.6269982",
"0.6265594",
"0.6239999",
"0.62008214",
"0.61940646",
"0.61854464",
"0.61854464",
"0.61793256",
"0.61633873",
"0.6124876",
"0.6116049",
"0.61105406",
"0.608417",
"0.6059042",
"0.6056063",
"0.6017871",
"0.6002079",
"0.598816",
"0.5972037",
"0.5965781",
"0.59550977",
"0.5943712",
"0.5938915",
"0.59371185",
"0.59326315",
"0.59246916",
"0.5901742",
"0.5899468",
"0.5890494",
"0.5884941",
"0.5881003",
"0.5871306",
"0.5860743",
"0.58220863",
"0.5820929",
"0.58145297",
"0.58114094",
"0.58103794",
"0.57921135",
"0.5791325",
"0.5783287",
"0.57831836",
"0.5778601",
"0.5774754",
"0.57734174",
"0.5768012",
"0.57633007",
"0.5740765",
"0.57340145",
"0.573278",
"0.5727322",
"0.57215863",
"0.57175785",
"0.5708605",
"0.570752",
"0.5698207",
"0.5696993",
"0.5693517",
"0.56911767",
"0.56896013",
"0.56896013",
"0.5662024",
"0.5659593",
"0.5653876",
"0.56500113",
"0.5641723",
"0.5634644",
"0.56315255",
"0.56259465",
"0.56115323",
"0.560615",
"0.5602598",
"0.5597953",
"0.55961406",
"0.5594869",
"0.5581616",
"0.55795556",
"0.55795556",
"0.5575724",
"0.557191",
"0.55717796",
"0.5564415",
"0.5560372",
"0.5552527",
"0.5529994",
"0.552714",
"0.55132866",
"0.5512155",
"0.55099183",
"0.5505395",
"0.5503897"
] |
0.0
|
-1
|
This method determines what role was provided by user input and which template should be used.
|
def determine_role()
templates = []
Dir.foreach(File.join(@relative_path, '..', 'blueberry', 'templates')) do |item|
next if item == '.' or item == '..'
templates << item.gsub(".erb", '').downcase # + "\n"
end
templates.join
template_folder = "/templates/"
if templates.include?(@role.downcase)
template_path = File.join(@relative_path, template_folder, @role + '.erb')
else
logger.fatal "Unable to find role: #{@role}. Try options --list to verify it exists."
abort
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def handle_role_def(role_def)\n if role_def.is_a? Hash\n app_type = role_def[:app_type]\n self.role_name = role_def[:role_name]\n self.for_user = role_def[:for_user]\n else\n self.role_name = role_def\n end\n\n self.app_type_id = if app_type\n Admin::AppType.active_app_types.find_by(name: app_type)&.id\n else\n item.current_user.app_type_id\n end\n\n raise FphsException, \"No active app type found in role definition for app type: #{app_type}\" unless app_type_id\n\n self.role_name = FieldDefaults.calculate_default(item, role_name) if role_name\n\n self.for_user = if for_user\n FieldDefaults.calculate_default(item, for_user)\n else\n item.current_user\n end\n\n self.for_user = case for_user\n when Integer\n User.active.find_by(id: for_user)\n when String\n User.active.find_by(email: for_user)\n else\n for_user\n end\n\n [role_name, app_type_id, for_user]\n end",
"def layout_chooser(current_user)\n unless current_user.nil?\n if current_user.role==\"applicant\" then\n @applicant=current_user.applicant\n layout=\"applicants\"\n elsif current_user.role==\"company\" then\n @company=current_user.company\n layout=\"companies\"\n else\n layout=\"admin\" \n end\n \n else\n layout=\"welcome\"\n end\n layout\n end",
"def select_role\n if params[:user] && params[:user][:role_id]\n stage_one\n render :new\n else\n redirect_to \"/welcome/advertiser\"\n end\n end",
"def role_selected?\n if current_user\n if current_user.transporter_role == false && current_user.livestock_owner_role == false\n render 'choose_role'\n end\n end\n end",
"def pick_the_role\n puts \"Would #{@human} be so kind as to pick the role?\"\n until @codemaker\n puts \"Please enter 'codemaker' or 'codebreaker'.\"\n role = gets.chomp.downcase\n if role == 'codemaker' || role == 'maker'\n puts \"#{@human} chose to be a 'codemaker'.\"\n @codemaker = @human\n @codebreaker = @robot\n elsif role == 'codebreaker' || role == 'breaker'\n puts \"#{@human} chose to be a 'codebreaker'.\"\n @codemaker = @robot\n @codebreaker = @human\n elsif role == '42'\n puts \"Ah, you're wise for a human. And yet, do select your role.\"\n else\n puts \"Can't understand you, please try again.\"\n end\n end\n end",
"def checkrole\n if roles_mask == 4\n 'User'\n elsif roles_mask == 6\n 'Administrator'\n end\n end",
"def get_role_or_nil\n if user_type == \"UserControl\"\n \"UserControl\"\n elsif user_signed_in?\n current_user.role.name\n else\n nil\n end\n end",
"def role_selection\n \"#{name}\"\n end",
"def users_role_with_this_submission(user)\n if self.corresponding_author == user\n return 'Corresponding Author'\n elsif self.coauthors.include?(user)\n return 'Coauthor'\n elsif self.reviewers.include?(user)\n return 'Reviewer'\n elsif section_editors.include?(user)\n return 'Section Editor'\n else\n return 'This user is not associated with this manuscript'\n end \n end",
"def current_user_role\n current_user.try(:role).try(:to_sym) || :normal\n end",
"def role\n if self.admin || (Setting.no_security == \"true\")\n return :admin\n elsif self.reviewer\n return :reviewer\n else\n return :default\n end\n end",
"def get_role\n return case self.role_id\n when 2\n \"User\"\n else\n \"N/A\"\n end\n end",
"def switch_role(student_action, tutor_action)\n case @prop[:role]\n when \"student\"\n student_action\n when \"Tutor\"\n tutor_action\n else\n puts 'You have selected an invalid option'\n end \n end",
"def determine_user_role\n if logged_in? #Then you are a member and you have a role\n if @current_user.role == \"Administrator\"\n @admin_user = true\n @superadmin_user = false\n @member = false\n elsif @current_user.role == \"Super Administrator\"\n @superadmin_user = true\n @admin_user = false\n @member = false\n #You are a member\n else\n @admin_user = false\n @superadmin_user = false\n @member = true\n end\n #else you are not a member and do not have a role\n else\n @admin_user = false\n @superadmin_user = false\n @member = false\n end\n end",
"def role; end",
"def role; end",
"def role?(role_name)\n role == role_name\n \n end",
"def role_str\n if (role == nil)\n role_result = \"participant\"\n else\n role_result = role\n end\n role_result\n end",
"def valid_role?(choice)\n\t\tchoice == \"codemaker\" || choice == \"codebreaker\" ? true : false\n\tend",
"def get_full_role\n\t\tif role == \"lead\"\n\t\t\treturn \"Project Lead\"\n\t\telsif role == \"editor\"\n\t\t\treturn \"editor\"\n\t\tend\n\tend",
"def getRole (user)\n case user.role\n when 0\n return 'user'\n when 1\n return 'operator'\n when 2\n return 'cto_user'\n when 3\n return 'owner'\n when 4\n return 'anonymous'\n else\n raise ('invalid user' + user.role)\n end\n end",
"def user_role(params)\n role = nil\n key = params.is_a?(String) ? params : (params && params.has_key?(:key) ? params[:key] : nil)\n\n unless key.blank?\n if self.moderator_key == key\n role = :moderator\n elsif self.attendee_key == key\n if BigbluebuttonRails.configuration.guest_support\n role = :guest\n else\n role = :attendee\n end\n end\n end\n role\n end",
"def is?( requested_role )\n self.role == requested_role.to_s\n end",
"def show\n render layout: @current_role.name\n end",
"def role(user)\n if user.admin\n return \"Admin\"\n else return \"User\"\n end\n end",
"def display_role\n ROLE_LIST[self.role]\n end",
"def get_full_role\n if role == \"admin\"\n return \"Administrator\"\n elsif role == \"lead\"\n return \"Organization Lead\"\n end\n end",
"def check_for_role\n self.role = ROLES[:user] if self.role.nil?\n end",
"def current_role\n \tcase current_user.role\n \twhen 1 \n \t\t@current_role='Empleado'\n \twhen 2 \n \t\t@current_role='Jefe Departamento'\n \twhen 3 \n \t\t@current_role='Auditor'\n \twhen 4 \n \t\t@current_role='Administrador'\n \tend\n end",
"def is?( requested_role )\n\t\tself.role = Role.find_by(name: \"regular\") if role.nil?\n \tself.role.name == requested_role.to_s\n end",
"def role\n admin ? \"admin\" : \"user\"\n end",
"def render_value(value, field:, **opt)\n (value.to_s == 'roles') ? roles(**opt) : super\n end",
"def index\n if current_user.nil?\n show_empty\n elsif current_user.role.id == 1\n show_analist\n elsif current_user.role.id == 2\n show_qa_analist\n elsif current_user.role.id == 3\n show_planner\n elsif current_user.role.id == 5\n show_admin\n else\n show_empty\n end\n end",
"def role_for(cdmp)\n case cdmp.role\n when 'http://credit.niso.org/contributor-roles/data-curation'\n 'DataCurator'\n when 'http://credit.niso.org/contributor-roles/formal-analysis',\n 'http://credit.niso.org/contributor-roles/validation'\n 'Researcher'\n when 'http://credit.niso.org/contributor-roles/investigation'\n 'ProjectLeader'\n when 'http://credit.niso.org/contributor-roles/methodology'\n 'DataManager'\n when 'http://credit.niso.org/contributor-roles/project-administration'\n 'ProjectManager'\n when 'http://credit.niso.org/contributor-roles/software'\n 'Producer'\n when 'http://credit.niso.org/contributor-roles/supervision'\n 'Supervisor'\n when 'http://credit.niso.org/contributor-roles/writing-review-editing'\n 'Editor'\n else\n 'ProjectMember'\n end\n end",
"def role\n if current_user.has_role?(:guest)\n redirect_to \"/workouts\"\n elsif current_user.has_role?(:instructor)\n redirect_to \"/workouts\"\n end\n end",
"def get_role\n\t\tif self.roles[0]\t\n\t\t\tself.roles[0].role_type \n\t\telse\n\t\t\t0\n\t\tend\n\tend",
"def display_erb_for_roles(roles_to_check, condition, &block)\n roles_to_check = smoosh(roles_to_check)\n \n roles_for_user = eval '@controller.roles_for_user', block\n raise \"Error: Could not retrieve the user's roles (is the permissions plugin setup properly?)\" unless roles_for_user\n\n #puts \"[erb_for_roles] roles = #{roles_for_user.inspect}\"\n \n for role in roles_to_check\n if condition.call(roles_for_user, role)\n data = capture(&block)\n eval(\"_erbout\", block).concat data\n end\n end\n \n nil\n end",
"def role\n @role ||=\n if is_admin?\n :admin\n else\n :customer\n end\n end",
"def role_str\n case name\n when ROLE_ADMIN then I18n.t(\"model.role.admin\") \n when ROLE_COMPANY then I18n.t(\"model.role.company\")\n when ROLE_ENGINEER then I18n.t(\"model.role.engineer\")\n when ROLE_NORMAL then I18n.t(\"model.role.normal\")\n end\n end",
"def role(req)\n \"admin:#{dealership(req).id}\"\n end",
"def type\n TYPES[roletype_id]\n end",
"def role_name\n @role_name ||= object.meta[:role].try(:capitalize)\n end",
"def role\n @role\n end",
"def role?(r)\n self.role == r.to_s\n end",
"def edit\n @role = current_user.role.name\n super\n end",
"def role_header_text\n case @role\n when TECH\n 'Your Lab Technician Timesheets'\n when CHK_OUT\n 'Your Equipment Checkout Timesheets'\n when TA_GRADER\n 'Your Lab TA/Grader Timesheets'\n end\n end",
"def check_for_role\n\t\tself.role = ROLES[:user] if self.role.nil?\n\tend",
"def role?(role)\n self.role == role.to_s\n end",
"def role?(role)\n self.role == role.to_s\n end",
"def role_template_id\n return @role_template_id\n end",
"def role_type\n return User.role_type_from_string(self.role)\n end",
"def user_role\n USER_ROLE[role]\n end",
"def check_for_role\n\t\tself.role = ROLES[:user] if !self.role.present?\n\tend",
"def clean_study_role(role)\n return 'Other' if role.blank?\n case role.downcase\n when /phys.*ther/\n 'Physical Therapist'\n when /physical/\n 'Other'\n when /phleb/\n 'Phlebotomist'\n when /nurse/\n 'Nurse'\n when /regu|coord/\n 'Coordinator'\n when /physici/\n 'Physicist'\n when /phys|doctor|md/\n 'Physician'\n when /pharm/\n 'Pharmicist'\n when /informat/\n 'Informaticist'\n when /advisor/\n 'Advisor'\n when /stude/\n 'Student'\n when /assist/\n 'Assistant'\n when /manag|admin/\n 'Administrator/Manager'\n when /tech/\n 'Technician'\n when /co-i|co_i|co-pd/\n 'Co-Investigator'\n when /principal|pd\\/pi|contact p|investigator|director/\n 'PI'\n when /fellow|post/\n 'Fellow'\n when /stat|data m|analyst/\n 'Biostatistician'\n when /pharm|other|o\\.s\\.p|advisor|sponso|rap|admin/\n 'Other'\n when /faculty|prof|mentor|collabor/\n 'Faculty'\n else\n 'Other'\n end\nend",
"def choose_role\n puts \"Press 1 to be the Codebreaker or 2 to be the Codemaker\"\n input = gets.chomp\n if input == \"1\"\n @maker.random_code\n elsif input == \"2\"\n @maker.set_code\n @breaker.ai = true\n else\n choose_role\n end\n end",
"def role\n permission_type\n end",
"def lookup_role(document=nil)\n raise NotImplementedError\n end",
"def role_home_path\n cu = current_user\n if cu.role.name == 'admin'\n users_path\n elsif cu.role.name == 'applicant'\n ad_path\n elsif cu.role.name == 'campus admin'\n review_proposals_path\n elsif cu.role.name == 'campus reviewer'\n review_proposals_path\n elsif cu.role.name == 'prrp admin'\n assignment_index_proposals_path\n elsif cu.role.name == 'prrp reviewer'\n review_proposals_path\n end\n end",
"def role?(role)\n self.role.to_s == role.to_s\n end",
"def plans_templates_show\n @user = User.find_by_id(session[:user_id])\n \n # If an institutional user, return the template \n if user_role_in?(:dmp_admin)\n @plan = Plan.find_by_id(params[:id])\n \n @plan\n elsif user_role_in?(:institutional_admin, :institutional_reviewer, :resource_editor, :template_editor)\n\n @plan = Plan.joins(:users).where(\"users.institution_id IN (?)\", @user.institution.id).find_by_id(params[:id])\n\n # User does not have access to the requested plan\n if @plan.nil?\n render_not_found\n else\n @plan\n end\n else\n render_unauthorized\n end\n end",
"def select_the_player_role\n output = nil\n # input validation\n until %w[maker breaker].include?(output)\n puts 'Do you want to be a [maker] or a [breaker]?'\n output = gets.chomp\n end\n output\n end",
"def template_from_params\n case params[:view]\n when 'scouts'\n 'scouts'\n else\n 'liiikes'\n end\n end",
"def role_for_object(object)\n # Order is important here as captains may change some but NOT all things via mass update\n if object.is_a?(Match) && (self.captained_teams.include?(object.home_participant) || self.captained_teams.include?(object.away_participant))\n :captain\n elsif Permissions.can_edit? object\n :admin\n else\n :default\n end\n end",
"def role?\n false\n end",
"def role_template_id=(value)\n @role_template_id = value\n end",
"def role\r\n r = read_attribute(:role)\r\n r.capitalize unless r.nil?\r\n end",
"def create_role_config\n template \"#{template_file}\", \"#{role_name}.json\"\n end",
"def assign_role(role)\n if role == 'cm'\n @player = 'codemaker'\n @computer = 'codebreaker'\n announce_role\n elsif role == 'cb'\n @player = 'codebreaker'\n @computer = 'codemaker'\n announce_role\n else\n puts \"Invalid Selection. Either choose 'cb' or 'cm'.\"\n choose_role\n end\n end",
"def role_given?\n self.resources_configuration[:self][:role].present?\n end",
"def validate_role(type)\n validation_success = false\n\n if defined? session[:user_type]\n if session[:user_type] == type\n validation_success = true\n end\n end\n\n if validation_success == false\n redirect_to (GyanV1::Application.config.landing_page.to_s)\n end\n end",
"def show\n if current_user.role.nil?\n flash.notice = \"You are not authorized for that operation.\"\n redirect_to home_index_path\n elsif current_user.role.include?(\"administrator\") || current_user.role.include?(\"intern\")\n render :show\n elsif current_user.role.include?(\"volunteer\")\n if current_user.customers.include? @order.customer\n render :show\n else\n flash.notice = \"You are not authorized for that operation.\"\n redirect_to home_index_path\n end\n else\n flash.notice = \"You are not authorized for that operation.\"\n redirect_to home_index_path\n end\n end",
"def check_user_role \t \n redirect_to root_path unless current_user.roles.first.name == \"empleado\" or current_user.roles.first.name == \"supervisor\"or current_user.roles.first.name == \"admin\" \n end",
"def is_role(r)\n return r == role\n end",
"def role?(role)\n self.role == role.to_s ? true : false\n end",
"def determine_template(options); end",
"def new\n if current_user == nil\n redirect_to root_path, :alert => 'Access Denied'\n \n else\n if (current_user.role == \"volunteer\") or (current_user.role == nil)\n redirect_to root_path, :alert => 'Access Denied'\n \n else\n build_resource({})\n set_minimum_password_length\n yield resource if block_given?\n respond_with self.resource\n end\n end\n end",
"def make_role_choice(human_name)\n puts \"Hi there #{human_name}! Enter b to play as the codeBreaker or m to play as the codeMaker.\"\n choice = gets.chomp.to_s\n if %w[b m].include?(choice)\n create_players(choice, human_name)\n else make_role_choice(human_name)\n end\n end",
"def ensure_there_is_a_role\n if role.blank?\n self.role = \"student\"\n end\n end",
"def define_user\n case new_resource.im_install_mode\n when 'admin'\n user = if new_resource.user.nil?\n 'root'\n else\n unless im_user_exists_unix?(new_resource.user)\n Chef::Log.fatal \"User Name provided #{new_resource.user}, does not exist\"\n raise \"User Verification 1: User Name provided #{new_resource.user}, does not exist\"\n end\n new_resource.user\n end\n user\n when 'nonAdmin', 'group'\n user = if new_resource.user.nil?\n Chef::Log.fatal \"User Name not provided! Please provide the user that should be used to install your product\"\n raise \"User Name not provided! Please provide the user that should be used to install your product\"\n else\n unless im_user_exists_unix?(new_resource.user)\n Chef::Log.fatal \"User Name provided #{new_resource.user}, does not exist\"\n raise \"User Verification 1: User Name provided #{new_resource.user}, does not exist\"\n end\n new_resource.user\n end\n user\n end\nend",
"def define_user\n case new_resource.im_install_mode\n when 'admin'\n user = if new_resource.user.nil?\n 'root'\n else\n unless im_user_exists_unix?(new_resource.user)\n Chef::Log.fatal \"User Name provided #{new_resource.user}, does not exist\"\n raise \"User Verification 1: User Name provided #{new_resource.user}, does not exist\"\n end\n new_resource.user\n end\n user\n when 'nonAdmin', 'group'\n user = if new_resource.user.nil?\n Chef::Log.fatal \"User Name not provided! Please provide the user that should be used to install your product\"\n raise \"User Name not provided! Please provide the user that should be used to install your product\"\n else\n unless im_user_exists_unix?(new_resource.user)\n Chef::Log.fatal \"User Name provided #{new_resource.user}, does not exist\"\n raise \"User Verification 1: User Name provided #{new_resource.user}, does not exist\"\n end\n new_resource.user\n end\n user\n end\nend",
"def Role(input, &block) # rubocop:disable Naming/MethodName\n result = case input\n when Sipity::Role\n input\n when String, Symbol\n Sipity::Role.find_or_create_by(name: input)\n end\n\n handle_conversion(input, result, :to_sipity_role, &block)\n end",
"def role\n @manifest_options[:role] || \"\"\n end",
"def has_role?( role_in_question )\n role_in_question == 'token'\n end",
"def role?\n role.name.to_sym\n end",
"def role?(role)\n if self.role == role.to_s\n return true\n else\n return false\n end\n end",
"def role(role_name)\n context.send(role_name)\n end",
"def resource_name\n\t\t\"role\"\n\tend",
"def role?(role)\n\t self.role.name == role\n end",
"def prompt_user_roles(account_id, user_id, selected_roles=[], options={})\n passed_role_names = []\n if !selected_roles.empty?\n if selected_roles.is_a?(String)\n passed_role_names = selected_roles.split(',').uniq.compact.collect {|r| r.strip}\n else\n passed_role_names = selected_roles\n end\n end\n\n available_roles = @account_users_interface.available_roles(account_id, user_id)['roles']\n\n if available_roles.empty?\n print_red_alert \"No available roles found.\"\n exit 1\n end\n role_options = available_roles.collect {|role|\n {'name' => role['authority'], 'value' => role['id']}\n }\n\n roles = []\n\n if !passed_role_names.empty?\n invalid_role_names = []\n passed_role_names.each do |role_name|\n found_role = available_roles.find {|ar| ar['authority'] == role_name || ar['id'] == role_name.to_i}\n if found_role\n roles << found_role\n else\n invalid_role_names << role_name\n end\n end\n if !invalid_role_names.empty?\n print_red_alert \"Invalid Roles: #{invalid_role_names.join(', ')}\"\n exit 1\n end\n else\n no_prompt = (options[:no_prompt] || (options[:options] && options[:options][:no_prompt]))\n v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'roles', 'fieldLabel' => 'Role', 'type' => 'select', 'selectOptions' => role_options, 'required' => true}], options[:options])\n role_id = v_prompt['roles']\n roles << available_roles.find {|r| r['id'].to_i == role_id.to_i }\n add_another_role = !no_prompt\n while add_another_role do\n v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'roles', 'fieldLabel' => 'Another Role', 'type' => 'select', 'selectOptions' => role_options, 'required' => false}], options[:options])\n if v_prompt['roles'].to_s.empty?\n add_another_role = false\n else\n role_id = v_prompt['roles']\n roles << available_roles.find {|r| r['id'].to_i == role_id.to_i }\n end\n end\n \n end\n\n roles = roles.compact\n return roles\n\n end",
"def role?(role_to_compare)\n self.role.to_s == role_to_compare.to_s\n end",
"def role\n return @role\n end",
"def authorized_for_roles(*args)\n # From: http://stackoverflow.com/a/6076035/999973\n # args.any? { |role_name| ROLES.include? role_name }\n # ROLES = %w[admin moderator editor author banned] in user model\n # calling it:\n # before_filter(only: [:edit, :update, :destroy]) {|c| c.authorized_for_roles \"admin\", \"editor\"}\n \n # args.any? { |role_name| current_user.role == role_name }\n \n\n unless signed_in?\n self.current_user = User.create( name: \"Guest\" )\n redirect_to(root_path) unless args.any? { |role_name| current_user.role == role_name }\n self.current_user = nil\n return\n end\n\n redirect_to(root_path) unless args.any? { |role_name| current_user.role == role_name }\n end",
"def role(role_name, placement=nil)\n add_to_run_list(\"role[#{role_name}]\", placement)\n self.instance_eval(&@@role_implications[role_name]) if @@role_implications[role_name]\n end",
"def action_allowed?\n ['Instructor',\n 'Teaching Assistant',\n 'Administrator'].include? current_role_name\n end",
"def action_allowed?\n ['Instructor',\n 'Teaching Assistant',\n 'Administrator'].include? current_role_name\n end",
"def action_allowed?\n ['Instructor',\n 'Teaching Assistant',\n 'Administrator'].include? current_role_name\n end",
"def show?\n user.can_modify_templates? && (phase.template.org_id == user.org_id)\n end",
"def validates_role\n self.role = Role.find_by_name \"Technician\" if self.role.nil?\n end",
"def main_menu_choose_option(user_input)\n case user_input\n when 'trains'\n manage_trains\n when 'routes'\n manage_routes\n when 'stations'\n manage_stations\n when 'cars'\n manage_cars\n else\n @ui.wrong_input_msg\n end\n end",
"def role\n puts \"Now give #{@name} a role\"\n @role = gets.chomp.upcase\n puts \"The Gods are considering your request, please wait 3 seconds\"\n sleep 3\n puts \"The Gods have heard you and #{@name} shall be a: #{@role}\"\n end"
] |
[
"0.63387823",
"0.6185178",
"0.61661524",
"0.6097327",
"0.5907389",
"0.5847887",
"0.5812435",
"0.5806212",
"0.577569",
"0.57585496",
"0.5751642",
"0.5709563",
"0.567694",
"0.5663513",
"0.562555",
"0.562555",
"0.5595641",
"0.5591923",
"0.5576684",
"0.5565431",
"0.5546345",
"0.55195516",
"0.550912",
"0.5509107",
"0.55007774",
"0.5489748",
"0.54773414",
"0.5463612",
"0.544178",
"0.54408103",
"0.54375684",
"0.5430151",
"0.54229885",
"0.5422056",
"0.5412751",
"0.5401242",
"0.53970003",
"0.5396698",
"0.5384911",
"0.5384768",
"0.5381696",
"0.53766245",
"0.5371006",
"0.53611034",
"0.53538805",
"0.53496385",
"0.5342325",
"0.53362066",
"0.53362066",
"0.53309923",
"0.5316763",
"0.5316254",
"0.53154856",
"0.52986974",
"0.52915233",
"0.5290962",
"0.52893525",
"0.5280266",
"0.52680117",
"0.52510625",
"0.5249105",
"0.52463037",
"0.52460843",
"0.5232574",
"0.52320105",
"0.5222704",
"0.52203083",
"0.52200836",
"0.52166325",
"0.5211282",
"0.52052754",
"0.51974845",
"0.5196905",
"0.51927084",
"0.51924706",
"0.51737136",
"0.51667476",
"0.5166017",
"0.5153876",
"0.5153876",
"0.5148419",
"0.51385444",
"0.51371413",
"0.5132881",
"0.51302505",
"0.5128766",
"0.5126532",
"0.512268",
"0.5115879",
"0.5113924",
"0.5110216",
"0.51061577",
"0.5097676",
"0.5089233",
"0.5089233",
"0.5089233",
"0.50890416",
"0.5088698",
"0.5078991",
"0.50787836"
] |
0.709624
|
0
|
Update variables in provided template.
|
def generate_template()
file_name = @hostname + '.tf'
check_file_exists(file_name)
template_path = determine_role()
template = File.read(template_path)
renderer = ERB.new(template, nil, '-')
open(file_name, 'w') { |f|
f.puts renderer.result(self.get_binding)
f.close
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update!(**args)\n @deidentify_template = args[:deidentify_template] if args.key?(:deidentify_template)\n @inspect_template = args[:inspect_template] if args.key?(:inspect_template)\n end",
"def update!(**args)\n @deidentify_template = args[:deidentify_template] if args.key?(:deidentify_template)\n @inspect_template = args[:inspect_template] if args.key?(:inspect_template)\n end",
"def update\n\n respond_to do |format|\n if @template.update(template_params)\n params[:template_fields].each do |p|\n # name: p[0], val: p[1]\n field = Field.find_by(:code => p[0])\n tf = TemplateField.find_by(:field_id => field.id, :template_id => @template.id)\n tf.val = p[1]\n tf.save\n end\n format.html { redirect_to dashboard_path, notice: t('template_updated') }\n else\n format.html { render :edit}\n end\n end\n end",
"def update!(**args)\n @kind = args[:kind] if args.key?(:kind)\n @status = args[:status] if args.key?(:status)\n @template_content = args[:template_content] if args.key?(:template_content)\n @template_name = args[:template_name] if args.key?(:template_name)\n @template_type = args[:template_type] if args.key?(:template_type)\n end",
"def update_template(key, value)\n t = { key => value }\n raw = read_attribute(\"template\") \n d = raw.nil? ? {} : JSON.parse(raw) \n merged = d.deep_merge(t)\n self.template = JSON.generate(merged)\n self.save!\n end",
"def update!(**args)\n @country = args[:country] if args.key?(:country)\n @template_name = args[:template_name] if args.key?(:template_name)\n @test_order = args[:test_order] if args.key?(:test_order)\n end",
"def replaceVariables\n\t\t@template = @template.gsub! \"###namespace###\", @namespace\n\t\t@template = @template.gsub! \"###model-name###\", @modelName\n\t\t@template = @template.gsub! \"###properties###\", @properties\n\tend",
"def update\n update_elements if elements_params.present?\n @template.update(name: template_params[:name]) if template_params[:name].present?\n\n if @template.errors.empty?\n render :show, status: :ok, location: @template\n else\n render json: @template.errors, status: :unprocessable_entity\n end\n end",
"def update!(**args)\n @message_set = args[:message_set] if args.key?(:message_set)\n @template_name = args[:template_name] if args.key?(:template_name)\n end",
"def replaceVariables\n\t\t@template = @template.gsub! \"###namespace###\", @namespace\n\t\t@template = @template.gsub! \"###model-name###\", @modelName\n\t\t@template = @template.gsub! \"###baseApi###\", (@baseApi.nil? ? \"\" : \" : #{@baseApi}\")\n\tend",
"def update_params\n { stack_name: stack.identifier }.merge(template_param).merge(options)\n end",
"def update_params\n { stack_name: stack.identifier }.merge(template_param).merge(options)\n end",
"def update!(**args)\n @variables = args[:variables] if args.key?(:variables)\n end",
"def update!(**args)\n @kind = args[:kind] if args.key?(:kind)\n @template = args[:template] if args.key?(:template)\n end",
"def update\n template = Template.find(params[:id])\n authorize template\n begin\n args = template_params\n # Swap in the appropriate visibility enum value for the checkbox value\n args[:visibility] = parse_visibility(args, current_user.org)\n template.assign_attributes(args)\n template.links = ActiveSupport::JSON.decode(params['template-links']) if params['template-links'].present?\n if template.save\n render(json: {\n status: 200,\n msg: success_message(template, _('saved'))\n })\n else\n render(json: {\n status: :bad_request,\n msg: failure_message(template, _('save'))\n })\n end\n rescue ActiveSupport::JSON.parse_error\n render(json: {\n status: :bad_request,\n msg: format(_('Error parsing links for a %{template}'),\n template: template_type(template))\n })\n nil\n rescue StandardError => e\n render(json: {\n status: :forbidden,\n msg: e.message\n }) and return\n end\n end",
"def update\n if @template.update(template_params)\n handle_save_success @template, :ok, t('templates.update_success')\n else\n handle_save_error @template.errors, :edit\n end\n end",
"def template_replace template, myhash\n #tmpltext=File::read(template);\n\n t = template.dup\n t.gsub!( /##(.*?)##/ ) {\n #raise \"Key '#{$1}' found in template but the value has not been set\" unless ( myhash.has_key?( $1 ) )\n myhash[ $1 ].to_s\n }\n t\n end",
"def fill_old(params={})\n params.each do |key,value|\n instance_variable_set(\"@#{key}\".to_sym,value)\n end\n self.body = (template).result binding\n self.body\n end",
"def update!(**args)\n @data_object = args[:data_object] if args.key?(:data_object)\n @ignore_data_object = args[:ignore_data_object] if args.key?(:ignore_data_object)\n @src = args[:src] if args.key?(:src)\n @templatetype = args[:templatetype] if args.key?(:templatetype)\n end",
"def update(name=nil)\n if name\n template = find(name)\n template.update\n else\n list.each do |template|\n template.update\n end\n end\n end",
"def update!(**args)\n @new_tag_template_field_id = args[:new_tag_template_field_id] if args.key?(:new_tag_template_field_id)\n end",
"def update\n @user_template = UserTemplate.find_or_initialize_by_alias(params[:user_template][:alias])\n #logger.info(params[:user_template])\n #logger.info(\"----------------\")\n respond_to do |format|\n if @user_template.update_attributes(params[:user_template])\n flash[:notice] = \"Template '#{@user_template.title}' was successfully updated.\"\n format.html { redirect_to(user_templates_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user_template.errors, :status => :unprocessable_entity }\n end\n end\n # remove the stale template info from the cache\n UserTemplate.clear_template_cache(@user_template.alias)\n add_audit_trail(:details => \"Updated a template with alias: #{@user_template.alias}\")\n end",
"def update(id, values, update_published = false)\n @client.call(method: :put, path: \"templates/#{id}\", body_values: values, query_values: { update_published: update_published })\n end",
"def update!(**args)\n @tag = args[:tag] if args.key?(:tag)\n @trigger = args[:trigger] if args.key?(:trigger)\n @variable = args[:variable] if args.key?(:variable)\n end",
"def update!(**args)\n @job_templates = args[:job_templates] if args.key?(:job_templates)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @unreachable = args[:unreachable] if args.key?(:unreachable)\n end",
"def update!(**args)\n @dataset_template = args[:dataset_template] if args.key?(:dataset_template)\n end",
"def update_template_with_image_id(template)\n params = template.parameters\n params.each do |key, value|\n update_params_with_image_id(params, key, value)\n end\n end",
"def set_content_variables(template)\n content = template.content\n tags = template.tags(content)\n tags.each do |tag|\n if @template.questions.where(tag: tag).count > 0\n replacement = @template.questions.where(tag: tag).first.answer\n content.gsub! tag, replacement\n end\n end\n return content\n end",
"def update\n puts template_params\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @imports = args[:imports] if args.key?(:imports)\n @interpreter = args[:interpreter] if args.key?(:interpreter)\n @main_template = args[:main_template] if args.key?(:main_template)\n @schema = args[:schema] if args.key?(:schema)\n @template = args[:template] if args.key?(:template)\n end",
"def update\n respond_to do |format|\n if @my_template.update(my_template_params)\n format.html { redirect_to @my_template, notice: 'My template was successfully updated.' }\n format.json { render :show, status: :ok, location: @my_template }\n else\n format.html { render :edit }\n format.json { render json: @my_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mytemplate = Mytemplate.get(params[:id])\n \n @mytemplate.name = params[:mytemplate][:name]\n @mytemplate.folder = params[:mytemplate][:folder]\n @mytemplate.description = params[:mytemplate][:description]\n \n respond_to do |format|\n if @mytemplate.save\n format.html { redirect_to mytemplates_path }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mytemplate.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @_template = @site.templates.find(params[:id])\n @_template.updated_by = current_user\n\n respond_to do |format|\n if @_template.update_attributes(params[:template])\n flash[:notice] = \"Template was successfully updated.\"\n format.html { redirect_to([:admin, @site, @_template]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @_template.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @column = args[:column] if args.key?(:column)\n @fields = args[:fields] if args.key?(:fields)\n @name = args[:name] if args.key?(:name)\n @template = args[:template] if args.key?(:template)\n @template_display_name = args[:template_display_name] if args.key?(:template_display_name)\n end",
"def update!(**args)\n @column = args[:column] if args.key?(:column)\n @fields = args[:fields] if args.key?(:fields)\n @name = args[:name] if args.key?(:name)\n @template = args[:template] if args.key?(:template)\n @template_display_name = args[:template_display_name] if args.key?(:template_display_name)\n end",
"def update!(**args)\n @encrypted_variables = args[:encrypted_variables] if args.key?(:encrypted_variables)\n @secret_variables = args[:secret_variables] if args.key?(:secret_variables)\n @variables = args[:variables] if args.key?(:variables)\n end",
"def update!(**args)\n @encrypted_variables = args[:encrypted_variables] if args.key?(:encrypted_variables)\n @secret_variables = args[:secret_variables] if args.key?(:secret_variables)\n @variables = args[:variables] if args.key?(:variables)\n end",
"def update\n if @custom_template.update custom_template_params\n redirect_to @custom_template\n else\n render 'edit'\n end\n end",
"def replace_path_variables(template_path, plugin_info)\n path = template_path.dup\n\n loop do\n replacement_variable_regexp = /%([\\w\\-]*)%/\n match = replacement_variable_regexp.match(path)\n\n break unless match\n\n replacement_value = plugin_info.send(match[1].to_sym)\n path.gsub!(replacement_variable_regexp, replacement_value)\n end\n\n path\n end",
"def update\n respond_to do |format|\n if @attr_template.update(attr_template_params)\n format.html { redirect_to @attr_template, notice: 'Attr template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @attr_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_positions\n params[\"edit_template_area_#{params[:id]}\"].each_with_index do |id, position|\n TemplateBox.update(id, :position => position)\n end\n init_template_areas\n #render :layout => false,\n # :partial => \"template_area\",\n # :object => @template_areas.find{|a| a.id == params[:id].to_i} #TODO Dry it\n flash[:notice] = \"Reihenfolge gespeichert\"\n render :update do |page|\n page.reload\n end\n end",
"def update\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to email_templates_path, notice: 'template was successfully updated.' }\n format.json { render :show, status: :ok, location: @template }\n else\n format.html { render :edit }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to template_path(@template), notice: 'Template was successfully updated.' }\n format.json { render :show, status: :ok, location: @template }\n else\n format.html { render :edit }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @description = args[:description] if args.key?(:description)\n @id = args[:id] if args.key?(:id)\n @insert_time = args[:insert_time] if args.key?(:insert_time)\n @labels = args[:labels] if args.key?(:labels)\n @name = args[:name] if args.key?(:name)\n @operation = args[:operation] if args.key?(:operation)\n @self_link = args[:self_link] if args.key?(:self_link)\n @status = args[:status] if args.key?(:status)\n @template_contents = args[:template_contents] if args.key?(:template_contents)\n end",
"def update(name, html_url, zip_url, screenshot_url)\n options = { :body => { \n :Name => name,\n :HtmlPageURL => html_url,\n :ZipFileURL => zip_url,\n :ScreenshotURL => screenshot_url }.to_json }\n response = CreateSend.put \"/templates/#{template_id}.json\", options\n end",
"def set_template\n @template = Spree::Template.find(params[:id])\n # puts \"ddsfsfsdfsdf\",@template.inspect\n # puts \"ddsfsfsdfsdf\",@template.inspect\n # put\n end",
"def update\n respond_to do |format|\n if @track_template.update(track_template_params)\n format.html { redirect_to @track_template, notice: 'Track template was successfully updated.' }\n format.json { render :show, status: :ok, location: @track_template }\n else\n format.html { render :edit }\n format.json { render json: @track_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def template_update(id, type, filename)\n check_id_or_raise id\n check_template_type_or_raise type\n check_filename_or_raise filename\n response = http_request_multipart :put, @base_url + \"/templates/#{id}.xml\", 200,\n { :provider_key => @provider_key,\n :draft => File.read(filename), \n :multipart => true}\n puts 'at update call'\n _id, _updated_at = parse_response response, type\n response = http_request :put, \"#{@base_url}/templates/#{id}/publish\", 200,\n { :params => { :provider_key => @provider_key } }\n puts 'at publish call'\n parse_response response, 'page'\n end",
"def update\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { render :show, status: :ok, location: @template }\n else\n format.html { render :edit }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { render :show, status: :ok, location: @template }\n else\n format.html { render :edit }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @templates = EmailTemplate.find(:all) \n @email_template = EmailTemplate.find(params[:id])\n @page_title = t('email_templates.new.title', :email_template_name => @email_template.name) \n respond_to do |format|\n if @email_template.update_attributes(params[:email_template])\n flash[:notice] = t('email_templates.new.success', :email_template_name => @email_template.name)\n format.html { redirect_to(edit_email_template_url(@email_template)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @email_template.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update \n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { render :show, status: :ok, location: @template }\n else\n format.html { render :edit }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @sms_template = args[:sms_template] if args.key?(:sms_template)\n @use_device_locale = args[:use_device_locale] if args.key?(:use_device_locale)\n end",
"def update\n restricted\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { render :show, status: :ok, location: @template }\n else\n format.html { render :edit }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :manage, :all\n respond_to do |format|\n if @question_template.update(question_template_params)\n format.html do redirect_to question_template_path(@question_template),\n notice: 'Question template was successfully updated.'\n end\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item_template.update(item_template_params)\n format.html { redirect_to @item_template, notice: 'Item template was successfully updated.' }\n format.json { render :show, status: :ok, location: @item_template }\n else\n format.html { render :edit }\n format.json { render json: @item_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def substitute_and_apply (fexp, template, workitem)\n\n re = RawExpression.new_raw(\n fexp.fei,\n fexp.parent_id,\n fexp.environment_id,\n application_context,\n template)\n\n update(re)\n\n apply(re, workitem)\n end",
"def update_question_template\n if @question_template.update(question_template_params)\n flash[:success] = success_message(@question_template, :update)\n redirect_to survey_template_path(@survey_template)\n else\n flash[:error] = error_message(@question_template, :update)\n render :edit\n end\n end",
"def update\n respond_to do |format|\n if @script_template.update(script_template_params)\n format.html { redirect_to script_template_url(@script_template), notice: \"Script template was successfully updated.\" }\n format.json { render :show, status: :ok, location: @script_template }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @script_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @induction_template.update(induction_template_params)\n format.html { redirect_to @induction_template, notice: 'Induction template was successfully updated.' }\n format.json { render :show, status: :ok, location: @induction_template }\n else\n format.html { render :edit }\n format.json { render json: @induction_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n \n if @question_template.update(question_template_params)\n format.html { redirect_to @question_template, notice: 'Question template was successfully updated.' }\n format.json { render :show, status: :ok, location: @question_template }\n else\n format.html { render :edit }\n format.json { render json: @question_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_template_instance_variables(opts)\n opts.each {|k,v| self.instance_variable_set(\"@#{k}\", v) }\n end",
"def reset_template_assigns; end",
"def process_template(tmpl, vars)\n require \"erb\"\n\n ERB\n .new(tmpl, trim_mode: \"%\")\n .public_send(vars.is_a?(Binding) ? :result : :result_with_hash, vars)\n end",
"def update\n respond_to do |format|\n if @request_template.update(request_template_params)\n respond format, 'Request template was successfully updated.'\n else\n format.html { render :edit }\n format.json { render json: @request_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @form_template.update(form_template_params)\n format.html { redirect_to @form_template, notice: 'Formularvorlage wurde erfolgreich aktualisiert' }\n format.json { render :show, status: :ok, location: @form_template }\n else\n format.html { render :edit }\n format.json { render json: @form_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_template\n Settings.reload!\n @template = Template.find(params[:id])\n end",
"def update\n\n if(template_params[:active_flg] == Template::ACTIVE_FLG[:ACTIVE].to_s)\n Template.clear_all_active_flg\n end\n\n # get template record. If the old active flg is 1,\n # it will not be updated if use @template created in :before_action\n @template = Template.find(params[:id])\n\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end",
"def update\n @inventory_template = InventoryTemplate.find(params[:id])\n # @inventory_template.restaurant = current_owner.restaurant\n\n respond_to do |format|\n if @inventory_template.update_attributes(params[:inventory_template])\n format.html { redirect_to @inventory_template, notice: 'Inventory template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @inventory_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_template_files(opts)\n template_id = opts.delete(:template_id)\n path = \"/template/update_files/#{template_id}\"\n prepare_files opts\n\n HelloSign::Resource::Template.new post(path, body: opts)\n end",
"def update\n respond_to do |format|\n if @post_template.update(post_template_params)\n format.html { redirect_to @post_template, notice: 'Post template was successfully updated.' }\n format.json { render :show, status: :ok, location: @post_template }\n else\n format.html { render :edit }\n format.json { render json: @post_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @questionnaire_template.update(questionnaire_template_params)\n format.html { redirect_to @questionnaire_template, notice: 'questionnaire template was successfully updated.' }\n format.json { render :show, status: :ok, location: @questionnaire_template }\n else\n format.html { render :edit }\n format.json { render json: @questionnaire_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @review_template.update(review_template_params)\n format.html { redirect_to @review_template, notice: 'Review template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @review_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(name, html_url, zip_url)\n options = { :body => {\n :Name => name,\n :HtmlPageURL => html_url,\n :ZipFileURL => zip_url }.to_json }\n put \"/templates/#{template_id}.json\", options\n end",
"def update\n respond_to do |format|\n if @survey_item_template.update(survey_item_template_params)\n format.html { redirect_to @survey_item_template.survey_item_category_template.survey_template, notice: 'Survey item template was successfully updated.' }\n format.json { render :show, status: :ok, location: @survey_item_template }\n else\n format.html { render :edit }\n format.json { render json: @survey_item_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @inspection_template.update(inspection_template_params)\n format.html { redirect_to @inspection_template, notice: 'Inspection template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @inspection_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n Spree::Template.update_all(:selected => false)\n @template = Spree::Template.find(params[:id])\n @template.selected = true\n @template.theme_color = params[:template][:theme_color]\n @template.variant_display_type = params[:template][:variant_display_type]\n @template.is_allowed_custom_theme = params[:template][:is_allowed_custom_theme]\n \n respond_to do |format|\n if @template.save!\n format.html { redirect_to admin_templates_path, notice: 'Template was successfully updated.' }\n format.json { head :no_content }\n else\n flash[:error] = \"#{@template.errors.full_messages.first}\"\n format.html { redirect_to admin_templates_path }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def use_template(template)\n @template = template\n end",
"def orgn_template_update\n @event.template_id = params[:template_id]\n\n if !params[:template_id]\n #redirect_to orgn_template_events_path, :flash => { :error => 'Select a template.' }\n flash[:alert] = 'Select a template.'\n render :action => :orgn_template\n return\n end\n \n @event.template_id = @event.template_id\n \n respond_to do |format|\n if @event.update(template_params)\n format.html { redirect_to event_invite_events_path }\n format.json { head :no_content }\n else\n format.html { redirect_to event_invite_events_path }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cf_template.update(cf_template_params)\n format.html { redirect_to cf_templates_path, notice: I18n.t('cf_templates.msg.updated') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cf_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @template = @form_item.template\n respond_to do |format|\n if @form_item.update(form_item_params)\n format.html {\n anchor = \"itemid_#{ @form_item.id }\"\n redirect_to template_path(@template, anchor: anchor.to_sym), notice: 'Form item was successfully updated.'\n }\n format.json { render :show, status: :ok, location: @form_item }\n else\n format.html { render :edit }\n format.json { render json: @form_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item_template.update(item_template_params)\n format.html { redirect_to @item_template, notice: 'Item Template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @purchase_template = PurchaseTemplate.find(params[:id])\n\n respond_to do |format|\n if @purchase_template.update_attributes(params[:purchase_template])\n format.html { redirect_to @purchase_template, notice: 'Purchase template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @purchase_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @notebook_runtime_template = args[:notebook_runtime_template] if args.key?(:notebook_runtime_template)\n end",
"def update\n respond_to do |format|\n if @survey_template.update(survey_template_params)\n format.html { redirect_to @survey_template, notice: 'Template was successfully updated.' }\n format.json { render :show, status: :ok, location: @survey_template }\n else\n @record = @survey_template\n format.html { render :edit }\n format.json { render json: @survey_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_instance_template_properties# {{{\n\t # if we got here, it means some of parameters changed\n\t # it does not matter which one - we just need to create another template\n\t # and generate refresh event (automatically)\n\t #\n\t #\tXXX may be we should have ensure property and skip this step when\n\t #\tit is set to :absent\n#\tbyebug\n\t create\n\treturn\n end",
"def replace_variables_in_document!\n document.css('w|t').each do |text_node|\n text = text_node.text\n\n next unless text =~ VARIABLE_MATCHER\n next if has_skippable_variable?(text)\n\n variable_replacement = special_variable_replacement(text)\n\n text.gsub!(VARIABLE_MATCHER) do |_match|\n next data[$1].to_s unless variable_replacement\n\n variable_replacement.is_a?(Proc) ?\n variable_replacement.call($1) :\n variable_replacement.to_s\n end\n text_node.content = text\n end\n end",
"def update\n respond_to do |format|\n if @issue_template.update(issue_template_params)\n format.html { redirect_to issue_templates_path, notice: 'Issue template was successfully updated.' }\n else\n format.html { redirect_to issue_templates_path, alert: issue_template.errors }\n end\n end\n end",
"def update_basic_info(info_params)\n p = info_params[:evaluation_template]\n self.update_attributes(name: p[:name], quarter_id: p[:quarter_id],\n active: p[:active], start_date: p[:start_date],\n end_date: p[:end_date])\n end",
"def update\n respond_to do |format|\n if @template_form_field.update(template_form_field_params)\n format.html { redirect_to @template_form_field, notice: 'Template form field was successfully updated.' }\n format.json { render :show, status: :ok, location: @template_form_field }\n else\n format.html { render :edit }\n format.json { render json: @template_form_field.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @event_template.update(event_template_params)\n format.html { redirect_to @event_template, notice: \"Event template was successfully updated.\" }\n format.json { render :show, status: :ok, location: @event_template }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @event_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def use_template(template)\n @template = template\n end",
"def update\n @view_template = ViewTemplate.find(params[:id])\n flash[:notice] = t(\"view_template.flash.notice.updated\") if\n @view_template.successful_update?(params)\n respond_with(@view_template)\n end",
"def update\n\n respond_to do |format|\n if @email_template.update(email_template_params)\n format.html { redirect_to email_templates_path, notice: 'Email template was successfully updated.' }\n format.json { render :show, status: :ok, location: @email_template }\n else\n format.html { render :edit }\n format.json { render json: @email_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product_template.update(product_template_params)\n format.html { redirect_to @product_template, notice: 'Product template was successfully updated.' }\n format.json { render :show, status: :ok, location: @product_template }\n else\n format.html { render :edit }\n format.json { render json: @product_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @invitation_template.update(invitation_template_params)\n format.html { redirect_to @invitation_template, notice: 'Invitation template was successfully updated.' }\n format.json { render :show, status: :ok, location: @invitation_template }\n else\n format.html { render :edit }\n format.json { render json: @invitation_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def process_template(template_name,map)\r\n template = File.dirname(__FILE__) + \"/../templates/#{template_name}.st\"\r\n map['timestamp']=Time.now.httpdate\r\n File.open(template,'r') do | f | \r\n # detect words inside dollar sign pairs\r\n replaced = f.read.gsub(/(\\$\\w*\\$)/) do | match |\r\n key = match[1..match.size-2]\r\n (map.has_key? key) ? map[key] : 'MISSING:'+key\r\n end \r\n return replaced\r\n end # file\r\n end",
"def shave_value(template)\n Mustache.render(template, binding)\n end",
"def update\n if @header_template.update header_template_params\n redirect_to @header_template\n else\n render 'edit'\n end\n end",
"def populate_template( template_id, imported_template )\n puts \"Populating new tempalte id: #{template_id}...\"\n\n uri = URI(@config['endpoint']+\"/#{template_id}/versions\")\n\n # Retrieve templates\n http = Net::HTTP.new( uri.host,uri.port )\n http.use_ssl = true\n request = Net::HTTP::Post.new( uri.request_uri, initheader = {'Content-Type:' => 'application/json'} )\n request.basic_auth(@secondary_username, @secondary_password)\n\n\n # If versions exist, transfer each to new template\n imported_template['versions'].each do |version|\n version.delete(\"id\")\n version.delete(\"user_id\")\n version.delete(\"template_id\")\n version.delete(\"updated_at\")\n\n puts \" Adding template version #{version['name']}...\"\n payload = version.to_json\n request.body = payload\n response = http.request( request )\n response_message = JSON.parse( response.body )\n end\n end"
] |
[
"0.71169126",
"0.71169126",
"0.6879675",
"0.6847859",
"0.6834008",
"0.6828902",
"0.67268366",
"0.67225343",
"0.66063327",
"0.6455532",
"0.6449829",
"0.6449829",
"0.6440274",
"0.6367196",
"0.6360587",
"0.6335289",
"0.6316196",
"0.6290611",
"0.6252233",
"0.62279",
"0.6198995",
"0.6175611",
"0.614056",
"0.61006933",
"0.60875696",
"0.60788864",
"0.6076265",
"0.6058525",
"0.6050373",
"0.60412145",
"0.6001706",
"0.5986377",
"0.5978083",
"0.59767514",
"0.59767514",
"0.59755397",
"0.59755397",
"0.59626853",
"0.59272426",
"0.59177154",
"0.59049344",
"0.5865076",
"0.5854974",
"0.5830341",
"0.58263546",
"0.58225965",
"0.58206636",
"0.5816658",
"0.5816485",
"0.5816485",
"0.5806803",
"0.5805988",
"0.5789921",
"0.57855237",
"0.5778465",
"0.5777753",
"0.57766265",
"0.5773766",
"0.5761611",
"0.5745462",
"0.5739488",
"0.57371914",
"0.5726396",
"0.57234895",
"0.57170826",
"0.57121295",
"0.5707873",
"0.57016265",
"0.57015914",
"0.56925833",
"0.5664071",
"0.56609505",
"0.5653689",
"0.5646106",
"0.5644283",
"0.5641916",
"0.5635446",
"0.5633769",
"0.5629354",
"0.5628043",
"0.5627179",
"0.56235826",
"0.5619496",
"0.5615834",
"0.56101406",
"0.5609211",
"0.5608391",
"0.56052995",
"0.56023824",
"0.5598756",
"0.55930346",
"0.5591435",
"0.5587122",
"0.5586568",
"0.55857724",
"0.5585607",
"0.5585185",
"0.5575548",
"0.5568981",
"0.55530155",
"0.5549531"
] |
0.0
|
-1
|
Check if a provided file_name exists. If not, create. If yes, abort.
|
def check_file_exists(file_name)
if File.exist?(file_name)
logger.fatal "#{file_name} already exists."
abort
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def ensure_exists(filename)\n puts(\"Couldn't find: #{filename}\") and exit unless FileTest.exist?(filename)\n end",
"def ensure_exists(filename)\n return if FileTest.exist?(filename)\n\n puts(\"Couldn't find: #{filename}\") and exit\n end",
"def checkForFileExistence(fileName)\n raise \"#{fileName} file already exists\" if File.exist?(fileName);\nend",
"def ensure_exists(file)\n File.exist?(file) ? file : nil\n end",
"def ok_to_create?(filepath)\n File.exist?(filepath) ? prompt_to_overwrite?(filepath) : true\n end",
"def ensure_file!(file)\n return if File.exists?(file)\n if VIM.evaluate(%{confirm(\"Create #{file}?\", \"&Yes\\n&No\", 1)}) == 1\n file_to_create = VIM.evaluate(%{input(\"File to create: \", \"#{file}\")})\n Pathname.new(file_to_create).dirname.mkpath\n File.open(file_to_create, \"w\") {}\n else\n raise RelatedError, \"File #{file} does not exist\"\n end\n end",
"def ensure_exists\n create unless Dir.exist? path\n end",
"def file_exists?(name)\n File.file?(File.join(path, name))\n end",
"def exist; File.exist?(@fname); end",
"def file_exists?(file_name)\n test(\"[ -f #{file_name} ]\")\n end",
"def check_file!(filename)\n unless ::File.exists?(filename)\n raise FileNotFound\n end\n end",
"def file_exists?(file)\n false\n end",
"def touch_if_not_exist(file)\n FileUtils.touch(file) unless File.exist?(file)\n file\n end",
"def file_exists?(filename)\n\tif !File.exists?(filename) \n\t\tabort \"Unable to read file #{filename}\"\n\tend\nend",
"def file_exists?\n File.exists?(@filename)\n end",
"def file_exists?\n !!file_path\n end",
"def file_exists?\n !!file_path\n end",
"def cry_exist?(filename)\n return File.exist?(filename)\n end",
"def check_file_exist(_Filename)\r\n unless File.exist?(\"#{_Filename.to_s}.yml\")\r\n File.open(\"#{_Filename.to_s}.yml\", 'w')\r\n end\r\n end",
"def ensure_exists(file)\n if not File.file?(file)\n throw Exception.new(\"No #{ File.extname(file) } file found at #{ file }. Please ensure it exists, or that you have transpiled the necessary files.\")\n else\n file\n end\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 file_exists?\n\tdirectory_name = \"db/seed_files\"\n\tunless File.exist?(directory_name)\n\t\tputs \"Created folder 'db/seed_files'\"\n\t\tDir.mkdir(directory_name)\n\tend\nend",
"def file_name_exist?(name)\n return true if !name.blank?\n errors.add(:name, \"Nazwa nie moze byc pusta!\")\n false\n end",
"def create_if_missing(path)\n FileUtils.mkdir(path) unless File.exists?(path)\n end",
"def create_if_missing(path)\n FileUtils.mkdir(path) unless File.exists?(path)\n end",
"def create_if_missing(path)\n FileUtils.mkdir(path) unless File.exists?(path)\n end",
"def file_exist?(_file_name_=false)\n File.exists?(_file_name_ || current_file_path)\n end",
"def file_exists\n end",
"def file_exists?(filename)\n shell_exec(\"test -f #{filename}\")\n rescue\n false\n else\n true\n end",
"def file_exists?(path)\n end",
"def fileExists?(filename)\n shell_exec(\"test -f #{filename}\") rescue return false\n true\n end",
"def file_exist?(file_path)\n File.exist?(file_path)\n end",
"def safeExists?(f)\r\n ret=false\r\n File.open(f,\"rb\") { ret=true } rescue nil\r\n return ret\r\nend",
"def exists?\n File.exists?(filename)\n end",
"def find_or_create_file(file, name, requires_edit=false)\n if File.exists?(file)\n file\n else\n create_file(file, name, requires_edit)\n end\n end",
"def check_exists\n raise GlusterFS::Error, \"File does not exist: #{@path}\" unless exists?\n end",
"def file_exists(file_name)\r\n if File.exists?(file_name) \r\n File.delete(file_name)\r\n end\r\nend",
"def create_if_missing \n if File.exists?(@folder)\n return\n else\n Dir.mkdir(@folder) unless \n $LOG.info(\"#{@name} : #{@folder} created\")\n end\n end",
"def has_file? name\n File.file? path / name\n end",
"def file_exists?(file)\n File.file? file\n end",
"def create_file(filename)\n # See zipfile branch in repository for zip file creation code.\n Dir.mkdir filename\n # TODO: Handle case where directory can't be created.\n end",
"def Check_File(_Filename)\r\n unless File.exist?(\"#{_Filename.to_s}.yml\")\r\n File.open(\"#{_Filename.to_s}.yml\", 'w')\r\n end\r\nend",
"def exist?(name)\n File.exist?(path(name))\n end",
"def exist?\n ::File.exist?(file_path)\n end",
"def file_exists?(file)\n File.exists?(file)\n end",
"def file_exists?\r\n File.file?(full_path)\r\n end",
"def exists?\n File.exist? file_path\n end",
"def test_file_existence(filename, path, file_data = nil)\n return true if file_data&.exists?(filename.downcase)\n return true if File.exist?(format(Common_filename_format, path, filename).downcase)\n false\n end",
"def check_file_exists(filename)\n\tif File.exist?(filename)\n\t\tputs \"image #{filename} found\"\n\telse\n\t\tabort \"ERROR: image #{filename} not found.\"\n\tend\nend",
"def file_exist?(path)\n exist?(path) && is_file?(path)\n end",
"def file_exist?\n return FileTest.exist?(@fileurl)\n end",
"def check_new\n if File.exist?(@new_file_path)\n #TODO: error properly\n abort\n end\n end",
"def file_exist(file)\n FileExistAssertion.new(file)\n end",
"def file_fixture_exists?(filename, step = '')\n return true if File.exist?(Rails.root.join(UPLOADED_FILES_DIR, filename))\n\n raise \"ERROR in step: '#{step}'\\n\" +\n \" The file #{filename}\\n\" +\n \" must exist in #{UPLOADED_FILES_DIR}\\n\" +\n \" but it doesn't. Either correct the file name to a file that does exist in that directory\\n\" +\n \" or create a file and put it in that directory.\\n\"\nend",
"def exists?(file)\n out = File.exist?(file) &&\n !File.zero?(file)\n raise \"File #{file} does not exist or is empty!\" unless out\n out\nend",
"def file_exists(file)\n File.exists?(file)\n end",
"def raise_if_no_file(filename)\n if !File.exists?(filename)\n raise \"File '#{filename}' does not exist.\"\n end\n end",
"def check_exists\n filename = params[\"file\"]\n if !valid_filename(filename, nil)\n Rails.logger.warn(\"check_exists: Invalid filename received (#{filename})\")\n render :json => {error: \"Invalid filename\"}, status: 400\n return\n end\n\n full_filename = ENV[\"EAD_XML_PENDING_FILES_PATH\"] + \"/\" + filename\n exist = File.exist?(full_filename)\n render :json => {exist: exist}\n end",
"def exists_or_false(file)\n File.exist?(file) ? file : false\n 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 strict_file_exists?(path)\n directory = `dirname #{path}`.chomp\n name = `basename #{path}`.chomp\n !`find \"#{directory}\" -name \"#{name}\"`.empty?\n end",
"def safeExists?(f)\n ret=false\n if f[/\\A[\\x20-\\x7E]*\\z/]\n return FileTest.exist?(f)\n end\n begin\n File.open(f,\"rb\") { ret=true }\n rescue Errno::ENOENT, Errno::EINVAL, Errno::EACCES\n ret=false\n end\n return ret\nend",
"def create_file (file_path)\n \"touch '#{file_path}'\"\n end",
"def exists?\n file.exists?\n end",
"def verify_file_path(file)\n FileUtils.mkdir_p(File.dirname(file)) unless File.exists?(File.dirname(file))\n end",
"def verify_file_path(file)\n FileUtils.mkdir_p(File.dirname(file)) unless File.exists?(File.dirname(file))\n end",
"def check_file_existence (file_path)\n \"[ -f '#{file_path}' ]\"\n end",
"def exists?\n File.exists?(@resource[:name])\n end",
"def exists?\n FileTest.exists?(@file)\n end",
"def validate_file_status(filename)\n raise IconGenerator::Error unless File.exists? filename\n end",
"def is_new?\n !File.exists? @filename\n end",
"def create_directory_if_not_exist(directory_name)\n Dir.mkdir(directory_name) unless File.exists?(directory_name)\n end",
"def suspend_file_exists?\n File.file? File.join(path, \"#{@name}.vmem\")\n end",
"def suspend_file_exists?\n File.file? File.join(path, \"#{@name}.vmem\")\n end",
"def exists?\n persistent? && (filename && filename.exist?)\n end",
"def has_file\n if id == nil \n false\n else\n FileTest.exists?( local_file_path )\n end\n end",
"def createpb filename\n return \"Phonebook already exists\" if File.file?(filename)\n pb = Phonebook.new\n pb.create(filename)\nend",
"def write( filename, contents )\n if File.exists? filename\n puts \"#{filename} already exists\"\n else\n puts \"Creating #{filename}\"\n ::File.open( filename, \"w\" ){ |f| f.write contents }\n end\nend",
"def ensure_pairs_file_exists\n file_exists = Helper.pairs_file_exists?\n\n unless file_exists\n if agree(\"Can't find a config file. Create a sample one? (yes/no)\")\n file_exists = Helper.create_pairs_file\n else\n Helper.complain_about_pairs_file\n file_exists = false\n end\n end\n\n file_exists\n end",
"def checkfile()\n if not File.file?(@file)\n abort(\"File #{@file} does not exist. Aborting...\")\n end\n end",
"def check_file_exist(path)\n raise \"Cannot find: #{path}\" unless File.exist?(path)\n end",
"def exists?\n File.exists? path\n end",
"def exists?\n # self.class.exists?(:filename => filename)\n 'CarrierWave::Storage::ActiveRecord::File#exists? FIXME!'\n end",
"def create_temp_file(file_name)\n if file_name.rindex(\"/\") != nil \n directory = file_name[0, file_name.rindex(\"/\")+1] # ASSUMING ONLY UNIX!\n if !File.exists?(directory)\n FileUtils.mkdir_p(\"#{@tmp_file_path}#{directory}\")\n end\n end\n tmp_file = File.new(\"#{@tmp_file_path}#{file_name}\", \"w\")\n tmp_file.close()\n end",
"def safeExists?(f)\n return FileTest.exist?(f) if f[/\\A[\\x20-\\x7E]*\\z/]\n ret=false\n begin\n File.open(f,\"rb\") { ret=true }\n rescue Errno::ENOENT, Errno::EINVAL, Errno::EACCES\n ret=false\n end\n return ret\nend",
"def opx_file_exist?(file)\n File.exist?(file)\n rescue => e\n opx_err(\"Fatal failure of File.exist? for file: #{file}\", e)\n end",
"def safeExists?(f)\n return FileTest.exist?(f) if f[/\\A[\\x20-\\x7E]*\\z/]\n ret = false\n begin\n File.open(f,\"rb\") { ret = true }\n rescue Errno::ENOENT, Errno::EINVAL, Errno::EACCES\n ret = false\n end\n return ret\nend",
"def user_file_exist?(file)\n File.exist? user_file_path(file)\n end",
"def file_exists?(directory, filename)\n return false if !exists? directory\n \n target = File.join(path, directory)\n Dir.chdir(target)\n File.exist?(filename)\n end",
"def ensure_file_and_filename\n return true if up_to_date_with_parent?\n \n # Kill existing file in S3, if any - before rename\n if filename && AWS::S3::S3Object.exists?(full_filename, bucket_name)\n AWS::S3::S3Object.delete(full_filename, bucket_name)\n end\n\n set_filename_from_parent\n copy_file_from_parent\n true\n end",
"def make_sure_exists dir\n FileUtils.mkdir_p(dir) unless Dir.respond_to?(:exists?) && Dir.exists?(dir)\n end",
"def destination_file_exist?\n File.exist?(final_destination_path)\n end",
"def assure_created_zip\n FileCreator::createNewZip(self)\n raise \"No file created\" unless File.exists? zip_path\n end",
"def create\n if @file.present?\n @id = SecureRandom.urlsafe_base64\n FileUtils.mv @file.tempfile, temp_path\n true\n else\n errors.add(:file, 'is required')\n false\n end\n end",
"def file_exists?(bucket_name:, key:)\n !!get_bucket!(bucket_name).file(key)\n end",
"def file_error(file_path)\n unless File.exists?(file_path)\n file = File.basename(file_path)\n session[:message] = \"#{file} does not exist.\"\n end\nend",
"def local_file_exists?(full_path)\n File.exists?(full_path)\nend",
"def fail_script_unless_file_exists(path)\n fail_script_unless path != nil && (File.directory?(path) || File.exists?(path)), \"File doesn't exist: '#{path}'\"\n end",
"def fail_script_unless_file_exists(path)\n fail_script_unless path != nil && (File.directory?(path) || File.exists?(path)), \"File doesn't exist: '#{path}'\"\n end",
"def save_exists?(index)\n File.exists?(DataManager.make_filename(index-1))\n end"
] |
[
"0.7400038",
"0.7385261",
"0.7219889",
"0.718316",
"0.7165819",
"0.71417445",
"0.711582",
"0.69836485",
"0.69578105",
"0.6855474",
"0.68459594",
"0.6822345",
"0.6792273",
"0.6753589",
"0.67385584",
"0.67188907",
"0.6717922",
"0.66920435",
"0.6664985",
"0.6645683",
"0.66287386",
"0.6615365",
"0.661172",
"0.65669435",
"0.65669435",
"0.65669435",
"0.6556885",
"0.6546025",
"0.65314394",
"0.64829946",
"0.6474062",
"0.6469526",
"0.64413494",
"0.6407949",
"0.638686",
"0.63779736",
"0.63654315",
"0.63460195",
"0.63414925",
"0.6328786",
"0.6295448",
"0.6285476",
"0.6262923",
"0.62592435",
"0.6252021",
"0.6241027",
"0.6240444",
"0.621582",
"0.62108415",
"0.6198889",
"0.618557",
"0.61702186",
"0.6164456",
"0.6146342",
"0.61425453",
"0.61265403",
"0.6123361",
"0.61004585",
"0.609673",
"0.6090735",
"0.6090294",
"0.6050802",
"0.6049358",
"0.6046513",
"0.6041452",
"0.6041452",
"0.60306954",
"0.6028171",
"0.6028021",
"0.60263914",
"0.6012709",
"0.6008409",
"0.60074323",
"0.60074323",
"0.60016316",
"0.59957486",
"0.5994341",
"0.5987977",
"0.59677684",
"0.59649825",
"0.5962767",
"0.59488493",
"0.5942774",
"0.5930883",
"0.59224164",
"0.59164536",
"0.59132016",
"0.59100175",
"0.59092355",
"0.589992",
"0.5884738",
"0.58842367",
"0.58688307",
"0.58477235",
"0.583856",
"0.5826311",
"0.5826285",
"0.58259284",
"0.58259284",
"0.5823672"
] |
0.7515807
|
0
|
Runs terraform plan to validate the manifest.
|
def deploy_instance(path)
Dir.chdir(path){
%x[#{'terraform plan'}]
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def pre_execute_checks(plan = @opts.get(:plan))\n validate_terraform_installed\n ensure_plan_exists plan\n tf_show(plan)\n say 'The above changes will be applied to your environment.'\n exit unless agree 'Are you sure you want to execute this plan? (y/n)'\n end",
"def run_validate\n run(\n result:\n ::Kitchen::Terraform::Client::Command\n .validate(\n options:\n ::Kitchen::Terraform::Client::Options\n .new\n .enable_check_variables\n .maybe_no_color(toggle: !config_color)\n .vars(keys_and_values: config_variables)\n .var_files(paths: config_variable_files),\n working_directory: instance_directory\n )\n )\n end",
"def scaffold_plan\n scaffold_template if @template.nil?\n\n @plan = Plan.new(template: @template, title: 'Test Plan', grant_number: 'Grant-123',\n principal_investigator: 'me', principal_investigator_identifier: 'me-1234',\n description: \"this is my plan's informative description\",\n identifier: '1234567890', data_contact: '[email protected]', visibility: :privately_visible,\n roles: [Role.new(user: User.last, creator: true)])\n\n assert @plan.valid?, \"unable to create new Plan: #{@plan.errors.map{|f, m| f.to_s + ' ' + m}.join(', ')}\"\n @plan.save!\n end",
"def scaffold_plan\r\n scaffold_template if @template.nil?\r\n\r\n @plan = Plan.new(template: @template, title: 'Test Plan', grant_number: 'Grant-123',\r\n principal_investigator: 'me', principal_investigator_identifier: 'me-1234',\r\n description: \"this is my plan's informative description\",\r\n identifier: '1234567890', data_contact: '[email protected]', visibility: :privately_visible,\r\n roles: [Role.new(user: User.last, creator: true)])\r\n\r\n assert @plan.valid?, \"unable to create new Plan: #{@plan.errors.map{|f, m| f.to_s + ' ' + m}.join(', ')}\"\r\n @plan.save!\r\n end",
"def validate\n dataset_hash = {}\n property_hash = {}\n\n assets.each do |asset|\n datasets, properties = asset.prefetch_zfs\n\n datasets.each do |ds|\n dataset_hash[ds] = true\n end\n\n properties.each do |p|\n property_hash[p] = true\n end\n end\n\n propreader = OsCtl::Lib::Zfs::PropertyReader.new\n tree = propreader.read(\n dataset_hash.keys,\n property_hash.keys,\n recursive: false,\n ignore_error: true,\n )\n\n run = Run.new(tree)\n\n assets.each do |asset|\n asset.send(:run_validation, run)\n end\n\n assets\n end",
"def execute!\n setup\n\n # Read the current state.\n read_state\n\n # Refresh the state.\n refresh_state\n\n # Collect any resources from the resource files, and validate them.\n collect_resources\n\n # Populate the resource ID's from the current state.\n populate_resource_ids\n\n # Compile each resource\n compile_resources\n\n # Validate each resource\n validate_resources\n\n # Build and print the plan.\n build_and_print_plan\n\n # Execute and save the changed state.\n if !@run_context.empty_plan? && configuration.execute\n logger.ask \"Do you wish to execute this plan? [y/n]\\n\"\n if $stdin.getch == 'y'\n execute_resources\n write_state\n end\n end\n\n @kernel.exit 0\n rescue => e\n logger.fatal e\n @kernel.exit 1\n end",
"def build_plan\n init\n mod_name = \"google-#{Google::StringUtils.underscore(@module)}\"\n file = Google::StringUtils.underscore(@resource_name || @name)\n\n # Possible statements for creating an object.\n create_change = [\n 'Chef Client finished,',\n \"#{@affected['create']}/#{@resources['create']}\",\n 'resources updated'\n ].join(' ')\n create_no_change = [\n \"Chef Client finished, 0/#{@resources['create']}\",\n 'resources updated'\n ].join(' ')\n\n # Possible statement for deleting an object.\n delete_change = [\n 'Chef Client finished,',\n \"#{@affected['delete']}/#{@resources['delete']}\",\n 'resources updated'\n ].join(' ')\n delete_no_change = [\n \"Chef Client finished, 0/#{@resources['delete']}\",\n 'resources updated'\n ].join(' ')\n\n @vars = {\n 'name' => @name,\n 'phases' => (@pre || []).concat(\n [\n {\n 'name' => 'cleanup',\n 'apply' => [\n {\n 'run' => \"#{mod_name}::#{@recipes['delete']}\",\n 'outputs' => [\n [\n \"Deleting #{@module}_#{file}[.*]\",\n \"#{@module}_#{file}[.*] action delete (up to date)\"\n ],\n (0..@affected['delete']).map do |index|\n ['Chef Client finished,',\n \"#{index}/#{@resources['delete']} resources\",\n 'updated'].join(' ')\n end\n ]\n }\n ]\n },\n {\n 'name' => 'create',\n 'apply' => [\n {\n 'run' => \"#{mod_name}::#{@recipes['create']}\",\n 'outputs' => [\n [\"Creating #{@module}_#{file}[.*]\"],\n [create_change]\n ]\n }\n ]\n },\n {\n 'name' => 'create{again}',\n 'apply' => [\n {\n 'run' => \"#{mod_name}::#{@recipes['create']}\",\n 'outputs' => [\n [\"#{@module}_#{file}[.*] action create (up to date)\"],\n [create_no_change]\n ]\n }\n ]\n }\n ]\n )\n }\n\n @vars['phases'] = @vars['phases'].concat(@change || [])\n @vars['phases'] = @vars['phases'].concat(\n [\n {\n 'name' => 'delete',\n 'apply' => [\n {\n 'run' => \"#{mod_name}::#{@recipes['delete']}\",\n 'outputs' => [\n [\"Deleting #{@module}_#{file}[.*]\"],\n [delete_change]\n ]\n }\n ]\n },\n {\n 'name' => 'delete{again}',\n 'apply' => [\n {\n 'run' => \"#{mod_name}::#{@recipes['delete']}\",\n 'outputs' => [\n [\"#{@module}_#{file}[.*] action delete (up to date)\"],\n [delete_no_change]\n ]\n }\n ]\n }\n ]\n ).concat(@post || [])\n\n apply_test_environment @vars\n\n @vars\n end",
"def execute_resources\n logger.info \"Executing plan\" do\n @run_context.execute!\n end\n end",
"def plan(&block)\n @plan = block\n end",
"def plan(app, pipeline_name, updated_pipeline)\n # diff existing_pipeline_json to updated_pipeline_json\n updated_pipeline_hash = JSON.parse(File.read(updated_pipeline))\n updated_pipeline_hash['name'] = pipeline_name\n SpinCli::Utils::Pipeline.compare(get(app, pipeline_name), updated_pipeline_hash)\n\n # Try to create the pipeline and then remove it\n # Create it under a different name\n rng = Random.new(Time.now.to_i)\n random_pipeline_number = rng.rand(1000)\n updated_pipeline_hash['name'] = \"#{pipeline_name}-#{random_pipeline_number}\"\n\n @http.pipelines.post updated_pipeline_hash.to_json\n puts \"Successfully validated pipeline changes for: #{pipeline_name}\".colorize(:green)\n puts \"\\nTo Update - Run: #{$PROGRAM_NAME} pipeline update #{app} #{pipeline_name} \" \\\n \"#{updated_pipeline}\".colorize(:green)\n\n # Cleanup validated pipeline\n delete(app, \"#{pipeline_name}-#{random_pipeline_number}\")\n rescue StandardError => e\n puts \"Error performing a plan on #{pipeline_name}: #{e}\"\n end",
"def plan( &block )\n nested_class( 'Plan', Yacl::Define::Plan, &block )\n end",
"def install_plan\n namespace nsprefix do\n desc 'Output the set plan to be executed by apply; specify ' \\\n 'optional CSV targets'\n task :plan, [:target] => [\n :\"#{nsprefix}:init\",\n :\"#{nsprefix}:write_tf_vars\"\n ] do |t, args|\n @before_proc.call(t.name, @tf_dir) unless @before_proc.nil?\n cmd = cmd_with_targets(\n ['terraform', 'plan', \"-var-file #{var_file_path}\"],\n args[:target],\n args.extras\n )\n\n stream_type = if HAVE_LANDSCAPE && !@disable_landscape\n @landscape_progress\n else\n :stream\n end\n outerr = terraform_runner(cmd, progress: stream_type)\n landscape_format(outerr) if HAVE_LANDSCAPE && !@disable_landscape\n @after_proc.call(t.name, @tf_dir) unless @after_proc.nil?\n end\n end\n end",
"def parse_terraform_plan_output(str)\n relaunches = []\n changes = []\n new_resources = []\n lines = str.split(\"\\n\")\n lines.each do |line|\n # the gsub is to strip possible ansi colors away\n # the match is to pick the TF notation about how the resource is about to change following the resource name itself\n m = line.gsub(/\\e\\[[0-9;]*m/, \"\").match(/^([-~+\\/]+)\\s(\\S+)/)\n if m\n # If the resource action contains a minus ('-' or '-/+') then\n # we know that the action will be destructive.\n if m[1].match(/[-]/)\n relaunches << m[2]\n elsif m[1] == \"~\"\n changes << m[2]\n elsif m[1] == \"+\"\n new_resources << m[2]\n end\n end\n end\n return {\n :relaunches => relaunches,\n :changes => changes,\n :new_resources => new_resources,\n }\n end",
"def plan; end",
"def run_manifest (manifest)\n if ENV.has_key? 'LOCAL_TEST'\n print 'Notice: Skipping apply_manifest changes, due to local test. Please run puppet apply manually with the manifest above.\\n'\n else\n # with local tests, we can't use beaker function like apply_manifest\n\n let(:manifest) { manifest }\n it 'should run without errors' do\n expect(apply_manifest(manifest, :catch_failures => true).exit_code).to eq(2)\n end\n\n it 'should re-run without changes' do\n expect(apply_manifest(manifest, :catch_changes => true).exit_code).to be_zero\n end\n end\nend",
"def plan\n unless planned?\n @plan_id = Gremlin.world.plan(template.to_class, args).id if validated\n self.save\n end\n end",
"def plan_integrity\n return if elected_plan_ids.blank?\n\n errors.add(:elected_plans, \"single plan must be the reference plan\") if (plan_option_kind == \"single_plan\") && (elected_plan_ids.first != reference_plan_id)\n\n if plan_option_kind == \"single_carrier\"\n errors.add(:elected_plans, \"single carrier must include reference plan\") unless elected_plan_ids.include? reference_plan_id\n errors.add(:elected_plans, \"not all from the same carrier as reference plan\") if elected_plans.detect { |plan| plan.carrier_profile_id != reference_plan.try(:carrier_profile_id) }\n end\n\n errors.add(:elected_plans, \"not all of the same metal level as reference plan\") if (plan_option_kind == \"metal_level\") && !(elected_plan_ids.include? reference_plan_id)\n end",
"def check_tf_version\n # run: terraform -version\n all_out_err, exit_status = TFWrapper::Helpers.run_cmd_stream_output(\n 'terraform version', @tf_dir\n )\n unless exit_status.zero?\n raise StandardError, \"ERROR: 'terraform -version' exited \" \\\n \"#{exit_status}: #{all_out_err}\"\n end\n all_out_err = all_out_err.strip\n # Find the terraform version string\n m = /Terraform v(\\d+\\.\\d+\\.\\d+).*/.match(all_out_err)\n unless m\n raise StandardError, 'ERROR: could not determine terraform version ' \\\n \"from 'terraform -version' output: #{all_out_err}\"\n end\n # the version will be a string like:\n # Terraform v0.9.2\n # or:\n # Terraform v0.9.3-dev (<GIT SHA><+CHANGES>)\n tf_ver = Gem::Version.new(m[1])\n unless tf_ver >= min_tf_version\n raise StandardError, \"ERROR: tfwrapper #{TFWrapper::VERSION} is only \" \\\n \"compatible with Terraform >= #{min_tf_version} but your terraform \" \\\n \"binary reports itself as #{m[1]} (#{all_out_err})\"\n end\n puts \"Running with: #{all_out_err}\"\n tf_ver\n end",
"def validate(resource, &block); end",
"def execute_plan_tests(node, plan)\n @env.ui.info(\"[#{node.name}]\")\n close_ssh\n configure_serverspec(node)\n plan['flags'].prepend \"-I #{@config.spec.directory} \"\n ret_code = RSpec::Core::Runner.run(plan['flags'].split, $stderr, $stdout)\n RSpec.clear_examples\n @ret_code = ret_code unless ret_code.zero?\n end",
"def validate_fragment!(resource)\n file = Tempfile.new('hosts_allow')\n\n begin\n file.write(capture(resource))\n file.rewind\n\n cmd = Mixlib::ShellOut.new(\"visudo -cf #{file.path}\").run_command\n unless cmd.exitstatus.zero?\n Chef::Log.error(\"Fragment validation failed: \\n\\n\")\n Chef::Log.error(file.read)\n Chef::Application.fatal!(\"Template #{file.path} failed fragment validation!\")\n end\n ensure\n file.close\n file.unlink\n end\nend",
"def run\n runner = self\n @test_cases.each do |path|\n next if ENV['TEST_CASE'] && !File.basename(path).match(ENV['TEST_CASE'])\n\n Aws::ModelValidators.load_json(path).tap do |test_case|\n\n models = test_case.inject({}) { |h,(k,v)| h[k.to_sym] = v; h }\n errors = models.delete(:errors)\n\n @group.it(File.basename(path[0..-6])) do\n pending unless errors\n results = described_class.new.validate(models, apply_schema: false)\n unless runner.results_match?(results, errors)\n expect(results).to eq(errors)\n end\n end\n\n end\n end\n end",
"def plan plan\n plan.myself if respond_to?(:run)\n end",
"def meta_validate\n desc 'Validates a directory of contract definitions'\n task :meta_validate, :dir do |_t, args|\n if args.to_a.size < 1\n fail Pacto::UI.yellow('USAGE: rake pacto:meta_validate[<contract_dir>]')\n end\n\n each_contract(args[:dir]) do |contract_file|\n fail unless Pacto.validate_contract contract_file\n end\n puts 'All contracts successfully meta-validated'\n end\n end",
"def install_apply\n namespace nsprefix do\n desc 'Apply a terraform plan that will provision your resources; ' \\\n 'specify optional CSV targets'\n task :apply, [:target] => [\n :\"#{nsprefix}:init\",\n :\"#{nsprefix}:write_tf_vars\",\n :\"#{nsprefix}:plan\"\n ] do |t, args|\n @before_proc.call(t.name, @tf_dir) unless @before_proc.nil?\n cmd_arr = %w[terraform apply]\n cmd_arr << '-auto-approve' if tf_version >= Gem::Version.new('0.10.0')\n cmd_arr << \"-var-file #{var_file_path}\"\n cmd = cmd_with_targets(\n cmd_arr,\n args[:target],\n args.extras\n )\n terraform_runner(cmd)\n\n update_consul_stack_env_vars unless @consul_env_vars_prefix.nil?\n @after_proc.call(t.name, @tf_dir) unless @after_proc.nil?\n end\n end\n end",
"def terraform(action, dir)\n Dir.chdir(dir)\n exit_status = system(\"terraform #{action} -auto-approve\")\n Dir.chdir(\"..\")\n return exit_status\nend",
"def verify_template\n verification_templates(main_only: true).each(&:verify)\n end",
"def process_manifest\n @manifest, @builder_version = @manifest_reader.load_output_manifest(@manifest_path)\n @manifest_reader.validate_migration_paths(@manifest_path, @manifest)\n end",
"def display_plan_information(result)\n ui.info ui.color(\"Pre-update resource planning report:\", :bold)\n unless print_plan_result(result, [result.name])\n ui.info \"No resources life cycle changes detected in this update!\"\n end\n if config[:plan_apply]\n return ui.info \"Realizing this stack plan...\"\n elsif config[:plan_only]\n return\n end\n ui.confirm \"Realize this stack plan?\"\n end",
"def validate_pkg_manifest\n log.info(log_key) { \"Validating package manifest\" }\n shellout!(\"pkglint -c /tmp/lint-cache -r http://pkg.oracle.com/solaris/release #{pkg_manifest_file}.5.res\")\n end",
"def execute!\n name_required!\n name = name_args.first\n\n stack_info = \"#{ui.color(\"Name:\", :bold)} #{name}\"\n begin\n stack = provider.stacks.get(name)\n rescue Miasma::Error::ApiError::RequestError\n stack = provider.stacks.build(name: name)\n end\n\n return display_plan_lists(stack) if config[:list]\n\n if config[:plan_name]\n # ensure custom attribute is dirty so we can modify\n stack.custom = stack.custom.dup\n stack.custom[:plan_name] = config[:plan_name]\n end\n\n use_existing = false\n\n unless config[:print_only]\n ui.info \"#{ui.color(\"SparkleFormation:\", :bold)} #{ui.color(\"plan\", :green)}\"\n if stack && stack.plan\n ui.warn \"Found existing plan for this stack\"\n begin\n if config[:load_existing]\n raise Bogo::Ui::ConfirmationDeclined\n end\n if config[:load_existing].nil?\n ui.confirm \"Destroy existing plan\"\n end\n ui.info \"Destroying existing plan to generate new plan\"\n stack.plan.destroy\n rescue Bogo::Ui::ConfirmationDeclined\n ui.info \"Loading existing stack plan for #{ui.color(stack.name, :bold)}...\"\n use_existing = true\n end\n end\n end\n\n unless use_existing\n config[:compile_parameters] ||= Smash.new\n\n if config[:file]\n s_name = [name]\n\n c_setter = lambda do |c_stack|\n if c_stack.outputs\n compile_params = c_stack.outputs.detect do |output|\n output.key == \"CompileState\"\n end\n end\n if compile_params\n compile_params = MultiJson.load(compile_params.value)\n c_current = config[:compile_parameters].fetch(s_name.join(\"__\"), Smash.new)\n config[:compile_parameters][s_name.join(\"__\")] = compile_params.merge(c_current)\n end\n c_stack.nested_stacks(false).each do |n_stack|\n s_name.push(n_stack.data.fetch(:logical_id, n_stack.name))\n c_setter.call(n_stack)\n s_name.pop\n end\n end\n\n if stack && stack.persisted?\n c_setter.call(stack)\n end\n\n ui.debug \"Compile parameters - #{config[:compile_parameters]}\"\n file = load_template_file(:stack => stack)\n stack_info << \" #{ui.color(\"Path:\", :bold)} #{config[:file]}\"\n else\n file = stack.template.dup\n end\n\n unless file\n if config[:template]\n file = config[:template]\n stack_info << \" #{ui.color(\"(template provided)\", :green)}\"\n else\n stack_info << \" #{ui.color(\"(no template update)\", :yellow)}\"\n end\n end\n unless config[:print_only]\n ui.info \" -> #{stack_info}\"\n end\n if file\n if config[:print_only]\n ui.puts format_json(parameter_scrub!(template_content(file)))\n return\n end\n\n original_parameters = stack.parameters\n\n apply_stacks!(stack)\n\n populate_parameters!(file, :current_parameters => stack.root_parameters)\n\n stack.parameters = config_root_parameters\n\n if config[:upload_root_template]\n upload_result = store_template(name, file, Smash.new)\n stack.template_url = upload_result[:url]\n else\n stack.template = parameter_scrub!(template_content(file, :scrub))\n end\n else\n apply_stacks!(stack)\n original_parameters = stack.parameters\n populate_parameters!(stack.template, :current_parameters => stack.root_parameters)\n stack.parameters = config_root_parameters\n end\n\n ui.info \" -> Generating plan information...\"\n else\n ui.info \" -> Loading plan information...\"\n end\n\n # Set options defined within config into stack instance for update request\n if config[:merge_api_options]\n config.fetch(:options, Smash.new).each_pair do |key, value|\n if stack.respond_to?(\"#{key}=\")\n stack.send(\"#{key}=\", value)\n end\n end\n end\n\n plan = stack.plan || stack.plan_generate\n namespace.const_get(:Realize).\n new(config, [name]).execute!\n end",
"def manifest(type)\n type = type.downcase\n say \"Rendering #{type} manifest\", :green\n @values = parse_cloud_config\n @tf_output = parse_tf_state('terraform/terraform.tfstate') if options[:cloud] == 'aws'\n\n if options[:cloud] == 'aws'\n @private_subnet = IPAddr.new(@values['aws']['private_subnet']['network']).to_range.to_a\n @public_subnet = IPAddr.new(@values['aws']['public_subnet']['network']).to_range.to_a\n else\n @private_subnet = IPAddr.new(@values['gcp']['subnet_cidr']).to_range.to_a\n end\n\n @static_ip_vault = @private_subnet[11].to_s\n @static_ips_concourse = [@private_subnet[12]].map(&:to_s)\n @static_ip_prometheus_stack = @private_subnet[18].to_s\n\n case type\n when \"bosh\"\n directory(\"#{options[:cloud]}/deployments/bosh\", 'deployments/bosh')\n template(\"#{options[:cloud]}/bosh-vars.yml.erb\", 'config/bosh-vars.yml')\n copy_file(\"#{options[:cloud]}/docs/bosh.md\", \"docs/bosh.md\")\n template(\"#{options[:cloud]}/bin/bosh-install.sh.tt\", \"bin/bosh-install.sh\")\n chmod('bin/bosh-install.sh', 0755)\n\n when \"concourse\"\n directory(\"#{options[:cloud]}/deployments/concourse\", \"deployments/concourse\")\n copy_file(\"#{options[:cloud]}/docs/concourse.md\", \"docs/concourse.md\")\n template(\"#{options[:cloud]}/bin/concourse-deploy.sh.tt\", \"bin/concourse-deploy.sh\")\n chmod('bin/concourse-deploy.sh', 0755)\n ingress_add_entry(@values['concourse']['hostname'], @static_ips_concourse, port: 8080)\n\n when \"vault\"\n template(\"#{options[:cloud]}/deployments/vault/vault.yml.erb\", \"deployments/vault/vault.yml\")\n copy_file(\"#{options[:cloud]}/docs/vault.md\", \"docs/vault.md\")\n template(\"#{options[:cloud]}/bin/vault-deploy.sh.tt\", \"bin/vault-deploy.sh\")\n chmod('bin/vault-deploy.sh', 0755)\n ingress_add_entry(@values['vault']['hostname'], [@static_ip_vault], port: 8200)\n\n when \"ingress\"\n template(\"#{options[:cloud]}/deployments/ingress/ingress.yml.erb\", \"deployments/ingress/ingress.yml\")\n copy_file(\"#{options[:cloud]}/docs/ingress.md\", \"docs/ingress.md\")\n template(\"#{options[:cloud]}/bin/ingress-deploy.sh.tt\", \"bin/ingress-deploy.sh\")\n template(\"#{options[:cloud]}/bin/ingress-update.sh.tt\", \"bin/ingress-update.sh\")\n chmod('bin/ingress-deploy.sh', 0755)\n chmod('bin/ingress-update.sh', 0755)\n\n when \"prometheus\"\n directory(\"#{options[:cloud]}/deployments/prometheus\", \"deployments/prometheus\")\n copy_file(\"#{options[:cloud]}/docs/prometheus.md\", \"docs/prometheus.md\")\n template(\"#{options[:cloud]}/bin/prometheus-deploy.sh.tt\", \"bin/prometheus-deploy.sh\")\n chmod('bin/prometheus-deploy.sh', 0755)\n ingress_add_entry(@values['alertmanager']['hostname'], [@static_ip_prometheus_stack], port: 9093)\n ingress_add_entry(@values['grafana']['hostname'], [@static_ip_prometheus_stack], port: 3000)\n ingress_add_entry(@values['prometheus']['hostname'], [@static_ip_prometheus_stack], port: 9090)\n\n else\n say \"Manifest type not specified\"\n\n end\n end",
"def validate(template)\n begin\n template = YAML.load_file(template)\n\n raise 'Name not found' unless template['name']\n\n OneProvision::Terraform.p_load\n\n unless OneProvision::Terraform.exist?(template['provider'])\n raise 'Invalid provider, available providers: ' \\\n \"#{OneProvision::Terraform.providers.join(', ')}\"\n end\n\n return template if template['provider'] == 'onprem'\n\n raise 'Connection info not found' unless template['connection']\n\n template\n rescue StandardError => e\n OpenNebula::Error.new(\"ERROR: #{e}\")\n end\n end",
"def run_account(config, account, options, tf_argv, log)\n\n # Skip excluded accounts\n if account[:excluded] == true\n log.info \"#{account[:name]}: excluded, skipping\"\n return\n end\n\n # Generate Terraform run directory with configured providers, backend and\n # profiles for the target account. This is where Terraform will be\n # executed from.\n log.info \"#{account[:name]}: Generating Terraform run directory\"\n Tfctl::Generator.make(\n config: config,\n terraform_io_org: config[:terraform_io_org],\n account_id: account[:id],\n account_name: account[:name],\n profiles: account[:profiles],\n execution_role: account[:tf_execution_role]\n )\n\n log.info \"#{account[:name]}: Executing Terraform #{tf_argv[0]}\"\n Tfctl::Executor.run(\n account_name: account[:name],\n config_name: config[:config_name],\n unbuffered: options[:unbuffered],\n log: log,\n argv: tf_argv\n )\nend",
"def new_plan(name, puppet: false)\n Bolt::PlanCreator.validate_input(config.project, name)\n Bolt::PlanCreator.create_plan(config.project.plans_path, name, puppet)\n end",
"def verify_manifest(package_directory, manifest, algorithm)\n valid = true\n message_io = STDOUT\n Dir.chdir(package_directory) do\n LOGGER.info(\"Validating manifest #{manifest}\")\n valid = Checksum::validate_manifest(manifest, algorithm, message_io: message_io)\n end\n valid\n end",
"def ensure_plan_checked\n errors.add(:base, 'Please ensure that you have selected at least 1 premium plan') if ((plan1 != true) rescue ArgumentError == ArgumentError)\n end",
"def apply(manifest, targets, code: '', noop: false)\n manifest_code = if manifest\n Bolt::Util.validate_file('manifest', manifest)\n File.read(File.expand_path(manifest))\n else\n code\n end\n\n targets = inventory.get_targets(targets)\n\n Puppet[:tasks] = false\n ast = pal.parse_manifest(manifest_code, manifest)\n\n if defined?(ast.body) &&\n (ast.body.is_a?(Puppet::Pops::Model::HostClassDefinition) ||\n ast.body.is_a?(Puppet::Pops::Model::ResourceTypeDefinition))\n message = \"Manifest only contains definitions and will result in no changes on the targets. \"\\\n \"Definitions must be declared for their resources to be applied. You can read more \"\\\n \"about defining and declaring classes and types in the Puppet documentation at \"\\\n \"https://puppet.com/docs/puppet/latest/lang_classes.html and \"\\\n \"https://puppet.com/docs/puppet/latest/lang_defined_types.html\"\n Bolt::Logger.warn(\"empty_manifest\", message)\n end\n\n # Apply logging looks like plan logging\n executor.publish_event(type: :plan_start, plan: nil)\n\n with_benchmark do\n apply_prep_results = pal.in_plan_compiler(executor, inventory, plugins.puppetdb_client) do |compiler|\n compiler.call_function('apply_prep', targets, '_catch_errors' => true)\n end\n\n apply_results = pal.with_bolt_executor(executor, inventory, plugins.puppetdb_client) do\n Puppet.lookup(:apply_executor)\n .apply_ast(ast, apply_prep_results.ok_set.targets, catch_errors: true, noop: noop)\n end\n\n Bolt::ResultSet.new(apply_prep_results.error_set.results + apply_results.results)\n end\n end",
"def plan_signature\n with_script_compiler do |compiler|\n sig = compiler.plan_signature(@plan)\n\n raise(\"Cannot find playbook %s in %s\" % [@plan, @modulepath.join(\":\")]) unless sig\n\n sig.params_type.elements.map do |elem|\n [elem.name, {\n \"type\" => elem.value_type.to_s,\n \"required\" => !elem.key_type.is_a?(Puppet::Pops::Types::POptionalType)\n }]\n end\n end\n end",
"def run \n create_model_file\n create_migration if @valid==true\n enable_apis if @valid==true\n end",
"def run_version\n run result: ::Kitchen::Terraform::Client::Command.version(working_directory: config.fetch(:kitchen_root))\n end",
"def plan\n @lines.select! do |line|\n line.include?(\"No changes. Infrastructure\") ||\n line.include?(\"Changes to Outputs\") ||\n line.include?(\"Plan:\") ||\n line.include?(\"Changes to \") ||\n line.include?(\"Error: \") # error\n end\n end",
"def plan\n AcceptOn::Plan.new(@plan)\n end",
"def verify_manifest(theme_path)\n manifest_path = File.join(theme_path, \"manifest.yml\")\n manifest_file = File.open( manifest_path )\n abort(\"rake aborted: repo must contain valid manifest.yml\") unless File.exist? manifest_file\n manifest = YAML.load( manifest_file )\n manifest_file.close\n manifest\nend",
"def run_apply\n run(\n result:\n ::Kitchen::Terraform::Client::Command\n .apply(\n options:\n ::Kitchen::Terraform::Client::Options\n .new\n .enable_lock\n .lock_timeout(duration: config_lock_timeout)\n .disable_input\n .enable_auto_approve\n .maybe_no_color(toggle: !config_color)\n .parallelism(concurrent_operations: config_parallelism)\n .enable_refresh\n .state(path: config_state)\n .state_out(path: config_state)\n .vars(keys_and_values: config_variables)\n .var_files(paths: config_variable_files),\n working_directory: instance_directory\n )\n )\n end",
"def perform_validation(_token, certname, raw_csr)\n results = []\n @log.debug 'validating using multiplexed external executables'\n policy_executables.each do |executable|\n @log.debug \"attempting to validate using #{executable}\"\n results << IO.popen(executable + ' ' + certname.to_s, 'r+') { |obj| obj.puts raw_csr; obj.close_write; obj.read; obj.close; $CHILD_STATUS.to_i }\n @log.debug \"exit code from #{executable}: #{results.last}\"\n end\n bool_results = results.map { |val| val == 0 }\n validate_using_strategy(bool_results)\n end",
"def pre_execute_checks\n validate_terraform_installed\n ensure_output_directory\n Dir.chdir(@opts.get(:input_dir)) do\n puts '=> Fetching modules...'\n tf_get\n end\n end",
"def puppet_parser_validate(*manifests)\n manifests = manifests.join(' ')\n sh \"puppet parser validate #{manifests}\"\nend",
"def verify\n @files = []\n @manifest = nil\n\n verify_required_files\n\n rescue Errno::ENOENT => e\n raise FoobarMod::Package::FormatError.new e.message\n rescue Gem::Package::TarInvalidError => e\n raise FoobarMod::Package::FormatError.new e.message, @mod\n end",
"def new\n @plan = Plan.new\n authorize @plan\n end",
"def stack_plan_load(stack)\n if stack.attributes[:plan]\n plan = stack.attributes[:plan]\n else\n plan = Stack::Plan.new(stack, name: changeset_name(stack))\n end\n if stack.custom[:plan_name]\n if stack.custom[:plan_name] != plan.name\n plan.name = stack.custom[:plan_name]\n else\n plan.name = changeset_name(stack)\n end\n end\n logger.debug(\"loading plan `#{plan.name}` for stack `#{stack.id}`\")\n result = nil\n Bogo::Retry.build(:linear, max_attempts: 10, wait_interval: 5, ui: Bogo::Ui.new) do\n begin\n result = request(\n :path => \"/\",\n :method => :post,\n :form => Smash.new(\n \"Action\" => \"DescribeChangeSet\",\n \"ChangeSetName\" => plan.name,\n \"StackName\" => stack.name,\n ),\n )\n rescue Error::ApiError::RequestError => e\n # Plan does not exist\n if e.response.code == 404\n logger.warn(\"plan `#{plan.name}` does not exist for stack `#{stack.id}`\")\n return nil\n end\n # Stack does not exist\n if e.response.code == 400 && e.message.include?(\"ValidationError: Stack\")\n logger.warn(\"stack `#{stack.id}` does not exist\")\n return nil\n end\n raise\n end\n status = result.get(:body, \"DescribeChangeSetResponse\", \"DescribeChangeSetResult\", \"ExecutionStatus\")\n if status != \"AVAILABLE\"\n logger.debug(\"plan `#{plan.name}` is not available (status: `#{status}`)\")\n raise \"Plan execution is not yet available\"\n end\n end.run!\n res = result.get(:body, \"DescribeChangeSetResponse\", \"DescribeChangeSetResult\")\n plan.id = res[\"ChangeSetId\"]\n plan.name = res[\"ChangeSetName\"]\n plan.custom = {\n :execution_status => res[\"ExecutionStatus\"],\n :stack_name => res[\"StackName\"],\n :stack_id => res[\"StackId\"],\n :status => res[\"Status\"],\n }\n plan.state = res[\"ExecutionStatus\"].downcase.to_sym\n plan.parameters = Smash[\n [res.get(\"Parameters\", \"member\")].compact.flatten.map { |param|\n [param[\"ParameterKey\"], param[\"ParameterValue\"]]\n }\n ]\n plan.created_at = res[\"CreationTime\"]\n plan.template = stack_plan_template(plan, :processed)\n items = {:add => [], :replace => [], :remove => [], :unknown => [], :interrupt => []}\n [res.get(\"Changes\", \"member\")].compact.flatten.each do |chng|\n if chng[\"Type\"] == \"Resource\"\n item_diffs = []\n [chng.get(\"ResourceChange\", \"Details\", \"member\")].compact.flatten.each do |d|\n item_path = [\n d.get(\"Target\", \"Attribute\"),\n d.get(\"Target\", \"Name\"),\n ].compact\n original_value = stack.template.get(\"Resources\", chng.get(\"ResourceChange\", \"LogicalResourceId\"), *item_path)\n if original_value.is_a?(Hash) && (stack.parameters || {}).key?(original_value[\"Ref\"])\n original_value = stack.parameters[original_value[\"Ref\"]]\n end\n new_value = plan.template.get(\"Resources\", chng.get(\"ResourceChange\", \"LogicalResourceId\"), *item_path)\n if new_value.is_a?(Hash) && plan.parameters.key?(new_value[\"Ref\"])\n new_value = plan.parameters[new_value[\"Ref\"]]\n end\n diff = Stack::Plan::Diff.new(\n :name => item_path.join(\".\"),\n :current => original_value.inspect,\n :proposed => new_value.inspect,\n )\n\n unless item_diffs.detect { |d| d.name == diff.name && d.current == diff.current && d.proposed == diff.proposed }\n item_diffs << diff\n end\n end\n type = case chng.get(\"ResourceChange\", \"Action\").to_s.downcase\n when \"add\"\n :add\n when \"modify\"\n chng.get(\"ResourceChange\", \"Replacement\") == \"True\" ?\n :replace : :interrupt\n when \"remove\"\n :remove\n else\n :unknown\n end\n items[type] << Stack::Plan::Item.new(\n :name => chng.get(\"ResourceChange\", \"LogicalResourceId\"),\n :type => chng.get(\"ResourceChange\", \"ResourceType\"),\n :diffs => item_diffs.sort_by(&:name),\n )\n end\n end.compact\n items.each do |type, list|\n plan.send(\"#{type}=\", list.sort_by(&:name))\n end\n if plan.custom[:stack_id]\n stack.id = plan.custom[:stack_id]\n stack.valid_state\n end\n logger.debug(\"plan `#{plan.name}` loaded for stack `#{stack.id}` - `#{plan.inspect}`\")\n stack.plan = plan.valid_state\n end",
"def plan\n plan_rebuilder.plan\n end",
"def define_task_validate(*args)\n desc 'Validate the git urls and branches, refs, or tags'\n task :validate do\n gitvalididation = Ra10ke::Validate::Validation.new(get_puppetfile.puppetfile_path)\n exit_code = 0\n if gitvalididation.bad_mods?\n exit_code = 1\n message = BAD_EMOJI + ' Not all modules in the Puppetfile are valid. '.red + BAD_EMOJI\n else\n message = GOOD_EMOJI + ' Puppetfile looks good. '.green + GOOD_EMOJI\n end\n tp gitvalididation.sorted_mods, :name, { url: { width: 50 } }, :ref, :status\n abort(message) if exit_code.positive?\n puts message\n end\n end",
"def compile\n puts \"#{'----->'.red.bold} Running #{'snyk test'.blue.bold} \"\n\n manifests = poms\n if manifests.empty?\n puts ' No manifests found'.yellow\n return\n end\n\n issues = perform_test manifests\n return if issues.empty?\n\n raise 'Snyk found vulnerabilities' unless dont_break_build?\n\n puts ' dont_break_build was defined, continuing despite vulnerabilities found'.yellow\n end",
"def validate(env, intention, attributes)\n # If AdminSet was selected, look for its PermissionTemplate\n template = PermissionTemplate.find_by!(source_id: attributes[:admin_set_id]) if attributes[:admin_set_id].present?\n\n validate_lease(env, intention, template) &&\n validate_release_type(env, intention, template) &&\n validate_visibility(env, attributes, template) &&\n validate_embargo(env, intention, attributes, template)\n end",
"def check_terraform_applied\n raise Kite::Error, 'Did you terraform apply? terraform.tfstate is missing!' unless File.file? \"terraform/terraform.tfstate\"\n end",
"def run!\n # When Chef Backend is configured, this is too early to verify\n # postgresql accessibility since we need to configure HAProxy\n # first\n unless PrivateChef['use_chef_backend']\n BootstrapPreflightValidator.new(node).run!\n PostgresqlPreflightValidator.new(node).run!\n end\n AuthPreflightValidator.new(node).run!\n SslPreflightValidator.new(node).run!\n BookshelfPreflightValidator.new(node).run!\n RequiredRecipePreflightValidator.new(node).run!\n if PrivateChef['opscode_erchef']['search_provider'] == 'opensearch'\n OpensearchPreflightValidator.new(node).run!\n else\n IndexingPreflightValidator.new(node).run!\n end\n rescue PreflightValidationFailed => e\n # use of exit! prevents exit handlers from running, ensuring the last thing\n # the customer sees is the descriptive error we've provided.\n Chef::Log.fatal(\"\\n\\n#{LINE_SEP}\\n#{e.message}#{LINE_SEP}\")\n exit! 128\n end",
"def check_manifest\n f = \"Manifest.tmp\"\n require \"find\"\n files = []\n with_config do |config, _|\n exclusions = config[\"exclude\"]\n\n Find.find \".\" do |path|\n next unless File.file? path\n next if path =~ exclusions\n files << path[2..-1]\n end\n\n files = files.sort.join \"\\n\"\n\n File.open f, \"w\" do |fp| fp.puts files end\n\n verbose = { :verbose => Rake.application.options.verbose }\n\n begin\n sh \"#{DIFF} -du Manifest.txt #{f}\", verbose\n ensure\n rm f, **verbose\n end\n end\n end",
"def plan\n Module.new do\n extend Activity::Path::Plan()\n\n task Trace::TaskWrap.method(:capture_args), id: \"task_wrap.capture_args\", before: \"task_wrap.call_task\"\n task Trace::TaskWrap.method(:capture_return), id: \"task_wrap.capture_return\", before: \"End.success\", group: :end\n end\n end",
"def plan_file?(uri)\n uri_path = PuppetLanguageServer::UriHelper.uri_path(uri)\n return false if uri_path.nil?\n # For the text searching below we need a leading slash. That way\n # we don't need to use regexes which is slower\n uri_path = \"/#{uri_path}\" unless uri_path.start_with?('/')\n if windows?\n plans_index = uri_path.upcase.index('/PLANS/')\n manifests_index = uri_path.upcase.index('/MANIFESTS/')\n else\n plans_index = uri_path.index('/plans/')\n manifests_index = uri_path.index('/manifests/')\n end\n return false if plans_index.nil?\n return true if manifests_index.nil?\n\n plans_index < manifests_index\n end",
"def plan(accountname)\n response = get_request(\"/users/#{accountname}/plan\")\n end",
"def plan(accountname)\n response = get_request(\"/users/#{accountname}/plan\")\n end",
"def pre_verify(packer)\n total = packer.machines.map(&:memory).inject { |a, e| a + e }\n physical = ::Chef.node['memory']['total'].to_i / 1024\n fail \"The fragments chosen require (#{total}MB) more than three \" \\\n \" of the physical memory (#{physical}MB) on this machine.\" \\\n if total > (physical * 0.75)\n end",
"def validate(filters = %w(ldm, pdm, metric_filter, invalid_objects))\n response = GoodData.post \"#{GoodData.project.md['validate-project']}\", 'validateProject' => filters\n polling_link = response['asyncTask']['link']['poll']\n polling_result = GoodData.get(polling_link)\n while polling_result['wTaskStatus'] && polling_result['wTaskStatus']['status'] == 'RUNNING'\n sleep(3)\n polling_result = GoodData.get(polling_link)\n end\n polling_result\n end",
"def validate\n script_name = shift_argument\n unless script_name\n error(\"Usage: mortar local:validate SCRIPT\\nMust specify SCRIPT.\")\n end\n validate_arguments!\n\n # cd into the project root\n project_root = options[:project_root] ||= Dir.getwd\n unless File.directory?(project_root)\n error(\"No such directory #{project_root}\")\n end\n Dir.chdir(project_root)\n\n script = validate_script!(script_name)\n params = config_parameters.concat(pig_parameters)\n\n ctrl = Mortar::Local::Controller.new\n ctrl.validate(script, pig_version, params)\n end",
"def create_plan(plan:, params:)\n plan.visibility = if params['visibility'].blank?\n Rails.configuration.x.plans.default_visibility\n else\n plan_params[:visibility]\n end\n\n plan.template = ::Template.find(params[:template_id])\n\n plan.title = if params[:title].blank?\n if current_user.firstname.blank?\n format(_('My Plan (%{title})'), title: plan.template.title)\n else\n format(_('%{user_name} Plan'), user_name: \"#{current_user.firstname}'s\")\n end\n else\n params[:title]\n end\n\n plan.org = process_org!(user: current_user)\n # If the user said there was no research org, use their org since Plan requires one\n plan.org = current_user.org if plan.org.blank?\n plan.funder = process_org!(user: current_user, namespace: 'funder')\n\n plan.title = plan.title.strip\n\n return unless plan.save\n\n # pre-select org's guidance and the default org's guidance\n ids = (::Org.default_orgs.pluck(:id) << plan.org_id).flatten.uniq\n ggs = ::GuidanceGroup.where(org_id: ids, optional_subset: false, published: true)\n\n plan.guidance_groups << ggs unless ggs.empty?\n plan.add_user!(current_user.id, :creator)\n\n # Set new identifier to plan id by default on create.\n # (This may be changed by user.)\n # ================================================\n # Start DMPTool customization\n # We are using this field as a Funding Opportunity Number\n # ================================================\n # @plan.identifier = @plan.id.to_s\n # ================================================\n # End DMPTool customization\n # ================================================\n plan.save\n plan\n end",
"def test_global_deploy_black_box_failure\n setup_template_dir(\"resource-quota\") do |target_dir|\n flags = \"-f #{target_dir} --selector app=krane\"\n out, err, status = krane_black_box(\"global-deploy\", \"#{KubeclientHelper::TEST_CONTEXT} #{flags}\")\n assert_empty(out)\n assert_match(\"FAILURE\", err)\n refute_predicate(status, :success?)\n assert_equal(status.exitstatus, 1)\n end\n end",
"def execute_plan!\n @selected_plan.call(@arguments.plan_arguments)\n end",
"def test_change_plan_with_latest_policy\n upload_catalog('Catalog-v1.xml', false, @user, @options)\n\n # basic-bimestrial has a trial period\n bp = create_basic_entitlement(1, 'BIMESTRIAL', '2013-08-01', nil, 0)\n\n # Move clock to 2013-08-31\n add_days_and_check_invoice_item(30, 2, 'basic-bimestrial', '2013-08-31', '2013-10-31', 1000.0)\n\n # Move clock to 2013-10-01\n kb_clock_add_days(31, nil, @options)\n\n # Effective date of the second catalog is 2013-10-01\n # Because of limitations of how effectiveDateForExistingSubscriptions is used, we need to upload this intermediate catalog:\n # if we were to upload v4 right away, the change plan would fail (unable to find basic-annual)\n upload_catalog('Catalog-v3.xml', false, @user, @options)\n\n # Move clock to 2013-10-31\n add_days_and_check_invoice_item(30, 3, 'basic-bimestrial', '2013-10-31', '2013-12-31', 1000.0)\n\n # Move clock to 2013-11-01\n kb_clock_add_days(1, nil, @options)\n\n # Effective date of the fourth catalog is 2013-11-01\n upload_catalog('Catalog-v4.xml', false, @user, @options)\n\n add_days(1)\n\n # Verify new CHANGE_OF_PLAN change alignment\n # Because the basic-annual has a 30 days trial, and because of the policy (CHANGE_PLAN) we invoice for a $0 trial\n # and therefore create a pro-ration credit for the part 2013-11-02 -> 2013-12-31\n change_base_entitlement(bp, 4, 'Basic', 'ANNUAL', '2013-08-01', '2013-11-02', nil, 0, -967.21)\n end",
"def setup_plans\n begin\n @@acme_projects ||= Chargify::ProductFamily.find_by_handle('acme-projects')\n rescue ActiveResource::ResourceNotFound\n @@acme_projects = Chargify::ProductFamily.new(\n :name => \"Acme Projects\"\n )\n result = @@acme_projects.save\n result.should be_true\n end\n \n begin\n @@basic_plan ||= Chargify::Product.find_by_handle('basic')\n rescue ActiveResource::ResourceNotFound\n @@basic_plan = Chargify::Product.new(\n :product_family_id => @@acme_projects.id,\n :name => \"Basic Plan\",\n :handle => \"basic\",\n :price_in_cents => 1000,\n :interval => 1,\n :interval_unit => 'month',\n :trial_interval => 1,\n :trial_interval_unit => 'month',\n :trial_price_in_cents => 0\n )\n result = @@basic_plan.save\n result.should be_true\n end\n\n begin\n @@pro_plan ||= Chargify::Product.find_by_handle('pro')\n rescue ActiveResource::ResourceNotFound\n @@pro_plan = Chargify::Product.new(\n :product_family_id => @@acme_projects.id,\n :name => \"Pro Plan\",\n :handle => \"pro\",\n :price_in_cents => 5000,\n :interval => 1,\n :interval_unit => 'month'\n )\n result = @@pro_plan.save\n result.should be_true\n end\n end",
"def execute_manifest\n # load manifest, it is on the root dir of the package\n root_new_files = @manifest_dir\n @log.debug(\"execute_manifest, search manifest in dir #{root_new_files}\")\n mani_filename = File.join(root_new_files, @manifest_fname)\n opt = YAML::load_file( mani_filename )\n if opt\n if opt.class == Hash\n arr_newdir = opt[:new_dir]\n version_title = opt[:version_title]\n arr_newfiles = opt[:new_file]\n @new_version_str = opt[:version_str]\n if version_title\n @log.info(\"Update description: #{version_title}\")\n end\n if arr_newdir\n # process all directories\n arr_newdir.each{|x| proc_dir_toinst(x, root_new_files)}\n end\n if arr_newfiles\n # process all single files\n arr_newfiles.each{|x| proc_file_toinst(x, root_new_files)}\n end\n else\n @log.error(\"Malformed manifest\")\n end\n else\n @log.error(\"Manifest file #{mani_filename} not found\")\n end\n rescue\n @log.error(\"Error on execute_manifest #{$!}\")\n raise(\"Errore nell'esecuzione del manifesto\")\n end",
"def validate_manifest_file manifest_dir\n manifest_file = \"#{manifest_dir}/Manifest.txt\"\n raise \"#{manifest_file} does not exist\" unless test ?f, manifest_file\n manifest = File.new(manifest_file).readlines.map { |x| x.strip }\n manifest -= perforce_ignore\n\n exclusions = with_config do |config, _|\n config[\"exclude\"]\n end\n\n local_manifest = []\n\n Dir.chdir manifest_dir do\n system 'rake clean'\n Find.find '.' do |f|\n next if f =~ exclusions\n local_manifest << f.sub(/^\\.\\//, '') if File.file? f\n end\n end\n\n local_manifest -= perforce_ignore\n\n extra_files = local_manifest - manifest\n missing_files = manifest - local_manifest\n\n msg = []\n\n unless extra_files.empty? then\n msg << \"You have files that are not in your manifest\"\n msg << \" #{extra_files.inspect}\"\n end\n\n unless missing_files.empty? then\n msg << \"You have files that are missing from your manifest\"\n msg << \" #{missing_files.inspect}\"\n end\n\n raise msg.join(\"\\n\") unless msg.empty?\n end",
"def verify_kubernetes_templates!\n # - make sure each file exists / valid\n # - make sure each deploy group has consistent labels\n # - only do this for one single deploy group since they are all identical\n element_groups = grouped_deploy_group_roles.first.map do |deploy_group_role|\n deploy_group_role.kubernetes_role.role_config_file(\n @job.commit, deploy_group: deploy_group_role.deploy_group\n ).elements\n end.compact\n Kubernetes::RoleValidator.validate_groups(element_groups)\n\n # make sure each template is valid\n temp_release_docs.each(&:verify_template)\n end",
"def validate\n\tvalidate_unexpected_assets_not_present && validate_expected_asset_present && validate_snippet_and_description\nend",
"def __run(requester_file, arguments)\n exit(\"Missing schema file argument\", true) unless arguments.size == 1\n unless File.exists?(schema_file = arguments.shift)\n exit(\"Unable to find #{schema_file}\") \n end\n Rubyrel::parse_ddl_file(schema_file)\n end",
"def verify(inspec_options:, inspec_profile_path:)\n if @hosts.empty?\n ::Kitchen::Terraform::InSpecWithoutHosts\n else\n ::Kitchen::Terraform::InSpecWithHosts\n end\n .new(options: inspec_options.merge(attributes: @attributes), profile_path: inspec_profile_path)\n .exec(system: self)\n\n self\n end",
"def validate\n # Installs a kacl-cli checker if needed\n system \"pip3 install --user python-kacl\" unless kacl_cli_installed?\n\n # Check that this is in the user's PATH after installing\n raise \"kacl-cli is not in the user's PATH, or it failed to install\" unless kacl_cli_installed?\n\n if changelog.nil?\n system \"kacl-cli verify --json > #{report}\"\n else\n system \"kacl-cli -f #{changelog} verify --json > #{report}\"\n end\n valid = kacl_report[\"valid\"]\n if !valid\n errors = kacl_report[\"errors\"]\n errors.each do |e|\n start_char_pos = 0\n if e.key?(\"start_char_pos\") && !e[\"start_char_pos\"].nil?\n start_char_pos = e[\"start_char_pos\"]\n end\n fail \"CHANGELOG:#{e['line_number']}:#{start_char_pos} error: #{e['error_message']}\"\n end\n end\n end",
"def authorize_planner\n\n can [:read], Organization do |organization|\n curr_account == organization.account\n end\n can [:adopt, :search], Employee\n can [:read], Employee do |employee|\n employee.organizations.include?(curr_organization)\n end\n can [:update, :create], Employee do |employee|\n (\n !employee.owner? || curr_employee == employee\n ) &&\n # organization_id is a virtual attribute of employee and is used to\n # create the membership for the current organization after create of the\n # employee. So the following line makes sure that memberships for orgs\n # of other account can not be created.\n (\n employee.organization_id.nil? ||\n employee.organization_id.to_i == curr_organization.id\n ) &&\n (\n employee.account.nil? ||\n curr_account == employee.account\n )\n end\n can :update_role, Employee do |employee|\n curr_employee != employee && # no one can update her/his own role\n curr_organization.employees.include?(employee)\n end\n can :manage, Plan do |plan|\n curr_organization == plan.organization\n end\n can :manage, Scheduling do |scheduling|\n curr_organization == scheduling.plan.organization &&\n ( !scheduling.represents_unavailability? || self_planning?(scheduling) )\n end\n can :manage, Shift do |shift|\n curr_organization == shift.plan_template.organization\n end\n can :manage, CopyWeek do |copy_week|\n curr_organization == copy_week.plan.organization\n end\n can :manage, ApplyPlanTemplate do |apply_plan_template|\n curr_organization == apply_plan_template.plan.organization\n end\n can :manage, Team do |team|\n curr_organization == team.organization\n end\n can :manage, Qualification do |qualification|\n curr_account == qualification.account\n end\n can :manage, PlanTemplate do |plan_template|\n curr_organization == plan_template.organization\n end\n can :manage, TeamMerge do |team_merge|\n (team_merge.team_id.blank? || curr_organization == team_merge.team.try(:organization)) &&\n (team_merge.other_team_id.blank? || curr_organization == team_merge.other_team.try(:organization)) &&\n (team_merge.new_team_id.blank? || curr_organization == team_merge.new_team.try(:organization))\n end\n can [:read, :create], Post do |post|\n curr_organization == post.blog.organization\n end\n can [:read, :create], Comment do |comment|\n commentable = comment.commentable\n if commentable.respond_to?(:blog) # comment on a post\n curr_organization == commentable.blog.organization\n elsif commentable.respond_to?(:plan) # comment on a scheduling\n curr_organization == commentable.plan.organization\n else\n false\n end\n end\n can :manage, Invitation do |invitation|\n curr_account == invitation.employee.account &&\n curr_organization == invitation.organization\n end\n can :manage, Milestone do |milestone|\n curr_organization == milestone.plan.organization\n end\n can :manage, Task do |task|\n curr_organization == task.milestone.plan.organization\n end\n\n can :show, Conflict do |conflict|\n curr_organization == conflict.provoker.plan.organization\n end\n\n # For reports we only check the base on which schedulings will be found. For\n # example we do not need to test if the plan_ids submitted belong to the\n # base.\n # Please see the report model for how records are fetched. The base is\n # always the account and one or more organizations within the account.\n # If the user would submit foreign plan_ids for example, this will not do\n # any harm as the result simply will be empty.\n can :create, Report do |report|\n # A planner is only able to see a report within an organization.\n # The filter for organizations will no be shown on the report page of the\n # organization. Therefore the organization_ids of the report should only\n # include the id of the current organization.\n org_ids = report.organization_ids\n org_ids.size == 1 &&\n org_ids.first.to_i == curr_organization.id\n end\n\n authorize_owner_and_planner\n authorize_employee\n end",
"def verify!(executable, *args, &block); end",
"def check_structure(plan)\n deadlines = plan.emission_deadlines\n\n # Now look for the timeouts\n errors = []\n deadlines.missed_deadlines(Time.now)\n .each do |deadline, event, generator|\n errors << MissedDeadlineError.new(generator, event, deadline)\n end\n\n errors\n end",
"def stack_plan_execute(stack)\n logger.debug(\"applying plan `#{stack.plan.id}` to stack `#{stack.id}`\")\n request(\n :path => \"/\",\n :method => :post,\n :form => Smash.new(\n \"Action\" => \"ExecuteChangeSet\",\n \"ChangeSetName\" => stack.plan.id,\n \"StackName\" => stack.name,\n ),\n )\n stack.reload\n end",
"def generate_resource_tests(pwd, data) end",
"def test_add_plan\n upload_catalog('Catalog-v1.xml', false, @user, @options)\n\n # basic-monthly has no trial period\n bp = create_basic_entitlement(1, 'MONTHLY', '2013-08-01', '2013-09-01', 1000.0)\n\n # Move clock to 2013-09-01\n add_days_and_check_invoice_item(31, 2, 'basic-monthly', '2013-09-01', '2013-10-01', 1000.0)\n\n # Effective date of the second catalog is 2013-10-01\n upload_catalog('Catalog-v3.xml', false, @user, @options)\n\n # Move clock to 2013-10-01\n # Original subscription is grandfathered (no effectiveDateForExistingSubscriptions specified)\n add_days_and_check_invoice_item(30, 3, 'basic-monthly', '2013-10-01', '2013-11-01', 1000.0)\n\n # The annual plan is only present in the v3 catalog\n create_basic_entitlement(4, 'ANNUAL', '2013-10-01', nil, 0)\n\n # Move clock to 2013-10-31 (BCD = 1)\n add_days_and_check_invoice_item(30, 5, 'basic-annual', '2013-10-31', '2014-10-01', 12_849.32)\n\n # Move clock to 2013-11-01\n # Verify original subscription is still grandfathered\n add_days_and_check_invoice_item(1, 6, 'basic-monthly', '2013-11-01', '2013-12-01', 1000.0)\n\n # Verify we can change to the new plan\n change_base_entitlement(bp, 7, 'Basic', 'ANNUAL', '2013-08-01', '2013-11-01', '2014-11-01', 14_000, 13_000)\n end",
"def test_apply_failure_with_sensitive_resources_hides_template_content\n logger.level = 0\n Krane::Deployment.any_instance.expects(:sensitive_template_content?).returns(true).at_least_once\n result = deploy_fixtures(\"hello-cloud\", subset: [\"web.yml.erb\"], render_erb: true) do |fixtures|\n bad_port_name = \"http_test_is_really_long_and_invalid_chars\"\n svc = fixtures[\"web.yml.erb\"][\"Service\"].first\n svc[\"spec\"][\"ports\"].first[\"targetPort\"] = bad_port_name\n deployment = fixtures[\"web.yml.erb\"][\"Deployment\"].first\n deployment[\"spec\"][\"template\"][\"spec\"][\"containers\"].first[\"ports\"].first[\"name\"] = bad_port_name\n end\n assert_deploy_failure(result)\n refute_logs_match(%r{Kubectl err:.*something/invalid})\n\n assert_logs_match_all([\n \"Command failed: apply -f\",\n /Invalid template: Deployment-web.*\\.yml/,\n ])\n\n refute_logs_match(\"kind: Deployment\") # content of the sensitive template\n end",
"def plan_file_args(plan_file, subcmd)\n output = []\n if subcmd == 'plan'\n output = [ \"-out=#{plan_file}\" ]\n\n elsif subcmd == 'apply'\n if File.exists?(plan_file)\n output = [ \"#{plan_file}\" ]\n else\n raise Tfctl::Error.new \"Plan file not found in #{plan_file}. Run plan first.\"\n end\n end\n output\n end",
"def run_on_project\n zones = @project.get_element('zones')\n\n # iterates all zones, descend into zone\n # for further checks, mark all those bad\n # zones, decide upon boolean return flag\n (run_on_project_zones(zones)\n .each do |zone_name, zone_data|\n # error occured in run_on_zone call. Lets mark this\n zone_data.store :status, :failed\n mark(\"Not all elements of zone \\'#{zone_name}\\' are valid.\",\n :zone, zone_name, zone_data)\n end.size > 0)\n end",
"def run(action, events, resource)\n if !@assertion_proc || !@assertion_proc.call\n @assertion_failed = true\n if Chef::Config[:why_run] && @whyrun_message\n events.provider_requirement_failed(action, resource, @exception_type, @failure_message)\n events.whyrun_assumption(action, resource, @whyrun_message) if @whyrun_message\n @resource_modifier.call if @resource_modifier\n else\n if @failure_message\n events.provider_requirement_failed(action, resource, @exception_type, @failure_message)\n raise @exception_type, @failure_message\n end\n end\n end\n end",
"def queue_plan(plan: nil , custom_revision: nil ,stage: nil, executeAllStages: true, variables: {})\n url = queue_plan_url(plan, custom_revision, stage,executeAllStages,variables)\n puts \"url = #{url}\" \n begin\n @logger.debug(\"url = #{url}\") \n response= RestClient::Request.execute(method: :post, url: url,\n user: @config[:user], password: @config[:password], :verify_ssl =>OpenSSL::SSL::VERIFY_NONE)\n @logger.info(\"plan queued successfully: #{response}\")\n return true\n rescue RestClient::Exception => error\n @logger.fatal(\"Cannot queue plan, #{error.class}\")\n response_code = error.http_code\n case response_code\n when 415 \n # post method payload is not form encoded\n @logger.fatal(\"post payload is not form encoded: url\")\n when 400\n #plan not queued due to bamboo limitation, like too many cocurrent builds for the current plan\n @logger.fatal(\"bamboo limitation, too many builds queued for current plan?\")\n when 404\n #plan does not exist\n @logger.fatal(\"current plan #{plan} not found\")\n when 401\n #user pemission issue\n @logger.fatal(\"user #{@config[:user]} permission issue, check username and password.\")\n when 405\n @logger.fatal(\"http method not allowd\")\n when 200\n @logger.info(\"plan queued successfully: #{error.to_s}\")\n else\n @logger.warn(\"Unexpected response code: #{response_code}, #{error.to_s}\")\n end \n return false\n end\n \n end",
"def linux_validation_rules\n\n template_validation_rule { finish_linux_configuration }\n\n resource_validation_rule(Azure::ARM::Compute::VirtualMachine) do |vm|\n vm.configure do\n os_profile admin_username: parameter('username'),\n linux_configuration: {\n disable_password_authentication: true,\n ssh: { public_keys:\n { path: concat('/home/',parameters('username'),'/.ssh/authorized_keys'),\n key_data: parameter('ssh_key') }\n }\n }\n if vm.storage_profile.nil? or vm.storage_profile.image_reference.nil?\n image Azure::ARM::Compute::VirtualMachine::UBUNTU_LTS\n end\n end\n end\n\n resource_validation_rule(Azure::ARM::Compute::VirtualMachineScaleSet) do |vmss|\n\n vmss.configure do\n\n vmss.properties.virtual_machine_profile.configure do |profile|\n\n if profile.os_profile.nil?\n os_profile admin_username: parameter('username'),\n computer_name_prefix: vmss.name,\n linux_configuration: {\n disable_password_authentication: true,\n ssh: { public_keys:\n { path: concat('/home/',parameters('username'),'/.ssh/authorized_keys'),\n key_data: parameter('ssh_key') }\n }\n }\n end\n\n if profile.storage_profile.nil? or profile.storage_profile.image_reference.nil?\n\n storage_profile (vmss.template.virtual_machine_scale_set_storage_profile image_reference: Azure::ARM::Compute::VirtualMachine::UBUNTU_LTS)\n\n end\n\n end\n\n os_disk\n\n network_configuration\n\n end\n\n end\n\n end",
"def call(kitchen_state)\n load_output kitchen_state: kitchen_state\n\n ::Kitchen::Verifier::Terraform::EnumerateGroupsAndHostnames\n .call(\n groups: config_groups,\n output: output\n ) do |group:, hostname:|\n verify(\n group: group,\n hostname: hostname\n )\n end\n rescue ::Kitchen::Terraform::Error => error\n raise(\n ::Kitchen::ActionFailed,\n error.message\n )\n end",
"def run_test(\n resource_type, password_property, sub_property_name, test_template_type,\n test_description, desired_test_result\n)\n cfn_model =\n CfnParser.new.parse read_test_template(\n file_path(\n resource_type, test_template_type, password_property,\n sub_property_name, test_description\n )\n )\n\n actual_logical_resource_ids = described_class.new.audit_impl cfn_model\n\n expect(actual_logical_resource_ids).to eq \\\n expected_logical_resource_ids(desired_test_result, resource_type)\nend",
"def run\n Precheck.config.load_configuration_file(Precheck.precheckfile_name)\n\n FastlaneCore::PrintTable.print_values(config: Precheck.config,\n hide_keys: [:output_path],\n title: \"Summary for precheck #{Fastlane::VERSION}\")\n\n unless Spaceship::Tunes.client\n UI.message(\"Starting login with user '#{Precheck.config[:username]}'\")\n Spaceship::Tunes.login(Precheck.config[:username])\n Spaceship::Tunes.select_team\n\n UI.message(\"Successfully logged in\")\n end\n\n UI.message(\"Checking app for precheck rule violations\")\n\n ensure_app_exists!\n\n processor_result = check_for_rule_violations(app: app, app_version: latest_app_version)\n\n if processor_result.items_not_checked?\n print_items_not_checked(processor_result: processor_result)\n end\n\n if processor_result.has_errors_or_warnings?\n summary_table = build_potential_problems_table(processor_result: processor_result)\n puts(summary_table)\n end\n\n if processor_result.should_trigger_user_error?\n UI.user_error!(\"precheck 👮♀️ 👮 found one or more potential problems that must be addressed before submitting to review\")\n return false\n end\n\n if processor_result.has_errors_or_warnings?\n UI.important(\"precheck 👮♀️ 👮 found one or more potential metadata problems, but this won't prevent fastlane from completing 👍\".yellow)\n end\n\n if !processor_result.has_errors_or_warnings? && !processor_result.items_not_checked?\n UI.message(\"precheck 👮♀️ 👮 finished without detecting any potential problems 🛫\".green)\n end\n\n return true\n end",
"def validate(file,schema)\n validator = Grayskull::Validator.new(file,schema)\n results = validator.validate\n \n if !results['result']\n puts 'Validation Failed with ' + results['errors'].count.to_s + ' errors';\n puts ''\n results[\"errors\"].each{\n |error|\n puts error \n }\n else\n puts 'Validated Successfully!'\n end\n end",
"def run\n print_banner\n @test_plan.each do |plan|\n found_nodes = nodes(plan)\n if found_nodes\n found_nodes.each { |node| execute_plan_tests(node, plan) }\n end\n end\n exit @ret_code\n end",
"def create\n plan = Plan.new\n authorize plan\n\n # If the template_id is blank then we need to look up the available templates and\n # return JSON\n if plan_params[:template_id].blank?\n # Something went wrong there should always be a template id\n respond_to do |format|\n flash[:alert] = _('Unable to identify a suitable template for your plan.')\n format.html { redirect_to new_plan_path }\n end\n else\n\n puts plan_params.inspect\n\n @plan = create_plan(plan: plan, params: plan_params)\n\n if @plan.is_a?(Plan)\n default = Template.default\n\n msg = \"#{success_message(@plan, _('created'))}<br />\"\n\n if !default.nil? && default == @plan.template\n # We used the generic/default template\n msg += \" #{_('This plan is based on the default template.')}\"\n\n elsif [email protected]_of.nil?\n # We used a customized version of the the funder template\n # rubocop:disable Layout/LineLength\n msg += \" #{_('This plan is based on the')} #{@plan.funder&.name}: '#{@plan.template.title}' #{_('template with customisations by the')} #{@plan.template.org.name}\"\n # rubocop:enable Layout/LineLength\n else\n # We used the specified org's or funder's template\n msg += \" #{_('This plan is based on the')} #{@plan.template.org.name}: '#{@plan.template.title}' template.\"\n end\n\n respond_to do |format|\n flash[:notice] = msg\n format.html { redirect_to plan_path(@plan) }\n end\n else\n # Something went wrong so report the issue to the user\n respond_to do |format|\n flash[:alert] = failure_message(plan, _('create'))\n format.html { redirect_to new_plan_path }\n end\n end\n end\n end",
"def verify_manifest\n abort \"cannot find your AndroidManifest.xml to extract info from it. Make sure you're in the root directory of your app\" unless\n File.exists? 'AndroidManifest.xml'\n @manifest ||= REXML::Document.new(File.read('AndroidManifest.xml')).root\nend",
"def test_modify_object_permissions\r\n\t\tVCR.use_cassette('get_schema') do\r\n\t\t\tschema_type=\"DigitalSpecimen\"\r\n\t\t\tdo_schema=CordraRestClient::DigitalObject.get_schema(API_URL, schema_type)\r\n\t\t\t# check that the right schema was delivered\r\n\t\t\tassert_equal \"object\", do_schema[\"type\"]\r\n\t\t\tassert_equal \"DigitalSpecimen\", do_schema[\"title\"]\r\n\t\tend\r\n\tend",
"def edit_check(exec_action)\n t = Chef::Resource::Template.new(tpl_name, run_context)\n t.cookbook new_resource.cookbook\n t.path tpl_path\n t.source 'monit.check.erb'\n t.variables monit_check_config\n if Chef::VERSION.to_f >= 12\n t.verify do |path|\n \"monit -tc #{path}\"\n end\n end\n t.run_action exec_action\n t.updated_by_last_action?\n end",
"def show_usage_and_exit\r\n puts 'Usage:', 'verifier.rb *filename* file should be a blockchain.txt file'\r\n exit 1\r\nend",
"def create_from_funder_requirements\n plan = ::Plan.new\n authorize plan\n\n # If the template_id is blank then we need to look up the available templates and\n # return JSON\n if plan_params[:template_id].blank?\n # Something went wrong there should always be a template id\n respond_to do |format|\n flash[:alert] = _('Unable to identify a suitable template for your plan.')\n format.html { redirect_to new_plan_path }\n end\n else\n @plan = create_plan(plan: plan, params: plan_params)\n\n if @plan.is_a?(Plan)\n default = ::Template.default\n\n msg = \"#{success_message(@plan, _('created'))}<br />\"\n\n if !default.nil? && default == @plan.template\n # We used the generic/default template\n msg += \" #{_('This plan is based on the default template.')}\"\n\n elsif [email protected]_of.nil?\n # We used a customized version of the the funder template\n # rubocop:disable Layout/LineLength\n msg += \" #{_('This plan is based on the')} #{@plan.funder&.name}: '#{@plan.template.title}' #{_('template with customisations by the')} #{@plan.template.org.name}\"\n # rubocop:enable Layout/LineLength\n else\n # We used the specified org's or funder's template\n msg += \" #{_('This plan is based on the')} #{@plan.template.org.name}: '#{@plan.template.title}' template.\"\n end\n\n respond_to do |format|\n flash[:notice] = msg\n format.html { redirect_to plan_path(@plan) }\n end\n else\n # Something went wrong so report the issue to the user\n respond_to do |format|\n flash[:alert] = failure_message(plan, _('create'))\n format.html { redirect_to new_plan_path }\n end\n end\n end\n end"
] |
[
"0.6711906",
"0.5714419",
"0.5712143",
"0.56716156",
"0.5624202",
"0.5571267",
"0.5516078",
"0.54607767",
"0.5451067",
"0.5430642",
"0.5408361",
"0.5398637",
"0.5327612",
"0.5293587",
"0.5272796",
"0.5120308",
"0.50909543",
"0.5080317",
"0.5075382",
"0.5039708",
"0.5013737",
"0.50025475",
"0.5002324",
"0.49612236",
"0.49554616",
"0.4949168",
"0.49476638",
"0.49429947",
"0.49355933",
"0.49330327",
"0.49090755",
"0.48811573",
"0.48637605",
"0.4858594",
"0.48582873",
"0.48474643",
"0.4841594",
"0.48230028",
"0.48140293",
"0.48121265",
"0.47838143",
"0.47776482",
"0.47714078",
"0.4770597",
"0.47620282",
"0.47367054",
"0.47284317",
"0.47175962",
"0.47062826",
"0.46892977",
"0.4682864",
"0.46823713",
"0.46736765",
"0.4655061",
"0.465269",
"0.4645859",
"0.463759",
"0.46251282",
"0.46226433",
"0.46154618",
"0.4612914",
"0.4612914",
"0.45955598",
"0.45932817",
"0.45872617",
"0.45853576",
"0.4565345",
"0.45569417",
"0.45428634",
"0.45364457",
"0.4536252",
"0.45249566",
"0.45206928",
"0.4511294",
"0.4511113",
"0.4508033",
"0.4507497",
"0.44981095",
"0.4487933",
"0.4486244",
"0.44780648",
"0.4469095",
"0.44586176",
"0.44583118",
"0.445339",
"0.44263196",
"0.4422631",
"0.4412084",
"0.44059306",
"0.43995267",
"0.4391863",
"0.43916428",
"0.4385903",
"0.43810037",
"0.43721178",
"0.43702057",
"0.43644753",
"0.4363829",
"0.4353124",
"0.43516213"
] |
0.4727043
|
47
|
GET /trips GET /trips.json
|
def index
@trips = Trip.all
render json: @trips
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def trips\n get '/gtfs/trips'\n end",
"def trips\n flight = Flight.where(\"id = ?\", params[:id]).take\n if flight.nil?\n render :json => {errors: \"404\"}, :status => 404\n else\n respond_with( flight.trips )\n end\n end",
"def trips\n @trip_requests = current_user.trip_requests.trips.paginate(page:params[:page], per_page:20)\n json_response(@trip_requests)\n end",
"def index\n @trips = Trip.all\n render :json => @trips\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def get_user_trips\n\n\t\tputs \"Trips driving\"\n\t\tputs current_user.past_trips_driven[0]\n\t\tputs current_user.trips_requested\n\t\tif current_user \n\t\t\trender json: {\n\t\t\t\tstatus: 'success',\n\t\t\t\ttrips_requested: Trip.where( :_id.in => current_user.trips_requested ),\n\t\t\t\ttrips_listed: Trip.where( :_id.in => current_user.trips_driving ),\n\t\t\t\ttrips_accepted: Trip.where( :_id.in => current_user.trips_accepted ),\n\t\t\t\texpired_requests: Trip.where( :_id.in => current_user.past_trips_requested),\n\t\t\t\texpired_listings: Trip.where( :_id.in => current_user.past_trips_driven),\n\t\t\t\tcurrent_userstrips: current_user.trips_driving\n\t\t\t}, status: 200\n\t\telse\n\t\t\trender json: {\n\t\t\t\tstatus: 'error',\n\t\t\t\tmessage: 'User is not signed in!'\n\t\t\t}, status: 422\n\t\tend\n\tend",
"def index\n @trips = Trip.all\n end",
"def index\n trips = Trip.all\n render json: trips\n end",
"def index\n \t@trips = Trip.all\n end",
"def list\n @trips = Trips.my_trips(cookies[ :user_id ] )\n end",
"def user_trips(user_id=self.username)\n connection.get(\"/users/#{user_id}/trips\").body.trips\n end",
"def index\n @trips = current_user.trips\n end",
"def index\n @trips = current_user.trips\n end",
"def index\n unless params[:user_id].nil?\n @user = User.find(params[:user_id])\n @trips = @user.trips\n else\n @trips = Trip.all\n end\n end",
"def my\n @trips = Trip.completed.\n includes(:driver, {trip_request: :rider}).\n joins(trip_request: :rider).\n where(users: {id: params[:rider_id]})\n\n options = {}\n # JSON API: https://jsonapi.org/format/#fetching-sparse-fieldsets\n # fast_jsonapi: https://github.com/Netflix/fast_jsonapi#sparse-fieldsets\n #\n # convert input params to options arguments\n if params[:fields]\n trip_params = params[:fields].permit(:trips).to_h.\n inject({}) { |h, (k,v)| h[k.singularize.to_sym] = v.split(\",\").map(&:to_sym); h }\n options.merge!(fields: trip_params)\n end\n\n render json: TripSerializer.new(@trips, options).serializable_hash\n end",
"def index\n @profile = Profile.find_by_user_id(current_user.id)\n @trips = @profile.trips\n end",
"def index\n @trips = Trip.desc.all\n @latest_trip = @trips.first\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trips }\n end\n end",
"def index\n @trips = Trip.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @trips }\n end\n end",
"def index\n @trips = Trip.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @trips }\n end\n end",
"def index\n @trips = Trip.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @trips }\n end\n end",
"def index\n trips = Trip.all\n respond_with trips\n end",
"def show\n @trips_connect = TripsConnect.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trips_connect }\n end\n end",
"def index\n\t@trips = Trip.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @trips }\n end\n end",
"def index\n search = TripSearch.new(search_params)\n trips = Trip.apply_scopes(\n search.start_location,\n search.driver_name,\n search.rider_name\n )\n\n render json: trips\n end",
"def trips_by_trip_id(trip_id)\n get \"/gtfs/trips/tripId/#{trip_id}\"\n end",
"def trips\n trips = RideShare::Trip.trips_by_rider(@id)\n if trips != nil\n return trips\n else\n return []\n end\n end",
"def index\n if params[:passenger_id]\n @passenger = Passenger.find_by(id: params[:passenger_id])\n @trips = @passenger.trips\n else\n render :notfound, status: :not_found\n end\n end",
"def trip(trip_id)\n connection.get(\"/trips/#{trip_id}\").body\n end",
"def trips\n RideShare::Trip.find_all_for_rider(@id)\n end",
"def index\n # Get trips for the trip type\n trips = Trip.all.where(trip_type: params[:trip_type] || 2)\n # (optional) if city_id params was provided\n trips = trips.joins(:city).where(\"cities.id = ?\", params[:city_id]) if params[:city_id]\n # (optional) if country_id params was provided\n trips = trips.joins(:city => :country).where(\"countries.id = ?\", params[:country_id]) if params[:country_id]\n # (optional) if sort params was provided\n if params[:sort]\n \n case params[:sort].downcase\n when 'popularity' # by number of bookings\n trips = trips.most_popular\n when 'rating' # by rating of reviews\n trips = trips.best_rated\n end\n\n end\n\n # Paginate\n trips = trips.page(params[:page] || 1).per(params[:per_page] || 20)\n\n render json: {\n trips: ActiveModelSerializers::SerializableResource.new(trips, each_serializer: TripSerializer),\n total: trips.total_count,\n page: trips.current_page,\n per_page: trips.limit_value\n }\n end",
"def all_trips\n return Rideshare::Trip.find_trip_by_rider(@id)\n end",
"def show\n # raise\n authorize @trip\n @user = current_user\n @routes = @trip.routes\n add_markers_and_site_geoloc if [email protected]? # add the markers and the @site_loc. Reject routes without localisation.\n\n @trips = []\n @trips << @user.trips\n @trips << @user.joint_user_trips.map { |jut| jut.trip }\n @trips = @trips.flatten\n end",
"def trips_by_route_id(route_id)\n get \"/gtfs/trips/routeid/#{route_id}\"\n end",
"def trips\n @agent.get(TRIPS_URL)\n\n # If session expires, re-login to citibikenyc.com. The site will redirect\n # back to TRIPS_URL upon sign in (friendly forwarding)\n login unless @agent.page.title == TRIPS_PAGE_TITLE\n\n rows = Nokogiri::HTML(@agent.page.body).xpath('//table/tbody/tr')\n\n # Reject bike trips that are either in progress or have durations <\n # MIN_TRIP_DURATION minutes.\n rows = rows.reject do |row|\n duration = row.at_xpath('td[6]/text()').to_s.match(/(\\d{1,2})m/)\n !duration || (duration.captures[0].to_i < MIN_TRIP_DURATION)\n end\n rows.map { |row| row_to_trip(row) }\n end",
"def index\n @trip = Trip.find(params[:trip_id])\n end",
"def show\n render json: @trip\n end",
"def show\n render json: @trip\n end",
"def show\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trip }\n end\n end",
"def show\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trip }\n end\n end",
"def show\n @request = Request.find(params[:id])\n #@sorted_trips = @request.get_sorted_trips\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @request }\n end\n end",
"def trips\n @analysis[:trips]\n end",
"def show\n @trip_item = TripItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trip_item }\n end\n end",
"def index\n @trips = Trip.where(user: current_user)\n @trip = Trip.new\n end",
"def trips\n Trip.where(:route_id => self.route_id)\n end",
"def trips\n Trip.where(:route_id => self.route_id)\n end",
"def index\n @tips_tricks = @tips_tricks.published.recent.page(params[:page]).per(10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tips_tricks }\n end\n end",
"def get_trip_listing \n\t\t@trip = Trip.find_by(_id: trip_params[:trip_id])\n\t\tif current_user.trips_driving.include?(trip_params[:trip_id]) || current_user.past_trips_driven.include?(trip_params[:trip_id])\n\t\t\t@user_requests = User.where(:_id.in => @trip.user_requests).map { |user|\n\t\t\t\tuser = {\n\t\t\t\t\t_id: user.id,\n\t\t\t\t\tfirst_name: user.first_name,\n\t\t\t\t\tlast_name: user.last_name,\n\t\t\t\t\tfacebook_link: user.facebook_link,\n\t\t\t\t\temail: user.email,\n\t\t\t\t\tphone_number: user.phone_number\n\t\t\t\t}\n\t\t\t}\n\t\t\t@accepted_users = User.where(:_id.in => @trip.accepted_users).map { |user| \n\t\t\t\tuser = {\n\t\t\t\t\t_id: user.id,\n\t\t\t\t\tfirst_name: user.first_name,\n\t\t\t\t\tlast_name: user.last_name,\n\t\t\t\t\tfacebook_link: user.facebook_link,\n\t\t\t\t\temail: user.email,\n\t\t\t\t\tphone_number: user.phone_number\n\t\t\t\t}\n\t\t\t}\n\t\t\trender json: {\n\t\t\t\tstatus: 'success',\n\t\t\t\ttrip: {\n\t\t\t\t\ttrip_details: @trip,\n\t\t\t\t\tuser_requests: @user_requests,\n\t\t\t\t\taccepted_users: @accepted_users\n\t\t\t\t}\n\t\t\t}\n\t\telse\n\t\t\trender json: {\n\t\t\t\tstatus: 'error',\n\t\t\t\tmessage: 'This user is not the driver for this trip'\n\t\t\t}\n\t\tend\n\tend",
"def get_trip\n\t\t@trip = Trip.find_by(_id: trip_params[:trip_id])\n\t\tif @trip\n\t\t\t@user_requests = User.where(:_id.in => @trip.user_requests).map { |user|\n\t\t\t\tuser = {\n\t\t\t\t\t_id: user.id,\n\t\t\t\t\tfirst_name: user.first_name,\n\t\t\t\t\tlast_name: user.last_name\n\t\t\t\t}\n\t\t\t}\n\t\t\t@accepted_users = User.where(:_id.in => @trip.accepted_users).map { |user| \n\t\t\t\tuser = {\n\t\t\t\t\t_id: user.id,\n\t\t\t\t\tfirst_name: user.first_name,\n\t\t\t\t\tlast_name: user.last_name\n\t\t\t\t}\n\t\t\t}\n\t\t\t@trip._id = @trip._id.to_s\n\t\t\t@driver = User.find_by(_id: @trip.driver)\n\t\t\trender json: {\n\t\t\t\tstatus: 'success',\n\t\t\t\ttrip: @trip,\n\t\t\t\tdriver: {\n\t\t\t\t\tfirst_name: @driver.first_name,\n\t\t\t\t\tlast_name: @driver.last_name,\n\t\t\t\t\trating: @driver.driver_rating\n\t\t\t\t},\n\t\t\t\tuser_requests: @user_requests,\n\t\t\t\taccepted_users: @accepted_users\n\t\t\t}, status: 200\n\t\telse\n\t\t\trender json: {\n\t\t\t\tstatus: 'error',\n\t\t\t\tmessage: 'That trip could not be found!'\n\t\t\t}, status: 422\n\t\tend\n\tend",
"def personal_trips\n @personal_trips = trips.where(driver_id: 0)\n end",
"def index\n tips = Tip.all\n json_response(tips)\n end",
"def index\n redirect_to find_trips_path\n end",
"def index\n @trips = current_user.trips_validated\n @pending_trips = current_user.pending_trips\n\n @visitor = current_user\n respond_to do |format|\n format.html{}\n format.js{}\n end\n end",
"def get_travellers\n if current_user != nil\n @trip = Trip.find(params[:id])\n render json: @trip.trip_json\n else\n render json: session[:trip].trip_json\n end\n\n end",
"def show\n @profile = Profile.find_by_user_id(current_user.id)\n @trip = @profile.trips.find(params[:id])\n end",
"def index\n @class_trips = ClassTrip.all\n end",
"def invites\n user = current_user\n\n # Query to get only not yet accepted trips associated wiht the current user\n @trips = Trip.joins(:user_trips).where(user_trips: { accepted: false }).where(user_trips: { user_id: user.id })\n render json: @trips\n end",
"def get_trip_detail(id)\n server_response = handle_timeouts do\n get \"/1/trips/#{id}.json?locale=en\"\n end\n server_response['response']\n end",
"def show\n @trip = Trips.find_trip(params[ :id ] )\n end",
"def index\n @trips = Trip.all\n @now = Date.today\n end",
"def group\n @trips = Trip.find(current_user).trip_users\n\n render json: { result: \"success\", data: @trips }\n end",
"def trips\n #will find upcoming trips/reservations for guests\n Reservation.where(guest_id: self.id)\n end",
"def trips\n Trip.find_for_driver(@driver_id)\n end",
"def trips\n @trips = Trip.all.select do |trip|\n trip.listing == self\n end\n end",
"def index\n @trip_routes = TripRoute.all\n end",
"def index\n @snips = Snip.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @snips }\n end\n end",
"def show\n @trip = Trip.find(params[:id])\nend",
"def new\n @trips_connect = TripsConnect.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trips_connect }\n end\n end",
"def accepted_trips\n trip_ids = self.user_trips.where(state: \"accepted\").map(&:trip_id)\n Trip.where(id: trip_ids)\n end",
"def show\n @trip = Trip.find(params[:trip_id])\n end",
"def index\n @future_trips = FutureTrip.all\n end",
"def find_trip\n @trip = Trip.find(params[:id])\n end",
"def flights\n trip = Trip.where('id = ?', params[:id]).take\n if !trip.nil\n respond_with( trip.flights )\n else\n render :json => { error: 404 }, :status => 404\n end\n end",
"def create\n trip = current_user.trips.new(trip_params)\n if trip.save\n render json: {\n status: :created,\n trip: trip\n }\n else\n render json: {\n status: 500,\n errors: trip.errors.full_messages\n }\n end\n end",
"def index\n # redirect /oj to here\n load_trips\n\n respond_to do |format|\n format.html { render :index }\n end\n end",
"def index\n @trips = Trip.order(params[:sort].to_s + \" \" + params[:direction].to_s)\n @tripLocation = Trip.pluck(:id)\n @markers = Marker.where(\"trip_id in (?)\", @tripLocation)\n @gmaps_options = @markers.to_gmaps4rails\n\n @polylines_json = {}\n polylines = []\n\n @trips.each_with_index do |trip, i|\n polylines[i] = []\n trip.markers.each do |marker|\n polylines[i] += [{:lng=>marker.longitude.to_f, :lat=>marker.latitude.to_f}]\n end\n end\n \n @polylines_json = polylines.to_json\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trips }\n end\n end",
"def trips \n Trips.all.each do |trip|\n trip \n end \n\n #return to airbnb\n \n\n\n \nend",
"def view_current_trips\n @trips = Request.all\n @count = Request.count\n @trips.each do |trip|\n @curLoc = trip.currentLoc\n @destination = trip.destination\n end\n end",
"def show\n if request.referer =~ /\\/embed\\/parks/ && request.format == 'html'\n redirect_to \"/embed\" + request.path\n return\n end\n\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json do\n @trip['start_lat'] = @trip.starting_trailhead.latitude\n @trip['start_lng'] = @trip.starting_trailhead.longitude\n @trip['end_lat'] = @trip.ending_trailhead.latitude\n @trip['end_lng'] = @trip.ending_trailhead.longitude\n render json: @trip\n end\n end\n end",
"def search_trips(trips, opts = {})\n service_id = opts[:service_id]\n route_id = opts[:route_id]\n service_id ||= 'S1'\n\n valid_trips = trips.select { |trip| \n trip[:service_id].eql? service_id\n }\n trips_with_route = valid_trips.select{ |trip| \n if !route_id.nil? then \n trip[:route_id].eql? route_id \n else \n true\n end \n }\n trips_with_route.map {|trip| trip[:trip_id]}\n end",
"def show\n @trip = Trip.find_by_marketable_url(params[:marketable_url])\n end",
"def index\n @trips = current_user.trips\n @unvalidated = @trips.where(:validated => false)\n @validated = @trips.where(:validated => true)\n end",
"def trips_stats \n @all = current_user.trip_requests.trips.count\n @completed = current_user.trip_requests.trips.completed.count\n @cancelled = current_user.trip_requests.trips.cancelled.count\n @pending = current_user.trip_requests.trips.pending.count\n @on_going = current_user.trip_requests.trips.on_going.count\n @active = current_user.trip_requests.trips.active.count\n @monthly_successful = current_user.trip_requests.completed.trips.group_by_month(:created_at, format: \"%b\", reverse:true).count\n @monthly_pending = current_user.trip_requests.pending.trips.group_by_month(:created_at, format: \"%b\", reverse:true).count\n @response = { all: @all, completed: @completed, cancelled: @cancelled, active: @active, monthly_pending:@monthly_pending, monthly_successful:@monthly_successful, pending: @pending, on_going: @on_going }\n json_response(@response)\n end",
"def index\n @guide_trips = GuideTrip.all\n end",
"def rider_trip_instances\n rider_trips = RideShare::Trip.all_rider_trip_instances(@rider_id)\n return rider_trips\n end",
"def index\n @trip_types = TripType.all\n end",
"def show\n\n set_no_cache\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trip }\n end\n\n end",
"def index\n # @locations = Location.all.where(:trip_id => @trip)\n @locations = Location.all.where(trip_id: @trip)\n @trip = Trip.find(params[:trip_id])\n end",
"def request_trip\n\t\t@trip = Trip.find_by(_id: trip_params[:trip_id])\n\t\t# Check that the current user has not requested more than 3 trips, \n\t\t# That the user has not already requested this trip\n\t\t# and that the trip has available spaces and that the driver is not the requestor\n\t\tif current_user.trips_requested.size <= 5 && \n\t\t\t!(@trip.user_requests.include?(current_user._id)) && @trip.spaces > 0 && @trip.driver != current_user.id.to_s && !(current_user.trips_accepted.include?(@trip.id))\n\n\t\t\[email protected]_requests << current_user._id\n\t\t\tcurrent_user.trips_requested << @trip._id.to_s\n\t\t\tcurrent_user.save!\n\t\t\[email protected]!\n\t\t\trender json: {\n\t\t\t\tstatus: 'success',\n\t\t\t\ttrip: @trip\n\t\t\t}, status: 200\n\t\telse\n\t\t\t# Error handling\n\t\t\tif current_user.trips_requested.size > 5\n\t\t\t\trender json: {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\tmessage: 'This user has requested too many requests!'\n\t\t\t\t}, status: 422\n\t\t\telsif @trip.user_requests.include?(current_user._id)\n\t\t\t\trender json: {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\tmessage: 'You have already requested this trip!'\n\t\t\t\t}, status: 422\n\t\t\telsif @trip.spaces <= 0\n\t\t\t\trender json: {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\tmessage: 'There is no more space in this trip!'\n\t\t\t\t}, status: 422\n\t\t\telsif @trip.driver == current_user.id.to_s\n\t\t\t\trender json: {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\tmessage: 'You cannot request your own trip!'\n\t\t\t\t}, status: 422\n\t\t\telsif current_user.trips_accepted.include?(@trip.id)\n\t\t\t\trender json: {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\tmessage: \"You've already been accepted on this trip!\"\n\t\t\t\t}, status: 422\n\t\t\telse\n\t\t\t\trender json: {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\tmessage: 'Something went wrong...'\n\t\t\t\t}, status: 422\n\t\t\tend\n\t\tend\n\tend",
"def show\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @trip.to_json, :callback => params[:callback] }\n end\n end",
"def show\n travels = Travel.find(params[:id])\n render json: travels, status: :ok\n end",
"def show\n\n trip = Trip.find(params[:id])\n\n departureOrder = LineStation.find_by_station_id(trip.departureStation_id).order\n arrivalOrder = LineStation.find_by_station_id(trip.arrivalStation_id).order\n\n lineStations = LineStation.where(:order => departureOrder..arrivalOrder)\n lineStations = lineStations.where(:line_id => trip.line_id)\n if departureOrder < arrivalOrder\n lineStations.order('order ASC')\n else\n lineStations.order('order DESC')\n end\n\n times = Array.new\n currentTime = trip.beginTime\n lineStations.each do |ls|\n \n station = Station.find(ls.station_id)\n train = Train.find(trip.train_id)\n\n times << { :station => station, :time => currentTime.strftime('%H:%M') }\n\n timeElapsed = ls.distance.to_f / train.velocity\n currentTime = currentTime + timeElapsed.hours\n end\n\n render :json => { :trip => trip, :times => times }\n\n end",
"def show\n @trip = Trip.find(params[:id])\n @places = @trip.places\n end",
"def trips\n Trip.all.filter do |trip|\n trip.listing == self\n end\n end"
] |
[
"0.8200744",
"0.8043299",
"0.7953297",
"0.7923607",
"0.7489528",
"0.7489528",
"0.7489528",
"0.7489528",
"0.7489528",
"0.7489528",
"0.7489528",
"0.74752015",
"0.7470604",
"0.7454113",
"0.7362034",
"0.73261654",
"0.7307701",
"0.7276205",
"0.7276205",
"0.726057",
"0.71996105",
"0.70870185",
"0.70484334",
"0.6971204",
"0.69445425",
"0.69445425",
"0.6939416",
"0.69311166",
"0.68987167",
"0.6893047",
"0.6837128",
"0.676819",
"0.6711015",
"0.67099917",
"0.6655993",
"0.6625289",
"0.6569384",
"0.65505785",
"0.653589",
"0.65116245",
"0.6456897",
"0.645134",
"0.645134",
"0.64425206",
"0.64425206",
"0.6410776",
"0.63861245",
"0.6367155",
"0.6361464",
"0.63494325",
"0.63494325",
"0.6321195",
"0.63199323",
"0.6318612",
"0.6315903",
"0.6307885",
"0.6302776",
"0.6301129",
"0.6295041",
"0.6288534",
"0.62119544",
"0.6174374",
"0.6171282",
"0.6169726",
"0.61606896",
"0.61176157",
"0.60775447",
"0.6062811",
"0.5990264",
"0.59899336",
"0.5988588",
"0.5987629",
"0.5957111",
"0.5948719",
"0.5938699",
"0.59322983",
"0.59228384",
"0.5922719",
"0.59208864",
"0.5897512",
"0.589674",
"0.5887556",
"0.5867949",
"0.58577025",
"0.5830833",
"0.5828658",
"0.5824773",
"0.5815122",
"0.5807024",
"0.58060676",
"0.57999045",
"0.5756714",
"0.57479334",
"0.5727894",
"0.57127446",
"0.57088965",
"0.5697766",
"0.5696028",
"0.56903934"
] |
0.80000377
|
3
|
GET /trips/1 GET /trips/1.json
|
def show
render json: @trip
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def trips\n flight = Flight.where(\"id = ?\", params[:id]).take\n if flight.nil?\n render :json => {errors: \"404\"}, :status => 404\n else\n respond_with( flight.trips )\n end\n end",
"def index\n @trips = Trip.all\n\n render json: @trips\n end",
"def index\n @trips = Trip.all\n\n render json: @trips\n end",
"def trips\n get '/gtfs/trips'\n end",
"def index\n @trips = Trip.all\n render :json => @trips\n end",
"def index\n @trips = Trip.desc.all\n @latest_trip = @trips.first\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trips }\n end\n end",
"def trips\n @trip_requests = current_user.trip_requests.trips.paginate(page:params[:page], per_page:20)\n json_response(@trip_requests)\n end",
"def index\n trips = Trip.all\n render json: trips\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n \t@trips = Trip.all\n end",
"def show\n @trips_connect = TripsConnect.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trips_connect }\n end\n end",
"def trip(trip_id)\n connection.get(\"/trips/#{trip_id}\").body\n end",
"def trips_by_trip_id(trip_id)\n get \"/gtfs/trips/tripId/#{trip_id}\"\n end",
"def index\n unless params[:user_id].nil?\n @user = User.find(params[:user_id])\n @trips = @user.trips\n else\n @trips = Trip.all\n end\n end",
"def my\n @trips = Trip.completed.\n includes(:driver, {trip_request: :rider}).\n joins(trip_request: :rider).\n where(users: {id: params[:rider_id]})\n\n options = {}\n # JSON API: https://jsonapi.org/format/#fetching-sparse-fieldsets\n # fast_jsonapi: https://github.com/Netflix/fast_jsonapi#sparse-fieldsets\n #\n # convert input params to options arguments\n if params[:fields]\n trip_params = params[:fields].permit(:trips).to_h.\n inject({}) { |h, (k,v)| h[k.singularize.to_sym] = v.split(\",\").map(&:to_sym); h }\n options.merge!(fields: trip_params)\n end\n\n render json: TripSerializer.new(@trips, options).serializable_hash\n end",
"def index\n @trip = Trip.find(params[:trip_id])\n end",
"def show\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trip }\n end\n end",
"def show\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trip }\n end\n end",
"def index\n @profile = Profile.find_by_user_id(current_user.id)\n @trips = @profile.trips\n end",
"def index\n @trips = current_user.trips\n end",
"def index\n @trips = current_user.trips\n end",
"def index\n @trips = Trip.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @trips }\n end\n end",
"def get_user_trips\n\n\t\tputs \"Trips driving\"\n\t\tputs current_user.past_trips_driven[0]\n\t\tputs current_user.trips_requested\n\t\tif current_user \n\t\t\trender json: {\n\t\t\t\tstatus: 'success',\n\t\t\t\ttrips_requested: Trip.where( :_id.in => current_user.trips_requested ),\n\t\t\t\ttrips_listed: Trip.where( :_id.in => current_user.trips_driving ),\n\t\t\t\ttrips_accepted: Trip.where( :_id.in => current_user.trips_accepted ),\n\t\t\t\texpired_requests: Trip.where( :_id.in => current_user.past_trips_requested),\n\t\t\t\texpired_listings: Trip.where( :_id.in => current_user.past_trips_driven),\n\t\t\t\tcurrent_userstrips: current_user.trips_driving\n\t\t\t}, status: 200\n\t\telse\n\t\t\trender json: {\n\t\t\t\tstatus: 'error',\n\t\t\t\tmessage: 'User is not signed in!'\n\t\t\t}, status: 422\n\t\tend\n\tend",
"def index\n trips = Trip.all\n respond_with trips\n end",
"def show\n @trip_item = TripItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trip_item }\n end\n end",
"def index\n @trips = Trip.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @trips }\n end\n end",
"def index\n @trips = Trip.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @trips }\n end\n end",
"def show\n @trip = Trips.find_trip(params[ :id ] )\n end",
"def trips_by_route_id(route_id)\n get \"/gtfs/trips/routeid/#{route_id}\"\n end",
"def get_trip_detail(id)\n server_response = handle_timeouts do\n get \"/1/trips/#{id}.json?locale=en\"\n end\n server_response['response']\n end",
"def list\n @trips = Trips.my_trips(cookies[ :user_id ] )\n end",
"def index\n\t@trips = Trip.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @trips }\n end\n end",
"def index\n # Get trips for the trip type\n trips = Trip.all.where(trip_type: params[:trip_type] || 2)\n # (optional) if city_id params was provided\n trips = trips.joins(:city).where(\"cities.id = ?\", params[:city_id]) if params[:city_id]\n # (optional) if country_id params was provided\n trips = trips.joins(:city => :country).where(\"countries.id = ?\", params[:country_id]) if params[:country_id]\n # (optional) if sort params was provided\n if params[:sort]\n \n case params[:sort].downcase\n when 'popularity' # by number of bookings\n trips = trips.most_popular\n when 'rating' # by rating of reviews\n trips = trips.best_rated\n end\n\n end\n\n # Paginate\n trips = trips.page(params[:page] || 1).per(params[:per_page] || 20)\n\n render json: {\n trips: ActiveModelSerializers::SerializableResource.new(trips, each_serializer: TripSerializer),\n total: trips.total_count,\n page: trips.current_page,\n per_page: trips.limit_value\n }\n end",
"def index\n if params[:passenger_id]\n @passenger = Passenger.find_by(id: params[:passenger_id])\n @trips = @passenger.trips\n else\n render :notfound, status: :not_found\n end\n end",
"def user_trips(user_id=self.username)\n connection.get(\"/users/#{user_id}/trips\").body.trips\n end",
"def show\n @profile = Profile.find_by_user_id(current_user.id)\n @trip = @profile.trips.find(params[:id])\n end",
"def show\n @request = Request.find(params[:id])\n #@sorted_trips = @request.get_sorted_trips\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @request }\n end\n end",
"def index\n search = TripSearch.new(search_params)\n trips = Trip.apply_scopes(\n search.start_location,\n search.driver_name,\n search.rider_name\n )\n\n render json: trips\n end",
"def show\n @trip = Trip.find(params[:id])\nend",
"def show\n @trip = Trip.find(params[:trip_id])\n end",
"def find_trip\n @trip = Trip.find(params[:id])\n end",
"def get_trip\n\t\t@trip = Trip.find_by(_id: trip_params[:trip_id])\n\t\tif @trip\n\t\t\t@user_requests = User.where(:_id.in => @trip.user_requests).map { |user|\n\t\t\t\tuser = {\n\t\t\t\t\t_id: user.id,\n\t\t\t\t\tfirst_name: user.first_name,\n\t\t\t\t\tlast_name: user.last_name\n\t\t\t\t}\n\t\t\t}\n\t\t\t@accepted_users = User.where(:_id.in => @trip.accepted_users).map { |user| \n\t\t\t\tuser = {\n\t\t\t\t\t_id: user.id,\n\t\t\t\t\tfirst_name: user.first_name,\n\t\t\t\t\tlast_name: user.last_name\n\t\t\t\t}\n\t\t\t}\n\t\t\t@trip._id = @trip._id.to_s\n\t\t\t@driver = User.find_by(_id: @trip.driver)\n\t\t\trender json: {\n\t\t\t\tstatus: 'success',\n\t\t\t\ttrip: @trip,\n\t\t\t\tdriver: {\n\t\t\t\t\tfirst_name: @driver.first_name,\n\t\t\t\t\tlast_name: @driver.last_name,\n\t\t\t\t\trating: @driver.driver_rating\n\t\t\t\t},\n\t\t\t\tuser_requests: @user_requests,\n\t\t\t\taccepted_users: @accepted_users\n\t\t\t}, status: 200\n\t\telse\n\t\t\trender json: {\n\t\t\t\tstatus: 'error',\n\t\t\t\tmessage: 'That trip could not be found!'\n\t\t\t}, status: 422\n\t\tend\n\tend",
"def index\n @trips = Trip.where(user: current_user)\n @trip = Trip.new\n end",
"def index\n @tips_tricks = @tips_tricks.published.recent.page(params[:page]).per(10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tips_tricks }\n end\n end",
"def trips\n trips = RideShare::Trip.trips_by_rider(@id)\n if trips != nil\n return trips\n else\n return []\n end\n end",
"def show\n # raise\n authorize @trip\n @user = current_user\n @routes = @trip.routes\n add_markers_and_site_geoloc if [email protected]? # add the markers and the @site_loc. Reject routes without localisation.\n\n @trips = []\n @trips << @user.trips\n @trips << @user.joint_user_trips.map { |jut| jut.trip }\n @trips = @trips.flatten\n end",
"def trips\n RideShare::Trip.find_all_for_rider(@id)\n end",
"def trips\n Trip.where(:route_id => self.route_id)\n end",
"def trips\n Trip.where(:route_id => self.route_id)\n end",
"def get_travellers\n if current_user != nil\n @trip = Trip.find(params[:id])\n render json: @trip.trip_json\n else\n render json: session[:trip].trip_json\n end\n\n end",
"def show\n @trip_driver = TripDriver.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trip_driver }\n end\n end",
"def flights\n trip = Trip.where('id = ?', params[:id]).take\n if !trip.nil\n respond_with( trip.flights )\n else\n render :json => { error: 404 }, :status => 404\n end\n end",
"def show\n @trip = Trip.find_by_marketable_url(params[:marketable_url])\n end",
"def index\n redirect_to find_trips_path\n end",
"def personal_trips\n @personal_trips = trips.where(driver_id: 0)\n end",
"def index\n @class_trips = ClassTrip.all\n end",
"def show\n\n set_no_cache\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trip }\n end\n\n end",
"def all_trips\n return Rideshare::Trip.find_trip_by_rider(@id)\n end",
"def index\n @trips = Trip.all\n @now = Date.today\n end",
"def new\n @trips_connect = TripsConnect.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trips_connect }\n end\n end",
"def show\n travels = Travel.find(params[:id])\n render json: travels, status: :ok\n end",
"def new\n @trip = Trip.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trip }\n end\n end",
"def new\n @trip = Trip.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trip }\n end\n end",
"def show\n @troop = Troop.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @troop }\n end\n end",
"def trips \n Trips.all.each do |trip|\n trip \n end \n\n #return to airbnb\n \n\n\n \nend",
"def show\n @tripdate = Tripdate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tripdate }\n end\n end",
"def show\n if request.referer =~ /\\/embed\\/parks/ && request.format == 'html'\n redirect_to \"/embed\" + request.path\n return\n end\n\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json do\n @trip['start_lat'] = @trip.starting_trailhead.latitude\n @trip['start_lng'] = @trip.starting_trailhead.longitude\n @trip['end_lat'] = @trip.ending_trailhead.latitude\n @trip['end_lng'] = @trip.ending_trailhead.longitude\n render json: @trip\n end\n end\n end",
"def index\n # @locations = Location.all.where(:trip_id => @trip)\n @locations = Location.all.where(trip_id: @trip)\n @trip = Trip.find(params[:trip_id])\n end",
"def index\n tips = Tip.all\n json_response(tips)\n end",
"def show\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @trip }\n end\n end",
"def show\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @trip }\n end\n end",
"def trips\n @analysis[:trips]\n end",
"def index\n @trip_routes = TripRoute.all\n end",
"def show\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @trip.to_json, :callback => params[:callback] }\n end\n end",
"def find_trip\n @find_trip = Trip.where(\"id = #{params[:trip_id]}\")\n end",
"def get_trip_listing \n\t\t@trip = Trip.find_by(_id: trip_params[:trip_id])\n\t\tif current_user.trips_driving.include?(trip_params[:trip_id]) || current_user.past_trips_driven.include?(trip_params[:trip_id])\n\t\t\t@user_requests = User.where(:_id.in => @trip.user_requests).map { |user|\n\t\t\t\tuser = {\n\t\t\t\t\t_id: user.id,\n\t\t\t\t\tfirst_name: user.first_name,\n\t\t\t\t\tlast_name: user.last_name,\n\t\t\t\t\tfacebook_link: user.facebook_link,\n\t\t\t\t\temail: user.email,\n\t\t\t\t\tphone_number: user.phone_number\n\t\t\t\t}\n\t\t\t}\n\t\t\t@accepted_users = User.where(:_id.in => @trip.accepted_users).map { |user| \n\t\t\t\tuser = {\n\t\t\t\t\t_id: user.id,\n\t\t\t\t\tfirst_name: user.first_name,\n\t\t\t\t\tlast_name: user.last_name,\n\t\t\t\t\tfacebook_link: user.facebook_link,\n\t\t\t\t\temail: user.email,\n\t\t\t\t\tphone_number: user.phone_number\n\t\t\t\t}\n\t\t\t}\n\t\t\trender json: {\n\t\t\t\tstatus: 'success',\n\t\t\t\ttrip: {\n\t\t\t\t\ttrip_details: @trip,\n\t\t\t\t\tuser_requests: @user_requests,\n\t\t\t\t\taccepted_users: @accepted_users\n\t\t\t\t}\n\t\t\t}\n\t\telse\n\t\t\trender json: {\n\t\t\t\tstatus: 'error',\n\t\t\t\tmessage: 'This user is not the driver for this trip'\n\t\t\t}\n\t\tend\n\tend",
"def new\n @trip_item = TripItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trip_item }\n end\n end",
"def show\n @trip = Trip.find(params[:id])\n @places = @trip.places\n end",
"def index\n @trips = current_user.trips_validated\n @pending_trips = current_user.pending_trips\n\n @visitor = current_user\n respond_to do |format|\n format.html{}\n format.js{}\n end\n end",
"def show\n @tipp = Tipp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipp }\n end\n end",
"def index\n @trip_types = TripType.all\n end",
"def index\n @future_trips = FutureTrip.all\n end",
"def index\n # redirect /oj to here\n load_trips\n\n respond_to do |format|\n format.html { render :index }\n end\n end",
"def create\n trip = current_user.trips.new(trip_params)\n if trip.save\n render json: {\n status: :created,\n trip: trip\n }\n else\n render json: {\n status: 500,\n errors: trip.errors.full_messages\n }\n end\n end",
"def index\n @tunes = Tune.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tunes }\n end\n end",
"def trips\n #will find upcoming trips/reservations for guests\n Reservation.where(guest_id: self.id)\n end",
"def show\n\n trip = Trip.find(params[:id])\n\n departureOrder = LineStation.find_by_station_id(trip.departureStation_id).order\n arrivalOrder = LineStation.find_by_station_id(trip.arrivalStation_id).order\n\n lineStations = LineStation.where(:order => departureOrder..arrivalOrder)\n lineStations = lineStations.where(:line_id => trip.line_id)\n if departureOrder < arrivalOrder\n lineStations.order('order ASC')\n else\n lineStations.order('order DESC')\n end\n\n times = Array.new\n currentTime = trip.beginTime\n lineStations.each do |ls|\n \n station = Station.find(ls.station_id)\n train = Train.find(trip.train_id)\n\n times << { :station => station, :time => currentTime.strftime('%H:%M') }\n\n timeElapsed = ls.distance.to_f / train.velocity\n currentTime = currentTime + timeElapsed.hours\n end\n\n render :json => { :trip => trip, :times => times }\n\n end",
"def show\n redirect_to trips_path\n end",
"def set_trip\n @trip = current_user.trips.find(params[:id])\n end",
"def index\n @snips = Snip.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @snips }\n end\n end",
"def group\n @trips = Trip.find(current_user).trip_users\n\n render json: { result: \"success\", data: @trips }\n end",
"def show\n @tramite = Tramite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tramite }\n end\n end"
] |
[
"0.7947233",
"0.77829236",
"0.77829236",
"0.7737289",
"0.77232826",
"0.76186705",
"0.7444222",
"0.7314744",
"0.7267888",
"0.7267888",
"0.7267888",
"0.7267888",
"0.7267888",
"0.7267888",
"0.7267888",
"0.71649575",
"0.7133354",
"0.7085653",
"0.7082653",
"0.70761305",
"0.70506203",
"0.69582045",
"0.692123",
"0.6899536",
"0.6899536",
"0.68823725",
"0.6881075",
"0.6881075",
"0.68475515",
"0.68352026",
"0.6831359",
"0.68242776",
"0.6785789",
"0.6785789",
"0.67238986",
"0.6719877",
"0.67096215",
"0.66885084",
"0.66809267",
"0.66645944",
"0.66349876",
"0.6628965",
"0.6591807",
"0.6540761",
"0.6536705",
"0.65130556",
"0.6487859",
"0.643871",
"0.6426537",
"0.63288635",
"0.6273655",
"0.6260402",
"0.6247579",
"0.6211342",
"0.6200417",
"0.6200417",
"0.6187784",
"0.61537236",
"0.61430997",
"0.6142673",
"0.6139086",
"0.6094286",
"0.60870636",
"0.6082713",
"0.60826325",
"0.6079874",
"0.60705733",
"0.6063794",
"0.6047022",
"0.6047022",
"0.6028733",
"0.6026124",
"0.6011257",
"0.60082793",
"0.600824",
"0.600657",
"0.5996821",
"0.5996821",
"0.59915435",
"0.59779006",
"0.5967894",
"0.59513265",
"0.59478706",
"0.5904435",
"0.59043777",
"0.58744025",
"0.58671033",
"0.58594245",
"0.5843405",
"0.5836171",
"0.5828576",
"0.58256924",
"0.5824951",
"0.5798241",
"0.57931405",
"0.57930976",
"0.5788677",
"0.57719696",
"0.5761136"
] |
0.66436434
|
41
|
POST /trips POST /trips.json
|
def create
@trip = Trip.new(user_id: current_user.id)
@trip.start_point = Station.find_by(uid: params[:station_id])
#Defined current user and updated credits. This change may cause issues.
@current_user = current_user
@current_user.credits = (@current_user.credits - 1)
if @trip.save
@current_user.save
#This is where the change ends
render json: @trip.attributes.merge(station: @trip.start_point.attributes), status: :created, location: @trip
else
render json: @trip.errors, status: :unprocessable_entity
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def trips\n get '/gtfs/trips'\n end",
"def create\n trip = current_user.trips.new(trip_params)\n if trip.save\n render json: {\n status: :created,\n trip: trip\n }\n else\n render json: {\n status: 500,\n errors: trip.errors.full_messages\n }\n end\n end",
"def trips\n flight = Flight.where(\"id = ?\", params[:id]).take\n if flight.nil?\n render :json => {errors: \"404\"}, :status => 404\n else\n respond_with( flight.trips )\n end\n end",
"def trips\n @trip_requests = current_user.trip_requests.trips.paginate(page:params[:page], per_page:20)\n json_response(@trip_requests)\n end",
"def index\n @trips = Trip.all\n\n render json: @trips\n end",
"def index\n @trips = Trip.all\n\n render json: @trips\n end",
"def create\n @trip = current_user.trips.build(params[:trip])\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to @trip, notice: 'Trip was successfully created.' }\n format.json { render json: @trip, status: :created, location: @trip }\n else\n format.html { render action: \"new\" }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @trips = Trip.all\n render :json => @trips\n end",
"def create\n trip = Trip.create(trip_params)\n\n respond_with trip\n end",
"def create\n @trip = current_user.trips.build(trip_params)\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to @trip, notice: 'Trip was successfully created.' }\n format.json { render action: 'show', status: :created, location: @trip }\n else\n format.html { render action: 'new' }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def my\n @trips = Trip.completed.\n includes(:driver, {trip_request: :rider}).\n joins(trip_request: :rider).\n where(users: {id: params[:rider_id]})\n\n options = {}\n # JSON API: https://jsonapi.org/format/#fetching-sparse-fieldsets\n # fast_jsonapi: https://github.com/Netflix/fast_jsonapi#sparse-fieldsets\n #\n # convert input params to options arguments\n if params[:fields]\n trip_params = params[:fields].permit(:trips).to_h.\n inject({}) { |h, (k,v)| h[k.singularize.to_sym] = v.split(\",\").map(&:to_sym); h }\n options.merge!(fields: trip_params)\n end\n\n render json: TripSerializer.new(@trips, options).serializable_hash\n end",
"def create\n err_objs=[]\n error=false\n user_id=MobileDevice.where(:access_token=>params[:access_token]).first.user_id\n if params.has_key?('trips')\n params[:trips].each do |trip|\n trip_id=trip[1][:trip_id] #save ref to trip id in case @trip.save fails (used in return response)\n if !create_trip(trip[1],user_id)\n error=true\n err_objs.push(trip_id)\n end\n end\n else\n error=true\n end\n respond_to do |format|\n if !error\n format.json { render json: {:msg => \"success\"}, status: :created }\n else\n format.json { render json: {:msg => \"Could not save the following trips. Please check that all required fields are filled out (license_plate, cargo, start_location, end_location, start_timestamp, end_timestamp)\", :err_ids => err_objs}, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trip = Trip.new(trip_params)\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to trips_path, notice: 'Cesta byla vytvořena.' }\n format.json { render :show, status: :created, location: @trip }\n else\n format.html { render :new }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trip = Trip.new(params[:trip])\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to @trip, :notice => 'Trip was successfully created.' }\n format.json { render :json => @trip, :status => :created, :location => @trip }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @trip.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @trip = Trip.new(trip_params)\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to @trip, notice: 'Trip was successfully created.' }\n format.json { render :show, status: :created, location: @trip }\n else\n format.html { render :new }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trips_connect = TripsConnect.new(params[:trips_connect])\n\n respond_to do |format|\n if @trips_connect.save\n format.html { redirect_to @trips_connect, notice: 'Trips connect was successfully created.' }\n format.json { render json: @trips_connect, status: :created, location: @trips_connect }\n else\n format.html { render action: \"new\" }\n format.json { render json: @trips_connect.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n # inflate a trip proxy object from the form params\n @trip_proxy = create_trip_proxy_from_form_params\n \n if @trip_proxy.valid?\n @trip = create_trip(@trip_proxy)\n end\n\n # Create makers for the map control\n @markers = create_markers(@trip_proxy)\n\n respond_to do |format|\n if @trip\n if @trip.save\n @trip.reload\n @planned_trip = @trip.planned_trips.first\n @planned_trip.create_itineraries\n format.html { redirect_to user_planned_trip_path(@traveler, @planned_trip) }\n format.json { render json: @planned_trip, status: :created, location: @planned_trip }\n else\n format.html { render action: \"new\" }\n format.json { render json: @trip_proxy.errors, status: :unprocessable_entity }\n end\n else\n format.html { render action: \"new\", flash[:alert] => t(:correct_errors_to_create_a_trip) }\n end\n end\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def create\n @trip = current_user.trips.new(params[:trip].except(:places))\n params[:trip][:places] ||= []\n @trip.add_trip_places(params[:trip][:places])\n if @trip.save\n flash[:notice] = \"Trip succesfully created\"\n redirect_to @trip\n else\n flash.now[:error] = @trip.errors.full_messages\n @places = params[:trip][:places]\n render \"new\"\n end\n end",
"def create\n # We have to convert the two posted values for each time into a single string\n # If we don't Trip.new can't populate the Trips values based on the post hash\n @trip = Trip.new(parse_post params[:trip])\n\n respond_to do |format|\n if @trip.save\n flash[:notice] = 'Trip was successfully created.'\n format.html { redirect_to(@trip) }\n format.xml { render :xml => @trip, :status => :created, :location => @trip }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trip.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n # We have to convert the two posted values for each time into a single string\n # If we don't Trip.new can't populate the Trips values based on the post hash\n @trip = Trip.new(parse_post params[:trip])\n\n respond_to do |format|\n if @trip.save\n flash[:notice] = 'Trip was successfully created.'\n format.html { redirect_to(@trip) }\n format.xml { render :xml => @trip, :status => :created, :location => @trip }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trip.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @trip_item = TripItem.new(params[:trip_item])\n\n respond_to do |format|\n if @trip_item.save\n format.html { redirect_to @trip_item, notice: 'Trip item was successfully created.' }\n format.json { render json: @trip_item, status: :created, location: @trip_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @trip_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trip = Trip.new(trip_params.merge(user_id: current_user.id))\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to @trip, notice: 'Trip was successfully created.' }\n format.json { render :show, status: :created, location: @trip }\n else\n format.html { render :new }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trip = Trip.new(trip_params)\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to current_user, notice: 'Trip was successfully created.' }\n format.json { render :show, status: :created, location: @trip }\n else\n format.html { redirect_to current_user, notice: \"Trip can't be created\" }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def index\n @trips = Trip.all\n end",
"def create\n @user = current_user()\n @trip = @user.own_trips.new(params[:trip])\n\n respond_to do |format|\n if @trip.save\n flash[:notice] = 'Trip was successfully created.'\n format.html { redirect_to(@trip) }\n format.xml { render :xml => @trip, :status => :created, :location => @trip }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trip.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def get_user_trips\n\n\t\tputs \"Trips driving\"\n\t\tputs current_user.past_trips_driven[0]\n\t\tputs current_user.trips_requested\n\t\tif current_user \n\t\t\trender json: {\n\t\t\t\tstatus: 'success',\n\t\t\t\ttrips_requested: Trip.where( :_id.in => current_user.trips_requested ),\n\t\t\t\ttrips_listed: Trip.where( :_id.in => current_user.trips_driving ),\n\t\t\t\ttrips_accepted: Trip.where( :_id.in => current_user.trips_accepted ),\n\t\t\t\texpired_requests: Trip.where( :_id.in => current_user.past_trips_requested),\n\t\t\t\texpired_listings: Trip.where( :_id.in => current_user.past_trips_driven),\n\t\t\t\tcurrent_userstrips: current_user.trips_driving\n\t\t\t}, status: 200\n\t\telse\n\t\t\trender json: {\n\t\t\t\tstatus: 'error',\n\t\t\t\tmessage: 'User is not signed in!'\n\t\t\t}, status: 422\n\t\tend\n\tend",
"def user_trips(user_id=self.username)\n connection.get(\"/users/#{user_id}/trips\").body.trips\n end",
"def new\n @trip = current_user.trips.build\n 5.times {@trip.places.build}\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trip }\n end\n end",
"def create\r\n # @trip = Trip.new(trip_params)\r\n @trip = current_user.trips.build(trip_params)\r\n if @trip.save\r\n redirect_to trips_path, notice: 'Trip was successfully created.'\r\n else\r\n redirect_to new_trip_path, notice: 'Cannot leave information blank.'\r\n end\r\n end",
"def create\n trip = Trip.new(trip_params)\n trip.rand_code = generate_code(6)\n\n # checks to see if photo was sent, and assigns default if none sent\n if params[:photo_base]\n trip.photo = params[:photo_base]\n else\n trip.photo = default_photo\n end\n\n trip.save!\n\n # creates a UserTrip object as a reference between Users and Trips\n tripid = Trip.last.id\n userid = params[:user_id]\n UserTrip.create(user_id: userid, trip_id: tripid)\n render json: trip\n end",
"def index\n unless params[:user_id].nil?\n @user = User.find(params[:user_id])\n @trips = @user.trips\n else\n @trips = Trip.all\n end\n end",
"def create_trip\n # Only attempt to create trip if all the necessary pieces are there\n return false unless @itinerary && @trip && @service && @user\n \n label = request_label(:book, trip_id)\n \n @http_request_bundler.add(\n label, \n @url + \"/create_trip\", \n :post,\n head: headers,\n body: body_for_booking(@booking_options).to_json\n ).response!(label)\n end",
"def create\n @trip = Trip.new(params[:trip])\n @trip.user = current_user\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to @trip, notice: 'Trip was successfully created.' }\n format.json { render json: @trip, status: :created, location: @trip }\n else\n format.html { render action: \"new\" }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n \t@trips = Trip.all\n end",
"def index\n trips = Trip.all\n render json: trips\n end",
"def trip_params\n params.require(:trip).permit(:starts_on, :ends_on, :name, :location, {:item_ids => []})\n end",
"def create\n @trip = Trip.new(params[:trip])\n @trip.user = current_user\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to @trip, notice: 'Trip was successfully created.' }\n format.json { render json: @trip, status: :created, location: @trip }\n else\n format.html { render action: \"new\" }\n end\n end\n end",
"def trip_params\n params.require(:trip).permit(:sightsnum, :location, :location_radius, :tag, :user_id)\n end",
"def index\n @trips = current_user.trips\n end",
"def index\n @trips = current_user.trips\n end",
"def create\n @origin = Origin.new(\n :latitude => trip_params[:origin][:latitude],\n :longitude => trip_params[:origin][:longitude]\n )\n @origin.save\n @destination = Destination.new(:address => trip_params[:destination][:address].concat(\" New York City\"))\n @destination.save\n @trip = Trip.new(:origin_id => @origin.id, :destination_id => @destination.id)\n @trip.save \n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to @trip }\n format.json { render action: 'show', status: :created, location: @trip }\n else\n format.html { render action: 'new' }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def trip_params\n params.require(:trip).permit(:student_id, :ymen_trips, :num_ymen_camping_trips, :camping_locations, :num_vocational_trips, :businesses_visited, :num_cultural_trips, :cultural_places_visited, :ymen_trips_fun_listed)\n end",
"def trip_params\n params.require(:trip).permit(:name, :description, :user_id, :start_date, :airport_id, :base64, attendee_ids:[], leg_ids:[])\n end",
"def list\n @trips = Trips.my_trips(cookies[ :user_id ] )\n end",
"def create\n @trip = Trip.new(trip_name: trip_params[:trip_name], user_id: current_user.id)\n respond_to do |format|\n if @trip.save\n UserTrip.create(user_id: current_user.id, trip_id: @trip.id)\n UserTrip.add_users_to_trip(params[:trippers], @trip.id, current_user)\n Exchange.set_defaults(@trip.id)\n format.html { redirect_to @trip, notice: 'Trip was successfully created.' }\n format.json { render action: 'show', status: :created, location: @trip }\n else\n format.html { render action: 'new' }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trip = Trip.new({\"name\" => \"New Trip\",\n \"beginning\" => Time.now.strftime(\"%d/%m/%Y\"),\n \"duration\" => \"0\",\n \"user\" => current_user})\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to @trip, notice: 'Trip was successfully created.' }\n format.json { render :show, status: :created, location: @trip }\n else\n format.html { render home_path }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def trip_params\n params.require(:trip).permit(:idRio, :nomeRio)\n end",
"def create_trip(trip_proxy)\n\n trip = Trip.new()\n trip.creator = current_or_guest_user\n trip.user = @traveler\n trip.trip_purpose = TripPurpose.find(trip_proxy.trip_purpose_id)\n\n # get the start for this trip\n from_place = TripPlace.new()\n from_place.sequence = 0\n place = get_preselected_place(trip_proxy.from_place_selected_type, trip_proxy.from_place_selected.to_i, true)\n if place[:poi_id]\n from_place.poi = Poi.find(place[:poi_id])\n elsif place[:place_id]\n from_place.place = @traveler.places.find(place[:place_id])\n else\n from_place.raw_address = place[:address]\n from_place.lat = place[:lat]\n from_place.lon = place[:lon] \n end\n\n # get the end for this trip\n to_place = TripPlace.new()\n to_place.sequence = 1\n place = get_preselected_place(trip_proxy.to_place_selected_type, trip_proxy.to_place_selected.to_i, false)\n if place[:poi_id]\n to_place.poi = Poi.find(place[:poi_id])\n elsif place[:place_id]\n to_place.place = @traveler.places.find(place[:place_id])\n else\n to_place.raw_address = place[:address]\n to_place.lat = place[:lat]\n to_place.lon = place[:lon] \n end\n\n # add the places to the trip\n trip.trip_places << from_place\n trip.trip_places << to_place\n\n planned_trip = PlannedTrip.new\n planned_trip.trip = trip\n planned_trip.creator = trip.creator\n planned_trip.is_depart = trip_proxy.arrive_depart == 'departing at' ? true : false\n planned_trip.trip_datetime = trip_proxy.trip_datetime\n planned_trip.trip_status = TripStatus.find_by_name(TripStatus::STATUS_NEW) \n \n trip.planned_trips << planned_trip\n\n return trip\n end",
"def trip_params\n params.require(:trip).permit(:trip_name, :tripper)\n end",
"def create\n @trip_todo = TripTodo.new(trip_todo_params)\n\n respond_to do |format|\n if @trip_todo.save\n format.html { redirect_to @trip_todo, notice: 'Trip todo was successfully created.' }\n format.json { render :show, status: :created, location: @trip_todo }\n else\n format.html { render :new }\n format.json { render json: @trip_todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def trip_params\n params.require(:trip).permit(:location, :latitude, :longitude, :start_date, :end_date, :days, :notes, :name, clips_attributes: [:uri, :day_list, :date_list, :type_list, :day, :date, :external_reference])\n end",
"def new\n @trips_connect = TripsConnect.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trips_connect }\n end\n end",
"def create\n @trip = Trip.new(trip_params)\n authorize @trip\n @trip.submitter = current_account.accountable\n\n\n @trip.estimated_expenses.each do |exp|\n exp.requests.each do |req|\n req.amount_from_total = req.percentrequested * exp.total\n req.destination = @trip.destination\n req.expense_type = 'estimated'\n end\n end\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to home_index_path, notice: 'Trip was successfully created.' }\n format.json { render :show, status: :created, location: @trip }\n else\n format.html { render :new }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trip = Trip.new(params[:trip])\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to @trip, notice: 'Trip was successfully created.' }\n format.json { render :json => @trip.to_json, :callback => params[:callback], status: :created, location: @trip }\n else\n format.html { render action: \"new\" }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n search = TripSearch.new(search_params)\n trips = Trip.apply_scopes(\n search.start_location,\n search.driver_name,\n search.rider_name\n )\n\n render json: trips\n end",
"def create\n @trip = Trip.new(trip_params)\n @trip.user_id = current_user.id\n\n authorize @trip, :create?\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to @trip, notice: 'Trip was successfully created.' }\n format.json { render action: 'show', status: :created, location: @trip }\n else\n format.html { render action: 'new' }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trip = Trip.new(params[:trip])\n @trip.user = @current_user\n r = Request.find_by_url(@trip.url)\n if r; r.destroy; end\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to(@trip, :notice => 'Trip was successfully created.') }\n format.xml { render :xml => @trip, :status => :created, :location => @trip }\n format.json { render :json => @trip }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trip.errors, :status => :unprocessable_entity }\n format.json { render :json => @trip.errors.full_messages, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @trip = Trip.new(trip_params)\n\n respond_to do |format|\n if @trip.save\n # Get the permission's type which represent an usual user and an admin one.\n permUser = Permission_type.find_by(permission: \"user\").id\n permAdmin = Permission_type.find_by(permission: \"admin\").id\n\n # Create current user's admin permission on the new created trip.\n adminPerm = Permission.new(:user_id => current_user.id, :trip_id => @trip.id, :permission_type_id => permAdmin, :accepted => 1)\n adminPerm.save\n # Create a \"user\" permission for each selected users.\n if params[\"users\"]\n params[\"users\"].each do |user|\n userId = user[2, user.length]\n\n # We don't add the current user, which is an admin.\n if userId != String(current_user.id)\n currentPermission = user[0] == \"1\" ? permAdmin : permUser\n\n perm = Permission.new(:user_id => userId, :trip_id => @trip.id, :permission_type_id => currentPermission, :accepted => 0)\n perm.save\n end\n end\n end\n\n # Create each waypoint of the trip.\n if params['waypoints']\n i = 0\n params['waypoints'].each do |waypoint|\n i += 1\n w = Stop.new(:title => @trip.title + \" - #{i}\", :loc_lat => waypoint[1][0], :loc_lon => waypoint[1][1], :trip_id => @trip.id, :etape_nb => i)\n w.save\n end\n\n # If the endpoint is also the startpoint, add an extra stop.\n if params['arrivalEqualsStart']\n w = Stop.new(:title => @trip.title + \" - #{i + 1}\", :loc_lat => params[\"waypoints\"][\"0\"][0], :loc_lon => params[\"waypoints\"][\"0\"][1], :trip_id => @trip.id, :etape_nb => (i + 1))\n w.save\n end\n end\n\n format.html { redirect_to @trip, notice: 'Trip was successfully created.' }\n format.json { render :show, status: :created, location: @trip }\n else\n format.html { render :new }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @profile = Profile.find_by_user_id(current_user.id)\n @trip = @profile.trips.build(params.require(:trip).permit(:date, :time, :pickup_location, :destination, :price, :seats_available, :driver_id, :profile_id))\n if @trip.save\n redirect_to profile_trip_url(@profile, @trip)\n else\n render :action => \"new\"\n end\n end",
"def trip_params\n #Ajouter identifiant de l’utilisateur dans le post\n params.require(:trip).permit(:city, :user_id)\n\tend",
"def create\n # binding.pry\n @trip = Trip.new(trip_params)\n respond_to do |format|\n if @trip.save\n @trip_user_list = TripUserList.new(trip_id: @trip.id,user_id: session[:user_id])\n # binding.pry\n @trip_user_list.save\n format.html { redirect_to \"/trips/#{@trip.id}/locations\", notice: 'Trip was successfully created.' }\n else\n format.html { render :index }\n end\n end\n end",
"def create\n @trip = Trip.new(trip_params)\n @trip.nomad_id = current_nomad.id\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to @trip, notice: 'Trip was successfully created.' }\n format.json { render :show, status: :created, location: @trip }\n else\n format.html { render :new }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n trips = Trip.all\n respond_with trips\n end",
"def trip_params\n params.require(:trip).permit(:user_id, :trip_name, :walked_at, :planned_at, :distance, :completion)\n end",
"def create\n @trip = Trip.new(user_id: params[:user_id], trip_name: params[:trip_name], distance: params[:distance], walked_at: Time.now)\n @origin = Place.new(user_id: params[:user_id], place_name: params[:origin_name], latitude: params[:origin_lat], longitude: params[:origin_long])\n @destination = Place.new(user_id: params[:user_id], place_name: params[:dest_name], latitude: params[:dest_lat], longitude: params[:dest_long])\n if @trip.save && @origin.save && @destination.save\n @origin_point = TripPoint.new(trip_id: @trip.id, place_id: @origin.id, place_type: \"Origin\")\n @destination_point = TripPoint.new(trip_id: @trip.id, place_id: @destination.id, place_type: \"Destination\")\n @origin_point.save\n @destination_point.save\n else\n render :json => {:success => false, :errors => [\"Trip creation failed.\"]}\n end\n end",
"def trip_params\n params.require(:trip).permit(:code, :name, :price, :temperature, :depart_at, :return_at, :url)\n end",
"def create\n @trip_waypoint = TripWaypoint.new\n @trip_waypoint.place_id = params[:place_id]\n @trip_waypoint.trip_id = params[:trip_id]\n @trip_waypoint.save\n\n respond_to do |format|\n if @trip_waypoint.save\n format.html { redirect_to edit_partner_trip_path(params[:trip_id]), notice: \"Le lieu a été ajouté à l'itinéraire\" }\n # format.json { render :show, status: :created, location: @trip_waypoint }\n else\n format.html { render :new }\n # format.json { render json: @trip_waypoint.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trip = Trip.new(trip_params)\n @trip.session_id = session.id\n @trip.user_id = current_user.id\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to @trip.parent || @trip, notice: 'Trip was successfully created.', change: 'list' }\n format.json { render action: 'show', status: :created, location: @trip, day: 1 }\n else\n format.html { render action: 'new' }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ministry = Ministry.find(params[:ministry])\n @trip = @ministry.trips.build(params[:trip])\n\n respond_to do |format|\n if @trip.save\n #flash[:notice] = 'Trip was successfully created.'\n format.html { redirect_to(@trip) }\n format.xml { render :xml => @trip, :status => :created,\n :location => @trip }\n else\n @data_files = DataFile.find(:all, :order => :name)\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trip.errors,\n :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @trips = Trip.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @trips }\n end\n end",
"def index\n @trips = Trip.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @trips }\n end\n end",
"def request_trip\n\t\t@trip = Trip.find_by(_id: trip_params[:trip_id])\n\t\t# Check that the current user has not requested more than 3 trips, \n\t\t# That the user has not already requested this trip\n\t\t# and that the trip has available spaces and that the driver is not the requestor\n\t\tif current_user.trips_requested.size <= 5 && \n\t\t\t!(@trip.user_requests.include?(current_user._id)) && @trip.spaces > 0 && @trip.driver != current_user.id.to_s && !(current_user.trips_accepted.include?(@trip.id))\n\n\t\t\[email protected]_requests << current_user._id\n\t\t\tcurrent_user.trips_requested << @trip._id.to_s\n\t\t\tcurrent_user.save!\n\t\t\[email protected]!\n\t\t\trender json: {\n\t\t\t\tstatus: 'success',\n\t\t\t\ttrip: @trip\n\t\t\t}, status: 200\n\t\telse\n\t\t\t# Error handling\n\t\t\tif current_user.trips_requested.size > 5\n\t\t\t\trender json: {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\tmessage: 'This user has requested too many requests!'\n\t\t\t\t}, status: 422\n\t\t\telsif @trip.user_requests.include?(current_user._id)\n\t\t\t\trender json: {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\tmessage: 'You have already requested this trip!'\n\t\t\t\t}, status: 422\n\t\t\telsif @trip.spaces <= 0\n\t\t\t\trender json: {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\tmessage: 'There is no more space in this trip!'\n\t\t\t\t}, status: 422\n\t\t\telsif @trip.driver == current_user.id.to_s\n\t\t\t\trender json: {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\tmessage: 'You cannot request your own trip!'\n\t\t\t\t}, status: 422\n\t\t\telsif current_user.trips_accepted.include?(@trip.id)\n\t\t\t\trender json: {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\tmessage: \"You've already been accepted on this trip!\"\n\t\t\t\t}, status: 422\n\t\t\telse\n\t\t\t\trender json: {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\tmessage: 'Something went wrong...'\n\t\t\t\t}, status: 422\n\t\t\tend\n\t\tend\n\tend",
"def trips\n @agent.get(TRIPS_URL)\n\n # If session expires, re-login to citibikenyc.com. The site will redirect\n # back to TRIPS_URL upon sign in (friendly forwarding)\n login unless @agent.page.title == TRIPS_PAGE_TITLE\n\n rows = Nokogiri::HTML(@agent.page.body).xpath('//table/tbody/tr')\n\n # Reject bike trips that are either in progress or have durations <\n # MIN_TRIP_DURATION minutes.\n rows = rows.reject do |row|\n duration = row.at_xpath('td[6]/text()').to_s.match(/(\\d{1,2})m/)\n !duration || (duration.captures[0].to_i < MIN_TRIP_DURATION)\n end\n rows.map { |row| row_to_trip(row) }\n end",
"def index\n @trips = Trip.where(user: current_user)\n @trip = Trip.new\n end",
"def trip(trip_id)\n connection.get(\"/trips/#{trip_id}\").body\n end",
"def index\n redirect_to find_trips_path\n end",
"def new\n @trip = current_user.trips.new\n @places = []\n end",
"def create\n @trip = Trip.new(params[:trip])\n\[email protected] = params[:trip][:seat].to_i + 1\n\t\n\tif params[:trip][:on_demand] == 'Passager'\n\t\[email protected]_demand = true\n\t\[email protected] = nil\n\telse\n\t\[email protected]_demand = false\n\t\[email protected] = current_user\n\tend\n respond_to do |format|\n if @trip.save\n\t\t @trip.users << current_user\n\t\t @trip.save\n format.html { redirect_to(@trip, :notice => 'Le trajet à correctement été enregistré') }\n format.xml { render :xml => @trip, :status => :created, :location => @trip }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trip.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @trip = Trip.new(trip_params)\n @trip.user = @current_user\n @trip.users.append(current_user)\n respond_to do |format|\n if @trip.save\n\n\n format.html { redirect_to @trip, notice: 'Trip was successfully created.' }\n format.json { render json: {message: 'Utworzono tripa.', admin_id: @trip.user_id}, status: :ok }\n else\n format.html { render :new }\n format.json {\n render json:\n {errors: @trip.errors}, status: :unprocessable_entity \n }\n end\n end\n end",
"def trip_params\n params.require(:trip).permit(:date, :destination, :distance, :price)\n end",
"def set_trip\n @trip = current_user.trips.find(params[:id])\n end",
"def trip_params\n params.require(:trip).permit(:driver_id, :source_id, :destination_id, :departure_time, :seats, :users)\n end",
"def group\n @trips = Trip.find(current_user).trip_users\n\n render json: { result: \"success\", data: @trips }\n end",
"def trip_params\n params.require(:trip).permit(:name, :start_date, :end_date, :town_id)\n end",
"def trip_params\n params.require(:trip).permit(:start_date, :end_date, :name, :completed, :notes)\n end",
"def trip_params\n params.require(:trip).permit(:name, :accomodation_url, :price_per_night, :number_of_possible_attendees, :start_date, :end_date, :start_location, :end_location, :type_of_trip, :total_possible_cost, :total_confirmed_cost, :started, :ended)\n end",
"def trip_params\n params.require(:trip).permit(:name, :description, :nomad_id)\n end",
"def create\n @trip = Trip.new(trip_params)\n\n\n user_ids = params[:trip][:users_attributes]\n\n puts user_ids\n if not user_ids.nil?\n user_ids.keys().each do |k|\n user = User.find(user_ids[k][\"id\"])\n @trip.users << user if user_ids[k][\"_destroy\"] != \"1\" and not @trip.users.include? user\n end\n end\n\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to @trip, flash: {success: \"Trip was successfully created.\" } }\n format.json { render :show, status: :created, location: @trip }\n else\n format.html { render :new }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @profile = Profile.find_by_user_id(current_user.id)\n @trips = @profile.trips\n end",
"def index\n @trips = Trip.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @trips }\n end\n end",
"def create\n @tip = Tip.new(params[:tip])\n\n respond_to do |format|\n if @tip.save\n format.html { redirect_to @tip, notice: 'Tip was successfully created.' }\n format.json { render json: @tip, status: :created, location: @tip }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def trip_params\n params.require(:trip).permit(:name, :description, :starts_at, :ends_at, :image, :image_cache, :place, :promo_cache, :promo, :default_time_zone)\n end",
"def create\n @user = User.find(session[:user_id])\n coordinates = Geocoder.coordinates(future_trip_params[:name])\n @future_trip = @user.future_trips.new(future_trip_params)\n FutureTrip.set_coordinates(@future_trip)\n\n respond_to do |format|\n if @future_trip.save\n\n format.html { redirect_to @future_trip, notice: 'Future trip was successfully created.' }\n format.json { render json: @future_trip }\n else\n format.html { render :new }\n format.json { render json: @future_trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if @tips_trick.save\n format.html { redirect_to @tips_trick, notice: 'Tips trick was successfully created.' }\n format.json { render json: @tips_trick, status: :created, location: @tips_trick }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tips_trick.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.7208045",
"0.70307076",
"0.6864295",
"0.68321437",
"0.6772133",
"0.6772133",
"0.6692161",
"0.66867685",
"0.664916",
"0.6610407",
"0.6559959",
"0.6522311",
"0.6514665",
"0.6384032",
"0.63697636",
"0.6347624",
"0.6323213",
"0.6318997",
"0.6318997",
"0.6318997",
"0.6318997",
"0.6318997",
"0.6318997",
"0.6318997",
"0.631402",
"0.6307524",
"0.6307524",
"0.6274269",
"0.6248592",
"0.6233168",
"0.6204192",
"0.61985326",
"0.61771584",
"0.61559904",
"0.61294633",
"0.6127715",
"0.6125794",
"0.6125532",
"0.61236835",
"0.61135316",
"0.61051804",
"0.60924006",
"0.6058759",
"0.6035928",
"0.601279",
"0.6010867",
"0.6010867",
"0.5978297",
"0.5935399",
"0.5907363",
"0.58978295",
"0.5895387",
"0.5882101",
"0.5880836",
"0.5868172",
"0.58383274",
"0.5819444",
"0.5817939",
"0.5811817",
"0.5809244",
"0.57962656",
"0.5789441",
"0.5782767",
"0.5772618",
"0.57700276",
"0.5769992",
"0.57637006",
"0.5763023",
"0.5762004",
"0.5756554",
"0.57434785",
"0.5730778",
"0.5728416",
"0.5722644",
"0.57206666",
"0.57136875",
"0.5709786",
"0.5709786",
"0.5701241",
"0.5697696",
"0.56867456",
"0.56844664",
"0.56793755",
"0.5674496",
"0.56735945",
"0.56690204",
"0.5668632",
"0.5656821",
"0.5654662",
"0.5653947",
"0.5650127",
"0.5637452",
"0.56368303",
"0.5624479",
"0.56219417",
"0.56217176",
"0.5619604",
"0.56108797",
"0.56106263",
"0.5604926",
"0.55977154"
] |
0.0
|
-1
|
PATCH/PUT /trips/1 PATCH/PUT /trips/1.json
|
def update
@trip = Trip.find(params[:id])
if @trip.end_point = Station.find_by(uid: params[:station_id])
render json: @trip.attributes.merge(station: @trip.end_point.attributes), location: @trip
else
render json: @trip.errors, status: :unprocessable_entity
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n if @trip.update_attributes(params[:trip])\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n end\n end\n end",
"def update\n @trip = Trip.find(params[:id])\n\n if @trip.update(trip_params)\n render :json => {:success => true}\n else\n render :json => {:success => false, :errors => [\"Trip update failed.\"]}\n end\n end",
"def update\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n if @trip.update_attributes(params[:trip])\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n if @trip.update_attributes(params[:trip])\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n if @trip.update_attributes(params[:trip])\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trip.update(trip_params)\n last_clip(@trip, trip_params[:clips_attributes].present?)\n format.html { redirect_to @trip.parent || @trip, notice: 'Trip was successfully updated.', change: \"list\" }\n format.json { head :no_content }\n else\n format.html { redirect_to @trip.parent || @trip }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trip.update_attributes(params[:trip])\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trip_item = TripItem.find(params[:id])\n\n respond_to do |format|\n if @trip_item.update_attributes(params[:trip_item])\n format.html { redirect_to @trip_item, notice: 'Trip item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trip_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n trip = Trip.find(params[:id])\n if trip.update(trip_params)\n redirect_to trip_path\n else\n render :edit, status: :bad_request\n end\n end",
"def update\n respond_to do |format|\n if @trip.update(trip_params)\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trip.update(trip_params)\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @trip, :update?\n respond_to do |format|\n if @trip.update(trip_params)\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trip.update(trip_params)\n format.html { redirect_to trips_path, notice: 'Trip was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip }\n else\n format.html { render :edit }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n if user_can_modify(@trip) and @trip.update_attributes(params[:trip])\n format.html { redirect_to(@trip, :notice => 'Trip was successfully updated.') }\n format.xml { head :ok }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @trip.errors, :status => :unprocessable_entity }\n format.json { render :json => @trip.errors.full_messages, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @trip = Trip.find(params[:id])\n respond_to do |format|\n if @trip.update(trip_params)\n format.html { redirect_to oj_path, notice: 'Trip was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end",
"def update\n trip = Trip.find_by_id(params[:trip_id])\n trip.title = params[:title]\n trip.city = params[:city]\n trip.state = params[:state]\n trip.country = params[:country]\n trip.start_date = params[:start_date]\n trip.end_date = params[:end_date]\n trip.description = params[:description]\n trip.link = params[:link]\n if params[:photo_base]\n trip.photo = params[:photo_base]\n end\n trip.save!\n render json: trip\n end",
"def update\n respond_to do |format|\n if @trip_todo.update(trip_todo_params)\n format.html { redirect_to @trip_todo, notice: 'Trip todo was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip_todo }\n else\n format.html { render :edit }\n format.json { render json: @trip_todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n if @trip.update_attributes(params[:trip])\n format.html { redirect_to(@trip, :notice => 'Trip was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @trip.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trip.update(trip_params)\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip }\n else\n format.html { render :edit }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trip.update(trip_params)\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip }\n else\n format.html { render :edit }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trip.update(trip_params)\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip }\n else\n format.html { render :edit }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trip.update(trip_params)\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip }\n else\n format.html { render :edit }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trip.update(trip_params)\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip }\n else\n format.html { render :edit }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trip.update(trip_params)\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip }\n else\n format.html { render :edit }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to trip_url(@user.trips.last.id), notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trip = Trip.find(params[:id])\n \n \n params[:trip][:category_ids] ||= []\n params[:trip][:type_ids] ||= []\n \n respond_to do |format|\n if @trip.update_attributes(params[:trip])\n format.html { redirect_to @trip, :notice => 'Trip was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @trip.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n if @trip.update_attributes(parse_post params[:trip])\n flash[:notice] = 'Trip was successfully updated.'\n format.html { redirect_to(@trip) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @trip.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n if @trip.update_attributes(parse_post params[:trip])\n flash[:notice] = 'Trip was successfully updated.'\n format.html { redirect_to(@trip) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @trip.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @trip = Trip.find_by(id: params[:id])\n if @trip.nil?\n head :not_found\n return\n elsif @trip.update(trip_params)\n redirect_to trip_path\n end\n end",
"def update\n respond_to do |format|\n if @trip.update(trip_params.merge(user_id: current_user.id))\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip }\n else\n format.html { render :edit }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trip = Trip.find(params[:id])\n #params[:trip][:participations] ||=[]\n respond_to do |format|\n if @trip.owner_id == current_user.id && @trip.update_attributes(params[:trip])\n flash[:notice] = 'Trip was successfully updated.'\n format.html { redirect_to(@trip) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @trip.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @troop = Troop.find(params[:id])\n\n respond_to do |format|\n if @troop.update_attributes(params[:troop])\n format.html { redirect_to @troop, notice: 'Troop was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @troop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tips_trick.update_attributes(params[:tips_trick])\n format.html { redirect_to @tips_trick, notice: 'Tips trick was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tips_trick.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @rip = Rip.find(params[:id])\n respond_to do |format|\n if @rip.update_attributes(params[:rip])\n format.html { redirect_to rip_url(@rip) }\n format.xml { head :ok }\n else\n format.html { render :action => 'edit' }\n format.xml { render :xml => @rip.errors.to_xml }\n end\n end\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n @todo = Todo.find(params[:id])\n @todo.update_attributes(params[:todo])\n render :json => @todo\n end",
"def update\n @trips_connect = TripsConnect.find(params[:id])\n\n respond_to do |format|\n if @trips_connect.update_attributes(params[:trips_connect])\n format.html { redirect_to @trips_connect, notice: 'Trips connect was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trips_connect.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trip = Trip.find(params[:id])\n if current_user.has_permission?(:trips)\n @trip.accessible = :all\n end\n\n respond_to do |format|\n if @trip.update_attributes(params[:trip])\n format.html { redirect_to [:admin, @trip], :notice => \"Trip was successfully updated.\" }\n else\n flash[:error] = \"Trip was not updated.\"\n format.html { render active_admin_template(:edit) }\n end\n end\n end",
"def update\n authorize @trip\n\n\n @trip.estimated_expenses.each do |exp|\n exp.requests.each do |req|\n req.amount_from_total = req.percentrequested * exp.total\n req.destination = @trip.destination\n req.expense_type = 'estimated'\n end\n end\n\n respond_to do |format|\n if @trip.update(trip_params)\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip }\n else\n format.html { render :edit }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n @tip = Tip.find(params[:id])\n\n respond_to do |format|\n if @tip.update_attributes(params[:tip])\n format.html { redirect_to @tip, notice: 'Tip was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tariff = Tariff.find params[:id]\n\n respond_to do |format|\n if @tariff.update(tariff_params)\n format.html { redirect_to @tariff, notice: 'Tariff was successfully updated.' }\n format.json { respond_with_bip(@tariff) }\n else\n format.html { render :edit }\n format.json { respond_with_bip(@tariff) }\n end\n end\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n @tip.update(tips_params)\n json_response(@tip)\n end",
"def edit\n @trip = Trip.find(params[:id])\n end",
"def update\n @user = User.find(params[:user_id])\n @trip.start = params[:trip][:start]\n @trip.end = params[:trip][:end]\n respond_to do |format|\n if @trip.update\n format.html { redirect_to [@user,@trip], notice: 'Trip was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trip = Trip.find(params[:id])\n @ministry = @trip.ministry\n\n respond_to do |format|\n if @trip.update_attributes(params[:trip])\n #flash[:notice] = 'Trip was successfully updated.'\n format.html { redirect_to(@trip) }\n format.xml { head :ok }\n else\n @data_files = DataFile.find(:all, :order => :name)\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @trip.errors,\n :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @future_trip.update(future_trip_params)\n format.html { redirect_to @future_trip, notice: 'Future trip was successfully updated.' }\n format.json { render :show, status: :ok, location: @future_trip }\n else\n format.html { render :edit }\n format.json { render json: @future_trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trip.update(trip_params)\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n else\n format.html { render :index }\n end\n end\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 if @troop.update(troop_params)\n render :show, status: :ok, location: @troop\n else\n render json: @troop.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @third_rip.update(third_rip_params)\n format.html { redirect_to @third_rip, notice: 'Third rip was successfully updated.' }\n format.json { render :show, status: :ok, location: @third_rip }\n else\n format.html { render :edit }\n format.json { render json: @third_rip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tap.update(tap_params)\n format.html { redirect_to taps_path, notice: 'Tap was successfully updated.' }\n format.json { head :no_content }\n else\n format.json { render json: @tap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def patch(path, opts = {})\n request(:patch, path, opts).body\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 @gtfs_trip = GtfsTrip.find(params[:id])\n\n respond_to do |format|\n if @gtfs_trip.update_attributes(params[:gtfs_trip])\n format.html { redirect_to(@gtfs_trip, :notice => 'Gtfs trip was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @gtfs_trip.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @todo = Todo.find(params[:id])\n if @todo.update(todo_params)\n render json: @todo\n else\n render json: @todo.errors, status: :unprocessable_entity\n end\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def update\n @trip_feature = TripFeature.find(params[:id])\n\n respond_to do |format|\n if @trip_feature.update_attributes(params[:trip_feature])\n format.html { redirect_to(@trip_feature, :notice => 'TripFeature was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @trip_feature.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n respond_to do |format|\n if @tip.update!(tip_params)\n format.html { redirect_to @tip, notice: \"#{@tip.name} tip has been updated.\" }\n format.json { render :show, status: :ok, location: @tip }\n else\n format.html { render :edit }\n format.json { render json: @tip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @first_rip.update(first_rip_params)\n format.html { redirect_to @first_rip, notice: 'First rip was successfully updated.' }\n format.json { render :show, status: :ok, location: @first_rip }\n else\n format.html { render :edit }\n format.json { render json: @first_rip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trompler = Trompler.find(params[:id])\n\n respond_to do |format|\n if @trompler.update_attributes(params[:trompler])\n format.html { redirect_to @trompler, notice: 'Trompler was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trompler.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trip = Trip.find(params[:id])\n params[:trip][:places] ||= []\n @trip.add_trip_places(params[:trip][:places])\n if @trip.update_attributes(params[:trip].except(:places))\n flash[:notice] = \"Trip succesfully updated\"\n redirect_to @trip\n else\n flash.now[:error] = @trip.errors.full_messages\n @places = params[:trip][:places]\n render \"edit\"\n end\n end",
"def update\n @trip = Trip.find(params[:id])\n @trip.assign_attributes(trip_params)\n\n if @trip.save\n redirect_to passenger_trip_path(@trip.passenger_id, @trip.id)\n end\n end",
"def update\n # @user_trick = UserTrick.find(params[:id])\n @user_trick.update(user_trick_params)\n render json: UserTrickSerializer.new(@user_trick).serialized_json\n end",
"def update\n @field_trip = FieldTrip.find(params[:id])\n\n respond_to do |format|\n if @field_trip.update_attributes(params[:field_trip])\n format.html { redirect_to(@field_trip, :notice => 'Field trip was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @field_trip.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def update\n respond_to do |format|\n if @troop.update(troop_params)\n format.html { redirect_to @troop, notice: 'Tropa exitosamente actualizada.' }\n format.json { render :show, status: :ok, location: @troop }\n else\n format.html { render :edit }\n format.json { render json: @troop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tripdate = Tripdate.find(params[:id])\n\n respond_to do |format|\n if @tripdate.update_attributes(params[:tripdate])\n format.html { redirect_to @tripdate, notice: 'Tripdate was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tripdate.errors, status: :unprocessable_entity }\n end\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 update # PATCH\n raise NotImplementedError\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n respond_to do |format|\n if @trump.update(trump_params)\n format.html { redirect_to @trump, notice: 'Trump was successfully updated.' }\n format.json { render :show, status: :ok, location: @trump }\n else\n format.html { render :edit }\n format.json { render json: @trump.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n travel = Travel.find(params[:id])\n if travel.update(travel_params)\n render json: travel, status: 200\n else\n render json: travel.errors, status: 422\n end\n end",
"def update\n @fleet = Fleet.find(params[:id])\n\n respond_to do |format|\n if @fleet.update_attributes(params[:fleet])\n format.html { redirect_to @fleet, notice: 'Fleet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fleet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tip.update(tip_params)\n format.html { redirect_to @tip, notice: 'Tip was successfully updated.' }\n format.json { render :show, status: :ok, location: @tip }\n else\n format.html { render :edit }\n format.json { render json: @tip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @profile = Profile.find_by_user_id(current_user.id)\n @trip = Trip.find(params[:id])\n if @trip.update_attributes(params.require(:trip).permit(:date, :time, :pickup_location, :destination, :price, :seats_available, :driver_id, :profile_id))\n redirect_to profile_trip_url(@profile, @trip)\n else\n render :action => \"edit\"\n end\n end",
"def update\n respond_to do |format|\n\n @pizza.toppings.each do |t|\n @pizza.toppings.delete(t)\n end\n\n params[:topping_ids].each do |tid|\n topping = Topping.find_by_id(tid)\n @pizza.toppings << topping\n end\n\n if @pizza.update(pizza_params)\n format.html { redirect_to @pizza, notice: 'Pizza was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pizza.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @spawner = Spawner.find(params[:id])\n @fieldtrips = Fieldtrip.all\n\n respond_to do |format|\n if @spawner.update_attributes(spawner_params)\n format.html { redirect_to @spawner, notice: 'Spawner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spawner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @trip.update_attributes(trip_params)\n flash[:success] = \"Trip updated for #{@trip.student.name}.\"\n redirect_to @trip\n else\n render 'edit'\n end\n end",
"def update\n @tier = Tier.find(params[:id])\n\n respond_to do |format|\n if @tier.update_attributes(params[:tier])\n format.html { redirect_to @tier, :notice => 'Tier was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @tier.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @templete = Templete.find(params[:id])\n\n respond_to do |format|\n if @templete.update_attributes(params[:templete])\n format.html { redirect_to @templete, :notice => 'Templete was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @templete.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trip_route.update(trip_route_params)\n format.html { redirect_to @trip_route, notice: 'Trip route was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip_route }\n else\n format.html { render :edit }\n format.json { render json: @trip_route.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end",
"def update\r\n if @trip.update(trip_params)\r\n redirect_to trips_path, notice: 'Trip was successfully updated.'\r\n else\r\n redirect_to edit_trip_path, notice: 'Cannot leave information blank.'\r\n end\r\n end",
"def update\n @trick = Trick.find(params[:id])\n\n respond_to do |format|\n if @trick.update_attributes(params[:trick])\n format.html { redirect_to @trick, notice: 'Trick was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trick.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n update_resource @ride, ride_params\n end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def update\n @tip_so = TipSo.find(params[:id])\n\n respond_to do |format|\n if @tip_so.update_attributes(params[:tip_so])\n format.html { redirect_to @tip_so, notice: 'Tip so was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tip_so.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit\n @trip = Trip.find_by(id: params[:id])\n \n if @trip.nil?\n redirect_to trip_path\n return\n end\n end",
"def update\n tip = Tip.find(params[:id])\n tip.update(tip_params)\n \n redirect_to tips_path\n end",
"def update\n @data = @recipe.update(params[:id], recipe_params)\n render json: @data\n end",
"def update\n respond_to do |format|\n if @trip_type.update(trip_type_params)\n format.html { redirect_to @trip_type, notice: 'Trip type was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip_type }\n else\n format.html { render :edit }\n format.json { render json: @trip_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @chest_triceps1.update(chest_triceps1_params)\n format.html { redirect_to \"/chest_triceps1s\" } \n format.json { render :show, status: :ok, location: @chest_triceps1 }\n else\n format.html { render :edit }\n format.json { render json: @chest_triceps1.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6753958",
"0.6746517",
"0.6706538",
"0.6706538",
"0.6702033",
"0.66963506",
"0.6536128",
"0.64736634",
"0.64628583",
"0.6445016",
"0.6445016",
"0.64286584",
"0.64213836",
"0.63920105",
"0.6363639",
"0.6358378",
"0.6349523",
"0.6347771",
"0.6331375",
"0.6331375",
"0.6331375",
"0.6331375",
"0.6331375",
"0.6331375",
"0.63221526",
"0.6284024",
"0.6271536",
"0.6271536",
"0.62128025",
"0.6205779",
"0.61946803",
"0.61634046",
"0.612496",
"0.6104622",
"0.6102989",
"0.60815924",
"0.606501",
"0.60478616",
"0.60358447",
"0.6003884",
"0.5969935",
"0.59618884",
"0.5959916",
"0.5957406",
"0.59434414",
"0.59363085",
"0.593161",
"0.5910007",
"0.58797973",
"0.58753335",
"0.58695525",
"0.584492",
"0.5836017",
"0.5833887",
"0.5826281",
"0.58261627",
"0.5821046",
"0.5817885",
"0.58095384",
"0.58092165",
"0.58092165",
"0.5793209",
"0.5784399",
"0.5779184",
"0.57770365",
"0.5776176",
"0.57614005",
"0.5759487",
"0.57521075",
"0.57515776",
"0.5742517",
"0.5740899",
"0.5740899",
"0.57397795",
"0.57381904",
"0.57222515",
"0.57144445",
"0.57084024",
"0.5705488",
"0.56900316",
"0.5689694",
"0.5686315",
"0.56858087",
"0.56829506",
"0.56770504",
"0.567549",
"0.56736416",
"0.5672608",
"0.56720805",
"0.5671879",
"0.5667707",
"0.5667586",
"0.56642675",
"0.5658951",
"0.5653134",
"0.564741",
"0.56416464",
"0.56346947",
"0.56314987",
"0.56249803"
] |
0.60384494
|
38
|
DELETE /trips/1 DELETE /trips/1.json
|
def destroy
@trip.destroy
head :no_content
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @trip = Trip.find(params[:id])\n @trip.destroy\n\n respond_to do |format|\n format.html { redirect_to find_trips_url }\n format.json { head :no_content }\n end\n end",
"def delete\n @trip = Trips.find_trip( params[ :id ])\n end",
"def destroy\n @trip = Trip.find(params[:id])\n @trip.destroy\n\n respond_to do |format|\n format.html { redirect_to trips_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @trip = Trip.find(params[:id])\n @trip.destroy\n\n respond_to do |format|\n format.html { redirect_to trips_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @trip = Trip.find(params[:id])\n @trip.destroy\n\n respond_to do |format|\n format.html { redirect_to trips_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip = Trip.find(params[:id])\n @trip.destroy\n\n respond_to do |format|\n format.html { redirect_to trips_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip = Trip.find(params[:id])\n @trip.destroy\n\n respond_to do |format|\n format.html { redirect_to trips_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n trip = Trip.find(params[:id])\n trip.destroy\n render json: {message: \"Successfully deleted trip\"}\n end",
"def destroy\n @trip.destroy\n\n respond_to do |format|\n format.html { redirect_to trips_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to trips_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to trips_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to trips_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip = Trip.find(params[:id])\n @trip.destroy\n\n respond_to do |format|\n format.html { redirect_to(trips_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @trip = Trip.find(params[:id])\n @trip.destroy\n\n respond_to do |format|\n format.html { redirect_to(trips_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @trip = Trip.find(params[:id])\n @trip.destroy\n\n respond_to do |format|\n format.html { redirect_to(trips_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @trip_item = TripItem.find(params[:id])\n @trip_item.destroy\n\n respond_to do |format|\n format.html { redirect_to trip_items_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n authorize @trip, :destroy?\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to trips_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trips_connect = TripsConnect.find(params[:id])\n @trips_connect.destroy\n\n respond_to do |format|\n format.html { redirect_to trips_connects_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to @trip.parent || trips_url, change: 'trip' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to trips_url, notice: 'Trip was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to trips_url, notice: 'Trip was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to trips_url, notice: 'Trip was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to trips_url, notice: 'Trip was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to trips_url, notice: 'Trip was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to trips_url, notice: 'Trip was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to trips_url, notice: 'Trip was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to trips_url, notice: 'Trip was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to trips_url, flash: {success: \"Trip was successfully deleted.\" } }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:user_id])\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to user_trips_url(@user) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to trips_url, alert: \"L'itinéraire a été supprimé.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip = Trip.find_by(id: params[:id])\n \n if @trip.nil?\n return\n end\n @trip.destroy\n redirect_to trips_path\n return\n end",
"def destroy\n if @trip.destroy\n render :json => {:success => true}\n else\n render :json => {:success => false, :errors => [\"Delete failed.\"]}\n end\n end",
"def destroy\n @trip = Trip.find(params[:trip])\n if current_user.trips.include?(@trip)\n @trip.destroy\n render json: {message: \"usunięto tripa\"}\n else\n @trip.errors.add(:permissions, 'brak uprawnień')\n render json: { errors: @trip.errors }, status: :unauthorized\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def destroy\n authorize @trip\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to trips_url, notice: 'Trip was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@trip = @user.organized_trips.find(params[:id])\n\t\[email protected]\n\t\trespond_with @trip\n\tend",
"def destroy\n @gtfs_trip = GtfsTrip.find(params[:id])\n @gtfs_trip.destroy\n\n respond_to do |format|\n format.html { redirect_to(gtfs_trips_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @field_trip = FieldTrip.find(params[:id])\n @field_trip.destroy\n\n respond_to do |format|\n format.html { redirect_to(field_trips_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @profile = Profile.find_by_user_id(current_user.id)\n @trip = Trip.find(params[:id])\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to profile_trips_path(@profile) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @step.destroy\n respond_to do |format|\n format.html { redirect_to @trip }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invoiced_trip.destroy\n respond_to do |format|\n format.html { redirect_to invoiced_trips_url, notice: 'Invoiced trip was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def delete_item(id)\n record \"/todos/delete_item/#{id}\"\n end",
"def destroy\n\n # set the @traveler variable\n get_traveler\n # set the @trip variable\n get_trip\n \n if @trip\n @trip.planned_trips.each do |pt| \n pt.itineraries.each { |x| x.destroy }\n end\n @trip.planned_trips.each { |x| x.destroy }\n @trip.trip_places.each { |x| x.destroy}\n @trip.destroy\n message = t(:trip_was_successfully_removed)\n else\n render text: t(:error_404), status: 404\n return\n end\n\n respond_to do |format|\n format.html { redirect_to(user_planned_trips_path(@traveler), :flash => { :notice => message}) } \n format.json { head :no_content }\n end\n \n end",
"def destroy\n @drip = Drip.find(params[:id])\n @drip.destroy\n\n respond_to do |format|\n format.html { redirect_to drips_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip = Trip.find(params[:id])\n @ministry = @trip.ministry\n @trip.destroy\n\n respond_to do |format|\n format.html { redirect_to(@ministry) }\n format.xml { head :ok }\n end\n end",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def delete(id)\n request(:delete, \"/recipes/#{id}.json\")\n end",
"def destroy\n @troop = Troop.find(params[:id])\n @troop.destroy\n\n respond_to do |format|\n format.html { redirect_to troops_url }\n format.json { head :ok }\n end\n end",
"def destroy\n # First delete trip's permissions.\n @trip.permissions.each do |perm|\n perm.destroy\n end\n\n # Then delete the trip itself.\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to trips_url, notice: 'Trip was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n @trip = Trip.find_by(deletion_token: params[:id])\n if @trip\n if @trip.soft_delete!\n # do nothing, render update page\n else\n render :not_found # let's give no information on this error to the internet\n end\n else\n render :not_found # let's give no information on this error to the internet\n end\n end",
"def destroy\n @trip = Trip.find(params[:id])\n @trip.destroy\n respond_to do |format|\n format.html {}\n format.js { render :layout => false }\n end\n end",
"def destroy\n @class_trip.destroy\n respond_to do |format|\n format.html { redirect_to class_trips_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip_todo.destroy\n respond_to do |format|\n format.html { redirect_to trip_todos_url, notice: 'Trip todo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destory\n @trip = Trips.delete_trip( params[ :id ] )\n flash[:notice] = \"Trip Deleted successfuly\"\n redirect_to(:action => 'list')\n end",
"def destroy\n @trap = Trap.find(params[:id])\n @trap.destroy\n\n respond_to do |format|\n format.html { redirect_to traps_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @guide_trip.destroy\n respond_to do |format|\n format.html { redirect_to guide_trips_url, notice: 'Guía turístico fue eliminado satisfactoriamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tramite = Tramite.find(params[:id])\n @tramite.destroy\n\n respond_to do |format|\n format.html { redirect_to tramites_url }\n format.json { head :no_content }\n end\n end",
"def delete!( opts = {} )\n http_action :delete, nil, opts\n end",
"def destroy\n @taxi = Taxi.find(params[:id])\n @taxi.destroy\n\n respond_to do |format|\n format.html { redirect_to taxis_url }\n format.json { head :ok }\n end\n end",
"def destroy\r\n @trip.destroy\r\n redirect_to trips_path, notice: 'Trip was successfully removed.'\r\n end",
"def destroy\n @tripdate = Tripdate.find(params[:id])\n @tripdate.destroy\n\n respond_to do |format|\n format.html { redirect_to tripdates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @snip = Snip.find(params[:id])\n @snip.destroy\n\n respond_to do |format|\n format.html { redirect_to snips_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip_story = TripStory.find(params[:id])\n @trip_story.destroy\n\n respond_to do |format|\n format.html { redirect_to(trip_stories_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @treq = Treq.find(params[:id])\n @treq.destroy\n\n respond_to do |format|\n format.html { redirect_to treqs_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def delete(path)\n request(:delete, path)\n end",
"def delete\n @delete ||= Verb.new do |verb|\n verb.entity :trip, :air, :lodging, :car, :profile, :rail, \\\n :transport, :cruise, :restaurant, :activity, :note, :map, \\\n :directions \\\n do |entity, id|\n do_request('delete', entity, {:id=>id}, nil)\n end\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @third_rip.destroy\n respond_to do |format|\n format.html { redirect_to third_rips_url, notice: 'Third rip was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def delete(path)\n request 'DELETE', path\n end",
"def destroy\n @clip.destroy\n respond_to do |format|\n format.html { redirect_to trip_path(@clip.trip.parent), change: 'list' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip_driver = TripDriver.find(params[:id])\n @trip_driver.destroy\n\n respond_to do |format|\n format.html { redirect_to trip_drivers_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 delete(path, params)\n parse_response @client[path].delete(:params => params)\n end",
"def delete\n request(:delete)\n end",
"def destroy\n @trail = Trail.find(params[:id])\n @trail.destroy\n\n respond_to do |format|\n format.html { redirect_to trails_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @trio.destroy\n respond_with(@trio, :location => trios_url)\n end",
"def recipe_delete # /v1/user/:id/recipes/:recipe_id (DELETE)\n params[:recipes] = params[:recipe_id]\n recipes_delete\n end",
"def destroy\n Todo.find(params[:id]).destroy\n render :json => {:message => \"Record deleted\", :item_id => params[:id]}\n end",
"def destroy\n @tap.destroy\n respond_to do |format|\n format.html { redirect_to taps_url }\n format.json { head :no_content }\n end\n end",
"def delete endpoint\n do_request :delete, endpoint\n end",
"def destroy\n @trail = Trail.find(params[:id])\n @trail.destroy\n\n respond_to do |format|\n format.html { redirect_to trails_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def destroy\n\n @trip = Trip.find(params[:id])\n\n stat(@trip, \"del\")\n\n ing = @trip.ing\n if ing\n trip_user_delete(@trip.driver)\n @trip.car.update_attribute(:current_trip, 0)\n @trip.workers.each do |worker|\n trip_user_delete(worker)\n end\n end\n\n @trip.workers.clear\n\n @trip.destroy\n\n respond_to do |format|\n format.html do\n flash[:success] = \"该出车记录已删除!\"\n sign_in(current_user)\n if ing\n redirect_to '/drivers/start'\n else\n redirect_to '/drivers/trips'\n end\n end\n format.json\n end\n end",
"def destroy\n @tetramod = Tetramod.find(params[:id])\n @tetramod.destroy\n\n respond_to do |format|\n format.html { redirect_to tetramods_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n travel = Travel.find(params[:id])\n travel.destroy\n head 204\n end",
"def delete(path, params = {})\n post(path, params.merge(\"_method\" => \"delete\"))\n end",
"def delete\n render :json => @fiestas.delete_at(params[:id].to_i)\n end",
"def destroy\n rid = params['id']\n if Aws.delete_recipe(rid) && Aws.delete_all_ingredients(rid)\n msg = {:notice => \"Recipe deleted!\"}\n render :json => msg\n else\n msg = {:notice => \"Error while deleting from DynamoDB!\"}\n render :json => msg\n end\n end",
"def destroy\n @future_trip.destroy\n respond_to do |format|\n format.html { redirect_to future_trips_url, notice: 'Future trip was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy \n\n \n @todo = Todo.find(params[:id])\n @todo.destroy\n\n respond_to do |format|\n format.html { redirect_to request.env['HTTP_REFERER'] }\n format.json { head :ok }\n end\n end",
"def destroy\n @line_item1 = LineItem1.find(params[:id])\n @line_item1.destroy\n\n respond_to do |format|\n format.html { redirect_to line_item1s_url }\n format.json { head :no_content }\n end\n end",
"def delete(path, opts = {})\n request(:delete, path, opts).body\n end",
"def destroy\n @todo = Todo.find(params[:id])\n @todo.destroy\n render json: nil, status: :ok\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end"
] |
[
"0.74139965",
"0.7404978",
"0.73848724",
"0.73848724",
"0.73744804",
"0.73744804",
"0.73744804",
"0.7304089",
"0.72812295",
"0.7253545",
"0.7253545",
"0.7253545",
"0.71911055",
"0.71911055",
"0.71911055",
"0.71823096",
"0.7141681",
"0.71213615",
"0.7002363",
"0.690559",
"0.6866053",
"0.6866053",
"0.6866053",
"0.6866053",
"0.6866053",
"0.6866053",
"0.6866053",
"0.6866053",
"0.6827641",
"0.68140346",
"0.6785337",
"0.67677975",
"0.6748828",
"0.67340326",
"0.67137164",
"0.66981006",
"0.669373",
"0.6663988",
"0.6663336",
"0.66438",
"0.66410154",
"0.66401696",
"0.66236174",
"0.6614948",
"0.6605268",
"0.6602853",
"0.6594833",
"0.658359",
"0.65740454",
"0.6563797",
"0.65631694",
"0.6562203",
"0.65542114",
"0.6549934",
"0.6538898",
"0.64982617",
"0.64883775",
"0.64844644",
"0.6473528",
"0.6469709",
"0.6452358",
"0.6440445",
"0.64313424",
"0.64272034",
"0.6420849",
"0.64191747",
"0.64087075",
"0.63951427",
"0.63926315",
"0.6391697",
"0.6391525",
"0.63836515",
"0.63681227",
"0.63511384",
"0.6345591",
"0.6344776",
"0.63430303",
"0.6342758",
"0.6342489",
"0.6330235",
"0.63221824",
"0.632178",
"0.6321735",
"0.63213974",
"0.6317007",
"0.6316456",
"0.6311366",
"0.6306768",
"0.63052374",
"0.6305218",
"0.6302457",
"0.6302152",
"0.629912",
"0.6296695",
"0.6290603",
"0.62862116",
"0.6284441",
"0.6282023",
"0.6282023",
"0.6282023"
] |
0.6919063
|
19
|
GET /master/specs/1 GET /master/specs/1.xml
|
def show
@master_spec = Master::Spec.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @master_spec }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @master_spec = Master::Spec.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @master_spec }\n end\n end",
"def specs_url\n \"http://#{@host}/#{SPECS_ARCHIVE_FILE}\"\n end",
"def show\n @specification = Specification.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @specification }\n end\n end",
"def get\n `curl -L -o ./tmp/specs.tar.gz http://github.com/CocoaPods/Specs/tarball/master`\n end",
"def dummy_data_fuse_response_xml\n path=\"#{Rails.root}/test/data_fuse_example.xml\"\n File.open(path, \"rb\").read\n end",
"def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n end\n end",
"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 fetch_specification(name, version)\n url = host + \"/quick/#{Configuration.marshal_identifier}\" \\\n \"/#{name}-#{version}.gemspec.rz\"\n\n http_get(url).body\n end",
"def show\n @lab_rack = LabRack.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lab_rack }\n end\n end",
"def test_srpm_spec_url\n get '/srpm/Sisyphus/glibc/spec'\n assert_equal 'http://packages.altlinux.org/ru/Sisyphus/srpms/glibc/spec', last_response.location\n assert_equal 301, last_response.status\n\n get '/srpm/Branch51/glibc/spec'\n assert_equal 'http://packages.altlinux.org/ru/5.1/srpms/glibc/spec', last_response.location\n assert_equal 301, last_response.status\n\n get '/srpm/p5/glibc/spec'\n assert_equal 'http://packages.altlinux.org/ru/Platform5/srpms/glibc/spec', last_response.location\n assert_equal 301, last_response.status\n\n get '/srpm/Branch41/glibc/spec'\n assert_equal 'http://packages.altlinux.org/ru/4.1/srpms/glibc/spec', last_response.location\n assert_equal 301, last_response.status\n\n get '/srpm/Branch4/glibc/spec'\n assert_equal 'http://packages.altlinux.org/ru/4.0/srpms/glibc/spec', last_response.location\n assert_equal 301, last_response.status\n end",
"def api_xml(path,method=:get,options={})\n xml_message(amee,\"/data\"+path,method,options)\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 get_xml\n response = @api.request(:get, @location, type: 'xml')\n response.body if response.status == 200\n end",
"def show\n @test_suite = TestSuite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @test_suite }\n end\n end",
"def show\n @range_specification = RangeSpecification.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @range_specification }\n end\n end",
"def show\n @suite = Suite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @suite }\n end\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 apis = site_account.api_docs_services\n .published\n .with_system_names((params[:services] || \"\").split(\",\"))\n .select{ |api| api.specification.swagger_1_2? }\n\n respond_with({\n swaggerVersion: \"1.2\",\n apis: apis.map!{ |service| swagger_spec_for(service) },\n basePath: \"#{request.protocol}#{request.host}\"\n })\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 respond_with(file)\n response_path = File.dirname(__FILE__) + \"/../fixtures/response/xml\"\n File.read \"#{response_path}/#{file}.xml\"\nend",
"def show\n if params[:format] == 'xml'\n send_file @test_plan.jmx.path, :type => 'application/xml', :disposition => 'attachment'\n end\n end",
"def test_url\n get('/html/urltest')\n assert last_response.ok?\n assert_equal File.new(\"./results/urltest.ml\").read, last_response.body\n\n get('/html/urltest/1')\n assert last_response.ok?\n assert_equal File.new(\"./results/urltest-part.ml\").read, last_response.body\n end",
"def test_index\n create_document(\"about.md\") # setup necessary data\n create_document(\"changes.txt\")\n\n get \"/\"\n \n assert_equal(200, last_response.status)\n assert_equal(\"text/html;charset=utf-8\", last_response[\"Content-Type\"])\n assert_includes(last_response.body, \"about.md\")\n assert_includes(last_response.body, \"changes.txt\")\n\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render xml: @repository }\n end\n end",
"def test2\n uri = 'http://dbhack1.nescent.org/cgi-bin/phylows.pl/phylows/tree/TB:1999'\n # @x = Net::HTTP.get_response(URI.parse(uri)).body\n @d = Nexml::Document.new(:url => uri)\n end",
"def spec_with_url(url, spec_name = nil)\n name = url.split('/').last\n name = name.chomp('.git') if name.end_with?('.git')\n name = spec_name unless spec_name.nil?\n\n target_dir = TRY_TMP_DIR + name\n target_dir.rmtree if target_dir.exist?\n\n downloader = Pod::Downloader.for_target(target_dir, :git => url)\n downloader.download\n\n spec_file = Pathname.glob(target_dir + \"#{name}.podspec{,.json}\").first\n Pod::Specification.from_file(spec_file)\n end",
"def show\n @req_breakdown = ReqBreakdown.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @req_breakdown }\n end\n end",
"def index\n @requirements = Requirement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @requirements }\n end\n end",
"def request(resource, method = \"get\", args = nil)\n \t \n \t @now_playing_url = 'http://62.216.251.203:80/nowplaying'\n \t @submission_url = 'http://62.216.251.205:80/protocol_1.2'\n \t @session_id = '17E61E13454CDD8B68E8D7DEEEDF6170'\n \t \n \t if @base_url == Scrobbler::API_URL\n \t pieces = resource.split('/')\n pieces.shift\n \t api_version = pieces.shift\n if api_version == \"1.0\"\n folder = pieces.shift\n file = pieces.last[0, pieces.last.index('.xml')]\n base_pieces = pieces.last.split('?')\n\n file = if base_pieces.size > 1\n # if query string params are in resource they are underscore separated for filenames\n base_pieces.last.split('&').inject(\"#{file}_\") { |str, pair| str << pair.split('=').join('_') + '_'; str }.chop!\n else\n file\n end\n\n File.read(File.dirname(__FILE__) + \"/../fixtures/xml/#{folder}/#{file}.xml\")\n elsif api_version == \"2.0\"\n method_pieces = pieces.last.split('&')\n api_method = method_pieces.shift\n if api_method == '?method=artist.search'\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/search/artist.xml\")\n elsif api_method == '?method=album.search'\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/search/album.xml\")\n elsif api_method == '?method=track.search'\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/search/track.xml\")\n elsif pieces.last =~ /[?&]method=album\\.getinfo/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/album/info.xml\")\n elsif pieces.last =~ /[?&]method=artist\\.gettoptags/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/artist/toptags.xml\")\n elsif pieces.last =~ /[?&]method=artist\\.search/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/artist/search.xml\")\n elsif pieces.last =~ /[?&]method=artist\\.gettopfans/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/artist/fans.xml\")\n elsif pieces.last =~ /[?&]method=artist\\.gettoptracks/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/artist/toptracks.xml\")\n elsif pieces.last =~ /[?&]method=artist\\.gettopalbums/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/artist/topalbums.xml\")\n elsif pieces.last =~ /[?&]method=artist\\.getsimilar/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/artist/similar.xml\")\n elsif pieces.last =~ /[?&]method=album\\.search/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/album/search.xml\")\n elsif pieces.last =~ /[?&]method=tag\\.gettoptracks/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/tag/toptracks.xml\")\n elsif pieces.last =~ /[?&]method=tag\\.gettopartists/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/tag/topartists.xml\")\n elsif pieces.last =~ /[?&]method=tag\\.gettopalbums/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/tag/topalbums.xml\")\n elsif pieces.last =~ /[?&]method=track\\.gettoptags/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/track/toptags.xml\")\n elsif pieces.last =~ /[?&]method=track\\.gettopfans/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/track/fans.xml\")\n elsif pieces.last =~ /[?&]method=track\\.search/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/track/search.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getlovedtracks/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/lovedtracks.xml\")\n elsif pieces.last =~ /[?&]method=user\\.gettopartists/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/topartists.xml\")\n elsif pieces.last =~ /[?&]method=user\\.gettopalbums/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/topalbums.xml\")\n elsif pieces.last =~ /[?&]method=user\\.gettoptracks/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/toptracks.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getfriends/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/friends.xml\")\n elsif pieces.last =~ /[?&]method=user\\.gettoptags/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/toptags.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getneighbours/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/neighbours.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getrecenttracks/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/recenttracks.xml\")\n elsif pieces.last =~ /[?&]method=user\\.playlists/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/playlists.xml\")\n elsif pieces.last =~ /[?&]method=event\\.getinfo/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/event/event.xml\")\n elsif pieces.last =~ /[?&]method=event\\.getshouts/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/event/shouts.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getweeklyalbumchart/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/weeklyalbumchart.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getweeklyartistchart/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/weeklyartistchart.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getweeklytrackchart/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/weeklytrackchart.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getevents/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/events.xml\")\n else\n old_request(resource, method, args)\n end\n end\n \t elsif @base_url == Scrobbler::AUTH_URL\n if args[:hs] == \"true\" && args[:p] == Scrobbler::AUTH_VER.to_s && args[:c] == 'rbs' &&\n args[:v] == '0.2.13' && args[:u] == 'chunky' && !args[:t].blank? &&\n args[:a] == Digest::MD5.hexdigest('7813258ef8c6b632dde8cc80f6bda62f' + args[:t])\n \n \"OK\\n#{@session_id}\\n#{@now_playing_url}\\n#{@submission_url}\"\n end\n elsif @base_url == @now_playing_url\n if args[:s] == @session_id && ![args[:a], args[:t], args[:b], args[:n]].any?(&:blank?)\n 'OK'\n end \n elsif @base_url == @submission_url\n if args[:s] == @session_id && \n ![args['a[0]'], args['t[0]'], args['i[0]'], args['o[0]'], args['l[0]'], args['b[0]']].any?(&:blank?)\n 'OK'\n end\n\t end\n\t end",
"def show\n @xml_sample = XmlSample.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @xml_sample }\n end\n end",
"def show\n render json: @specification, serializer: Web::V1::SpecificationSerializer\n end",
"def download_specs\n UI.puts 'Downloading Rubygem specification index...'\n fetcher = Gem::SpecFetcher.fetcher\n results, errors = fetcher.available_specs(:released)\n\n unless errors.empty?\n UI.puts 'Error downloading Rubygem specification index: ' +\n errors.first.error.to_s\n return []\n end\n\n flatten_fetcher_results(results)\n end",
"def config\n respond_to { |format| format.xml }\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @compliance }\n end\n end",
"def show\n @target_def = TargetDef.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @target_def }\n end\n end",
"def show\n @expectation_stem = RiGse::ExpectationStem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @expectation_stem }\n end\n end",
"def download(full_spec, path) # :nodoc:\n end",
"def create\n @master_spec = Master::Spec.new(params[:master_spec])\n\n respond_to do |format|\n if @master_spec.save\n format.html { redirect_to(@master_spec, :notice => 'Spec was successfully created.') }\n format.xml { render :xml => @master_spec, :status => :created, :location => @master_spec }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @master_spec.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def docs api\n\t\tget_html \"#{@options[:docs]}/#{@apis[api][:url]}.htm\"\n\tend",
"def show\n @defect = Defect.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @defect }\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 index\n @node = Fedora.rest('rest/')\n end",
"def show\n @reqinfo = Reqinfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @reqinfo }\n end\n end",
"def retrieve_docs_from_host1\n apis = {}\n host = @doc_urls[:doc_base1][%r{^https?:\\/\\/[^\\/]+}]\n apis_received = open(@doc_urls[:doc_base1], @api_docs, &:read).scan(/<a class=\"swagger-list--item-link\" href=\"\\/(.+?)\".*?>\\s*(.+?)\\s*<\\/a>/i)\n \n apis_received.each do |path, title|\n begin\n api = { path: \"#{@doc_urls[:doc_base1]}#{path}\",\n title: title.sub(/\\s*\\(.+?\\)$/, ''),\n deprecated: title.include?('(Deprecated)') }\n\n fetched_path = open(api['path'], Options, &:read).scan(%r{url:\\s*'(.+?)'})\n api[:path] = \"#{host}#{fetched_path}\"\n apis[api[:title]] = api\n rescue OpenURI::HTTPError\n # Some log here\n end\n end\n\n apis\n end",
"def show\n @probe = Probe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @probe }\n end\n end",
"def show\n @specification = Specification.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @specification }\n end\n end",
"def test\n get(\"/help/test.json\")\n end",
"def test\n get(\"/help/test.json\")\n end",
"def show \n @doc = \"Nothing\"\n @scenario = Scenario.find(params[:id])\n\tdir_name = \"#{Rails.root}/data/#{session[:session_id]}\"\n\tDir.mkdir(dir_name) unless File.exists?(dir_name)\n\n\tbuild_xml()\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @scenario }\n end\n end",
"def index\n @index ||= Gem::SourceIndex.from_gems_in File.join(path, \"specifications\")\n end",
"def show\n @lab = @course.labs.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render xml: @lab }\n end\n end",
"def get_listings_xml(url)\n @client.get_content(url)\n end",
"def root; get(\"\"); end",
"def request_matching specs\n specs = specs_matching specs\n req = specs && pack_path(specs)\n req\n end",
"def open_api_spec\r\n OpenAPISpecController.instance\r\n end",
"def readSrepData(config_index)\n file_name = $srep_file_path + config_index.to_s() + \".xml\"\n f = File.open(file_name)\n doc = Nokogiri::XML(f)\n f.close\n return doc\nend",
"def update\n @master_spec = Master::Spec.find(params[:id])\n\n respond_to do |format|\n if @master_spec.update_attributes(params[:master_spec])\n format.html { redirect_to(@master_spec, :notice => 'Spec was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @master_spec.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def list\n get('/')\n end",
"def show\n @documentation = Documentation.find(params[:id])\n @documentations = Documentation.find(:all)\n \n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @documentation }\n end\n end",
"def index\n @solutions = Solution.all\n respond_to do |format|\n format.html { render_template } # index.html.erb\n format.xml { render xml: @solutions }\n end\n end",
"def index\n @brand_specification_for_comparisons = website.brand.specification_for_comparisons\n @brand_specification_for_comparison = BrandSpecificationForComparison.new\n respond_to do |format|\n format.html { render_template } # index.html.erb\n format.xml { render xml: @brand_specification_for_comparisons }\n end\n end",
"def spec_with_name(name)\n set = config.sources_manager.search(Dependency.new(name))\n if set\n set.specification.root\n else\n raise Informative, \"Unable to find a specification for `#{name}`\"\n end\n end",
"def show\n @yml_file = Cmtool::YmlFile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @yml_file }\n end\n end",
"def show\n @expectation = RiGse::Expectation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @expectation }\n end\n end",
"def index\n respond_to do |format|\n format.html\n format.xml\n end\n end",
"def new\n @specification = Specification.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @specification }\n end\n end",
"def show\n respond_to do |format|\n format.html\n format.xml { render xml: @gadget_file.html }\n end\n end",
"def show\n @tm_dev1 = TmDev1.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tm_dev1 }\n end\n end",
"def show\n @versioned_jnlp_url = MavenJnlp::VersionedJnlpUrl.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @versioned_jnlp_url }\n end\n end",
"def get_api_results(_url)\n JSON.parse File.read('spec/inspector/stubbed_example.json')\n end",
"def index\n puts \"test/index\"\n ap params\n done 404\n end",
"def get(url); end",
"def show\n @revision = Revision.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @revision }\n end\n end",
"def show\n @revision = Revision.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @revision }\n end\n end",
"def show\n @erratum = Erratum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @erratum }\n end\n end",
"def show\n @versioned_jnlp = MavenJnlp::VersionedJnlp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @versioned_jnlp }\n end\n end",
"def show\n respond_to do |format|\n format.html { render_template } # show.html.erb\n format.xml { render xml: @software_training_module }\n end\n end",
"def show\n respond_to do |format|\n format.xml { }\n format.html { render 'show' }\n end\n end",
"def index\n @sys_configs = @system.sys_configs.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @sys_configs.to_xml }\n end\n end",
"def index\n @perf_benchmarks = @app.perf_benchmarks.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @perf_benchmarks }\n end\n end",
"def get_specification_info\n start = Time.now\n\n # open the json file of all cars and models and years\n # if the specs file exists, use it, else start with the styles\n json = if File.exist?(@all_cars_file_with_years_overview_styles_specs)\n JSON.parse(File.read(@all_cars_file_with_years_overview_styles_specs))\n else\n JSON.parse(File.read(@all_cars_file_with_years_overview_styles))\n end\n\n if json.nil?\n puts \"ERROR - could not find json file\"\n exit\n end\n\n hydra = Typhoeus::Hydra.new(max_concurrency: @max_concurrency)\n request = nil\n total_downloaded = 0\n total_to_download = 0\n\n # for each car, model, year - get overview\n json.each do |key_car, car|\n puts \"-----------\"\n puts \"car: #{car['name']}\"\n car['models'].each do |key_model, model|\n puts \"- model: #{model['name']}\"\n model['years'].each do |year|\n year = year.to_s\n\n # only continue if the styles hash exists\n if !model['details'][year]['styles'].nil?\n\n model['details'][year]['styles'].keys.each do |style|\n # if the style data already exists, skip it\n # else get the data\n if model['details'][year]['styles'][style].nil?\n\n request = Typhoeus::Request.new(\n @specs_url.gsub('{slug}', style),\n :headers=>{\"User-Agent\" => @user_agent},\n followlocation: true, ssl_verifypeer: false, ssl_verifyhost: 0\n )\n\n total_to_download += 1\n\n request.on_complete do |response|\n # process the html\n model['details'][year]['styles'][style] = process_specification_page(response.response_body)\n\n total_downloaded += 1\n\n if total_downloaded % 50 == 0\n puts \"\\n\\n- #{total_downloaded} specification files downloaded so far (out of #{total_to_download}); time so far = #{((Time.now-start)/60).round(2)} minutes\\n\\n\"\n end\n\n # since there are lots of files to download\n # let's save to file after every 1000 records are processed\n if total_downloaded % 1000 == 0\n puts \"\\n\\n- saving to file \\n\\n\"\n File.open(@all_cars_file_with_years_overview_styles_specs, 'wb') { |file| file.write(JSON.generate(json)) }\n end\n end\n hydra.queue(request)\n end\n end\n end\n end\n end\n end\n\n hydra.run\n\n puts \"FINISHED DOWNLOAD DATA!!\"\n\n # save to file\n File.open(@all_cars_file_with_years_overview_styles_specs, 'wb') { |file| file.write(JSON.generate(json)) }\n\n puts \"TOTAL TIME TO DOWNLOAD AND WRITE SPECIFICATIONS TO FILE = #{((Time.now-start)/60).round(2)} minutes\"\nend",
"def show\n @software = Software.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @software }\n end\n end",
"def show\n @software = Software.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @software }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @configurations }\n end\n end",
"def info\n get '/'\n end",
"def get(path, **args); end",
"def get_root\n @logger.debug \"GET #{@jenkins_path}/\"\n request = Net::HTTP::Get.new(\"#{@jenkins_path}/\")\n make_http_request(request)\n end",
"def show\n @discovery = Discovery.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @discovery }\n end\n end",
"def read_big_xml\n return File.read(File.expand_path('../../benchmark/fixtures/big.xml', __FILE__))\nend",
"def index\n @requests = Request.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @requests }\n end\n end",
"def pacscl_xml\n document = Blacklight.default_index.search(q: \"id:#{params[:id]}\")&.dig(\"response\", \"docs\")&.first\n document = SolrDocument.new(document)\n document.suppress_xml_containers!\n respond_to do |format|\n format.xml do\n render xml: document.export_as_xml\n end\n end\n end",
"def show\n @config_file = ConfigFile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @config_file }\n end\n end",
"def serve\n @repository = Project.find(params[:id]).repositories.first\n\n repoName = File.basename(@repository.root_url, File.extname(@repository.root_url))\n path = \"/srv/documentation/#{ repoName }/#{ params[:file] }\"\n\n send_file path, :disposition => 'inline'\n end",
"def test\n get(\"/help/test\")\n end",
"def test_srpm_changelog_url\n get '/srpm/Sisyphus/glibc/changelog'\n assert_equal 'http://packages.altlinux.org/ru/Sisyphus/srpms/glibc/changelog', last_response.location\n assert_equal 301, last_response.status\n\n get '/srpm/Branch51/glibc/changelog'\n assert_equal 'http://packages.altlinux.org/ru/5.1/srpms/glibc/changelog', last_response.location\n assert_equal 301, last_response.status\n\n get '/srpm/p5/glibc/changelog'\n assert_equal 'http://packages.altlinux.org/ru/Platform5/srpms/glibc/changelog', last_response.location\n assert_equal 301, last_response.status\n\n get '/srpm/Branch41/glibc/changelog'\n assert_equal 'http://packages.altlinux.org/ru/4.1/srpms/glibc/changelog', last_response.location\n assert_equal 301, last_response.status\n\n get '/srpm/Branch4/glibc/changelog'\n assert_equal 'http://packages.altlinux.org/ru/4.0/srpms/glibc/changelog', last_response.location\n assert_equal 301, last_response.status\n end",
"def show\n\n @definition = Definition.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @definition.to_xml(:request => request) }\n format.json { render :json => @definition.to_json(:request => request) }\n end\n end",
"def show\n respond_to do |format|\n format.html\n format.xml { render xml: @project } # show.html.erb\n end\n end",
"def show\n @step = TaskrequestsStep.find(params[:taskrequests_step_id])\n @absence_request = @step.absence_requests.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @absence_request }\n end\n end",
"def index\n @branches = @repository.branches\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @branches }\n end\n end",
"def index\n\n @definitions = Definition.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @definitions.to_xml(:request => request) }\n format.json { render :json => @definitions.to_json(:request => request) }\n end\n end"
] |
[
"0.5969229",
"0.5894081",
"0.58925503",
"0.58811957",
"0.5809886",
"0.5751717",
"0.57088244",
"0.5664951",
"0.5643978",
"0.5584736",
"0.55566347",
"0.55167085",
"0.55149746",
"0.5472753",
"0.5438112",
"0.541631",
"0.54162216",
"0.53945076",
"0.53545535",
"0.53439003",
"0.5333821",
"0.5332579",
"0.5326142",
"0.5316877",
"0.5316491",
"0.52978736",
"0.5281698",
"0.52573436",
"0.5251299",
"0.5247273",
"0.5232286",
"0.52285546",
"0.5228402",
"0.52166414",
"0.5211694",
"0.52089304",
"0.5207239",
"0.519936",
"0.51926297",
"0.51925683",
"0.5182185",
"0.51786655",
"0.51695347",
"0.51621777",
"0.51533866",
"0.5149402",
"0.51474416",
"0.51474416",
"0.5146031",
"0.5145875",
"0.51396",
"0.51257575",
"0.5123001",
"0.5121515",
"0.5111084",
"0.51099193",
"0.5102931",
"0.5099993",
"0.509352",
"0.50928146",
"0.50926644",
"0.5088554",
"0.50864786",
"0.5085146",
"0.50843847",
"0.5073384",
"0.506096",
"0.5054779",
"0.50537014",
"0.5052863",
"0.50511324",
"0.5049086",
"0.50459605",
"0.50459605",
"0.5041912",
"0.5040964",
"0.5037988",
"0.5025223",
"0.5024009",
"0.5021046",
"0.50208104",
"0.5019334",
"0.5019334",
"0.5019311",
"0.5019021",
"0.50173914",
"0.5016381",
"0.5016168",
"0.5014268",
"0.50121003",
"0.5011355",
"0.5011061",
"0.5010446",
"0.5009459",
"0.5008381",
"0.5007933",
"0.500714",
"0.50046426",
"0.4999234",
"0.49979737"
] |
0.66035926
|
0
|
GET /master/specs/new GET /master/specs/new.xml
|
def new
@master_spec = Master::Spec.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @master_spec }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @specification = Specification.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @specification }\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_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 respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @software }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @system }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @get_started_page }\n end\n end",
"def new\n @lab_rack = LabRack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lab_rack }\n end\n end",
"def new\n @suite = Suite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @suite }\n end\n end",
"def new\n @reqinfo = Reqinfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @reqinfo }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @compliance }\n end\n end",
"def new\n respond_to do |format|\n format.html\n format.xml\n end\n end",
"def create\n @master_spec = Master::Spec.new(params[:master_spec])\n\n respond_to do |format|\n if @master_spec.save\n format.html { redirect_to(@master_spec, :notice => 'Spec was successfully created.') }\n format.xml { render :xml => @master_spec, :status => :created, :location => @master_spec }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @master_spec.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @repo = Repo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @repo }\n end\n end",
"def new\n @testcase = Testcase.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @testcase }\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 @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 newX\n @server = Server.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @server }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @software_training_module }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml \n end\n end",
"def new\n @test_suite = TestSuite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @test_suite }\n end\n end",
"def new\n @scratch = Scratch.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @scratch }\n end\n end",
"def new\n @documentation = Documentation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @documentation }\n end\n end",
"def new\n @req_breakdown = ReqBreakdown.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @req_breakdown }\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 @ref = Ref.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ref }\n end\n end",
"def new\n @thing = Thing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thing }\n end\n end",
"def new\n @discovery = Discovery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @discovery }\n end\n end",
"def new\n @requirement = Requirement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @requirement }\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 @definition = Definition.new\n\n respond_to do |wants|\n wants.html # new.html.erb\n wants.xml { render :xml => @definition }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @page }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @software_training_class }\n end\n end",
"def new\n @defect = Defect.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @defect }\n end\n end",
"def new\n @server_rack = ServerRack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @server_rack }\n end\n end",
"def new\n respond_to do |format|\n format.html { render :layout => 'application' }\n format.xml { render :xml => @recommand }\n end\n end",
"def new\n @want = Want.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @want }\n end\n end",
"def new\n @svn_module = SvnModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @svn_module }\n end\n end",
"def new\n @test = Mg::Test.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @test }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tool_part }\n format.xml { render xml: @tool_part }\n end\n end",
"def new\n @service = Service.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @brand }\n end\n end",
"def new\n @range_specification = RangeSpecification.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @range_specification }\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 @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 @monkey = Monkey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @monkey }\n end\n end",
"def new\n @rails_url = RailsUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rails_url }\n end\n end",
"def new\n @versioned_jnlp_url = MavenJnlp::VersionedJnlpUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @versioned_jnlp_url }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ontology }\n end\n end",
"def new\n @robot = Robot.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @robot }\n end\n end",
"def new\n @repository = Repository.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @repository }\n end\n end",
"def new\n @repository = Repository.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @repository }\n end\n end",
"def new\n @thing_list = ThingList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thing_list }\n end\n end",
"def new\n @test_plant = TestPlant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @test_plant }\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 @part = Part.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @part }\n end\n end",
"def new\n @doc = Doc.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @doc }\n end\n end",
"def new\n @software = Software.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @software }\n end\n end",
"def new\n @software = Software.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @software }\n end\n end",
"def new\n @software = Software.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @software }\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 @service_version = ServiceVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @service_version }\n end\n end",
"def new\n @project_path = ProjectPath.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project_path }\n end\n end",
"def new\n @target_def = TargetDef.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @target_def }\n end\n end",
"def new\n @work = Work.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @work }\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 @shelf = Shelf.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shelf }\n end\n end",
"def new\n @url_migration = UrlMigration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @url_migration }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @notifier }\n end\n end",
"def new_rest\n @item_usage = ItemUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_usage }\n end\n end",
"def new\n @protocol = Protocol.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @protocol }\n end\n end",
"def new\n @testing = Testing.new\n @testing.build_documents\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @testing }\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 @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 @feature = Feature.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @feature }\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 @git_repo = GitRepo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @git_repo }\n end\n end",
"def new\n @good = Good.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @good }\n end\n end",
"def new\n @tracker = Tracker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tracker }\n end\n end",
"def new\n @entry = @resource_finder.new\n initialize_new_resource\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @show }\n end\n end",
"def new\n @config_file = ConfigFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @config_file }\n end\n end",
"def new \n @how_to = HowTo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @how_to }\n end\n end",
"def new\n @retain_node_selector = RetainNodeSelector.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @retain_node_selector }\n end\n end",
"def new\n @_template = @site.templates.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @_template }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |wants|\n wants.html # new.html.erb\n wants.xml { render :xml => @page }\n end\n end",
"def new\n @erratum = Erratum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @erratum }\n end\n end",
"def new\n @docent = Docent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @docent }\n end\n end",
"def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @recipe }\n end\n end",
"def new\n @workunit = Workunit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @workunit }\n end\n end",
"def new\n @machine = Machine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @machine }\n end\n end",
"def new\n @sprint = Sprint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sprint }\n end\n end",
"def new\n @sprint = Sprint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sprint }\n end\n end",
"def new\n @node = Node.new(:displayed => true)\n @node.template = Template.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n @template = Template.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @template }\n end\n end",
"def new\n @changelog = Changelog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @changelog }\n end\n end",
"def new\n @work = Work.new\n \n @title = \"New work\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @work }\n end\n end"
] |
[
"0.67625713",
"0.6704832",
"0.6476256",
"0.6459433",
"0.6417115",
"0.6395765",
"0.6299874",
"0.62626505",
"0.6258952",
"0.6258943",
"0.6188972",
"0.61699307",
"0.6156262",
"0.6153337",
"0.61510324",
"0.6143918",
"0.6141141",
"0.6125987",
"0.61139834",
"0.6112314",
"0.6110646",
"0.6108341",
"0.6088703",
"0.6084043",
"0.60569185",
"0.60545367",
"0.60537976",
"0.604745",
"0.6040392",
"0.6039619",
"0.6030944",
"0.6024532",
"0.602057",
"0.6020249",
"0.60006136",
"0.5996859",
"0.5994934",
"0.59945095",
"0.59840274",
"0.5976845",
"0.5970421",
"0.5969509",
"0.5969001",
"0.5969001",
"0.5960633",
"0.5955948",
"0.5952178",
"0.5949986",
"0.59495294",
"0.5943365",
"0.5940214",
"0.5940214",
"0.5939641",
"0.5937487",
"0.5936697",
"0.5934724",
"0.59327406",
"0.59308416",
"0.59308416",
"0.59308416",
"0.5929746",
"0.5928089",
"0.5927037",
"0.59254587",
"0.5924819",
"0.59196126",
"0.5913762",
"0.59106344",
"0.59076256",
"0.59029716",
"0.59002155",
"0.5900033",
"0.58936614",
"0.58936614",
"0.58936614",
"0.5891595",
"0.5884179",
"0.5880466",
"0.5879362",
"0.58784384",
"0.5877036",
"0.5875893",
"0.5873096",
"0.5871349",
"0.5870796",
"0.5865731",
"0.58632153",
"0.58605397",
"0.58601224",
"0.58596635",
"0.5858648",
"0.58584267",
"0.5852238",
"0.5850639",
"0.5850366",
"0.5850366",
"0.58493954",
"0.58492553",
"0.5846904",
"0.58431965"
] |
0.71503454
|
0
|
POST /master/specs POST /master/specs.xml
|
def create
@master_spec = Master::Spec.new(params[:master_spec])
respond_to do |format|
if @master_spec.save
format.html { redirect_to(@master_spec, :notice => 'Spec was successfully created.') }
format.xml { render :xml => @master_spec, :status => :created, :location => @master_spec }
else
format.html { render :action => "new" }
format.xml { render :xml => @master_spec.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def submit_report(json, cookbookname)\n data = File.read(json)\n uri = URI.parse($SPEC_ENDPOINT)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = uri.scheme == \"https\"\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(\"/api/reports\")\n request.add_field('Content-Type', 'application/json')\n request.body = {\n :spec_result => data,\n :hostname => `hostname`.chomp,\n :cookbook_name => cookbookname\n }.to_json\n response = http.request(request)\n end",
"def new\n @master_spec = Master::Spec.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @master_spec }\n end\n end",
"def do_submission(path, xml = nil)\n if xml.nil?\n form = create(:form, question_types: %w(integer integer))\n form.publish!\n xml = build_odk_submission(form)\n end\n\n # write xml to file\n require 'fileutils'\n FileUtils.mkpath('test/fixtures')\n fixture_file = Rails.root.join('test/fixtures/', ODK_XML_FILE)\n File.open(fixture_file.to_s, 'w') { |f| f.write(xml) }\n\n # Upload and do request.\n uploaded = fixture_file_upload(fixture_file, 'text/xml')\n post(path, {:xml_submission_file => uploaded, :format => 'xml'}, 'HTTP_AUTHORIZATION' => encode_credentials(@user.login, 'password'))\n assigns(:response)\n end",
"def test_post_sample_traces\n header 'Content-Type', 'application/json'\n\n (0..4).each do |i|\n data = File.read \"sample-traces/#{i}.json\"\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n assert last_response.ok?\n end\n end",
"def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end",
"def update\n @master_spec = Master::Spec.find(params[:id])\n\n respond_to do |format|\n if @master_spec.update_attributes(params[:master_spec])\n format.html { redirect_to(@master_spec, :notice => 'Spec was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @master_spec.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def specification_params\n params.require(:specification).permit(:show_order, :spec_title, :status)\n end",
"def create\n @ba_spec = BaSpec.new(params[:ba_spec])\n\n respond_to do |format|\n if @ba_spec.save\n format.html { redirect_to ba_specs_path }\n format.json { render json: @ba_spec, status: :created, location: @ba_spec }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ba_spec.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_report dep_name, user, vars, log\n require 'net/http'\n require 'uri'\n\n returning(Net::HTTP.post_form(\n URI.parse('http://gist.github.com/api/v1/xml/new'),\n {\n \"files[from]\" => user,\n \"files[vars.yml]\" => vars,\n \"files[#{dep_name}.log]\" => log.decolorize\n }\n )) do |response|\n report_report_result dep_name, response\n end.is_a? Net::HTTPSuccess\n end",
"def gen_request_specs\n Dir.glob('spec/requests/*.rb').each do |filename|\n editor = RequestSpecEditor.new(filename)\n editor.add_directions\n end\n end",
"def create\n @specification = Specification.new(params[:specification])\n\n respond_to do |format|\n if @specification.save\n format.html { redirect_to @specification, notice: 'Specification was successfully created.' }\n format.json { render json: @specification, status: :created, location: @specification }\n else\n format.html { render action: \"new\" }\n format.json { render json: @specification.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \t# add actions here\n # This action takes place in the test suite controller\n end",
"def create\n @product_spec = ProductSpec.new(product_spec_params)\n\n respond_to do |format|\n if @product_spec.save\n format.html { redirect_to @product_spec, notice: 'Product spec was successfully created.' }\n format.json { render :show, status: :created, location: @product_spec }\n else\n format.html { render :new }\n format.json { render json: @product_spec.errors, status: :unprocessable_entity }\n end\n end\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 specification_params\n params.require(:specification).permit(:title, :version, :project_id)\n end",
"def save_podspec(filename, spec)\n\t\t \t\topen(filename, 'w') { |f|\n\t\t \t\t\tf.puts spec\n\t\t\t\t}\n\t\t \tend",
"def perform_study_file_upload(filename, study_file_params, study_id)\n file_upload = Rack::Test::UploadedFile.new(Rails.root.join('test', 'test_data', filename))\n study_file_params[:study_file].merge!(upload: file_upload)\n patch \"/single_cell/studies/#{study_id}/upload\", params: study_file_params, headers: {'Content-Type' => 'multipart/form-data'}\nend",
"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 generate_request_spec\n template 'request_spec.rb', File.join('spec/requests', \"#{name.underscore.pluralize}_spec.rb\")\n end",
"def product_spec_params\n params.require(:product_spec).permit(:spree_product_id, :specs_id)\n end",
"def run_serverspec(target_specdir)\n $log.debug 'Running serverspec'\n cmd = \"cd #{target_specdir} && sudo rake spec\"\n $log.debug \"cmd=#{cmd}\"\n result = `#{cmd}`\n puts result\n end",
"def post_config(url_prefix, xml)\n url_prefix = URI.escape(\"#{@jenkins_path}#{url_prefix}\")\n http = Net::HTTP.start(@server_ip, @server_port)\n request = Net::HTTP::Post.new(\"#{url_prefix}\")\n puts \"[INFO] PUT #{url_prefix}\" if @debug\n request.basic_auth @username, @password\n request.body = xml\n request.content_type = 'application/xml'\n response = http.request(request)\n response.code\n end",
"def specification!\n \t\tFile.open(@dir + '/specification.yaml', 'w' ) do |out|\n \t\t\tYAML.dump({:name => @experiment, :date => Time.now, :configuration => Experiment::Config.to_h, :cross_validations => @cvs, :params => @@params}, out )\n \t\tend\n \tend",
"def test_attach_file\n# post :upload, \"note\"=>{\"title\"=>\"my note\"}, \"courseid\"=>\"806350272748085520\",\n# \"processor\"=>{\"id\"=>\"1000001\"}, \"success\"=>\"/course/806350272748085520/ACMA-320/share_notes\", \n# \"upload_id\"=>\"1169944954\", \n# \"failure\"=>\"/course/806350272748085520/ACMA-320/share_notes\"\n \n post :upload, \"noteid\"=>\"816717565610925385\", \"processor\"=>{\"id\"=>\"1000001\"}\n \n end",
"def create\n @test_suite = TestSuite.new(params[:test_suite])\n\n respond_to do |format|\n if @test_suite.save\n format.html { redirect_to(@test_suite, :notice => 'Test suite was successfully created.') }\n format.xml { render :xml => @test_suite, :status => :created, :location => @test_suite }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @test_suite.errors, :status => :unprocessable_entity }\n end\n end\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 writeToXML(fileName)\n f = File.new(fileName, \"w\")\n f.puts \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\"\n f.puts \"<SAFTestBundle \" + \\\n \" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" + \\\n \" xsi:noNamespaceSchemaLocation=\\\"SAFTestBundle.xsd\\\" \" + \\\n \" schemaVersion=\\\"1\\\">\\n\"\n\n # Initial Cases\n f.puts \"<SAFTestCaseList type=\\\"initial\\\" mode=\\\"sequential\\\">\\n\"\n @cases['initial'].each do |c|\n c.saveToXML(f)\n end\n\n @specCases.keys().each do |specName|\n f.puts \"<!-- Initial Cases for spec %s -->\\n\" % [specName.upcase()]\n @specCases[specName]['initial'].each do |c|\n c.saveToXML(f)\n end\n end\n f.puts \"</SAFTestCaseList>\\n\"\n \n # Main Cases\n f.puts \"<SAFTestCaseList type=\\\"main\\\" mode=\\\"%s\\\">\\n\" % [@mainMode]\n @cases['main'].each do |c|\n c.saveToXML(f)\n end\n\n @specCases.keys().each do |specName|\n f.puts \"<!-- Main Cases for spec %s -->\\n\" % [specName.upcase()]\n @specCases[specName]['main'].each do |c|\n c.saveToXML(f)\n end\n end\n f.puts \"</SAFTestCaseList>\\n\"\n\n # Final Cases\n f.puts \"<SAFTestCaseList type=\\\"final\\\" mode=\\\"sequential\\\">\\n\"\n @specCases.keys().each do |specName|\n f.puts \"<!-- Final Cases for spec %s -->\\n\" % [specName.upcase()]\n @specCases[specName]['final'].each do |c|\n c.saveToXML(f)\n end\n end\n\n @cases['final'].each do |c|\n c.saveToXML(f)\n end\n\n f.puts \"</SAFTestCaseList>\\n\"\n \n f.puts \"</SAFTestBundle>\\n\"\n end",
"def create\n @specification = Specification.new(specification_params)\n\n if @specification.save\n audit(@specification, current_user)\n render json: @specification, status: :created, serializer: Web::V1::SpecificationSerializer\n else\n render json: @specification.errors, status: :unprocessable_entity\n end\n end",
"def new_spec_content\n content = JSON.parse(File.read(path = Utils.base + '.shoperb'))\n spec_content = {\n handle: content['handle'],\n compile: {\n stylesheets: ['application.css'],\n javascripts: ['application.js']\n }\n }.to_json\n Dir.mkdir 'config' unless File.exist?('config')\n File.open('config/spec.json', 'w') {|f| f.write(spec_content) }\n spec_content\n end",
"def test_should_create_project_via_API_XML\r\n get \"/logout\"\r\n post \"/projects.xml\", :api_key=>'testapikey',\r\n :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 :created\r\n end",
"def destroy\n @master_spec = Master::Spec.find(params[:id])\n @master_spec.destroy\n\n respond_to do |format|\n format.html { redirect_to(master_specs_url) }\n format.xml { head :ok }\n end\n end",
"def test_run_xml_input\n T2Server::Run.create($uri, WKF_XML, $creds, $conn_params) do |run|\n run.input_port(\"xml\").value =\n \"<hello><yes>hello</yes><no>everybody</no><yes>world</yes></hello>\"\n run.input_port(\"xpath\").value = \"//yes\"\n run.start\n run.wait\n assert_equal(run.output_port(\"nodes\").value, [\"hello\", \"world\"])\n assert(run.delete)\n end\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def create\n @spec_type = SpecType.new(spec_type_params)\n\n respond_to do |format|\n if @spec_type.save\n format.html { redirect_to @spec_type, notice: 'Spec type was successfully created.' }\n format.json { render :show, status: :created, location: @spec_type }\n else\n format.html { render :new }\n format.json { render json: @spec_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_spec\n @spec = Spec.find(params[:id])\n end",
"def set_spec\n @spec = Spec.find(params[:id])\n end",
"def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend",
"def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend",
"def scaffold\n response_json = RestClient.post(api_path, params.except(:action, :controller))\n\n render template: \"rspec/show\", locals: JSON.parse(response_json)\n end",
"def add_spec_to_project\n mkdir_p('doc')\n cp(\"../#{@spec_filename}\", 'doc')\n end",
"def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\treturn \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\tend",
"def spec_params\n params.require(:spec).permit(:name, :role, :class_id)\n end",
"def post_config(url_prefix, xml)\n post_data(url_prefix, xml, 'application/xml;charset=UTF-8')\n end",
"def test_post_then_get\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n id = last_response.body\n\n get \"/traces/#{id}\"\n check_valid_trace last_response.body\n end",
"def test_should_create_post_via_API_XML\r\n get \"/logout\"\r\n post \"/forum_posts.xml\", :api_key=>'testapikey',\r\n :forum_post => {:title=>'API Test Post',\r\n :body=>'Test Post desc',\r\n :user_id=>1}\r\n assert_response :created\r\n end",
"def send_request( xml )\n write( xml )\n read\n end",
"def show\n @master_spec = Master::Spec.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @master_spec }\n end\n end",
"def create\n @especy = Especie.new(params[:especy])\n\n respond_to do |format|\n if @especy.save\n format.html { redirect_to @especy, notice: 'Especie was successfully created.' }\n format.json { render json: @especy, status: :created, location: @especy }\n else\n format.html { render action: \"new\" }\n format.json { render json: @especy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @suite = Suite.new\n @resorts = Resort.all\n @suite.suite_specs.build ##stores nested attributes into memory holds till parent populates\n\n respond_to do |format|\n format.html { render :layout => 'admin_layout'}\n format.xml { render :xml => @suite }\n end\n end",
"def generatesingletestplan\n\trelease = params[:release]\n\tpriority = params[:priority]\n\texectype = params[:exectype]\n\ttimelimit = params[:timelimit]\n\t# получаем с сервера нужные данные\n\tmds = Hash.new()\n\tTCPSocket.open('172.20.5.130', 2000){ |client|\n\t\t# say Hello to server\n\t\tclient.puts \"MasterOnline\"\n\t\tclient.gets\n\t\tclient.puts \"master_set get_singletestplan #{release} #{priority} #{exectype} #{timelimit}\"\n\t\tmds = JSON.parse(client.gets)\n\t\tclient.puts \"master_set close_connection\"\n\t}\n\t# подготавливаем данные для отправки на веб страницу\n\tnewTree = mds\n\t#newTree = newTree[\"TestItem\"][0]\n\t# новое дерево\n\t# вводим фиктивную вершину\n\tvalue = Hash.new()\n\tvalue[:data] = \"Тестирование \" + release\n\t\tfalseAttr = Hash.new()\n\t\tfalseAttr[:class] = \"jstree-checked\"\n\t\tfalseAttr[:id] = \"0001\"\n\t\tfalseAttr[:MethodName] = \"\"\n\t\tfalseAttr[:UnitName] = \"\"\n\tvalue[:attr] = falseAttr\n\t# получаем дерево\n\tchildrens = Array.new()\n\tnewTree[\"TestItem\"].each do |x|\n\t\ttree = createTreeForView(x)\n\t\tchildrens.push(tree)\n\tend\n\tvalue[:children] = childrens\n\trawarray = { :data => value}\n\tmds_for_send = rawarray.to_json\n\trender :text => mds_for_send\n end",
"def output_specs_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: OutputApi.output_specs ...'\n end\n # resource path\n local_var_path = '/outputs/_specs'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/vnd.feedpushr.output-spec.v1+json; type=collection'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<OutputSpec>' \n\n # auth_names\n auth_names = opts[:auth_names] || []\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: OutputApi#output_specs\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def createRun(projectId, suiteId, name, desc, caseids)\r\n\t#{}\"http://testrailgw.jupiter.bbc.co.uk/?action=add_run&project_id=#{projectId}&suite_id=#{suiteId}&name=#{name}&desc={words+to+describe+the+run}&case_ids=1,2,32\"\r\n\tif !(caseids == \"\")\r\n\t\turi = \"http://testrailgw.jupiter.bbc.co.uk/?action=add_run&project_id=#{projectId}&suite_id=#{suiteId}&name=#{name}&desc=#{desc}&case_ids=#{caseids}&sharedSecret=thI5iSourSHAREDsecret\"\r\n\telse\r\n\t\turi = \"http://testrailgw.jupiter.bbc.co.uk/?action=add_run&project_id=#{projectId}&suite_id=#{suiteId}&name=#{name}&desc=#{desc}&sharedSecret=thI5iSourSHAREDsecret\"\r\n\t\t#uri = \"http://testrailgw.jupiter.bbc.co.uk/?action=add_run&project_id=154&suite_id=4176&name=BigTed Active X v2.5.2.7206 - 25/08/2015 16:27&desc=This is a test report for BigTed Active X v2.5.2.7206&sharedSecret=thI5iSourSHAREDsecret\"\r\n\tend\r\n\turi = uri.gsub(\" \", \"%20\")\r\n\r\n\txml_data = open(uri).read\r\n\tif(xml_data.include? '{\"id\":')\r\n\t\trun = xml_data.split('{\"id\":')[1]\r\n\t\trunId = run.split(',\"suite_id\"')[0]\r\n\t\tputs runId\r\n\telse\r\n\t\tputs xml_data\r\n\t\tfail \"Cannot create RUN in Testrail, check Webservice\"\r\n\tend\r\n\r\n\tfiles = \"//zgbwcfs3005.jupiter.bbc.co.uk/QA/Jenkins/Jupiter/ICETEArunid.txt\"\r\n\tf = File.open(files,'w')\r\n\tf.write(runId)\r\n\tf.close\r\nend",
"def post(opts)\n client = HTTPClient.new\n path = opts[:path] || \"meta\"\n type = opts[:type] || \"application/vnd.talis.changeset+xml\"\n\n client = HTTPClient.new\n url = \"http://api.talis.com/stores/#{@store}/#{path}\"\n client.set_auth(url, @settings[:user], @settings[:pass]) if @settings[:user]\n result = client.post(url, opts[:content], 'Content-Type' => type)\n unless [200,201,202,204].include?(result.status)\n raise RepositoryError, \"An error occurred while posting to the Talis store: HTTP code #{result.status}, extra info: #{result.body.content}\"\n end\n result.status\n end",
"def test_new_06\n Curl::Easy.new(TestServlet.url) do|curl|\n curl.http_post\n assert_equal \"POST\\n\", curl.body_str\n end\n end",
"def create\n @testsuite = Testsuite.new(testsuite_params)\n\n respond_to do |format|\n if @testsuite.save\n format.html { redirect_to @testsuite, notice: 'Testsuite was successfully created.' }\n format.json { render :show, status: :created, location: @testsuite }\n else\n format.html { render :new }\n format.json { render json: @testsuite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test_suite = TestSuite.new(test_suite_params)\n\n respond_to do |format|\n if @test_suite.save\n format.html { redirect_to @test_suite, notice: 'Test suite was successfully created.' }\n format.json { render :show, status: :created, location: @test_suite }\n else\n format.html { render :new }\n format.json { render json: @test_suite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @specification = Specification.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @specification }\n end\n end",
"def create\n respond_to do |format|\n format.html do\n @xml_sample = XmlSample.new(params[:xml_sample])\n if @xml_sample.save\n redirect_to @xml_sample, notice: 'Xml sample was successfully created.'\n else\n render action: \"new\"\n end\n end\n format.xml do\n rexml = REXML::Document.new(params[\"xml\"])\n attr = Hash.from_xml(rexml.to_s)\n @xml_sample = XmlSample.new(attr[\"xmlsample\"])\n if @xml_sample.save\n xml = {msg: \"complete\", status: \"OK\"}.to_xml\n else\n xml = {msg: \"failed\", status: \"NG\"}.to_xml\n end\n return render xml: xml\n end\n end\n end",
"def get\n `curl -L -o ./tmp/specs.tar.gz http://github.com/CocoaPods/Specs/tarball/master`\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 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 specs_matching specs\n req = DeferredRequest.pull response_service.uuid, specs\n revised_specs = req && unpack_request(req)\n revised_specs\n end",
"def generate_specfile(builddir)\n File.open(specfile(builddir), \"w\") do |f|\n f.puts render_spec\n end\n end",
"def post_spec\n \"it_behaves_like 'POST', params: {}\"\n end",
"def test_create\n #create a new resourceset\n post :create, :exp=> 'SemanticExpression.new.union(:s,Namespace.lookup(:rdf,:type),Namespace.lookup(:rdfs,:Class))'\n assert @controller.resourceset.resources.size > 0 #assert that set was remove\n assert_response :success #assert that the request was executed successful\n \n end",
"def set_tests_specification\n @tests_specification = TestsSpecification.find(params[:id])\n end",
"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 specs_url\n \"http://#{@host}/#{SPECS_ARCHIVE_FILE}\"\n end",
"def send_post(data_xml,url)\r\n result = @client.post(self.target_uri(url), :body => data_xml , :head => {'Content-Type' => 'application/xml'} ) \r\n raise \"Invalid status #{result.http_status} from server #{@host}:#{@port}\" if(result.http_status != '200') \r\n #reply = Reply.from_xml(result.http_body)\r\n if block_given?\r\n yield(result.http_body)\r\n else\r\n result.http_body\r\n end\r\n end",
"def add_specs(*gem_specs); end",
"def create\n\t\trespond_with Species.create(species_params)\n\tend",
"def create\n @lab_rack = LabRack.new(params[:lab_rack])\n\n respond_to do |format|\n if @lab_rack.save\n format.html { redirect_to(@lab_rack, :notice => 'Lab rack was successfully created.') }\n format.xml { render :xml => @lab_rack, :status => :created, :location => @lab_rack }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lab_rack.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def dummy_data_fuse_response_xml\n path=\"#{Rails.root}/test/data_fuse_example.xml\"\n File.open(path, \"rb\").read\n end",
"def add_specs_to_repo\n UI.puts \"Adding the #{'spec'.pluralize(podspec_files.count)} to repo `#{@repo}'\\n\"\n podspec_files.each do |spec_file|\n spec = Pod::Specification.from_file(spec_file)\n output_path = File.join(repo_specs_dir, spec.name, spec.version.to_s)\n UI.puts \" --> #{get_message(output_path, spec)}\"\n if @local_only\n create_json_in_path(output_path, spec)\n else\n # TODO push to local disabled until virtual repo support\n raise Informative, 'Pushing specs to Artifactory is currently disabled'\n=begin\n begin\n podspec_json_tmp_path = create_json_in_path(output_path, spec)\n rescue => e\n FileUtils.remove(output_path, :force => true)\n raise Informative, \"Error writing spec file in target path '#{output_path}': #{e.message}\"\n end\n\n begin\n push_to_remote(spec, podspec_json_tmp_path)\n rescue => e\n FileUtils.remove(output_path, :force => true)\n raise Informative, \"Error pushing to remote '#{@repo}': #{e.message}\"\n end\n FileUtils.remove(podspec_json_tmp_path, :force => true)\n=end\n end\n end\n end",
"def index\n 3.times { @product.product_specifications.build }\n respond_to do |format|\n format.html { render_template } # index.html.erb\n format.xml { render xml: @product_specifications }\n end\n end",
"def test_submit\n quote_details = SAMPLE_QUOTE_DETAILS.deep_dup\n quote_details['fixed_price_services_requested']['price'] = 1200\n params_hash = {\n udprn: SAMPLE_UDPRN,\n services_required: SAMPLE_SERVICES_REQUIRED,\n payment_terms: SAMPLE_PAYMENT_TERMS,\n quote_details: quote_details.to_json\n }\n first_params_hash = params_hash.deep_dup\n first_params_hash[:quote_details] = SAMPLE_QUOTE_DETAILS.to_json\n post :new_quote_for_property, first_params_hash\n post :new, params_hash\n assert_response 200\n\n quote = Agents::Branches::AssignedAgents::Quote.last\n ### Now lets submit the quote\n post :submit, { udprn: SAMPLE_UDPRN, quote_id: quote.id }\n response = Oj.load(@response.body)\n assert_response 200\n assert_equal response['message'], 'The quote is accepted'\n end",
"def test_new_microtask\r\n #@assignment = assignments(:Assignment_Microtask1)\r\n questionnaire_id = questionnaires(:questionnaire1).id\r\n instructorid = users(:instructor1).id\r\n courseid = courses(:course_object_oriented).id,\r\n number_of_topics = SignUpTopic.count\r\n # create a new assignment\r\n post :new, :assignment => { :name => \"Assignment_Microtask1\",\r\n :directory_path => \"CSC517_instructor1/Assignment_Microtask1\",\r\n :submitter_count => 0,\r\n :course_id => courseid,\r\n :instructor_id => instructorid,\r\n :num_reviews => 1,\r\n :num_review_of_reviews => 0,\r\n :num_review_of_reviewers => 0,\r\n :review_questionnaire_id => questionnaire_id,\r\n :reviews_visible_to_all => 0,\r\n :require_signup => 0,\r\n :num_reviewers => 3,\r\n :team_assignment => 0,\r\n :team_count => 1,\r\n :microtask => true }\r\n\r\n assert_response 200\r\n assert Assignment.find(:all, :conditions => \"name = 'Assignment_Microtask1'\")\r\n\r\n end",
"def suscriber_wm\n\t\turi = URI(\"http://staging.benchprep.com/api/v1/test/fixtures.json\")\t\n\n\t\tres = Net::HTTP.post_form(uri, 'email' => '[email protected]&enrollments_persona=subscriber&devices_persona=web_and_mobile')\n\t\t# write this output to a file\n\t\toutput = File.open( \"spec/fixtures/sp_wm_persona.json\",'w' ){|f| \n\t\t\tf.flock(File::LOCK_EX)\n\t\t\tf.write(res.body)\n\t\t}\n\n\t\t# Now parse this string as json\n\t\tjson = File.read('spec/fixtures/sp_wm_persona.json')\n\t\templs = JSON.parse(json)\n\n\t\treturn empls #pretty printed output\n\tend",
"def post_check(excon, body)\n excon.request(\n method: :post,\n path: '/check',\n headers: { 'Content-Type' => 'application/json' },\n body: body\n )\nend",
"def create\n @specification = Specification.new(specification_params)\n\n @specification.attachment.created_by = current_user\n if @specification.save\n CommonActions.notification_process('Specification', @specification)\n respond_with :specifications\n else\n respond_with @specification\n end\n end",
"def create\n @test_suite = TestSuite.new(params[:test_suite])\n\n respond_to do |format|\n if @test_suite.save\n format.html { redirect_to @test_suite, notice: 'Test suite was successfully created.' }\n format.json { render json: @test_suite, status: :created, location: @test_suite }\n else\n format.html { render action: \"new\" }\n format.json { render json: @test_suite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def postEntityYext_list( entity_id, yext_list_id, description, name, type)\n params = Hash.new\n params['entity_id'] = entity_id\n params['yext_list_id'] = yext_list_id\n params['description'] = description\n params['name'] = name\n params['type'] = type\n return doCurl(\"post\",\"/entity/yext_list\",params)\n end",
"def spec_params\n params.require(:spec).permit(:result_no, :generate_no, :e_no, :ap, :en, :en_recovery, :movement, :weight, :turning_speed, :jump, :max_power, :search, :precision, :punding, :aerosol, :pysics, :spirit, :particle, :flame, :electric, :loading, :max_loading)\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 specdatum_params\n params.require(:specdatum).permit(:gen_info, :proby, :activity,\n :provid, :specialization_id, :file,\n :bootsy_image_gallery_id)\n end",
"def write_specs(path)\n @templates.write_specs(path)\n end",
"def test_get_tags\n post '/repos', {:name => GIT_REPO}\n post \"/repos/#{GIT_REPO}.git/branches/master/files\", {:name => \"myfile.txt\", :data => \"Hello There\", :encoding => \"utf-8\", :user => \"Rune Madsen\", :email => \"[email protected]\", :message => \"My First Commit\"}\n sha = JSON.parse(last_response.body)[\"commit_sha\"]\n post \"/repos/#{GIT_REPO}.git/tags\", {:tag => \"version1\", :message => \"hello\", :sha => sha, :type => \"commit\", :user => \"Rune Madsen\", :email => \"[email protected]\"}\n get \"/repos/#{GIT_REPO}.git/tags\"\n end",
"def create\n @car_specific_spec = CarSpecificSpec.new(car_specific_spec_params)\n\n respond_to do |format|\n if @car_specific_spec.save\n format.html { redirect_to @car_specific_spec, notice: 'Car specific spec was successfully created.' }\n format.json { render :show, status: :created, location: @car_specific_spec }\n else\n format.html { render :new }\n format.json { render json: @car_specific_spec.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(summary, description, assignee, product=\"TestProduct\", component=\"\")\n @log.debug \"Attempting to file a new bug\"\n url = \"#{@url}/enter_bug.cgi?product=#{product}&assigned_to=#{assignee}&component=#{component}\"\n @log.debug url\n page = @agent.get(url)\n form_name = 'Create'\n form = page.form_with(:name => form_name)\n if form\n form['short_desc']=summary\n form['comment']=description\n form['assignee']=assignee\n form['component']=component if not component.empty?\n page = @agent.submit form if not @dummy\n @log.info page.search(\".//td[@id='title']\")[0].content.strip\n # Read the bug number from the page\n return page.search(\".//a[@title='NEW - #{summary}']\")[0].content.match(/Bug ([0-9]+)/)[1] \n else\n @log.error \"Unable to find form with name #{form_name}\"\n end\n end",
"def create(params)\n\nxml =<<XML\n<entry xmlns=\"http://purl.org/atom/ns#\">\n <title>#{params[:title]}</title>\n <link rel=\"related\" type=\"text/html\" href=\"#{params[:url]}\" />\n <summary type=\"text/plain\">#{params[:comment]}</summary>\n</entry>\nXML\n\n post('/post', xml)\n end",
"def create\n @product_specification = ProductSpecification.new(product_specification_params)\n\n respond_to do |format|\n if @product_specification.save\n format.html { redirect_to @product_specification, notice: 'Product specification was successfully created.' }\n format.json { render :show, status: :created, location: @product_specification }\n else\n format.html { render :new }\n format.json { render json: @product_specification.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tooling_specification = ToolingSpecification.new(params[:tooling_specification])\n\n respond_to do |format|\n if @tooling_specification.save\n format.html { redirect_to @tooling_specification, notice: 'Tooling Spec was successfully created.' }\n format.json { render json: @tooling_specification, status: :created, location: @tooling_specification }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tooling_specification.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n begin\n specification_params = params.require(:specification).permit(:name)\n specification = Specification.new(specification_params)\n if specification.save\n @product_specification.specification = specification\n elsif specification = Specification.where(name: specification_params[:name]).first\n @product_specification.specification = specification\n end\n rescue\n # probably didn't have a form that can provide a new Specification\n end\n respond_to do |format|\n if @product_specification.save\n format.html { redirect_to(admin_product_product_specifications_path(@product), notice: 'Product specification was successfully created.') }\n format.xml { render xml: @product_specification, status: :created, location: @product_specification }\n format.js\n website.add_log(user: current_user, action: \"Added a #{@product_specification.specification.name} spec to #{@product_specification.product.name}\")\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @product_specification.errors, status: :unprocessable_entity }\n format.js { render template: \"admin/product_specifications/create_error\" }\n end\n end\n end",
"def new\n @test_suite = TestSuite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @test_suite }\n end\n end",
"def post\n \"\n desc 'create #{resource.singularize}' do\n tags %w[#{resource.singularize}]\n end\n params do\n # TODO: specify the parameters\n end\n post do\n # your code goes here\n end\"\n end",
"def test_commit_comment\n post_to_service(:commit_comment)\n end",
"def write_specs(path)\n SPEC_TEMPLATES.each do |template|\n File.open(File.join(path, template.sub(/dataset/, short_name)), 'w') do |file|\n file.puts render(File.join(SPEC_TEMPLATE_DIR, template))\n end\n end\n true\n end",
"def tests_specification_params\n params.require(:tests_specification)\n .permit(\n :code,\n :limit_time,\n :limit_mem,\n :exercise_id,\n tests_attributes: %I[id\n output\n input\n visible\n _destroy]\n )\n end",
"def create_recipe_request(version, auth_headers, data = {})\n post \"/api/recipes\", params: data, headers: {'Content-Type' => \"application/json\", 'Accept' => \"application/vnd.ink.#{version}\" }.merge(auth_headers)\nend",
"def startTest(client, dtype, dname, logid, passw, ttype, tcsno, wifis, build)\n\n\t\t#$dname = client.waitForDevice(\"\\\"@name='#{dname}' AND @remote='true'\\\"\", 300000)\n\t\t@dtype = dtype\n\t\t@dname = dname\n\t\t@logid = logid\n\t\t@passw = passw\n\t\t@ttype = ttype\n\t\t@tcsno = tcsno\n\t\t@wifis = wifis\n\t\t@build = build\n\n\t\tif @ttype == \"select\"\n\t\t\tx = @tcsno.split \",\"\n\t\t\tputs \"::MSG::TCs to be EXECUTED : #{x}\"\n\t\t\t$total_tc = x.length\n\t\telse\n\t\t\t$total_tc = 37\n\t\tend\n\n\t\tif @dtype == \"ios\"\n\t\t\t#temp: code for reserving a remote iOS device\n\t\t\turi = URI('http://10.4.136.3:8081/api/v1/devices')\n\t\t\treq = Net::HTTP::Get.new(uri)\n\t\t\treq.basic_auth 'admin', 'Unext1101'\n\t\t\t#req.basic_auth 'unext-qa', 'Unextqa1'\n\t\t\tres = Net::HTTP.start(uri.hostname, uri.port) {|http|\n\t\t\t http.request(req)\n\t\t\t}\n\t\t\t#Get the device id for the desired device\n\t\t\tapi_result = JSON.parse(res.body)\n\t\t\tdevices_array = api_result[\"data\"]\n\t\t\trequested_device_id = \"\"\n\t\t\t\n\t\t\tdevices_array.each do |device|\n\t\t\t \tif device[\"deviceName\"] == @dname\n\t\t\t\t\trequested_device_id = device[\"id\"]\t\t\t\t\t\n\t\t\t\tend\n\t\t\tend\n\t\t\t#And now reserve the device\n\t\t\turi = URI('http://10.4.136.3:8081/api/v1/devices/' + requested_device_id + '/reservations/new')\n\t\t\treq = Net::HTTP::Post.new(uri)\n\t\t\treq.basic_auth 'admin', 'Unext1101'\n\t\t\t#req.basic_auth 'unext-qa', 'Unextqa1'\n\t\t\treq.set_form_data('start' => Time.new.strftime(\"%Y-%m-%d-%H-%M-%S\"), 'end' => '2016-12-30-23-00-00', 'clientCurrentTimestamp' => Time.new.strftime(\"%Y-%m-%d-%H-%M-%S\"))\n\t\t\tres = Net::HTTP.start(uri.hostname, uri.port) {|http|\n\t\t\t http.request(req)\n\t\t\t}\n\t\t\tclient.addDevice(\"c24994f50118a6ae9db6a911da628b477a0ba401\", \"ipadair\")\n\t\t\tclient.setDevice(\"#{\"ios_app:\" + @dname}\")\n\t\t\t#client.setDevice(\"#{@dname}\")\n\t\t\t#temp\n\t\t\tclient.openDevice()\n\t\t\tclient.sleep(2000)\n\t\t\t$obj_utili.andConnectingWifi(client, @dtype, @dname, @wifis)\n\t\t\tclient.sleep(2000)\n\t\t\tif @build == nil\n\t\t\t\tputs \"::MSG:: Apps will be using currently installed build\"\n\t\t\telse\n\t\t\t\tputs ($obj_instl.ios_testInstallApps(client, @build))\n\t\t\tend\n\t\t\tclient.launch(\"jp.unext.mediaplayer\", true, false)\n\t\t\tclient.sleep(5000)\n\t\t\t$obj_slctv.iosSelectiveTests(client, @logid, @passw, @ttype, @tcsno)\n\t\telsif @dtype == \"android\"\t\t\t\t\t\t\n\t\t\t#client.setDevice(\"#{$dname}\")\n\t\t\t#client.waitForDevice(\"\\\"@name='#{$dname}' AND @remote='true'\\\"\", 300000)\n\t\t\t#temp: code for reserving a remote iOS device\n\t\t\turi = URI('http://10.4.136.3:8081/api/v1/devices')\n\t\t\treq = Net::HTTP::Get.new(uri)\n\t\t\treq.basic_auth 'admin', 'Unext1101'\n\t\t\t#req.basic_auth 'unext-qa', 'Unextqa1'\n\t\t\tres = Net::HTTP.start(uri.hostname, uri.port) {|http|\n\t\t\t http.request(req)\n\t\t\t}\n\t\t\t#Get the device id for the desired device\n\t\t\tapi_result = JSON.parse(res.body)\n\t\t\tdevices_array = api_result[\"data\"]\n\t\t\trequested_device_id = \"\"\n\t\t\t\n\t\t\tdevices_array.each do |device|\n\t\t\t \tif device[\"deviceName\"] == @dname\n\t\t\t\t\trequested_device_id = device[\"id\"]\t\t\t\t\t\n\t\t\t\tend\n\t\t\tend\n\t\t\t#And now reserve the device\n\t\t\turi = URI('http://10.4.136.3:8081/api/v1/devices/' + requested_device_id + '/reservations/new')\n\t\t\treq = Net::HTTP::Post.new(uri)\n\t\t\treq.basic_auth 'admin', 'Unext1101'\n\t\t\t#req.basic_auth 'unext-qa', 'Unextqa1'\n\t\t\treq.set_form_data('start' => Time.new.strftime(\"%Y-%m-%d-%H-%M-%S\"), 'end' => '2016-12-30-23-00-00', 'clientCurrentTimestamp' => Time.new.strftime(\"%Y-%m-%d-%H-%M-%S\"))\n\t\t\tres = Net::HTTP.start(uri.hostname, uri.port) {|http|\n\t\t\t http.request(req)\n\t\t\t}\n\t\t\tclient.addDevice(\"CB5A233UKX\", \"401SO\")\n\t\t\tclient.setDevice(\"#{@dname}\")\n\t\t\t#temp\n\n\t\t\tclient.openDevice()\n\t\t\tclient.sleep(2000)\n\t\t\t$obj_utili.andConnectingWifi(client, @dtype, @dname, @wifis)\n\t\t\t#CURRENTLY AUTO BUILD FOR ANDROID IS NOT PREPARED, WHEN JENKINS AUTO BUILD WILL BE DELIVERED, TEST CAN BE RESUMED\n\t\t\t#if @build == nil\n\t\t\t#\tputs \"::MSG:: Apps will be using currently installed build\"\n\t\t\t#else\n\t\t\t#\tputs ($obj_instl.testInstallApps(client, @build))\n\t\t\t#end\n\t\t\tclient.launch(\"jp.unext.mediaplayer/jp.co.unext.unextmobile.MainActivity\", true, false)\n\t\t\tclient.sleep(5000)\t\t\t\n\t\t\t$obj_slctv.andSelectiveTests(client, @logid, @passw, @ttype, @tcsno)\t\t\n\t\telse\n\t\t\tputs \"::MSG:: 該当デバイスが見つかりません「Confirm target test devcie」\"\n\t\tend\t\t\n\tend"
] |
[
"0.5847994",
"0.5658567",
"0.5361486",
"0.5327027",
"0.53061795",
"0.5244435",
"0.5230415",
"0.5190378",
"0.5181827",
"0.5166815",
"0.5148998",
"0.513836",
"0.5131548",
"0.5130455",
"0.51065415",
"0.50868356",
"0.50819963",
"0.50566936",
"0.5020518",
"0.5010084",
"0.5005596",
"0.49940842",
"0.49935856",
"0.49650228",
"0.49612015",
"0.49600247",
"0.49445197",
"0.49385995",
"0.49341288",
"0.49254262",
"0.4924918",
"0.49215028",
"0.49026486",
"0.48743236",
"0.48709866",
"0.48709866",
"0.48680067",
"0.48678568",
"0.48671973",
"0.48641098",
"0.48429796",
"0.4822977",
"0.48166767",
"0.48124424",
"0.4808396",
"0.48048645",
"0.4791679",
"0.47869322",
"0.47734985",
"0.47720224",
"0.47693354",
"0.4757514",
"0.47570053",
"0.47502208",
"0.4746407",
"0.4746201",
"0.47439545",
"0.47427437",
"0.47422877",
"0.473729",
"0.47366768",
"0.47280693",
"0.47234756",
"0.47198656",
"0.471607",
"0.47153017",
"0.47142085",
"0.47131085",
"0.47113672",
"0.47096333",
"0.47090444",
"0.47046912",
"0.47022057",
"0.47005188",
"0.4698877",
"0.46893468",
"0.46777964",
"0.46770424",
"0.46740004",
"0.4668312",
"0.46671727",
"0.46665987",
"0.46664348",
"0.46635583",
"0.4658453",
"0.46533534",
"0.46530467",
"0.4652689",
"0.4650664",
"0.46402737",
"0.46314648",
"0.46102878",
"0.46100518",
"0.46090755",
"0.460828",
"0.46052557",
"0.4603322",
"0.46022195",
"0.45963365",
"0.45936662"
] |
0.6442089
|
0
|
PUT /master/specs/1 PUT /master/specs/1.xml
|
def update
@master_spec = Master::Spec.find(params[:id])
respond_to do |format|
if @master_spec.update_attributes(params[:master_spec])
format.html { redirect_to(@master_spec, :notice => 'Spec was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @master_spec.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 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 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_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 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 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 test_put_expenses_1_xml\n @parameters = {:expense => {:description => 'NewDescription'}}\n if ActiveRecord::VERSION::MAJOR < 4\n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/expenses/1.xml',\n {:expense => {:description => 'NewDescription'}},\n {:success_code => :ok})\n end\n\n assert_no_difference('Expense.count') do\n put '/expenses/1.xml', @parameters, credentials('admin')\n end\n\n expense = Expense.find(1)\n assert_equal \"NewDescription\", expense.description\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update(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 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 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 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_specfiles(version)\n spec_files.each do |spec_file|\n spec = File.read(spec_file)\n spec.gsub!(/^(\\s*)Version:(\\s*).*$/, \"\\\\1Version:\\\\2#{version}\")\n File.write(spec_file, spec)\n end\nend",
"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 put(path = '/files/', params = {})\n request :put, path, params\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 perform_study_file_upload(filename, study_file_params, study_id)\n file_upload = Rack::Test::UploadedFile.new(Rails.root.join('test', 'test_data', filename))\n study_file_params[:study_file].merge!(upload: file_upload)\n patch \"/single_cell/studies/#{study_id}/upload\", params: study_file_params, headers: {'Content-Type' => 'multipart/form-data'}\nend",
"def put!\n request! :put\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def solveticket(assigneeid, ticketidxml)\n\n raise ArgumentError.new(\"no assignee is present\") if assigneeid.empty?\n raise ArgumentError.new(\"ticketid is present text provided\") if ticketidxml.empty?\n\n xml = createsolvedticketxml(assigneeid)\n\n begin\n resource = RestClient::Resource.new @hostname, @username, @password\n url = 'tickets/'+ ticketidxml\n httpresponse = resource[url].put xml.to_s, :content_type => 'application/xml', :accept => '*/*'\n processresponse(httpresponse) # call success handler\n rescue => e\n processerror(e) # call error handler\n end\n\n end",
"def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end",
"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 put(path, opts = {})\n request(:put, path, opts).body\n end",
"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 => '[email protected]',\r\n :user_id => 1 }\r\n assert_response 401\r\n end",
"def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end",
"def update options={}\n client.put(\"/#{id}\", options)\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 update\n @xml_sample = XmlSample.find(params[:id])\n \n respond_to do |format|\n format.html do\n @xml_sample = XmlSample.update_attributes(params[:xml_sample])\n if @xml_sample.save\n return redirect_to @xml_sample, notice: 'Xml sample was successfully updated.'\n else\n return render action: \"new\"\n end\n end\n format.xml do\n rexml = REXML::Document.new(params[\"xml\"])\n attr = Hash.from_xml(rexml.to_s)\n if @xml_sample.update_attributes(attr[\"xmlsample\"])\n xml = {msg: \"complete\", status: \"OK\"}.to_xml\n else\n xml = {msg: \"failed\", status: \"NG\"}.to_xml\n end\n return render xml: xml\n end\n end\n end",
"def create\n @master_spec = Master::Spec.new(params[:master_spec])\n\n respond_to do |format|\n if @master_spec.save\n format.html { redirect_to(@master_spec, :notice => 'Spec was successfully created.') }\n format.xml { render :xml => @master_spec, :status => :created, :location => @master_spec }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @master_spec.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(*args)\n request :put, *args\n end",
"def test_put_success\n put \"/blah\", @test_obj do |response|\n assert response.ok?, \"Update test object failed\"\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\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 update(uri, payload)\n url = \"#{@config[:base_url]}#{@config[:rest_path]}/#{extract_pid(uri)}\"\n request = Request.new(\n \"Put\", url, payload.to_s, {\n \"Accept\" => \"application/json\",\n \"Content-Type\" => \"application/json\",\n \"Content-Length\" => \"nnnn\",\n @auth_header => @token\n }\n )\n response = request.perform\n response\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n fn = params[:id].gsub('DOTDOT','.').gsub('SLASHSLASH','/')\n File.open(fn,'w+') { |f| \n f.puts params[:content]\n }\n respond_to do |format|\n format.json { render json: { success: true} }\n end\n end",
"def set_spec\n @spec = Spec.find(params[:id])\n end",
"def set_spec\n @spec = Spec.find(params[:id])\n end",
"def destroy\n @master_spec = Master::Spec.find(params[:id])\n @master_spec.destroy\n\n respond_to do |format|\n format.html { redirect_to(master_specs_url) }\n format.xml { head :ok }\n end\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"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 update\n @especy = Especie.find(params[:id])\n\n respond_to do |format|\n if @especy.update_attributes(params[:especy])\n format.html { redirect_to @especy, notice: 'Especie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @especy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def http_put(request, response)\n body = request.body_as_stream\n path = request.path\n\n # Intercepting Content-Range\n if request.header('Content-Range')\n # An origin server that allows PUT on a given target resource MUST send\n # a 400 (Bad Request) response to a PUT request that contains a\n # Content-Range header field.\n #\n # Reference: http://tools.ietf.org/html/rfc7231#section-4.3.4\n fail Exception::BadRequest, 'Content-Range on PUT requests are forbidden.'\n end\n\n # Intercepting the Finder problem\n expected = request.header('X-Expected-Entity-Length').to_i\n if expected > 0\n # Many webservers will not cooperate well with Finder PUT requests,\n # because it uses 'Chunked' transfer encoding for the request body.\n #\n # The symptom of this problem is that Finder sends files to the\n # server, but they arrive as 0-length files in PHP.\n #\n # If we don't do anything, the user might think they are uploading\n # files successfully, but they end up empty on the server. Instead,\n # we throw back an error if we detect this.\n #\n # The reason Finder uses Chunked, is because it thinks the files\n # might change as it's being uploaded, and therefore the\n # Content-Length can vary.\n #\n # Instead it sends the X-Expected-Entity-Length header with the size\n # of the file at the very start of the request. If this header is set,\n # but we don't get a request body we will fail the request to\n # protect the end-user.\n\n # Only reading first byte\n first_byte = body.read(1)\n unless first_byte\n fail Exception::Forbidden, 'This server is not compatible with OS/X finder. Consider using a different WebDAV client or webserver.'\n end\n\n # The body needs to stay intact, so we copy everything to a\n # temporary stream.\n\n new_body = StringIO.new\n new_body.write(first_byte)\n IO.copy_stream(body, new_body)\n new_body.rewind\n\n body = new_body\n end\n\n if @server.tree.node_exists(path)\n node = @server.tree.node_for_path(path)\n\n # If the node is a collection, we'll deny it\n unless node.is_a?(IFile)\n fail Exception::Conflict, 'PUT is not allowed on non-files.'\n end\n\n etag = Box.new\n return false unless @server.update_file(path, body, etag)\n etag = etag.value\n\n response.update_header('Content-Length', '0')\n response.update_header('ETag', etag) if etag\n response.status = 204\n else\n # If we got here, the resource didn't exist yet.\n etag = Box.new\n unless @server.create_file(path, body, etag)\n # For one reason or another the file was not created.\n return false\n end\n etag = etag.value\n\n response.update_header('Content-Length', '0')\n response.update_header('ETag', etag) if etag\n response.status = 201\n end\n\n # Sending back false will interupt the event chain and tell the server\n # we've handled this method.\n false\n end",
"def save\n @client.patch(@endpoint, :content=>@changed)\n return nil\n end",
"def put(path, params = {}, env = {}, &block)\n env[:request_method] = \"PUT\"\n mock_request(path, params, env, &block)\n end",
"def update\n head :ok\n end",
"def update(context, name, should)\n res = context.transport.put_request(context, \"blobstores/#{should[:type]}/#{name}\", should[:attributes])\n\n context.err(res.body) unless res.success?\n end",
"def put(path, opts = {}, &block)\n request(:put, path, opts, &block)\n end",
"def put(path, opts = {}, &block)\n request(:put, path, opts, &block)\n end",
"def api_put(path, data = {})\n api_request(:put, path, :data => data)\n end",
"def render_put\n respond_to do |wants| \n wants.html {render :to_xml => 'PUT.xml.builder', :layout => false, :status => 200}\n wants.json {render :to_json => 'PUT.xml.builder', :status => 200}\n wants.xml {render :to_xml => 'PUT.xml.builder', :layout => false, :status => 200}\n wants.yaml {render :to_yaml => 'PUT.xml.builder', :status => 200}\n end \n end",
"def put(path, params={})\n RestClient.put request_base+path, params\n end",
"def update\n @lab_rack = LabRack.find(params[:id])\n\n respond_to do |format|\n if @lab_rack.update_attributes(params[:lab_rack])\n format.html { redirect_to(@lab_rack, :notice => 'Lab rack was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lab_rack.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(path, options={})\n request :put, path, options\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def update\n @specification = Specification.find(params[:id])\n\n respond_to do |format|\n if @specification.update_attributes(params[:specification])\n format.html { redirect_to @specification, notice: 'Specification was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @specification.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_update\n set = ResourceSet.new('SemanticExpression.new().spo(\\'<http://www.w3.org/2000/01/rdf-schema#Class>\\',\\'<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>\\',\\'<http://www.w3.org/2000/01/rdf-schema#Class>\\')') \n size = set.resources.size\n #create a new resourceset. Note that the expression must return more resource than the first one.\n #we will check the number of resources to verify whether the set was updated.\n post :update, :exp => 'SemanticExpression.new.union(:s,Namespace.lookup(:rdf,:type),:o)', :id => set.rsid\n assert @controller.resourceset.resources.size > size #assert that set was remove\n assert_response :success #assert that the request was executed successful\nend",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def update_metadata(params)\n @client.put(metadata_path, nil, params, \"Content-Type\" => \"application/json\")\n end",
"def test_putpoi_delete_not_found\n changeset = create(:changeset)\n cs_id = changeset.id\n user = changeset.user\n\n amf_content \"putpoi\", \"/1\", [\"#{user.email}:test\", cs_id, 1, 999999, 0, 0, {}, false]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 3, result.size\n assert_equal -4, result[0]\n assert_equal \"node\", result[1]\n assert_equal 999999, result[2]\n end",
"def put(path, doc = nil, options = {})\n execute('PUT', path, options, doc)\n end",
"def update\n @server_rack = ServerRack.find(params[:id])\n\n respond_to do |format|\n if @server_rack.update_attributes(params[:server_rack])\n format.html { redirect_to(@server_rack, :notice => 'Server rack was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @server_rack.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(path, params)\n request(:put, path, params)\n end",
"def test_change_status\n expected = 200\n post_id = 1\n data = {\n status: 1\n }\n uri = URI.parse('http://localhost:3000/v1/posts/'+post_id.to_s+'/status')\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end",
"def update_changeset(xml, changeset_id)\n xml_attr_rewrite(xml, \"changeset\", changeset_id)\n end",
"def update\n put :update\n end",
"def test_update\n\n subsection_01_1_2 = subsections(:subsection_01_1_2)\n subsection_01_1_1 = subsections(:subsection_01_1_1)\n subsect = Subsection.find(subsection_01_1_2.id)\n assert_equal(subsection_01_1_1.url, subsect.url)\n\n subsect.url = 'www.yahoo.com'\n post(:update, { :subsection => subsect.attributes }, cathy_admin_session)\n assert_equal('Subsection was successfully updated.', flash['notice'])\n assert_redirected_to(:controller => 'checklist',\n\t\t\t :action => 'edit',\n :id => subsection_01_1_1.checklist.id)\n\n end",
"def put(path, params)\n parse_response @client[path].put(params)\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 multipart_put(path, params = {}, env = {}, &block)\n env[:request_method] = \"PUT\"\n env[:test_with_multipart] = true\n mock_request(path, params, env, &block)\n end",
"def test_update\n ## First test with no user credentials\n # try and update a node without authorisation\n # first try to delete node without auth\n private_user = create(:user, :data_public => false)\n private_node = create(:node, :changeset => create(:changeset, :user => private_user))\n user = create(:user)\n node = create(:node, :changeset => create(:changeset, :user => user))\n\n content node.to_xml\n put :update, :params => { :id => node.id }\n assert_response :unauthorized\n\n ## Second test with the private user\n\n # setup auth\n basic_authorization private_user.email, \"test\"\n\n ## trying to break changesets\n\n # try and update in someone else's changeset\n content update_changeset(private_node.to_xml,\n create(:changeset).id)\n put :update, :params => { :id => private_node.id }\n assert_require_public_data \"update with other user's changeset should be forbidden when data isn't public\"\n\n # try and update in a closed changeset\n content update_changeset(private_node.to_xml,\n create(:changeset, :closed, :user => private_user).id)\n put :update, :params => { :id => private_node.id }\n assert_require_public_data \"update with closed changeset should be forbidden, when data isn't public\"\n\n # try and update in a non-existant changeset\n content update_changeset(private_node.to_xml, 0)\n put :update, :params => { :id => private_node.id }\n assert_require_public_data \"update with changeset=0 should be forbidden, when data isn't public\"\n\n ## try and submit invalid updates\n content xml_attr_rewrite(private_node.to_xml, \"lat\", 91.0)\n put :update, :params => { :id => private_node.id }\n assert_require_public_data \"node at lat=91 should be forbidden, when data isn't public\"\n\n content xml_attr_rewrite(private_node.to_xml, \"lat\", -91.0)\n put :update, :params => { :id => private_node.id }\n assert_require_public_data \"node at lat=-91 should be forbidden, when data isn't public\"\n\n content xml_attr_rewrite(private_node.to_xml, \"lon\", 181.0)\n put :update, :params => { :id => private_node.id }\n assert_require_public_data \"node at lon=181 should be forbidden, when data isn't public\"\n\n content xml_attr_rewrite(private_node.to_xml, \"lon\", -181.0)\n put :update, :params => { :id => private_node.id }\n assert_require_public_data \"node at lon=-181 should be forbidden, when data isn't public\"\n\n ## finally, produce a good request which still won't work\n content private_node.to_xml\n put :update, :params => { :id => private_node.id }\n assert_require_public_data \"should have failed with a forbidden when data isn't public\"\n\n ## Finally test with the public user\n\n # try and update a node without authorisation\n # first try to update node without auth\n content node.to_xml\n put :update, :params => { :id => node.id }\n assert_response :forbidden\n\n # setup auth\n basic_authorization user.email, \"test\"\n\n ## trying to break changesets\n\n # try and update in someone else's changeset\n content update_changeset(node.to_xml,\n create(:changeset).id)\n put :update, :params => { :id => node.id }\n assert_response :conflict, \"update with other user's changeset should be rejected\"\n\n # try and update in a closed changeset\n content update_changeset(node.to_xml,\n create(:changeset, :closed, :user => user).id)\n put :update, :params => { :id => node.id }\n assert_response :conflict, \"update with closed changeset should be rejected\"\n\n # try and update in a non-existant changeset\n content update_changeset(node.to_xml, 0)\n put :update, :params => { :id => node.id }\n assert_response :conflict, \"update with changeset=0 should be rejected\"\n\n ## try and submit invalid updates\n content xml_attr_rewrite(node.to_xml, \"lat\", 91.0)\n put :update, :params => { :id => node.id }\n assert_response :bad_request, \"node at lat=91 should be rejected\"\n\n content xml_attr_rewrite(node.to_xml, \"lat\", -91.0)\n put :update, :params => { :id => node.id }\n assert_response :bad_request, \"node at lat=-91 should be rejected\"\n\n content xml_attr_rewrite(node.to_xml, \"lon\", 181.0)\n put :update, :params => { :id => node.id }\n assert_response :bad_request, \"node at lon=181 should be rejected\"\n\n content xml_attr_rewrite(node.to_xml, \"lon\", -181.0)\n put :update, :params => { :id => node.id }\n assert_response :bad_request, \"node at lon=-181 should be rejected\"\n\n ## next, attack the versioning\n current_node_version = node.version\n\n # try and submit a version behind\n content xml_attr_rewrite(node.to_xml,\n \"version\", current_node_version - 1)\n put :update, :params => { :id => node.id }\n assert_response :conflict, \"should have failed on old version number\"\n\n # try and submit a version ahead\n content xml_attr_rewrite(node.to_xml,\n \"version\", current_node_version + 1)\n put :update, :params => { :id => node.id }\n assert_response :conflict, \"should have failed on skipped version number\"\n\n # try and submit total crap in the version field\n content xml_attr_rewrite(node.to_xml,\n \"version\", \"p1r4t3s!\")\n put :update, :params => { :id => node.id }\n assert_response :conflict,\n \"should not be able to put 'p1r4at3s!' in the version field\"\n\n ## try an update with the wrong ID\n content create(:node).to_xml\n put :update, :params => { :id => node.id }\n assert_response :bad_request,\n \"should not be able to update a node with a different ID from the XML\"\n\n ## try an update with a minimal valid XML doc which isn't a well-formed OSM doc.\n content \"<update/>\"\n put :update, :params => { :id => node.id }\n assert_response :bad_request,\n \"should not be able to update a node with non-OSM XML doc.\"\n\n ## finally, produce a good request which should work\n content node.to_xml\n put :update, :params => { :id => node.id }\n assert_response :success, \"a valid update request failed\"\n end",
"def save\n return if @content.nil?\n put_rest \"extra/#{@name}\", @content, :content_type => \"application/octet-stream\"\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def test_update_successful\n data = {\n firstname: \"Anh\",\n lastname: \"Hoang\",\n avatar: \"avatar.png\",\n address: \"111D Ly Chinh Thang\",\n city: \"Ho Chi Minh\",\n email: \"[email protected]\",\n mobile: \"0309433343545\",\n gender: 1,\n birthday: \"1991/10/10\"\n }\n\n user_id = 28\n expected = 200\n uri = URI.parse('http://localhost:3000/v1/users/'+user_id.to_s)\n\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end",
"def put(uri, doc = nil, options = {})\n execute(uri, :put, options, doc)\n end",
"def update\n @ba_spec = BaSpec.find(params[:id])\n\n respond_to do |format|\n if @ba_spec.update_attributes(params[:ba_spec])\n format.html { redirect_to session[:return_to] }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ba_spec.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, data, params = {}, request_options = {})\n request(:put, path, data, params)\n end",
"def update\n respond_to do |format|\n if @tests_specification.update(tests_specification_params)\n format.html { redirect_to edit_tests_specification_path(@tests_specification), notice: \"Tests specification was successfully updated.\" }\n format.json { render :show, status: :ok, location: @tests_specification }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @tests_specification.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, data = {})\n request 'PUT', path, body: data.to_json\n end",
"def put(path, parameters = {})\n request(:put, path, parameters)\n end",
"def update\n @specie = Specie.find(params[:id])\n\n respond_to do |format|\n if @specie.update_attributes(params[:specie])\n format.html { redirect_to @specie, notice: 'Specie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @specie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @system.update(system_params)\n format.html { redirect_to([:admin, @system], notice: 'System was successfully updated.') }\n format.xml { head :ok }\n website.add_log(user: current_user, action: \"Updated spec: #{@system.name}\")\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @system.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put\n RestClient.put(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def put(path_part, payload, additional_headers = {}, &block)\n api_request { @rest.put('/REST/' + path_part, payload.to_json, additional_headers, &block) }\n end",
"def update\n @expectation_stem = RiGse::ExpectationStem.find(params[:id])\n\n respond_to do |format|\n if @expectation_stem.update_attributes(params[:expectation_stem])\n flash[:notice] = 'RiGse::ExpectationStem.was successfully updated.'\n format.html { redirect_to(@expectation_stem) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @expectation_stem.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit_xml(path, &block)\n write path, xml(path).tap(&block).to_s\n end",
"def put(path, body = nil, ctype = 'application/json')\n make_call(mk_conn(path, 'Content-Type': ctype,\n 'Accept': 'application/json'),\n :put, nil, body.to_json)\n end",
"def template_update(id, type, filename)\n check_id_or_raise id\n check_template_type_or_raise type\n check_filename_or_raise filename\n response = http_request_multipart :put, @base_url + \"/templates/#{id}.xml\", 200,\n { :provider_key => @provider_key,\n :draft => File.read(filename), \n :multipart => true}\n puts 'at update call'\n _id, _updated_at = parse_response response, type\n response = http_request :put, \"#{@base_url}/templates/#{id}/publish\", 200,\n { :params => { :provider_key => @provider_key } }\n puts 'at publish call'\n parse_response response, 'page'\n end",
"def update\n @vdocs_requirement = VdocsRequirement.find(params[:id])\n\t@contract = @vdocs_requirement.contract\n\n respond_to do |format|\n if @vdocs_requirement.update_attributes(params[:vdocs_requirement])\n flash[:notice] = 'VdocsRequirement was successfully updated.'\n format.html { redirect_to(@vdocs_requirement) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @vdocs_requirement.errors, :status => :unprocessable_entity }\n end\n end\n end"
] |
[
"0.64990985",
"0.62210554",
"0.6115232",
"0.60151887",
"0.5976467",
"0.5941422",
"0.59266657",
"0.5835868",
"0.57190835",
"0.56962234",
"0.5635543",
"0.56301236",
"0.5626566",
"0.56115407",
"0.55938125",
"0.55379415",
"0.54916644",
"0.5470896",
"0.5440586",
"0.541428",
"0.5388051",
"0.5347009",
"0.53375435",
"0.53165275",
"0.528799",
"0.5232678",
"0.5226988",
"0.52253103",
"0.52243215",
"0.52162236",
"0.5187328",
"0.51788986",
"0.5173157",
"0.5172627",
"0.5162773",
"0.5150531",
"0.5143136",
"0.51367944",
"0.51367944",
"0.5130663",
"0.512834",
"0.512834",
"0.512834",
"0.5124886",
"0.5115869",
"0.5113311",
"0.5110684",
"0.50991386",
"0.50863326",
"0.50836945",
"0.5071833",
"0.5071833",
"0.50664186",
"0.5062838",
"0.50576717",
"0.5055266",
"0.50525707",
"0.50512755",
"0.50512755",
"0.50512755",
"0.50512755",
"0.50512755",
"0.50512755",
"0.50512755",
"0.50512755",
"0.5043192",
"0.5041818",
"0.5041606",
"0.5041606",
"0.5033392",
"0.5028075",
"0.5025457",
"0.50199383",
"0.5016853",
"0.50060207",
"0.49915227",
"0.4984192",
"0.49840474",
"0.49822605",
"0.49799904",
"0.4979835",
"0.49797732",
"0.4973534",
"0.497292",
"0.4969399",
"0.49653065",
"0.49630684",
"0.49587476",
"0.4955419",
"0.4948684",
"0.494459",
"0.49394667",
"0.4920578",
"0.49204335",
"0.49153686",
"0.49149197",
"0.49132085",
"0.4903914",
"0.48950985",
"0.48926273"
] |
0.64523923
|
1
|
DELETE /master/specs/1 DELETE /master/specs/1.xml
|
def destroy
@master_spec = Master::Spec.find(params[:id])
@master_spec.destroy
respond_to do |format|
format.html { redirect_to(master_specs_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 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_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 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 chef_server_rest.delete(\"nodes/#{name}\")\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 destroy\n @testmaster = Testmaster.find(params[:id])\n @testmaster.destroy\n\n respond_to do |format|\n format.html { redirect_to(testmasters_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @expectation = RiGse::Expectation.find(params[:id])\n @expectation.destroy\n\n respond_to do |format|\n format.html { redirect_to(expectations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @test_suite = TestSuite.find(params[:id])\n @test_suite.destroy\n\n respond_to do |format|\n format.html { redirect_to(test_suites_url) }\n format.xml { head :ok }\n end\n end",
"def test_043\n test_000\n login(\"root\",\"root\")\n register_master(\"normal\", MASTER_FILES[\"normal\"])\n master_chosen = Master.find(:last)\n all_segments_of_master = Segment.find_all_by_fk_id(master_chosen)\n assert_not_equal all_segments_of_master, []\n delete_master\n wait_for_text_present(_(\" deleted successfully!\"))\n all_segments_of_master = Segment.find_all_by_fk_id(master_chosen)\n assert_equal all_segments_of_master, []\n logout\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", 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 destroy\n @user_testcase_xref = UserTestcaseXref.find(params[:id])\n @user_testcase_xref.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_testcase_xrefs_url) }\n format.xml { head :ok }\n end\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def destroy\n @auto1h_fold_change = Auto1hFoldChange.find(params[:id])\n @auto1h_fold_change.destroy\n\n respond_to do |format|\n format.html { redirect_to(auto1h_fold_changes_url) }\n format.xml { head :ok }\n end\n end",
"def delete(name)\n\n end",
"def delete(name); end",
"def delete(name); end",
"def cmd_delete argv\n setup argv\n e = @hash['element']\n response = @api.delete(e)\n msg response\n return response\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 @ba_spec = BaSpec.find(params[:id])\n @ba_spec.destroy\n\n respond_to do |format|\n format.html { redirect_to ba_specs_url }\n format.json { head :no_content }\n end\n end",
"def test_045\n test_000\n login(\"root\",\"root\")\n register_master(\"normal\", MASTER_FILES[\"normal\"])\n master_chosen = Master.find(:last)\n all_temp_file_of_master = TempFile.find_all_by_master_id(master_chosen)\n delete_master\n wait_for_text_present(_(\" deleted successfully!\"))\n all_temp_file_of_master = TempFile.find_all_by_master_id(master_chosen)\n assert_equal all_temp_file_of_master, []\n logout\n end",
"def test_044\n test_000\n login(\"root\",\"root\")\n register_master(\"normal\", MASTER_FILES[\"normal\"])\n master_chosen = Master.find(:last)\n all_directory_tree_of_master = DirectoryTree.find_all_by_fk_id(master_chosen)\n assert_not_equal all_directory_tree_of_master, []\n delete_master\n wait_for_text_present(_(\" deleted successfully!\"))\n all_directory_tree_of_master= DirectoryTree.find_all_by_fk_id(master_chosen)\n assert_equal all_directory_tree_of_master, []\n logout\n end",
"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 delete(name)\n @ctx.delete(@path + name)\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 @test = Mg::Test.find(params[:id])\n @test.destroy\n\n respond_to do |format|\n format.html { redirect_to(mg_tests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @suite = Suite.find(params[:id])\n @suite.destroy\n\n respond_to do |format|\n format.html { redirect_to(suites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @suite = Suite.find(params[:id])\n @suite.destroy\n\n respond_to do |format|\n format.html { redirect_to(suites_url) }\n format.xml { head :ok }\n end\n end",
"def delete_from_disk; end",
"def rm(*path)\n super; on_success{ nil }\n end",
"def delete(command)\n pp @client.files.delete(clean_up(command[1]))\n end",
"def test_del\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 id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def delete_demo(id)\n delete_record \"/demos/#{id}\"\n end",
"def destroy\n @configattribmaster.destroy\n respond_to do |format|\n format.html { redirect_to configattribmasters_url, notice: 'Configattribmaster was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @target_def = TargetDef.find(params[:id])\n @target_def.destroy\n\n respond_to do |format|\n format.html { redirect_to(target_defs_url) }\n format.xml { head :ok }\n end\n end",
"def delete_file(filename,repo)\n curl_delete(\"#{self.host}/api2/repos/#{repo}/file/?p=#{filename}\").body_str\n end",
"def destroy\n @expectation_stem = RiGse::ExpectationStem.find(params[:id])\n @expectation_stem.destroy\n\n respond_to do |format|\n format.html { redirect_to(expectation_stems_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_xmls_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end",
"def destroy\n #FIXME: Double check auth is working for deletion. Also, maybe should only delete if not associated with any experiments.\n @data_file.destroy\n \n respond_to do |format|\n format.html { redirect_to(data_files_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @file_version.destroy\n head :no_content\n end",
"def destroy\n @testcase = Testcase.find(params[:id])\n @testcase.destroy\n\n respond_to do |format|\n format.html { redirect_to(testcases_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @config_file = ConfigFile.find(params[:id])\n @config_file.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_files_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n Iterable.request(conf, base_path).delete\n end",
"def teardown\n File.delete 'file.xml' if File.exists?('file.xml')\n File.delete '.file.xml.duxml' if File.exists?('.file.xml.duxml')\n end",
"def destroy\n @atest = Atest.find(params[:id])\n @atest.destroy\n\n respond_to do |format|\n format.html { redirect_to(atests_url) }\n format.xml { head :ok }\n end\n end",
"def delete(*uris); end",
"def rm path\n end",
"def destroy\n @erratum = Erratum.find(params[:id])\n @erratum.destroy\n\n respond_to do |format|\n format.html { redirect_to(errata_url) }\n format.xml { head :ok }\n end\n end",
"def delete(path)\n make_call(mk_conn(path), :delete)\n end",
"def delete\n start { |connection| connection.request http :Delete }\n end",
"def destroy\n @node_config = NodeConfig.destroy(params[:id])\n xml=@node_config.to_xml\n json=@node_config.to_json\n @node_config.destroy\n\n respond_to do |format|\n format.html { redirect_to(node_configs_url) }\n format.json { render :json => json}\n format.xml { render :xml => xml}\n end\n end",
"def destroy\n @vdocs_requirement = VdocsRequirement.find(params[:id])\n @vdocs_requirement.destroy\n\n respond_to do |format|\n format.html { redirect_to(vdocs_requirements_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @test_test = TestTest.find(params[:id])\n @test_test.destroy\n\n respond_to do |format|\n format.html { redirect_to(test_tests_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 @yml_file = Cmtool::YmlFile.find(params[:id])\n @yml_file.destroy\n\n respond_to do |format|\n format.html { redirect_to(cmtool.yml_files_url, notice: I18n.t('cmtool.action.destroy.successful', model: Cmtool::YmlFile.model_name.human)) }\n format.xml { head :ok }\n end\n end",
"def delete_by_id id, opts = {}\n update opts.merge(:data => xml.delete_by_id(id))\n end",
"def del\n delete\n end",
"def destroy\n @req_breakdown = ReqBreakdown.find(params[:id])\n @req_breakdown.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_req_breakdowns_url) }\n format.xml { head :ok }\n end\n end",
"def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def destroy\n @chef_att_source.destroy\n respond_to do |format|\n format.html { redirect_to chef_att_sources_url, notice: 'Chef att source was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\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 @genbank_file.destroy\n\n respond_to do |format|\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy1\n @compare = Compare.find(params[:id])\n @compare.destroy\n\n respond_to do |format|\n format.html { redirect_to(compares_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n \n end",
"def delete\n end",
"def delete\n request(:delete)\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 test_remove_a_file\n a.rm(\"one\").commit(\"a removed one\")\n \n assert_equal nil, a['one']\n assert_equal \"one content\", b['one']\n \n b.pull\n \n assert_equal nil, a['one']\n assert_equal nil, b['one']\n \n assert_log_equal [\n \"a added one\",\n \"a removed one\"\n ], b\n end",
"def destroy\n @expectation = Expectation.find(params[:id])\n @expectation.destroy\n\n respond_to do |format|\n format.html { redirect_to expectations_url }\n format.json { head :no_content }\n end\n end",
"def delete!\n\t\t\tClient.delete @root\n\t\tend",
"def delete(filename); end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def delete\n delete_from_server single_url\n end",
"def delete(path)\n root.delete(path)\n end",
"def delete_checksums\n # puts \"Del: #{@basename}\"\n @pkgdb.query(\"delete from checksums where basename = '#{@basename}'\")\n end",
"def test_delete_file()\n\n path = 'folder/FileTest.pdf'\n versionId = nil\n storage = 'First Storage'\n request = DeleteFileRequest.new(path, versionId, storage)\n\n result = @storage_api.delete_file(request)\n assert result.code == 200,'Error while deleting document'\n\n end",
"def destroy\n @test_case = current_user.test_cases.find(params[:id])\n @test_case.logical_delete\n \n respond_to do |format|\n format.html { redirect_to(test_cases_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @admin_test = Admin::Test.find(params[:id])\n @admin_test.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_tests_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n\n end",
"def destroy\n @tm_dev1 = TmDev1.find(params[:id])\n @tm_dev1.destroy\n\n respond_to do |format|\n format.html { redirect_to(tm_dev1s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy; delete end",
"def deleteEssence\n \n begin\n \n # Gets @filename and @path\n getPathAndFilename \n name = @filename \n filepath = @path\n puts \"filepath: \" + filepath \n puts \"filename: \" + name\n \n # Find the device \n device = User.find_by_username(params[:username]).devices.find_by_dev_name(params[:devicename])\n \n # Essence can't be deleted from a virtual container\n if device.dev_type == \"virtual_container\"\n render :text => \"Error: Essence can't be deleted from a virtual container'\", :status => 409\n return \n end\n \n file = nil\n if device != nil\n file = device.devfiles.find(:first, :conditions => [\"name = ? and path = ?\", name, filepath])\n if file == nil\n puts \"FILE NOT FOUND: \" + name\n render :text => \"Error. File's metadata can not be found.\", :status => 404\n return\n end\n \n if params[:blob_hash]\n blob = file.blobs.find(:first, :conditions => [\"blob_hash = ?\", params[:blob_hash]])\n else\n blob = file.blobs.find_by_follower_id(nil)\n end\n end\n \n # Checks that the file's and it's version's metadata can be found in database.\n if file == nil or blob == nil\n puts \"Blob not found for file: \" + name\n render :text => \"Error. File's metadata can not be found.\", :status => 404\n return\n end\n \n if blob.uploaded == false\n render :text => \"Error: Essence of the file was not on the server.\", :status => 409\n return\n end\n \n # Remove the fileupload entry\n fup = Fileupload.find_by_blob_id(blob.id)\n if fup != nil\n fup.destroy\n end\n \n # Update blob not to be uploaded and upload_requested to nil\n blob.update_attribute(:uploaded, false)\n blob.update_attribute(:upload_requested, nil)\n \n \n # Remove the actual essence\n deletepath = \"public/devfiles/\" + file.device_id.to_s + \"/\" + blob.blob_hash + \"_\" + file.name\n \n if File.exists?(deletepath)\n FileUtils.rm_f(deletepath)\n puts \"deleted the essence...\"\n else\n puts \"Essence not found and could not be deleted...\"\n end\n \n rescue => exp\n putsE(exp)\n render :text => \"There was an error when trying to delete the essence from the server\", :status => 409\n return\n end\n \n render :text => \"Essence of the file deleted from the server\", :status => 200\n return\n end",
"def destroy\n @normal_example = NormalExample.find(params[:id])\n @normal_example.destroy\n\n respond_to do |format|\n format.html { redirect_to(normal_examples_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @child_dupa2 = ChildDupa2.find(params[:id])\n @child_dupa2.destroy\n\n respond_to do |format|\n format.html { redirect_to(child_dupa2s_url) }\n format.xml { head :ok }\n end\n end",
"def delete_all(xpath); end",
"def destroy\n @colonoscopytest = Colonoscopytest.find(params[:id])\n @colonoscopytest.destroy\n\n respond_to do |format|\n format.html { redirect_to(colonoscopytests_url) }\n format.xml { head :ok }\n end\n end",
"def delete(*rest) end",
"def destroy\n @test = TkdTest.find(params[:id])\n @test.destroy\n\n respond_to do |format|\n format.html { redirect_to(:action => :index) }\n format.xml { head :ok }\n end\n end",
"def destroy\n self.class.mongo_client.database.fs.find(:_id=>BSON::ObjectId.from_string(@id)).delete_one\n end",
"def destroy\n self.class.mongo_client.database.fs.find(:_id=>BSON::ObjectId.from_string(@id)).delete_one\n end",
"def delete!\n Recliner.delete(uri)\n end",
"def destroy\n @childmaster = Childmaster.find(params[:id])\n @childmaster.destroy\n\n respond_to do |format|\n format.html { redirect_to(childmasters_url) }\n format.xml { head :ok }\n end\n end"
] |
[
"0.6665547",
"0.6332672",
"0.62881094",
"0.6220732",
"0.6220732",
"0.62166125",
"0.6187354",
"0.618502",
"0.6128621",
"0.6082107",
"0.60667366",
"0.606662",
"0.6064507",
"0.60605204",
"0.60419977",
"0.60294765",
"0.6011616",
"0.5998494",
"0.59954184",
"0.59954184",
"0.599276",
"0.59850645",
"0.59750706",
"0.59708345",
"0.5967526",
"0.59659773",
"0.59653956",
"0.59649587",
"0.5955084",
"0.59540063",
"0.59540063",
"0.5938398",
"0.5935572",
"0.59292245",
"0.5926553",
"0.5921962",
"0.5921147",
"0.59159845",
"0.5914451",
"0.5906271",
"0.5893753",
"0.5890179",
"0.58871007",
"0.5886975",
"0.58849365",
"0.5881889",
"0.588178",
"0.58782023",
"0.5875295",
"0.5875141",
"0.5874861",
"0.58729905",
"0.5868716",
"0.58666825",
"0.58639634",
"0.5853109",
"0.5850463",
"0.58493704",
"0.5843229",
"0.58417374",
"0.584149",
"0.58328885",
"0.58277124",
"0.58273983",
"0.58232623",
"0.58228946",
"0.5817764",
"0.58174455",
"0.58122927",
"0.5811531",
"0.58086455",
"0.5807391",
"0.5807391",
"0.5807391",
"0.5807391",
"0.5805389",
"0.5795958",
"0.5790289",
"0.57848597",
"0.5784011",
"0.5783134",
"0.578254",
"0.577839",
"0.57775825",
"0.5774242",
"0.5765777",
"0.57655656",
"0.57642037",
"0.5759087",
"0.57557243",
"0.5754154",
"0.5744844",
"0.574409",
"0.5743693",
"0.57363886",
"0.5735736",
"0.5729965",
"0.5729965",
"0.57284117",
"0.5726177"
] |
0.70528185
|
0
|
GET /sales GET /sales.json
|
def index
@sales = Sale.all
render json: @sales
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @sales = @saleService.all_to_json().as_json;\n end",
"def show\n render json: @invoice, methods: [:sales]\n end",
"def show\n render json: @sale\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def sales\n FarMar::Sale.get_by(\"vendor\", id)\n end",
"def index\n @pre_sales = PreSale.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pre_sales }\n end\n end",
"def index\n @sells = Sell.all\n\n render json: @sells\n end",
"def show\n @sale = Sale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sale }\n end\n end",
"def show\n @sale = Sale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sale }\n end\n end",
"def getDate\n @sales = Sale.where(\"date = ?\", params[:date])\n render json: @sales\n end",
"def sales(options = {})\n options[:product_id] = epages_id(options[:product_id]) if options[:product_id]\n perform_get_with_object('/sales', format_dates_options(options), Epages::SalesSummary)\n end",
"def sales\n Sale.find_all_by_vendor_id(@id)\n end",
"def show\n @sales_datum = SalesDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_datum }\n end\n end",
"def salesApi\n require 'uri'\n require 'net/http'\n require 'json'\n\n #Arrays for each category\n \n @frequency = Hash.new(0)\n\n url = URI(\"https://api.salesloft.com/v2/people.json\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n\n request = Net::HTTP::Get.new(url)\n request[\"Authorization\"] = 'Bearer ' + ENV[\"API_KEY\"]\n\n response = http.request(request)\n \n @body = JSON.parse(response.body)['data']\n return @body\n end",
"def index\n @sales = Sale\n .where(\"EXTRACT(MONTH FROM transaction_date)=EXTRACT(MONTH FROM CURRENT_DATE) AND EXTRACT(YEAR FROM transaction_date)=EXTRACT(YEAR FROM CURRENT_DATE)\")\n .order(:created_at).reverse_order\n .pagination(params[:page])\n\n @customers = Customer.order(:name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sales }\n format.js\n end\n end",
"def index\n @sales_productivities = SalesProductivity.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sales_productivities }\n end\n end",
"def index\n @sale_orders = current_company.sale_orders.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sale_orders }\n end\n end",
"def index\n @salespeople = Salesperson.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @salespeople }\n end\n end",
"def index\n @product_sales = ProductSale.all\n end",
"def index\n @sales = Sale.paginate(:page => params[:page], :per_page => 10)\n end",
"def index\n @sales_ads = SalesAd.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sales_ads }\n end\n end",
"def show\n @sales_productivity = SalesProductivity.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_productivity }\n end\n end",
"def show\n @sale_day_total = SaleDayTotal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sale_day_total }\n end\n end",
"def index\n @sales_items = SalesItem.all\n end",
"def index\n page = params[:page].to_i\n limit = params[:limit].to_i\n offset = (page - 1) * limit\n\n results = Sale.joins(:product, :status, :sale_lead)\n .order(time: :desc)\n .select(\n 'sales.id',\n 'sales.customer',\n 'sales.demand',\n 'sales.connection',\n 'sales.email',\n 'sales.phone',\n 'sales.time',\n 'statuses.name AS status_name',\n 'products.name AS product_name',\n 'sale_leads.name AS sale_lead_name',\n ).limit(limit).offset(offset)\n\n count = results.length\n\n (statuses, products, sale_leads) = [Status, Product, SaleLead].map(&:names)\n\n render json: {\n items: results,\n statusOptions: statuses,\n productOptions: products,\n leadOptions: sale_leads,\n total: count,\n }, status: :ok\n end",
"def show\n @sales_order = SalesOrder.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_order }\n end\n end",
"def alltime_sales(type, product_ids=[], options={})\n accept_types = %w{products products+countries countries countries+products}\n raise ArgumentError, \"Type must be one of TYPE: #{accept_types}\" unless accept_types.include?(type)\n product_ids = [product_ids] unless product_ids.is_a?(Array)\n\n options.merge!({:basic_auth => @auth, :products => product_ids.join(\";\")})\n url = \"/reports/sales/#{type}\"\n self.class.get(url, options)\n end",
"def show\n @sales_term = SalesTerm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_term }\n end\n end",
"def index\n @gross_revenue = Sale.sum(:sale_total)\n @sales = Sale.order('created_at desc').page params[:page]\n end",
"def sales\n end",
"def index\n @sales_products = SalesProduct.all\n end",
"def index\n @sales = Sale.where(env: nil, user_id: current_user.id)\n end",
"def get_sale\n sales.first\n end",
"def index\n @sales_entries = SalesEntry.all\n end",
"def index\n events = Event.where(team: current_team)\n @sales = Sale.where(event: events)\n end",
"def show\n @sales_ad = SalesAd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_ad }\n end\n end",
"def index\n @origin_sales = OriginSale.paginate(:page => params[:page], :per_page => 10)\n end",
"def sales_invoice(id)\n get \"sales_invoices/#{id}\"\n end",
"def index\n render json: Seller.all\n end",
"def show\n render json: @sell\n end",
"def sales(type, start_date, end_date, product_ids, options={})\n raise ArgumentError, \"Type must be one of TYPE: #{TYPE.values.join(\", \")}\" unless TYPE.values.index(type)\n raise ArgumentError, \"Type must be one of DATASOURCE: #{DATASOURCE.values.join(\", \")}\" if (options[:data_source] && !DATASOURCE.values.index(options[:data_source]))\n\n product_ids = [product_ids] unless product_ids.is_a?(Array)\n options.merge!({:basic_auth => @auth, :product_ids => product_ids.join(\";\")})\n url = \"/sales/#{type}/#{start_date}/#{end_date}/\" \n self.class.get(url, options)\n end",
"def index\n @business_sales = BusinessSale.all\n end",
"def sale_get(api_key, opts = {})\n data, _status_code, _headers = sale_get_with_http_info(api_key, opts)\n return data\n end",
"def sale_get_sales_with_http_info(site_id, version, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SaleApi.sale_get_sales ...'\n end\n # verify the required parameter 'site_id' is set\n if @api_client.config.client_side_validation && site_id.nil?\n fail ArgumentError, \"Missing the required parameter 'site_id' when calling SaleApi.sale_get_sales\"\n end\n # verify the required parameter 'version' is set\n if @api_client.config.client_side_validation && version.nil?\n fail ArgumentError, \"Missing the required parameter 'version' when calling SaleApi.sale_get_sales\"\n end\n # resource path\n local_var_path = '/public/v{version}/sale/sales'.sub('{' + 'version' + '}', version.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml', 'multipart/form-data'])\n header_params[:'siteId'] = site_id\n header_params[:'authorization'] = opts[:'authorization'] if !opts[:'authorization'].nil?\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 => 'GetSalesResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SaleApi#sale_get_sales\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def sale_get_with_http_info(api_key, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: SaleApi.sale_get ...\"\n end\n # verify the required parameter 'api_key' is set\n if @api_client.config.client_side_validation && api_key.nil?\n fail ArgumentError, \"Missing the required parameter 'api_key' when calling SaleApi.sale_get\"\n end\n # resource path\n local_var_path = \"/api/Sale\"\n\n # query parameters\n query_params = {}\n query_params[:'saleId'] = opts[:'sale_id'] if !opts[:'sale_id'].nil?\n query_params[:'maxRecords'] = opts[:'max_records'] if !opts[:'max_records'].nil?\n query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?\n query_params[:'to'] = opts[:'to'] if !opts[:'to'].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', 'text/json', 'application/xml', 'text/xml'])\n header_params[:'ApiKey'] = api_key\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 => 'Array<SwiftPOSVenue>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SaleApi#sale_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def sale\n ret = nil\n if @json_body.include?('sale_id')\n ret = @mc2p.sale('id' => @json_body['sale_id'])\n ret.retrieve\n end\n ret\n end",
"def index\n @shop_special_offers_transactions = Shop::SpecialOffersTransaction.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shop_special_offers_transactions }\n end\n end",
"def index\n @shop = Shop.find(1)\n render :json => @shop\n return\n end",
"def get_sale_all_using_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SupportApi.get_sale_all_using_get ...'\n end\n # resource path\n local_var_path = '/sales'\n\n # query parameters\n query_params = {}\n query_params[:'ascending'] = opts[:'ascending'] if !opts[:'ascending'].nil?\n query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?\n query_params[:'order_by'] = opts[:'order_by'] if !opts[:'order_by'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PageSale')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SupportApi#get_sale_all_using_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @revenue = Revenue.find(params[:id])\n\n render json: @revenue\n end",
"def index\n all=Sale.where(active:true)\n ventas= resumen all \n\n render json:ventas\n end",
"def index\n @items = @sale.items\n end",
"def index\n @expenses = find_expenses.all\n render json: @expenses\n end",
"def index\n @purchases = Purchase.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @purchases }\n end\n end",
"def index\n @purchases = Purchase.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @purchases }\n end\n end",
"def show\n @pre_sale = PreSale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pre_sale }\n end\n end",
"def index\n @sales_channels = SalesChannel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @sales_channels }\n end\n end",
"def index\n @msales = Msale.all \n end",
"def show\n @sales_code = SalesCode.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_code }\n end\n end",
"def show\n @sales_team = SalesTeam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_team }\n end\n end",
"def index\n \n @sales_types = SalesType.find_all_by_company_id(current_user.company_id)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sales_types }\n end\n \n end",
"def sales\n return array_of_instances(FarMar::Sale.all, \"product_id\", product_id)\n end",
"def index\n @accesory_sales = AccesorySale.all\n end",
"def get_sale_using_get_with_http_info(sales_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SupportApi.get_sale_using_get ...'\n end\n # verify the required parameter 'sales_id' is set\n if @api_client.config.client_side_validation && sales_id.nil?\n fail ArgumentError, \"Missing the required parameter 'sales_id' when calling SupportApi.get_sale_using_get\"\n end\n # resource path\n local_var_path = '/sales/{sales_id}'.sub('{' + 'sales_id' + '}', sales_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Sale')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SupportApi#get_sale_using_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @salesperson = Salesperson.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @salesperson }\n end\n end",
"def index\n @cal_month_sales = CalMonthSale.paginate(page: params[:page])\n end",
"def index\n @sales_orders = SalesOrder.all\n end",
"def show\n @product_sold = ProductSold.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product_sold }\n end\n end",
"def index\n @salespeople = Salesperson.all\n end",
"def sales\n FarMar::Sale.all.find_all { |sale| sale.product_id == id }\n end",
"def index\n @sales_sellers = Sales::Seller.all\n end",
"def sales\n FarMar::Sale.all.find_all { |sale| sale.product_id == @id }\n end",
"def get_sale\n @ventad = Sale.find(params[:sale_id])\n end",
"def show\n @d_sale_item = DSaleItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @d_sale_item }\n end\n end",
"def index\n @taxes = Tax.all\n\n render json: @taxes\n end",
"def index\n @totals = {subtotal: 0, iva: 0, retencion: 0, other_concepts: 0, total: 0 }\n @title = t('view.sale_invoices.index_title', month: @monthly_movement.month, year: @monthly_movement.year)\n if params[:firm].present?\n @sale_invoices = @monthly_movement.sale_invoices.where('firms.nombre LIKE ?', \"%#{params[:firm]}%\")\n else\n @sale_invoices = @monthly_movement.sale_invoices\n end\n\n @sale_invoices = @sale_invoices.includes(:firm).order('date asc')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sale_invoices }\n end\n end",
"def region_sales(start_date, end_date, options={})\n options.merge!({:basic_auth => @auth})\n url = \"/sales/regions/#{start_date}/#{end_date}\" \n self.class.get(url, options)\n end",
"def index\n \tcustomers = Customer.all\n \trender json: customers\n \tend",
"def index\n @requested_sales_documents = RequestedSalesDocument.all\n end",
"def index\n @per_page = 5\n @sales = Sale.paginate(per_page: @per_page, page: params[:page])\n end",
"def index\n @sales_channel = SalesChannel.find(params[:sales_channel_id])\n @sales_channel_apis = @sales_channel.apis\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @sales_channel_apis }\n end\n end",
"def sales\n FarMar::Sale.all.find_all {|instance| instance.product_id == id}\n end",
"def new\n @sale = Sale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sale }\n end\n end",
"def new\n @sale = Sale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sale }\n end\n end",
"def new\n @sale = Sale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sale }\n end\n end",
"def index\n @stores = Store.all\n render json: @stores\n end",
"def index\n @title = t('view.sellers.index_title')\n @sellers = Seller.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sellers }\n end\n end",
"def index\n @supermarkets = Supermarket.all\n respond_to do |format|\n format.json { render json: @supermarkets, status: :ok } \n end \n end",
"def show\n @sell = Sell.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sell }\n end\n end",
"def sales(ven_id)\n FarMar::Sale.all.find_all { |sale_item| sale_item.vendor_id == ven_id }\n end",
"def index\r\n @sales_orders = @customer.sales_orders\r\n end",
"def index\n @point_of_sales = PointOfSale.all\n end",
"def index\n @purchases = Purchase.where(user_id: get_current_user.id.to_i)\n\n render json: @purchases\n end",
"def index\n @shops = Shop.all\n @search = Shop.search(params[:q])\n @shops = @search.result.page(params[:page]).per(30)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shops }\n end\n\n end"
] |
[
"0.81421864",
"0.7505555",
"0.734486",
"0.7266149",
"0.7266149",
"0.7266149",
"0.7266149",
"0.7266149",
"0.7266149",
"0.7266149",
"0.72475237",
"0.72210985",
"0.7124364",
"0.70870465",
"0.70870465",
"0.70577073",
"0.7030278",
"0.7018311",
"0.7000222",
"0.695755",
"0.6918693",
"0.6913336",
"0.69009894",
"0.6893327",
"0.68326914",
"0.68264455",
"0.6824798",
"0.67539334",
"0.67476624",
"0.67344403",
"0.66926336",
"0.66874474",
"0.6669207",
"0.6660905",
"0.664095",
"0.6622472",
"0.66127956",
"0.66123605",
"0.65953815",
"0.65807784",
"0.6574215",
"0.6568011",
"0.65150636",
"0.65019417",
"0.64999413",
"0.6492696",
"0.64781034",
"0.6438235",
"0.64363533",
"0.6425327",
"0.63947934",
"0.6390681",
"0.6389564",
"0.63786036",
"0.63757765",
"0.63530433",
"0.6351176",
"0.6349149",
"0.6329553",
"0.6321324",
"0.6321324",
"0.6317992",
"0.63138777",
"0.631296",
"0.63128906",
"0.63075155",
"0.6305501",
"0.6300866",
"0.62991124",
"0.6292738",
"0.6287233",
"0.62834585",
"0.6283388",
"0.6271291",
"0.62600857",
"0.6259189",
"0.62528294",
"0.6250087",
"0.6247792",
"0.6239319",
"0.6235117",
"0.6227909",
"0.6225621",
"0.622369",
"0.6220835",
"0.62130433",
"0.62080926",
"0.6184317",
"0.6175794",
"0.6175794",
"0.6175794",
"0.6168391",
"0.6158758",
"0.61509687",
"0.6145044",
"0.61399096",
"0.61338013",
"0.6131609",
"0.6131464",
"0.6109602"
] |
0.8167744
|
0
|
GET /sales/1 GET /sales/1.json
|
def show
render json: @sale
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @sales = Sale.all\n\n render json: @sales\n end",
"def index\n @sales = @saleService.all_to_json().as_json;\n end",
"def show\n render json: @invoice, methods: [:sales]\n end",
"def show\n @sale = Sale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sale }\n end\n end",
"def show\n @sale = Sale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sale }\n end\n end",
"def show\n @sales_datum = SalesDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_datum }\n end\n end",
"def index\n @pre_sales = PreSale.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pre_sales }\n end\n end",
"def getDate\n @sales = Sale.where(\"date = ?\", params[:date])\n render json: @sales\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def show\n @sales_productivity = SalesProductivity.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_productivity }\n end\n end",
"def sales\n FarMar::Sale.get_by(\"vendor\", id)\n end",
"def index\n @sells = Sell.all\n\n render json: @sells\n end",
"def show\n @sales_order = SalesOrder.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_order }\n end\n end",
"def get_sale\n sales.first\n end",
"def index\n @sales_productivities = SalesProductivity.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sales_productivities }\n end\n end",
"def show\n @sale_day_total = SaleDayTotal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sale_day_total }\n end\n end",
"def index\n @sales = Sale\n .where(\"EXTRACT(MONTH FROM transaction_date)=EXTRACT(MONTH FROM CURRENT_DATE) AND EXTRACT(YEAR FROM transaction_date)=EXTRACT(YEAR FROM CURRENT_DATE)\")\n .order(:created_at).reverse_order\n .pagination(params[:page])\n\n @customers = Customer.order(:name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sales }\n format.js\n end\n end",
"def index\n @sale_orders = current_company.sale_orders.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sale_orders }\n end\n end",
"def sales\n Sale.find_all_by_vendor_id(@id)\n end",
"def index\n @salespeople = Salesperson.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @salespeople }\n end\n end",
"def show\n @sales_term = SalesTerm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_term }\n end\n end",
"def show\n @sales_ad = SalesAd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_ad }\n end\n end",
"def index\n @sales_items = SalesItem.all\n end",
"def index\n @sales = Sale.paginate(:page => params[:page], :per_page => 10)\n end",
"def index\n @product_sales = ProductSale.all\n end",
"def sales_invoice(id)\n get \"sales_invoices/#{id}\"\n end",
"def index\n @shop = Shop.find(1)\n render :json => @shop\n return\n end",
"def index\n @sales_ads = SalesAd.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sales_ads }\n end\n end",
"def show\n @pre_sale = PreSale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pre_sale }\n end\n end",
"def show\n @sales_code = SalesCode.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_code }\n end\n end",
"def show\n @d_sale_item = DSaleItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @d_sale_item }\n end\n end",
"def index\n page = params[:page].to_i\n limit = params[:limit].to_i\n offset = (page - 1) * limit\n\n results = Sale.joins(:product, :status, :sale_lead)\n .order(time: :desc)\n .select(\n 'sales.id',\n 'sales.customer',\n 'sales.demand',\n 'sales.connection',\n 'sales.email',\n 'sales.phone',\n 'sales.time',\n 'statuses.name AS status_name',\n 'products.name AS product_name',\n 'sale_leads.name AS sale_lead_name',\n ).limit(limit).offset(offset)\n\n count = results.length\n\n (statuses, products, sale_leads) = [Status, Product, SaleLead].map(&:names)\n\n render json: {\n items: results,\n statusOptions: statuses,\n productOptions: products,\n leadOptions: sale_leads,\n total: count,\n }, status: :ok\n end",
"def salesApi\n require 'uri'\n require 'net/http'\n require 'json'\n\n #Arrays for each category\n \n @frequency = Hash.new(0)\n\n url = URI(\"https://api.salesloft.com/v2/people.json\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n\n request = Net::HTTP::Get.new(url)\n request[\"Authorization\"] = 'Bearer ' + ENV[\"API_KEY\"]\n\n response = http.request(request)\n \n @body = JSON.parse(response.body)['data']\n return @body\n end",
"def show\n @revenue = Revenue.find(params[:id])\n\n render json: @revenue\n end",
"def show\n @salesperson = Salesperson.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @salesperson }\n end\n end",
"def sales(options = {})\n options[:product_id] = epages_id(options[:product_id]) if options[:product_id]\n perform_get_with_object('/sales', format_dates_options(options), Epages::SalesSummary)\n end",
"def index\n @sales_products = SalesProduct.all\n end",
"def index\n @sales_entries = SalesEntry.all\n end",
"def alltime_sales(type, product_ids=[], options={})\n accept_types = %w{products products+countries countries countries+products}\n raise ArgumentError, \"Type must be one of TYPE: #{accept_types}\" unless accept_types.include?(type)\n product_ids = [product_ids] unless product_ids.is_a?(Array)\n\n options.merge!({:basic_auth => @auth, :products => product_ids.join(\";\")})\n url = \"/reports/sales/#{type}\"\n self.class.get(url, options)\n end",
"def index\n @sales = Sale.where(env: nil, user_id: current_user.id)\n end",
"def index\n @purchases = Purchase.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @purchases }\n end\n end",
"def index\n @purchases = Purchase.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @purchases }\n end\n end",
"def show\n @title = t('view.sale_invoices.show_title')\n @sale_invoice = SaleInvoice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sale_invoice }\n end\n end",
"def show\n @product_sold = ProductSold.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product_sold }\n end\n end",
"def show\n render json: @sell\n end",
"def new\n @sale = Sale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sale }\n end\n end",
"def new\n @sale = Sale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sale }\n end\n end",
"def new\n @sale = Sale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sale }\n end\n end",
"def index\n @api_v1_stores = Store.all\n json_response(@api_v1_stores)\n end",
"def get_sale\n @ventad = Sale.find(params[:sale_id])\n end",
"def show\n @sales_team = SalesTeam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_team }\n end\n end",
"def index\n render json: Seller.all\n end",
"def sale\n ret = nil\n if @json_body.include?('sale_id')\n ret = @mc2p.sale('id' => @json_body['sale_id'])\n ret.retrieve\n end\n ret\n end",
"def index\n @shop_special_offers_transactions = Shop::SpecialOffersTransaction.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shop_special_offers_transactions }\n end\n end",
"def show\n @supermarket = Supermarket.find(params[:id])\n respond_to do |format|\n format.json { render json: @supermarket, status: :ok } \n end \n end",
"def index\n @items = @sale.items\n end",
"def sales\n end",
"def index\n @origin_sales = OriginSale.paginate(:page => params[:page], :per_page => 10)\n end",
"def show\n @sale = Sale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sale }\n end\n end",
"def show\n @sale = Sale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sale }\n end\n end",
"def sale_get_sales_with_http_info(site_id, version, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SaleApi.sale_get_sales ...'\n end\n # verify the required parameter 'site_id' is set\n if @api_client.config.client_side_validation && site_id.nil?\n fail ArgumentError, \"Missing the required parameter 'site_id' when calling SaleApi.sale_get_sales\"\n end\n # verify the required parameter 'version' is set\n if @api_client.config.client_side_validation && version.nil?\n fail ArgumentError, \"Missing the required parameter 'version' when calling SaleApi.sale_get_sales\"\n end\n # resource path\n local_var_path = '/public/v{version}/sale/sales'.sub('{' + 'version' + '}', version.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml', 'multipart/form-data'])\n header_params[:'siteId'] = site_id\n header_params[:'authorization'] = opts[:'authorization'] if !opts[:'authorization'].nil?\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 => 'GetSalesResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SaleApi#sale_get_sales\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @sell = Sell.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sell }\n end\n end",
"def index\n @supermarkets = Supermarket.all\n respond_to do |format|\n format.json { render json: @supermarkets, status: :ok } \n end \n end",
"def index\n all=Sale.where(active:true)\n ventas= resumen all \n\n render json:ventas\n end",
"def show\n @sales_rep = SalesRep.find(params[:id])\n # @follow_up = FollowUp.new\n # @meeting = Meeting.new\n # @client = Client.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_rep }\n end\n end",
"def index\n \tcustomers = Customer.all\n \trender json: customers\n \tend",
"def index\n @business_sales = BusinessSale.all\n end",
"def show\n @shop_purchase = Shop::Purchase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shop_purchase }\n end\n end",
"def index\n @gross_revenue = Sale.sum(:sale_total)\n @sales = Sale.order('created_at desc').page params[:page]\n end",
"def index\n events = Event.where(team: current_team)\n @sales = Sale.where(event: events)\n end",
"def sale_get_with_http_info(api_key, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: SaleApi.sale_get ...\"\n end\n # verify the required parameter 'api_key' is set\n if @api_client.config.client_side_validation && api_key.nil?\n fail ArgumentError, \"Missing the required parameter 'api_key' when calling SaleApi.sale_get\"\n end\n # resource path\n local_var_path = \"/api/Sale\"\n\n # query parameters\n query_params = {}\n query_params[:'saleId'] = opts[:'sale_id'] if !opts[:'sale_id'].nil?\n query_params[:'maxRecords'] = opts[:'max_records'] if !opts[:'max_records'].nil?\n query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?\n query_params[:'to'] = opts[:'to'] if !opts[:'to'].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', 'text/json', 'application/xml', 'text/xml'])\n header_params[:'ApiKey'] = api_key\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 => 'Array<SwiftPOSVenue>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SaleApi#sale_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n\n @sales_type = SalesType.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sales_type }\n end\n \n end",
"def index\n \n @sales_types = SalesType.find_all_by_company_id(current_user.company_id)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sales_types }\n end\n \n end",
"def search\n render json: Consultation.first(10)\n end",
"def index\n @sales_channels = SalesChannel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @sales_channels }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n @store_cust_group = CustomerGroup.find_by_name(\"Bakul/Toko\")\n @workshop_cust_group = CustomerGroup.find_by_name(\"Bengkel/Montir\")\n\n @sale_histories = SaleDetail.where(:product_id => @product.id).order(:updated_at).reverse_order.limit(10)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def index\n @purchases = Purchase.where(user_id: get_current_user.id.to_i)\n\n render json: @purchases\n end",
"def new\n @sales_datum = SalesDatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sales_datum }\n end\n end",
"def sales(type, start_date, end_date, product_ids, options={})\n raise ArgumentError, \"Type must be one of TYPE: #{TYPE.values.join(\", \")}\" unless TYPE.values.index(type)\n raise ArgumentError, \"Type must be one of DATASOURCE: #{DATASOURCE.values.join(\", \")}\" if (options[:data_source] && !DATASOURCE.values.index(options[:data_source]))\n\n product_ids = [product_ids] unless product_ids.is_a?(Array)\n options.merge!({:basic_auth => @auth, :product_ids => product_ids.join(\";\")})\n url = \"/sales/#{type}/#{start_date}/#{end_date}/\" \n self.class.get(url, options)\n end",
"def show\n @sales_channel = SalesChannel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @sales_channel }\n end\n end",
"def show\n render json: @shop\n end",
"def index\n @totals = {subtotal: 0, iva: 0, retencion: 0, other_concepts: 0, total: 0 }\n @title = t('view.sale_invoices.index_title', month: @monthly_movement.month, year: @monthly_movement.year)\n if params[:firm].present?\n @sale_invoices = @monthly_movement.sale_invoices.where('firms.nombre LIKE ?', \"%#{params[:firm]}%\")\n else\n @sale_invoices = @monthly_movement.sale_invoices\n end\n\n @sale_invoices = @sale_invoices.includes(:firm).order('date asc')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sale_invoices }\n end\n end",
"def show\n @shop_special_offers_transaction = Shop::SpecialOffersTransaction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shop_special_offers_transaction }\n end\n end",
"def set_sale\n @sale = Sale.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n render json: {\n success: false,\n msg: 'Sale not found',\n }\n end",
"def show\n @shop = Shop.find(params[:id])\n @rates = @shop.rates.page(params[:page])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shop }\n end\n end",
"def show\n @customer = Customer.includes(:invoices).find(params[:id].split(\",\"))\n\n render json: @customer\n end",
"def get_sale_using_get_with_http_info(sales_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SupportApi.get_sale_using_get ...'\n end\n # verify the required parameter 'sales_id' is set\n if @api_client.config.client_side_validation && sales_id.nil?\n fail ArgumentError, \"Missing the required parameter 'sales_id' when calling SupportApi.get_sale_using_get\"\n end\n # resource path\n local_var_path = '/sales/{sales_id}'.sub('{' + 'sales_id' + '}', sales_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Sale')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SupportApi#get_sale_using_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @expenses = find_expenses.all\n render json: @expenses\n end",
"def index\n @title = t('view.sellers.index_title')\n @sellers = Seller.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sellers }\n end\n end",
"def index\n @sales_orders = SalesOrder.all\n end",
"def index\n @taxes = Tax.all\n\n render json: @taxes\n end",
"def index\n @sales_channel = SalesChannel.find(params[:sales_channel_id])\n @sales_channel_apis = @sales_channel.apis\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @sales_channel_apis }\n end\n end",
"def company_intel\n company_id = params[:company_id]\n start_date = params[:start_date]\n end_date = params[:end_date]\n\n @intel = ItemPurchase.get_market_share(company_id, start_date, end_date)\n\n respond_to do |format|\n format.json\n end\n \n \n \n \n end",
"def index\n @q = params[:q]\n @q ||= \"\"\n @shops = Shop.search(@q).records\n\n\n respond_to do |format|\n format.html { render action: 'index' }\n format.json { render json: @shops, each_serializer: ShopListSerializer }\n end\n end"
] |
[
"0.7997595",
"0.7861047",
"0.738936",
"0.73351467",
"0.73351467",
"0.7176229",
"0.7145493",
"0.7095389",
"0.70836246",
"0.70836246",
"0.70836246",
"0.70836246",
"0.70836246",
"0.70836246",
"0.70836246",
"0.69917196",
"0.6968056",
"0.6920125",
"0.6917463",
"0.688621",
"0.686224",
"0.68614215",
"0.684033",
"0.68287754",
"0.68128175",
"0.6755651",
"0.67426234",
"0.6664361",
"0.66617566",
"0.66512966",
"0.6641963",
"0.66364396",
"0.66233677",
"0.6623024",
"0.6607435",
"0.6585453",
"0.6560563",
"0.655649",
"0.654856",
"0.6539632",
"0.65335363",
"0.64865535",
"0.6476022",
"0.6458467",
"0.645507",
"0.6450693",
"0.6445328",
"0.6445328",
"0.64420635",
"0.64328873",
"0.6429564",
"0.64235497",
"0.64235497",
"0.64235497",
"0.6398154",
"0.63979644",
"0.6389442",
"0.63746893",
"0.63650626",
"0.6361052",
"0.63592786",
"0.63585466",
"0.634423",
"0.63073236",
"0.6299094",
"0.6299094",
"0.62805855",
"0.62720114",
"0.6268273",
"0.6257767",
"0.62575805",
"0.625566",
"0.62468296",
"0.6244099",
"0.6240834",
"0.62292373",
"0.62283885",
"0.62195873",
"0.6216091",
"0.62116325",
"0.6210153",
"0.6205152",
"0.62032986",
"0.6202837",
"0.6199535",
"0.6193409",
"0.6191542",
"0.6190327",
"0.61902773",
"0.6190104",
"0.61874396",
"0.61631393",
"0.6159672",
"0.61552083",
"0.6154649",
"0.61420137",
"0.6140012",
"0.61353755",
"0.6125628",
"0.612369"
] |
0.73710763
|
3
|
POST /sales POST /sales.json
|
def create
@sale = Sale.new(sale_params)
if @sale.save
render json: @sale, status: :created, location: @sale
else
render json: @sale.errors, status: :unprocessable_entity
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n instance = Sale.new(sale_params)\n\n if instance.save\n render json: { msg: instance }, status: :created\n else\n render json: { msg: instance.errors }, status: :unprocessable_entity\n end\n end",
"def create\n @sale = Sale.new(sale_params)\n @sale.user = current_user\n @sale.total = @sale.total_all\n respond_to do |format|\n if @sale.save\n format.html { redirect_to team_event_sale_url(@sale.event, @sale), notice: 'Sale was successfully created.' }\n format.json { render :show, status: :created, location: team_event_sale_detail_url }\n else\n format.html { render :new }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sale = Sale.new(params[:sale])\n\n respond_to do |format|\n if @sale.save\n format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n format.json { render json: @sale, status: :created, location: @sale }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sale = Sale.new(params[:sale])\n\n respond_to do |format|\n if @sale.save\n format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n format.json { render json: @sale, status: :created, location: @sale }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sale = Sale.new(params[:sale])\n\n respond_to do |format|\n if @sale.save\n format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n format.json { render json: @sale, status: :created, location: @sale }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @sales = @saleService.all_to_json().as_json;\n end",
"def create\n @sale = @organization.sales.new(sale_params.merge(user_id: current_user.id, sale_number: Organization.get_next_sale_number(@organization),\n date_of_sale: DateTime.now))\n\n respond_to do |format|\n if @sale.save!\n format.html { redirect_to customer_sale_path(@sale.customer,@sale), notice: 'Sale was successfully created.' }\n format.json { render :show, status: :created, location: @sale }\n else\n format.html { render :new }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def _sales_add(sale_data)\n begin\n return set_error_object({message: @configuration.not_initialized_message}) if not_initialized?\n url = \"#{base_uri}/#{@configuration.sales_path}/add.#{@configuration.api_request_format}\"\n response = post url, body: {data: sale_data}\n JSON.parse (response.body && !response.body.empty?) ? response.body : set_error_object #returns the complete object\n rescue => e\n puts e.to_s #debug the error\n end\n end",
"def create\n @sale = Sale.new(sale_params)\n respond_to do |format|\n if @sale.save\n format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n format.json { render :show, status: :created, location: @sale }\n else\n format.html { render :new }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sale = Sale.new(sale_params)\n respond_to do |format|\n if @sale.save\n format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n format.json { render :show, status: :created, location: @sale }\n else\n format.html { render :new }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sale = Sale.new(sale_params)\n\n respond_to do |format|\n if @sale.save\n format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n format.json { render :show, status: :created, location: @sale }\n else\n format.html { render :new }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sale = Sale.new(sale_params)\n\n respond_to do |format|\n if @sale.save\n format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sale }\n else\n format.html { render action: 'new' }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @sales = Sale.all\n\n render json: @sales\n end",
"def create\n @sales_datum = SalesDatum.new(params[:sales_datum])\n\n respond_to do |format|\n if @sales_datum.save\n format.html { redirect_to @sales_datum, notice: 'Sales datum was successfully created.' }\n format.json { render json: @sales_datum, status: :created, location: @sales_datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sales_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @invoice = Invoice.new(invoice_params)\n sales = params[:invoice][:sales_attributes]\n success = false\n \n begin\n @invoice.pick_sales sales\n success = @invoice.save\n rescue Existence::NotEnoughExistence => ex\n @invoice.errors.add :sales, \"Not Enough Existence\"\n success = false\n rescue\n success = false\n end\n\n if success\n render json: @invoice, status: :created, location: @invoice\n else\n render json: {errors: @invoice.errors}, status: :unprocessable_entity\n end\n end",
"def create\n @sale = Sale.new(sale_params)\n\n respond_to do |format|\n if @sale.save && calculate_taxes(@sale)\n format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n format.json { render :show, status: :created, location: @sale }\n else\n format.html { render :new }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if current_user\n @sale = current_user.sales.build(sale_params)\n respond_to do |format|\n if @sale.save\n format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n format.json { render :show, status: :created, location: @sale }\n else\n format.html { render :new }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to root_path, notice: 'You must be logged in to do this'\n end\n end",
"def create\n @sales = Sale.create(safe_params[:sales])\n @sales = [@sales] unless @sales.instance_of? Array\n render :show\n end",
"def create\n @order = Order.new(params[:order])\n @order_sales = @order.sales\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sale = Sale.new(sale_params)\n @sale.user = current_user\n respond_to do |format|\n if @sale.save\n format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n format.json { render :show, status: :created, location: @sale }\n else\n format.html { render :new }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sale_params\n params[:sale].permit(:sales_type, :sales_date, :client_id, :staff_id)\n end",
"def create\n @sales_product = SalesProduct.new(sales_product_params)\n\n respond_to do |format|\n if @sales_product.save\n format.html { redirect_to @sales_product, notice: 'Sales product was successfully created.' }\n format.json { render :show, status: :created, location: @sales_product }\n else\n format.html { render :new }\n format.json { render json: @sales_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sale_params\n params.require(:sale).permit(:date, :total_price, :contact_name)\n end",
"def sales\n end",
"def create\n @sales_order = SalesOrder.new(sales_order_params)\n\n respond_to do |format|\n if @sales_order.save\n format.html { redirect_to @sales_order, notice: 'Sales order was successfully created.' }\n format.json { render :show, status: :created, location: @sales_order }\n else\n format.html { render :new }\n format.json { render json: @sales_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sale = Sale.new\n\n @sale.user_id = session[:user_id]\n @sale.user = session[:user_name]\n @sale.date_sale = DateTime.current.to_date\n\n price = 0\n\n sale_params[:medicaments].each do |medicament|\n medicament = Medicament.find(medicament)\n price += medicament.price\n end\n\n sale_params[:medicaments].each do |medicament|\n @sale.saleDetails.build(:price => price, :medicament_id => medicament)\n end\n\n respond_to do |format|\n if @sale.save\n p @sale\n format.html { redirect_to @sale, notice: \"Compra realizada com sucesso.\" }\n format.json { render :show, status: :created, location: @sale }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sales_item = SalesItem.new(sales_item_params)\n\n respond_to do |format|\n if @sales_item.save\n format.html { redirect_to @sales_item, notice: 'Sales item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sales_item }\n else\n format.html { render action: 'new' }\n format.json { render json: @sales_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sale = Sale.new(params[:sale])\n\n respond_to do |format|\n if @sale.save\n flash[:notice] = 'Sale was successfully created.'\n format.html { redirect_to(sales_url) }\n format.xml { render :xml => @sale, :status => :created, :location => @sale }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sale.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @business_sale = BusinessSale.new(business_sale_params)\n\n respond_to do |format|\n if @business_sale.save\n format.html { redirect_to @business_sale, notice: 'Business sale was successfully created.' }\n format.json { render :show, status: :created, location: @business_sale }\n else\n format.html { render :new }\n format.json { render json: @business_sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product_sale = ProductSale.new(product_sale_params)\n\n respond_to do |format|\n if @product_sale.save\n format.html { redirect_to @product_sale, notice: 'Product sale was successfully created.' }\n format.json { render :show, status: :created, location: @product_sale }\n else\n format.html { render :new }\n format.json { render json: @product_sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sales_order = SalesOrder.new(sales_order_params)\n @sales_order.date = Time.now\n sodetails = @sales_order.sales_order_details\n sodetails.each do |sod|\n sod.pending_rg = sod.quantity\n sod.pending_cg = sod.quantity\n sod.pending_inv = sod.quantity\n end\n \n respond_to do |format|\n if @sales_order.save\n format.html {\n flash[:notice] = 'La Orden de Venta se creó satisfactoriamente.'\n redirect_to sales_orders_path\n }\n format.json { render :show, status: :created, location: @sales_order }\n else\n format.html { \n flash[:error] = @sales_order.errors\n redirect_to new_sales_order_path\n }\n format.json { render json: @sales_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @detail_sale = DetailSale.new(detail_sale_params)\n\n respond_to do |format|\n if @detail_sale.save\n format.html { redirect_to @detail_sale, notice: \"Detail sale was successfully created.\" }\n format.json { render :show, status: :created, location: @detail_sale }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @detail_sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sale_day_total = SaleDayTotal.new(params[:sale_day_total])\n\n respond_to do |format|\n if @sale_day_total.save\n format.html { redirect_to @sale_day_total, notice: 'Sale day total was successfully created.' }\n format.json { render json: @sale_day_total, status: :created, location: @sale_day_total }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sale_day_total.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sale = Sale.new(sale_params)\n\n respond_to do |format|\n if @sale.save\n format.js\n format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sale }\n else\n format.js\n format.html { render action: 'new' }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sales_entry = SalesEntry.new(sales_entry_params)\n\n respond_to do |format|\n if @sales_entry.save\n format.html { redirect_to @sales_entry, notice: 'Sales entry was successfully created.' }\n format.json { render :show, status: :created, location: @sales_entry }\n else\n format.html { render :new }\n format.json { render json: @sales_entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @daily_sale = DailySale.new(daily_sale_params)\n\n respond_to do |format|\n if @daily_sale.save\n format.html { redirect_to new_daily_sale_path(page: page), notice: 'Daily Sale was successfully created.' }\n format.json { render :show, status: :created, location: @daily_sale }\n else\n format.html { render :new }\n format.json { render json: @daily_sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sale = Sale.new(sale_params)\n\n respond_to do |format|\n if @sale.save\n #format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n \n session[:id_venta_session] = @sale.id\n session[:tipo_venta_session] = @sale.sales_type\n format.html { redirect_to new_sales_article_path }\n format.json { render :show, status: :created, location: @sale }\n else\n obtener_clientes\n obtener_empleados \n format.html { render :new }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_sale_using_post_with_http_info(sale_request, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SupportApi.create_sale_using_post ...'\n end\n # verify the required parameter 'sale_request' is set\n if @api_client.config.client_side_validation && sale_request.nil?\n fail ArgumentError, \"Missing the required parameter 'sale_request' when calling SupportApi.create_sale_using_post\"\n end\n # resource path\n local_var_path = '/sales'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(sale_request)\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Sale')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SupportApi#create_sale_using_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create\n @sale = Sale.new(sale_params)\n @sale.total_price = 0;\n @sale.date = Date.today\n @sale.user_id = current_user.id\n\n respond_to do |format|\n if @sale.save\n format.html { redirect_to @sale, notice: 'La commande a été créée avec succès.' }\n format.json { render :show, status: :created, location: @sale }\n else\n format.html { render :new }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cal_month_sale = CalMonthSale.new(cal_month_sale_params)\n\n respond_to do |format|\n if @cal_month_sale.save\n format.html { redirect_to @cal_month_sale, notice: 'Cal month sale was successfully created.' }\n format.json { render :show, status: :created, location: @cal_month_sale }\n else\n format.html { render :new }\n format.json { render json: @cal_month_sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sale_params\n params.require(:sale).permit(:fecha, :subtotal, :total, :client_id, :user_id, :estado)\n end",
"def create_sale(sale)\n request = Braspag::Request::CreateSaleRequest.new(merchant, environment)\n\n request.execute(sale)\n end",
"def create\n @sale = Sale.new(params[:sale])\n employment_id = params[:employment_id]\n @sale.employee_id = @sale.employment.employee.id\n\n respond_to do |format|\n if @sale.save\n \n logger.info \"Sale #{@sale.title} created by #{current_user.email}\"\n \n format.html { redirect_to(sales_path, :notice => 'Sale was successfully created.') }\n format.xml { render :xml => @sale, :status => :created, :location => @sale }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sale.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @sell = Sell.new(sell_params)\n\n if @sell.save\n render json: @sell, status: :created, location: @sell\n else\n render json: @sell.errors, status: :unprocessable_entity\n end\n end",
"def create\n @sales_productivity = SalesProductivity.new(params[:sales_productivity])\n\n respond_to do |format|\n if @sales_productivity.save\n format.html { redirect_to new_sales_productivity_path, notice: 'Sales productivity was successfully created.' }\n format.json { render json: @sales_productivity, status: :created, location: @sales_productivity }\n else\n @salesman = Salesman.where(id: params[:sales_productivity][\"salesmen_id\"])\n @brand = Merk.all\n format.html { render action: \"new\" }\n format.json { render json: @sales_productivity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sale_params\n params.require(:sale).permit(:email, :order_date, :amount)\n end",
"def create\n @sales_term = SalesTerm.new(params[:sales_term])\n\n respond_to do |format|\n if @sales_term.save\n format.html { redirect_to @sales_term, notice: 'Sales Term was successfully created.' }\n format.json { render json: @sales_term, status: :created, location: @sales_term }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sales_term.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n cliente = Client.find(sale_params[:client_id])\n temp = sale_params\n temp[\"client_id\"] = cliente.id\n @sale = Sale.new(temp)\n\n respond_to do |format|\n if @sale.save\n format.html { redirect_to :sales, notice: 'Venta Creada' }\n format.json { render :show, status: :created, location: @sale }\n else\n format.html { render :new }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sale_params\n params.require(:sale).permit(:event_date, :product_id, :product_variety_id, :product_presentation_id, \n :total_price, :status, :greenhouse_id, :sale_item_ids)\n end",
"def create_sale(sale_parameters)\n Cielo::Request::ApiSale.new(merchant, environment).create(sale_parameters)\n end",
"def index\n @pre_sales = PreSale.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pre_sales }\n end\n end",
"def show\n render json: @invoice, methods: [:sales]\n end",
"def create\n @sale_order = current_user.sale_orders.new(params[:sale_order])\n\n respond_to do |format|\n if @sale_order.save\n format.html { redirect_to sale_orders_path, notice: 'Sale order was successfully created.' }\n format.json { render json: @sale_order, status: :created, location: @sale_order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sale_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @sale = Sale.new(sale_params)\n @message=''\n \n if @sale.save\n articulos= params[:sale][:articulos_vendidos]\n\n articulos.each do |articulo|\n inventario= Item.find(articulo[:id_item])\n inventario.existencia = inventario.existencia - articulo[:item_cantidad]\n inventario.save() \n end \n\n\n \n articulos.each do |articulo|\n sold = ItemsSold.new(items_solds_params)\n ultima_venta= Sale.last\n sold.id_item=articulo[:id_item]\n sold.id_sale=ultima_venta.id\n sold.cantidad=articulo[:item_cantidad]\n sold.save()\n \n end \n else\n @message='error'\n end \n \n\n render json:{sale: @sale, message: @message}\n \n end",
"def create\n @sale = Sale.new(sale_params)\n respond_to do |format|\n if @sale.valid?\n format.html { redirect_to livrodiario_path, notice: 'Fato cadastrado com sucesso.' }\n format.json { render :show, status: :created, location: @sale }\n else\n format.html { render :new }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def new\n @order = Order.new\n @order.sales.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def sale_params\n params.require(:sale).permit(:person_id, :product_id, :saledate, :saleprice)\n end",
"def sale_params\n params.require(:sale).permit(:person_id, :product_id, :saledate, :saleprice)\n end",
"def new\n @sale = Sale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sale }\n end\n end",
"def new\n @sale = Sale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sale }\n end\n end",
"def new\n @sale = Sale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sale }\n end\n end",
"def create\n @sales_article = SalesArticle.new(sales_article_params)\n\n respond_to do |format|\n if @sales_article.save\n #format.html { redirect_to @sales_article, notice: 'Sales article was successfully created.' }\n format.html { redirect_to new_sales_article_path }\n format.json { render :show, status: :created, location: @sales_article }\n else\n obtener_articulos\n format.html { render :new }\n format.json { render json: @sales_article.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sale = Sale.new(sale_params)\n authorize @sale\n respond_to do |format|\n if @sale.save\n format.html { redirect_to (params[:save_and_new].present? ? new_sale_path : @sale), success: I18n.t('notices.created', entity: Sale.model_name.human, id: @sale.id) }\n format.json { render :show, status: :created, location: @sale }\n else\n format.html { render :new }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @sales_datum = SalesDatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sales_datum }\n end\n end",
"def show\n render json: @sale\n end",
"def sale(params = {})\r\n @PARAM_HASH['TRANSACTION_TYPE'] = 'SALE'\r\n @PARAM_HASH['AMOUNT'] = params[:amount]\r\n @PARAM_HASH['RRNO'] = params[:trans_id] || ''\r\n @PARAM_HASH['CUST_TOKEN'] = params[:customer_token] if params[:customer_token]\r\n @api = \"bp10emu\"\r\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def sale_params\n params.require(:sale).permit(:id_client, :id_financing_models, :id_financing_types, :id_paid_systems, :cantidad_pagos, :fecha_venta, :estatus,:total_venta,:pago_diferido, :active)\n end",
"def create\n @requested_sales_document = RequestedSalesDocument.new(requested_sales_document_params)\n\n respond_to do |format|\n if @requested_sales_document.save\n format.html { redirect_to @requested_sales_document, notice: 'Requested sales document was successfully created.' }\n format.json { render :show, status: :created, location: @requested_sales_document }\n else\n format.html { render :new }\n format.json { render json: @requested_sales_document.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sales(options = {})\n options[:product_id] = epages_id(options[:product_id]) if options[:product_id]\n perform_get_with_object('/sales', format_dates_options(options), Epages::SalesSummary)\n end",
"def sale_params\n params.fetch(:sale, {}).permit(\n :date,\n :description,\n :evidence,\n :partner_id,\n :amount,\n :amount_males,\n :amount_females,\n )\n end",
"def create\n @sale_payment = SalePayment.new(sale_payment_params)\n\n respond_to do |format|\n if @sale_payment.save\n format.html { redirect_to @sale_payment, notice: 'Sale payment was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sale_payment }\n else\n format.html { render action: 'new' }\n format.json { render json: @sale_payment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sales_team = SalesTeam.new(params[:sales_team])\n\n respond_to do |format|\n if @sales_team.save\n format.html { redirect_to @sales_team, notice: 'Sales team was successfully created.' }\n format.json { render json: @sales_team, status: :created, location: @sales_team }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sales_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sale(params = {})\r\n @PARAM_HASH['TRANSACTION_TYPE'] = 'SALE'\r\n @PARAM_HASH['AMOUNT'] = params[:amount]\r\n @PARAM_HASH['RRNO'] = params[:trans_id] || ''\r\n @api = \"bp10emu\"\r\n end",
"def create\n @sale_type = SaleType.new(sale_type_params)\n\n respond_to do |format|\n if @sale_type.save\n format.html { redirect_to @sale_type, notice: \"Sale type was successfully created.\" }\n format.json { render :show, status: :created, location: @sale_type }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @sale_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @d_sale_item = DSaleItem.new(params[:d_sale_item])\n\n respond_to do |format|\n if @d_sale_item.save\n format.html { redirect_to @d_sale_item, notice: 'D sale item was successfully created.' }\n format.json { render json: @d_sale_item, status: :created, location: @d_sale_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @d_sale_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sale_order = SaleOrder.new(params[:sale_order])\n @customers = Customer.find(:all).sort\n\n respond_to do |format|\n if @sale_order.save!\n flash[:notice] = 'Sale Order was successfully created.'\n format.html { redirect_to(@sale_order) }\n format.xml { render :xml => @sale_order, :status => :created, :location => @sale_order }\n else\n flash[:notice] = 'Failed to create the Sale Order.'\n format.html { redirect_to :controller => 'store', :action => 'sale' }\n format.xml { render :xml => @sale_order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def push_sale\n\n details = {\n name: self.customer.name,\n location: self.location,\n quantity: self.quantity,\n product: self.product.name,\n sold_at: self.created_at.strftime('%l:%M %p %A')\n }\n Pusher['flamingmoe'].trigger('sale', details)\n logger.debug(\"pushed sale details to pusher.com: #{details.inspect}\")\n\n push_counts\n end",
"def sale_params\n params.require(:sale).permit(:medicaments => [])\n end",
"def create\n monthly_slip(params)\n # secure valid input\n return render json: { msg: \"input valid number\" } unless @annual_salary > 0\n @timestamp = DateTime.now\n slip = Slip.new({\n \"time_stamp\" => @timestamp,\n \"annual_salary\" => @annual_salary,\n \"employee_name\" => @employee_name,\n \"monthly_income_tax\" => @monthly_income_tax,\n })\n if slip.save\n render json: { status: \"SUCCESS\", message: \"Saved Infotmation\", data: slip }, status: :ok\n else\n render json: { status: \"ERROR\", message: \"Information not saved\", data: slip.errors }, status: :unprocessable_entity\n end\n end",
"def create\n @sales_associate = SalesAssociate.new(sales_associate_params)\n\n respond_to do |format|\n if @sales_associate.save\n format.html { redirect_to @sales_associate, notice: 'Sales associate was successfully created.' }\n format.json { render :show, status: :created, location: @sales_associate }\n else\n format.html { render :new }\n format.json { render json: @sales_associate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sales_plan = SalesPlan.new(sales_plan_params)\n\n respond_to do |format|\n if @sales_plan.save\n format.html { redirect_to @sales_plan, notice: 'Sales plan was successfully created.' }\n format.json { render :show, status: :created, location: @sales_plan }\n else\n format.html { render :new }\n format.json { render json: @sales_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @accesory_sale = AccesorySale.new(accesory_sale_params)\n\n respond_to do |format|\n if @accesory_sale.save\n format.html { redirect_to @accesory_sale, notice: 'Accesory sale was successfully created.' }\n format.json { render :show, status: :created, location: @accesory_sale }\n else\n format.html { render :new }\n format.json { render json: @accesory_sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sale = Sale.new(sale_params)\n respond_to do |format|\n if @sale.save\n quantity = params[:quotes_quantity].gsub(/[^\\d^\\.]/, '').to_i\n\n for i in 1..quantity\n @quote = Quote.new\n @quote.amount = (params[:amount]).gsub(/[^\\d^\\.]/, '').to_f\n @quote.is_paid = false\n @quote.number = i\n @quote.total = quantity\n @quote.mounth = (@sale.date + i.month).month\n @quote.year = (@sale.date + i.month).year\n @quote.sale = @sale\n @quote.save\n end\n\n format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sale }\n else\n format.html { render action: 'new' }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sale_params\n params.require(:sale).permit(:quantity, :merchant_id, :product_id, :customer_id)\n end",
"def create\n @sales_upsale_product = SalesUpsaleProduct.new(sales_upsale_product_params)\n\n respond_to do |format|\n if @sales_upsale_product.save\n format.html { redirect_to sales_upsale_products_url, notice: 'Sales upsale product was successfully created.' }\n format.json { render :show, status: :created, location: @sales_upsale_product }\n else\n format.html { render :new }\n format.json { render json: @sales_upsale_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pre_sale = PreSale.new_with(params[:pre_sale], params[:date])\n\n respond_to do |format|\n if @pre_sale.save\n format.html { redirect_to @pre_sale, notice: I18n.t('app.views.pre_sales.messages.create.success') }\n else\n format.html { render action: \"new\" }\n end\n end\n end",
"def sale_params\n params.require(:sale).permit(:item_sold, :item_price, :note, :date_of_sale, :user_id, :customer_id)\n end",
"def sale_params\n params[:sale][:user_id] = current_user.id\n params.require(:sale).permit(:totalValue, :date_time, :customer_id, :user_id)\n end",
"def post\n Salesforce.set_http(session[:accesstoken], session[:accessurl])\n \t@response = Salesforce.create_post(params)\n \trespond_to do |format|\n format.json { render :json => @response.to_json}\n # example of multiple reponses mapped to one object\n # format.json { render :json => {:data => @response, :meta => @describe}.to_json}\n \tend\n end",
"def create\n @sales_stage = SalesStage.new(sales_stage_params)\n\n respond_to do |format|\n if @sales_stage.save\n format.html { redirect_to sales_stages_path, notice: 'Sales stage was successfully created.' }\n format.json { render :show, status: :created, location: @sales_stage }\n else\n format.html { render :new }\n format.json { render json: @sales_stage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sale\n ret = nil\n if @json_body.include?('sale_id')\n ret = @mc2p.sale('id' => @json_body['sale_id'])\n ret.retrieve\n end\n ret\n end",
"def salesApi\n require 'uri'\n require 'net/http'\n require 'json'\n\n #Arrays for each category\n \n @frequency = Hash.new(0)\n\n url = URI(\"https://api.salesloft.com/v2/people.json\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n\n request = Net::HTTP::Get.new(url)\n request[\"Authorization\"] = 'Bearer ' + ENV[\"API_KEY\"]\n\n response = http.request(request)\n \n @body = JSON.parse(response.body)['data']\n return @body\n end",
"def create\n @sales_rep = SalesRep.new(params[:sales_rep])\n\n respond_to do |format|\n if @sales_rep.save\n format.html { redirect_to @sales_rep, notice: 'Sales rep was successfully created.' }\n format.json { render json: @sales_rep, status: :created, location: @sales_rep }\n format.js {}\n else\n format.html { render action: \"new\" }\n format.json { render json: @sales_rep.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6976473",
"0.69668937",
"0.6917975",
"0.6917975",
"0.6917975",
"0.6904136",
"0.68784654",
"0.68595415",
"0.6855698",
"0.6855698",
"0.6838506",
"0.6753126",
"0.67094505",
"0.67054194",
"0.6683496",
"0.66826385",
"0.65999943",
"0.6558466",
"0.65480006",
"0.654032",
"0.6496904",
"0.6463458",
"0.64541686",
"0.6436737",
"0.6396794",
"0.6385367",
"0.638315",
"0.63828313",
"0.6361108",
"0.6358889",
"0.63518906",
"0.634489",
"0.6334761",
"0.6311662",
"0.6279589",
"0.62706554",
"0.6237914",
"0.62023",
"0.619518",
"0.61909944",
"0.61866796",
"0.61859596",
"0.61675745",
"0.61558914",
"0.61490947",
"0.614804",
"0.6115706",
"0.61141473",
"0.6110539",
"0.6072668",
"0.6072045",
"0.6063722",
"0.6042227",
"0.6035597",
"0.6032097",
"0.6028879",
"0.6025847",
"0.6025847",
"0.6024781",
"0.6024781",
"0.6024781",
"0.6023767",
"0.60208535",
"0.6008981",
"0.60061413",
"0.59959435",
"0.59944975",
"0.59944975",
"0.59944975",
"0.59944975",
"0.59944975",
"0.59944975",
"0.59944975",
"0.5984216",
"0.5981096",
"0.5958913",
"0.59456587",
"0.5933955",
"0.5922957",
"0.59129673",
"0.59039074",
"0.58935314",
"0.58929455",
"0.5890579",
"0.5886638",
"0.58859515",
"0.588506",
"0.5884393",
"0.5876666",
"0.5874285",
"0.58739",
"0.5870554",
"0.58700824",
"0.5850188",
"0.5844961",
"0.5840823",
"0.58395493",
"0.5837865",
"0.58301955",
"0.5826685"
] |
0.73994184
|
0
|
PATCH/PUT /sales/1 PATCH/PUT /sales/1.json
|
def update
@sale = Sale.find(params[:id])
if @sale.update(sale_params)
head :no_content
else
render json: @sale.errors, status: :unprocessable_entity
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @sale = Sale.find(params[:id])\n\n respond_to do |format|\n if @sale.update_attributes(params[:sale])\n format.html { redirect_to @sale, notice: 'Sale was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @sale = Sale.find(params[:id])\n\n respond_to do |format|\n if @sale.update_attributes(params[:sale])\n format.html { redirect_to @sale, notice: 'Sale was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @sale = Sale.find(params[:id])\n\n respond_to do |format|\n if @sale.update_attributes(params[:sale])\n format.html { redirect_to @sale, notice: 'Sale was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sale.update(sale_params)\n format.html { redirect_to @sale, notice: 'Sale was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sale.update(sale_params)\n format.html { redirect_to @sale, notice: 'Sale was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @sale.update(sale_params)\n SalesServices::Relations.new(@sale, params).call(create: false)\n # Sale.update_products(@sale, params[:products])\n\n render json: {\n success: true,\n msg: 'Sale successfully updated',\n product: SaleSerializer.new(@sale)\n }\n else\n render json: {\n success: false,\n msg: 'Something went wrong',\n errors: @sale.errors\n }\n end\n end",
"def update\n if @sale.update(sale_params)\n render json: { msg: @sale }, status: :ok\n else\n render json: { msg: @sale.errors }, status: :unprocessable_entity\n end\n end",
"def update\n @sales_rep = SalesRep.find(params[:id])\n \n respond_to do |format|\n if @sales_rep.update_attributes(params[:sales_rep])\n format.html { redirect_to @sales_rep, notice: 'Sales rep was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sales_rep.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @supermarket = Supermarket.find(params[:id]) \n respond_to do |format|\n if @supermarket.update(supermarket_params)\n format.json { render json: @supermarket, status: :ok }\n end\n end\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n authorize @sale\n respond_to do |format|\n if @sale.update(sale_params)\n format.html { redirect_to @sale, success: I18n.t('notices.updated', entity: Sale.model_name.human, title: @sale.reference) }\n format.json { render :show, status: :ok, location: @sale }\n else\n format.html { render :edit }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sale.update(sale_params)\n format.html { redirect_to @sale, notice: 'Sale was successfully updated.' }\n format.json { render :show, status: :ok, location: @sale }\n else\n format.html { render :edit }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sale.update(sale_params)\n format.html { redirect_to @sale, notice: 'Sale was successfully updated.' }\n format.json { render :show, status: :ok, location: @sale }\n else\n format.html { render :edit }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sale.update(sale_params)\n format.html { redirect_to @sale, notice: 'Sale was successfully updated.' }\n format.json { render :show, status: :ok, location: @sale }\n else\n format.html { render :edit }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sale.update(sale_params)\n format.html { redirect_to @sale, notice: 'Sale was successfully updated.' }\n format.json { render :show, status: :ok, location: @sale }\n else\n format.html { render :edit }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sale.update(sale_params)\n format.html { redirect_to @sale, notice: 'Sale was successfully updated.' }\n format.json { render :show, status: :ok, location: @sale }\n else\n format.html { render :edit }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sale.update(sale_params)\n format.html { redirect_to @sale, notice: 'Sale was successfully updated.' }\n format.json { render :show, status: :ok, location: @sale }\n else\n format.html { render :edit }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sale.update(sale_params)\n format.html { redirect_to @sale, notice: 'Sale was successfully updated.' }\n format.json { render :show, status: :ok, location: @sale }\n else\n format.html { render :edit }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sale.update(sale_params)\n format.html { redirect_to @sale, notice: 'Sale was successfully updated.' }\n format.json { render :show, status: :ok, location: @sale }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #params[:sale][:existing_purchase_attributes] ||= {}\n respond_to do |format|\n if @sale.update(sale_params) && calculate_taxes(@sale)\n format.html { redirect_to @sale, notice: 'Sale was successfully updated.' }\n format.json { render :show, status: :ok, location: @sale }\n else\n format.html { render :edit }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sale.update(sale_params)\n format.html { redirect_to customer_sale_path(@sale.customer,@sale), notice: 'Sale was successfully updated.' }\n format.json { render :show, status: :ok, location: @sale }\n else\n format.html { render :edit }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sales_item.update(sales_item_params)\n format.html { redirect_to @sales_item, notice: 'Sales item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sales_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end",
"def update\n respond_to do |format|\n if @sale.update(sale_params)\n format.html { redirect_to :sales, notice: 'Venta Actualizada' }\n format.json { render :show, status: :ok, location: @sale }\n else\n format.html { render :edit }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @sale = Sale.find(params[:id])\n employment_id = params[:id][:employment_id]\n @sale.employee_id = @sale.employment.employee.id\n \n \n\n respond_to do |format|\n if @sale.update_attributes(params[:sale])\n \n logger.info \"Sale #{@sale.title} updated by #{current_user.email}\"\n \n format.html { redirect_to(sales_path, :notice => 'Sale was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @sale.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @sales_datum = SalesDatum.find(params[:id])\n\n respond_to do |format|\n if @sales_datum.update_attributes(params[:sales_datum])\n format.html { redirect_to @sales_datum, notice: 'Sales datum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sales_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sale.update(sale_params)\n format.html { redirect_to @sale, notice: 'Sale was successfully updated.' }\n format.json { render :show, status: :ok, location: @sale }\n else\n format.html { render :edit }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_sale_using_put_with_http_info(sales, sales_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SupportApi.update_sale_using_put ...'\n end\n # verify the required parameter 'sales' is set\n if @api_client.config.client_side_validation && sales.nil?\n fail ArgumentError, \"Missing the required parameter 'sales' when calling SupportApi.update_sale_using_put\"\n end\n # verify the required parameter 'sales_id' is set\n if @api_client.config.client_side_validation && sales_id.nil?\n fail ArgumentError, \"Missing the required parameter 'sales_id' when calling SupportApi.update_sale_using_put\"\n end\n # resource path\n local_var_path = '/sales/{sales_id}'.sub('{' + 'sales_id' + '}', sales_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(sales)\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Sale')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SupportApi#update_sale_using_put\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update\n @sale = Sale.find(params[:id])\n\n respond_to do |format|\n if @sale.update_attributes(params[:sale])\n flash[:notice] = 'Sale was successfully updated.'\n format.html { redirect_to(sales_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @sale.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @sale_order = current_company.sale_orders.find(params[:id])\n\n respond_to do |format|\n if @sale_order.update_attributes(params[:sale_order])\n format.html { redirect_to sale_orders_path, notice: 'Sale order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sale_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @invoice = Invoice.find(params[:id])\n\n success = false\n begin\n ActiveRecord::Base.transaction do\n @invoice.destroy!\n @invoice = Invoice.new(invoice_params)\n sales = params[:invoice][:sales_attributes]\n success = false\n @invoice.pick_sales sales\n success = @invoice.save!\n end\n rescue ActiveRecord::RecordInvalid => ex\n puts ex\n rescue Existence::NotEnoughExistence => ex\n @invoice.errors.add :sales, \"Not Enough Existence\"\n end\n\n if success\n head :no_content\n else\n render json: {errors: @invoice.errors}, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @sale.update(sale_params)\n format.html { redirect_to @sale, notice: \"Compra atualizada com sucesso.\" }\n format.json { render :show, status: :ok, location: @sale }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n respond_to do |format|\n if @requested_sales_document.update(requested_sales_document_params)\n format.html { redirect_to @requested_sales_document, notice: 'Requested sales document was successfully updated.' }\n format.json { render :show, status: :ok, location: @requested_sales_document }\n else\n format.html { render :edit }\n format.json { render json: @requested_sales_document.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sale.update(sale_params)\n format.html { redirect_to @sale, notice: \"Venda atualizada com sucesso\" }\n format.json { render :show, status: :ok, location: @sale }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @pre_sale = PreSale.find(params[:id])\n\n respond_to do |format|\n if @pre_sale.update_attributes_with(params[:pre_sale], params[:date])\n format.html { redirect_to @pre_sale, notice: I18n.t('app.views.pre_sales.messages.update.success') }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pre_sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sales_product.update(sales_product_params)\n format.html { redirect_to @sales_product, notice: 'Sales product was successfully updated.' }\n format.json { render :show, status: :ok, location: @sales_product }\n else\n format.html { render :edit }\n format.json { render json: @sales_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sales_order.update(sales_order_params)\n format.html { redirect_to @sales_order, notice: 'Sales order was successfully updated.' }\n format.json { render :show, status: :ok, location: @sales_order }\n else\n format.html { render :edit }\n format.json { render json: @sales_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sale.update(sale_params)\n\n format.html { redirect_to @sale, notice: 'La commande a été modifiée avec succès.' }\n format.json { render :show, status: :ok, location: @sale }\n else\n format.html { render :edit }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\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 update\n respond_to do |format|\n if @detail_sale.update(detail_sale_params)\n format.html { redirect_to @detail_sale, notice: \"Detail sale was successfully updated.\" }\n format.json { render :show, status: :ok, location: @detail_sale }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @detail_sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sales_entry.update(sales_entry_params)\n format.html { redirect_to @sales_entry, notice: 'Sales entry was successfully updated.' }\n format.json { render :show, status: :ok, location: @sales_entry }\n else\n format.html { render :edit }\n format.json { render json: @sales_entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n respond_to do |format|\n if @product_sale.update(product_sale_params)\n format.html { redirect_to @product_sale, notice: 'Product sale was successfully updated.' }\n format.json { render :show, status: :ok, location: @product_sale }\n else\n format.html { render :edit }\n format.json { render json: @product_sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n get_data\n @sale_detail = @sale.details.find(params[:id])\n @sale_detail.update_attributes(params[:sale_detail])\n get_data\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def update\n @sales_productivity = SalesProductivity.find(params[:id])\n\n respond_to do |format|\n if @sales_productivity.update_attributes(params[:sales_productivity])\n format.html { redirect_to @sales_productivity, notice: 'Sales productivity was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sales_productivity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @business_sale.update(business_sale_params)\n format.html { redirect_to @business_sale, notice: 'Business sale was successfully updated.' }\n format.json { render :show, status: :ok, location: @business_sale }\n else\n format.html { render :edit }\n format.json { render json: @business_sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # no se puede actualizar una venta por el momento\n respond_to do |format|\n\n previous_sale = @sale\n \n if @sale.update(sale_params)\n\n @sale.cliente.update(client_params)\n \n #verifica si cambió el estado de la venta y realiza las acciones que corresponda\n Sale.verificar_cambios(previous_sale, @sale, current_user)\n #Sale.verificarCambioDeEstado(estado_anterior, @sale, current_user) if estado_anterior != @sale.estado\n \n format.html { redirect_to @sale, notice: 'Venta actualizada con exito.' }\n format.json { render :show, status: :ok, location: @sale }\n else\n format.html { render :edit }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def test_update\n #Again the delete feature from ActiveResource does not work out of the box.\n #Using custom delete function\n puts \"--create a new account--\"\n new_acct = Salesforce::Rest::Account.new(:Name => \"test numero uno\", :BillingStreet=> \"Fairway Meadows\",\n :BillingState => \"NY\", :ShippingCity => \"New York\")\n resp = new_acct.save()\n\n assert (resp.code == 201)\n j = ActiveSupport::JSON\n @sf_oid = j.decode(resp.body)[\"id\"]\n puts \"New Object created: id -> \" + @sf_oid\n\n puts \"--update that new account--\"\n serialized_json = '{\"BillingState\":\"WA\"}'\n #http = Net::HTTP.new(@rest_svr_url, 443)\n http = Net::HTTP.new('na7.salesforce.com', 443)\n http.use_ssl = true\n \n class_name = \"Account\"\n path = \"/services/data/v21.0/sobjects/#{class_name}/#{@sf_oid}\"\n headers = {\n 'Authorization' => \"OAuth \"+ @oauth_token,\n \"content-Type\" => 'application/json',\n }\n code = serialized_json\n\n \n req = Net::HTTPGenericRequest.new(\"PATCH\", true, true, path, headers)\n\n resp = http.request(req, code) { |response| }\n assert !resp.nil?\n\n puts resp.to_s\n end",
"def update\n @sales_team = SalesTeam.find(params[:id])\n\n respond_to do |format|\n if @sales_team.update_attributes(params[:sales_team])\n format.html { redirect_to @sales_team, notice: 'Sales team was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sales_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(url, payload, headers={})\n RestClient.patch url, payload, headers\n end",
"def update\n respond_to do |format|\n if @sales_coffee.update(sales_coffee_params)\n format.html { redirect_to @sales_coffee, notice: \"Sales coffee was successfully updated.\" }\n format.json { render :show, status: :ok, location: @sales_coffee }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @sales_coffee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @sales_term = SalesTerm.find(params[:id])\n\n respond_to do |format|\n if @sales_term.update_attributes(params[:sales_term])\n format.html { redirect_to @sales_term, notice: 'Sales term was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sales_term.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n product = Product.find(params[:id])\n product_details = params.permit(:title, :inventory_count, :price)\n\n product.update(product_details)\n\n render json: product\n end",
"def update_rest\n @item_usage = ItemUsage.find(params[:id])\n\n respond_to do |format|\n if @item_usage.update_attributes(params[:item_usage])\n flash[:notice] = 'ItemUsage was successfully updated.'\n format.html { redirect_to(@item_usage) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item_usage.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @rest.update(rest_params)\n format.html { redirect_to @rest, notice: 'Rest was successfully updated.' }\n format.json { render :show, status: :ok, location: @rest }\n else\n format.html { render :edit }\n format.json { render json: @rest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sales_order_detail.update(sales_order_detail_params)\n format.html { redirect_to @sales_order_detail, notice: 'Sales order detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @sales_order_detail }\n else\n format.html { render :edit }\n format.json { render json: @sales_order_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # { clinic: {id: references, \"license_id\"=>nil, \"name\"=>string } }\n \n if @clinic.update_attributes(params[:clinic].except(:api_license_id))\n head :no_content\n else\n render json: clinic.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @sales_stage.update(sales_stage_params)\n format.html { redirect_to sales_stages_path, notice: 'Sales stage was successfully updated.' }\n format.json { render :show, status: :ok, location: @sales_stage }\n else\n format.html { render :edit }\n format.json { render json: @sales_stage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update # PATCH\n raise NotImplementedError\n end",
"def update\n @sale = Sale.find(params[:id])\n\n if @sale != nil\n s = params[:sale]\n @sale.sold_on = filter_time(s, :sold_on)\n @sale.product_id = s[:product] unless s[:product] == \"\"\n @sale.employee_id = s[:employee] unless s[:employee] == \"\"\n @sale.price = s[:price]\n @sale.price_commission = s[:price_commission]\n @sale.percentage = s[:percentage]\n @sale.plan = s[:plan]\n\n @sale.save\n\n respond_to do |f|\n f.html { redirect_to @sale, notice: 'Venda alterada'}\n end\n else\n respond_to do |f|\n f.html { render action: \"edit\", notice: 'Erro ao editar venda'}\n end\n end\n #respond_to do |format|\n # if @sale.update_attributes(params[:sale])\n # @sale.sold_on = filter_time(params[:sale], :sold_on)\n # format.html { redirect_to @sale, notice: 'Venda alterada com sucesso.' }\n # format.json { head :ok }\n # @sale.save\n # else\n # format.html { render action: \"edit\" }\n # format.json { render json: @sale.errors, status: :unprocessable_entity }\n # end\n #end\n end",
"def update\n\n # update shops\n shops_edit = JSON.parse(params[:mall][:shops_in_mall])\n\n respond_to do |format|\n if @mall.update_with_shops(mall_params, shops_edit)\n format.html { redirect_to director_malls_path, notice: 'Mall was successfully updated.' }\n format.json { render :show, status: :ok, location: @mall }\n else\n format.html {\n @shops = Shop.to_options.to_json\n @shops_in_mall = @mall.shops.to_options.to_json\n render :edit\n }\n format.json { render json: @mall.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def rest_patch(base_uri,json_payload,params)\n begin\n @response = RestClient.patch(base_uri,json_payload,params)\n rescue => e\n puts @response.code\n end\n return @response\n end",
"def update\n put :update\n end",
"def update\n respond_to do |format|\n if @point_of_sale.update(point_of_sale_params)\n format.json { render :show, status: :ok, location: @point_of_sale }\n else\n format.json { render json: @point_of_sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @rest_api.update(rest_api_params)\n format.html { redirect_to @rest_api, notice: 'Rest api was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @rest_api.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @sales_type = SalesType.find(params[:id])\n\n respond_to do |format|\n if @sales_type.update_attributes(params[:sales_type])\n format.html { redirect_to(sales_types_path, :notice => 'Sales type was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @sales_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n\n format.json { render json: Axis.find(params[:id]).update( name: params[:name]) }\n end\n\n # end\n end",
"def update!(**args)\n @annotations = args[:annotations] if args.key?(:annotations)\n @cancellations = args[:cancellations] if args.key?(:cancellations)\n @id = args[:id] if args.key?(:id)\n @price = args[:price] if args.key?(:price)\n @product = args[:product] if args.key?(:product)\n @quantity_canceled = args[:quantity_canceled] if args.key?(:quantity_canceled)\n @quantity_delivered = args[:quantity_delivered] if args.key?(:quantity_delivered)\n @quantity_ordered = args[:quantity_ordered] if args.key?(:quantity_ordered)\n @quantity_pending = args[:quantity_pending] if args.key?(:quantity_pending)\n @quantity_returned = args[:quantity_returned] if args.key?(:quantity_returned)\n @quantity_shipped = args[:quantity_shipped] if args.key?(:quantity_shipped)\n @return_info = args[:return_info] if args.key?(:return_info)\n @returns = args[:returns] if args.key?(:returns)\n @shipping_details = args[:shipping_details] if args.key?(:shipping_details)\n @tax = args[:tax] if args.key?(:tax)\n end",
"def update\n respond_to do |format|\n if @sales_order.update(sales_order_params)\n format.html { \n flash[:notice] = 'La Orden de Venta se actualizó satisfactoriamente.'\n redirect_to sales_orders_path\n }\n format.json { render :show, status: :ok, location: @sales_order }\n else\n format.html { \n flash[:error] = @sales_order.errors\n redirect_to edit_sales_order_path(@sales_order.id)\n }\n format.json { render json: @sales_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(resource,identifier,json)\n raise 'Not Yet Implemented'\n end",
"def update\n respond_to do |format|\n if @pplan.update(pplan_params)\n\n\n @sale = Sale.find_by(:id => @pplan.sale_id)\n @sale.update(:approve => nil)\n @pplan.update(:saledate => @sale.saledate, :selling_price => @sale.selling_price, :contact_id => @sale.contact_id, :batch_id => @sale.batch_id )\n\n\n format.html { redirect_to :back , notice: 'Pplan was successfully updated.' }\n format.json { head :no_content }\n\n\n else\n format.html { render action: 'edit' }\n format.json { render json: @pplan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @sales_channel_api = SalesChannelApi.find(params[:id])\n\n respond_to do |format|\n if @sales_channel_api.update_attributes(params[:sales_channel_api])\n format.html { redirect_to @sales_channel_api, :notice => 'Sales channel api was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @sales_channel_api.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @sales_code = SalesCode.find(params[:id])\n\n respond_to do |format|\n if @sales_code.update_attributes(params[:sales_code])\n format.html { redirect_to @sales_code, notice: 'Sales code was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sales_code.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product_sold = ProductSold.find(params[:id])\n\n respond_to do |format|\n if @product_sold.update_attributes(params[:product_sold])\n format.html { redirect_to @product_sold, notice: 'Product sold was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product_sold.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @opportunity = Opportunity.find(params[:id])\n\n if @opportunity.update(opportunity_params)\n head :no_content\n else\n render json: @opportunity.errors, status: :unprocessable_entity\n end\n end",
"def update_sale_setting\n service_response = ClientManagement::UpdateSaleSetting.new(params).perform\n render_api_response(service_response)\n end",
"def update\n respond_to do |format|\n if @sold_product.update_attributes(sold_product_params)\n format.html { redirect_to @sold_product, notice: 'Sold product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sold_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def update\n @sale_day_total = SaleDayTotal.find(params[:id])\n\n respond_to do |format|\n if @sale_day_total.update_attributes(params[:sale_day_total])\n format.html { redirect_to @sale_day_total, notice: 'Sale day total was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sale_day_total.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cal_month_sale.update(cal_month_sale_params)\n format.html { redirect_to @cal_month_sale, notice: 'Cal month sale was successfully updated.' }\n format.json { render :show, status: :ok, location: @cal_month_sale }\n else\n format.html { render :edit }\n format.json { render json: @cal_month_sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @sale.update(sale_params)\n redirect_to current_user\n else\n end\n end",
"def patch_resource(payload)\n execute(resource_path, method: :patch, payload: payload.to_json)\n end",
"def update\n @d_sale_item = DSaleItem.find(params[:id])\n\n respond_to do |format|\n if @d_sale_item.update_attributes(params[:d_sale_item])\n format.html { redirect_to @d_sale_item, notice: 'D sale item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @d_sale_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n @shop_claim = ShopClaim.find(params[:id])\n\n if @shop_claim.update(shop_claim_params)\n head :no_content\n else\n render json: @shop_claim.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @sell.update(sell_params)\n head :no_content\n else\n render json: @sell.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @sales_group.update(sales_group_params)\n format.html { redirect_to @sales_group, notice: 'Sales group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sales_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n document = Document.find(params[:id])\n document.update!(update_params)\n render json: {}\n end",
"def update\n @sprint.update!(sprint_params)\n json_response(@sprint)\n end",
"def update\n respond_to do |format|\n if @sales_plan.update(sales_plan_params)\n format.html { redirect_to @sales_plan, notice: 'Sales plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @sales_plan }\n else\n format.html { render :edit }\n format.json { render json: @sales_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(data, &block)\n request :patch, @data[:id], data, &block\n end"
] |
[
"0.65441173",
"0.65441173",
"0.65149",
"0.6514514",
"0.6514514",
"0.6472801",
"0.6440159",
"0.636378",
"0.6363627",
"0.6348585",
"0.63309866",
"0.6330706",
"0.6330706",
"0.6330706",
"0.6330706",
"0.6330706",
"0.6330706",
"0.6330706",
"0.6314734",
"0.6274482",
"0.6261295",
"0.6247109",
"0.6209028",
"0.62024933",
"0.61930597",
"0.6180796",
"0.6180011",
"0.61781853",
"0.617197",
"0.61627185",
"0.6153547",
"0.6125566",
"0.61170167",
"0.6115622",
"0.6114919",
"0.6072557",
"0.60597676",
"0.6055244",
"0.6049602",
"0.60329974",
"0.60106033",
"0.5993861",
"0.59877294",
"0.59794754",
"0.5971172",
"0.596568",
"0.596568",
"0.5965211",
"0.5942413",
"0.59422475",
"0.5941112",
"0.5940004",
"0.59327984",
"0.5917141",
"0.58830553",
"0.5870984",
"0.5868964",
"0.5868127",
"0.58651006",
"0.585632",
"0.585597",
"0.58495885",
"0.5847314",
"0.58441156",
"0.5841916",
"0.58393466",
"0.58379304",
"0.58294636",
"0.58294636",
"0.5825552",
"0.5802285",
"0.5794468",
"0.57922107",
"0.57873756",
"0.5776039",
"0.57737863",
"0.5771698",
"0.5771401",
"0.57593936",
"0.5758659",
"0.57573915",
"0.5743376",
"0.574305",
"0.5741799",
"0.5741414",
"0.573966",
"0.5730652",
"0.5730321",
"0.5726534",
"0.5726123",
"0.57186604",
"0.5717335",
"0.57098347",
"0.5706648",
"0.56980413",
"0.569629",
"0.56899375",
"0.5672899",
"0.5672297",
"0.56706506"
] |
0.68390846
|
0
|
DELETE /sales/1 DELETE /sales/1.json
|
def destroy
@sale.destroy
head :no_content
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @sale = Sale.find(params[:id])\n @sale.destroy\n\n respond_to do |format|\n format.html { redirect_to sales_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale = Sale.find(params[:id])\n @sale.destroy\n\n respond_to do |format|\n format.html { redirect_to sales_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale.destroy\n respond_to do |format|\n format.html { redirect_to sales_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale = Sale.find(params[:id])\n @sale.destroy\n\n respond_to do |format|\n format.html { redirect_to sales_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @sale = Sale.find(params[:id])\n @sale.destroy\n\n respond_to do |format|\n format.html { redirect_to sales_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @sales_item.destroy\n respond_to do |format|\n format.html { redirect_to sales_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sales_datum = SalesDatum.find(params[:id])\n @sales_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to sales_data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale.destroy\n respond_to do |format|\n format.html { redirect_to sales_url, notice: 'Sale was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale.destroy\n respond_to do |format|\n format.html { redirect_to sales_url, notice: 'Sale was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale.destroy\n respond_to do |format|\n format.html { redirect_to sales_url, notice: 'Sale was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale.destroy\n respond_to do |format|\n format.html { redirect_to sales_url, notice: 'Sale was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale.destroy\n respond_to do |format|\n format.html { redirect_to sales_url, notice: 'Sale was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale.destroy\n respond_to do |format|\n format.html { redirect_to sales_url, notice: 'Sale was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale.destroy\n respond_to do |format|\n format.html { redirect_to sales_url, notice: 'Sale was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale.destroy\n respond_to do |format|\n format.html { redirect_to sales_url, notice: 'Sale was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale.destroy\n respond_to do |format|\n format.html { redirect_to sales_url, notice: 'Sale was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale.destroy\n respond_to do |format|\n format.html { redirect_to sales_url, notice: \"Compra removida com sucesso.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale = Sale.find(params[:id])\n @sale.destroy\n respond_to do |format|\n format.html { redirect_to :sales }\n format.json { head :no_content }\n format.js { render :layout => false }\n end\n\n end",
"def destroy\n @sales_rep = SalesRep.find(params[:id])\n @sales_rep.destroy\n\n respond_to do |format|\n format.html { redirect_to sales_reps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale.destroy\n respond_to do |format|\n format.html { redirect_to sales_url, notice: '売上を削除しました' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale.destroy\n respond_to do |format|\n format.js\n format.html { redirect_to sales_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale.destroy\n respond_to do |format|\n format.html { redirect_to (@customer ? customer_sales_url(@customer) : sales_url), notice: 'Sale was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n \n @sale = Sale.find(params[:id])\n logger.info \"Sale #{@sale.title} destroyed by #{current_user.email}\"\n \n @sale.destroy\n\n respond_to do |format|\n format.html { redirect_to(sales_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @daily_sale.destroy\n respond_to do |format|\n format.html { redirect_to daily_sales_url, notice: 'Daily sale was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sales_order = SalesOrder.find(params[:id])\n @sales_order.destroy\n\n respond_to do |format|\n format.html { redirect_to sales_orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pre_sale = PreSale.find(params[:id])\n @pre_sale.destroy\n\n respond_to do |format|\n format.html { redirect_to pre_sales_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n instance = @sale.destroy\n render json: { msg: instance }, status: :ok\n end",
"def destroy\n @detail_sale.destroy\n respond_to do |format|\n format.html { redirect_to detail_sales_url, notice: \"Detail sale was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale.destroy\n respond_to do |format|\n format.html { redirect_to \"/bridge/delete_old_deal\", notice: 'Sale was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize @sale\n @sale.destroy\n respond_to do |format|\n format.html { redirect_to sales_url, notice: 'Sale was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale_invoice = SaleInvoice.find(params[:id])\n @sale_invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to monthly_movement_sale_invoices_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @d_sale_item = DSaleItem.find(params[:id])\n #@d_sale_item.destroy\n\n respond_to do |format|\n format.html { redirect_to d_sale_items_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @sale_day_total = SaleDayTotal.find(params[:id])\n @sale_day_total.destroy\n\n respond_to do |format|\n format.html { redirect_to sale_day_totals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale_order = current_company.sale_orders.find(params[:id])\n @sale_order.destroy\n\n respond_to do |format|\n format.html { redirect_to sale_orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sales_entry.destroy\n respond_to do |format|\n format.html { redirect_to sales_entries_url, notice: 'Sales entry was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @point_of_sale.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @purchase.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @business_sale.destroy\n respond_to do |format|\n format.html { redirect_to business_sales_url, notice: 'Business sale was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sales_type = SalesType.find(params[:id])\n @sales_type.destroy\n\n respond_to do |format|\n format.html { redirect_to({:controller=>\"sales_types\", :action=>\"index\"}) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @product_sale.destroy\n respond_to do |format|\n format.html { redirect_to product_sales_url, notice: 'Product sale was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rr_sale = RrSale.find(params[:id])\n @rr_sale.destroy\n\n respond_to do |format|\n format.html { redirect_to(rr_sales_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n render json: Company.delete(params[\"id\"])\n end",
"def destroy\n @sales_productivity = SalesProductivity.find(params[:id])\n @sales_productivity.destroy\n\n respond_to do |format|\n format.html { redirect_to sales_productivities_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @sales_order.destroy\n respond_to do |format|\n format.html { redirect_to sales_orders_url, notice: 'Sales order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale_payment.destroy\n respond_to do |format|\n format.html { redirect_to sale_payments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n for product_sale in @sale.product_sale\n product_sale.destroy\n end\n @sale.destroy\n respond_to do |format|\n format.html { redirect_to sales_url, notice: \"Venda apagada com sucesso.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sales_term = SalesTerm.find(params[:id])\n @sales_term.destroy\n\n respond_to do |format|\n format.html { redirect_to sales_terms_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @sales_product.destroy\n respond_to do |format|\n format.html { redirect_to sales_products_url, notice: 'Sales product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @requested_sales_document.destroy\n respond_to do |format|\n format.html { redirect_to requested_sales_documents_url, notice: 'Requested sales document was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n product = Product.find(params[:id])\n\n product.sales.each do |sale|\n sale.destroy\n end\n\n product.delete\n\n redirect_to controller: \"products\", action: \"index\"\n end",
"def destroy_rest\n @item_usage = ItemUsage.find(params[:id])\n @item_usage.destroy\n\n respond_to do |format|\n format.html { redirect_to(item_usages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @salesperson = Salesperson.find(params[:id])\n @salesperson.destroy\n\n respond_to do |format|\n format.html { redirect_to salespeople_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sales_history.destroy\n respond_to do |format|\n format.html { redirect_to sales_histories_url, notice: 'Sales history was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(*rest) end",
"def destroy\n @sale.destroy\n quotes = Quote.where(sale_id: @sale.id)\n\n quotes.each { |q| q.destroy }\n message = \"The sale: \\\"#{@sale.description.to_s.capitalize } \\\" was successfully deleted.\"\n respond_to do |format|\n format.html { redirect_to sales_url, notice: message }\n format.json { head :no_content }\n end\n end",
"def destroy\n @accesory_sale.destroy\n respond_to do |format|\n format.html { redirect_to accesory_sales_url, notice: 'Accesory sale was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def destroy\n @referral_sale.destroy\n respond_to do |format|\n format.html { redirect_to referral_sales_url, notice: 'Referral sale was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale_order = SaleOrder.find(params[:id])\n @sale_order.destroy\n\n respond_to do |format|\n format.html { redirect_to(sale_orders_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n get_data\n @sale_detail = @sale.details.find(params[:id])\n @sale_detail.destroy\n get_data\n end",
"def destroy\n authorize @origin_sale\n @origin_sale.destroy\n respond_to do |format|\n format.html { redirect_to origin_sales_url, notice: 'Origen de Venta eliminado con exito.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sales_order.destroy\n respond_to do |format|\n format.html { \n flash[:notice] = 'La Orden de Venta se eliminó satisfactoriamente.'\n redirect_to sales_orders_path\n }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shop_purchase = Shop::Purchase.find(params[:id])\n @shop_purchase.destroy\n\n respond_to do |format|\n format.html { redirect_to shop_purchases_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @purchase_datum.destroy\n respond_to do |format|\n format.html { redirect_to purchase_data_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n #realiza acciones necesarias para anular la venta\n @sale.anular_venta\n @sale.destroy\n \n respond_to do |format|\n format.html { redirect_to sales_url, notice: 'La Venta ha sido eliminada con exito. El producto está en stock nuevamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n @purchase.destroy\n respond_to do |format|\n\n format.html { redirect_to purchases_url }\n format.json { head :no_content }\n end\n\n end",
"def destroy\n @analytics_purchase.destroy\n respond_to do |format|\n format.html { redirect_to analytics_purchases_url, notice: 'Analytics purchase was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @supermarket = Supermarket.find(params[:id]) \n @supermarket.destroy\n respond_to do |format|\n format.json { render json: @supermarket, status: :ok }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @purchase.destroy\n respond_to do |format|\n format.html { redirect_to purchase_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @purchase = Purchase.find(params[:id])\n @purchase.destroy\n\n respond_to do |format|\n format.html { redirect_to purchases_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @purchase = Purchase.find(params[:id])\n @purchase.destroy\n\n respond_to do |format|\n format.html { redirect_to purchases_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @cal_month_sale.destroy\n respond_to do |format|\n format.html { redirect_to cal_month_sales_url, notice: 'Cal month sale was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @purchase = Purchase.find(params[:id])\n @purchase.destroy\n\n respond_to do |format|\n format.html { redirect_to purchases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @purchase = Purchase.find(params[:id])\n @purchase.destroy\n\n respond_to do |format|\n format.html { redirect_to purchases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @purchase = Purchase.find(params[:id])\n @purchase.destroy\n\n respond_to do |format|\n format.html { redirect_to purchases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @purchase = Purchase.find(params[:id])\n @purchase.destroy\n\n respond_to do |format|\n format.html { redirect_to purchases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @purchase = Purchase.find(params[:id])\n @purchase.destroy\n\n respond_to do |format|\n format.html { redirect_to purchases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sales_associate.destroy\n respond_to do |format|\n format.html { redirect_to sales_associates_url, notice: 'Sales associate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sales_group.destroy\n respond_to do |format|\n format.html { redirect_to sales_groups_url }\n format.json { head :no_content }\n end\n end",
"def delete\n request(:delete)\n end",
"def destroy\n @sales_coffee.destroy\n respond_to do |format|\n format.html { redirect_to sales_coffees_url, notice: \"Sales coffee was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete_index\n @customer = Customer.with_deleted.find(params[:id])\n if params[:type]=='normal'\n @customer.delete\n elsif params[:type]=='restore'\n @customer.restore\n @customer.update(deleted_at: nil)\n end\n\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_path, notice: 'Customer was successfully removed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n record = InvoiceLineItem.find(params[:id])\n record.destroy\n\n respond_to do |format| \n format.json { head :no_content }\n end\n end",
"def destroy\n # find ALL servings associated with this purchase and delete them\n all_servings = Serving.where(purchase_id: @purchase.id)\n puts \"all servings associated with this purchase: #{all_servings}\"\n all_servings.destroy_all\n puts \"deleted servings\"\n @purchase.destroy\n puts \"deleted purchase\"\n render json: {status: 204, purchase: @purchase}\n end",
"def destroy\n @sale_on_sale_import = SaleOnSaleImport.find(params[:id])\n @sale_on_sale_import.destroy\n\n respond_to do |format|\n format.html { redirect_to(sale_on_sale_imports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sale_type.destroy\n respond_to do |format|\n format.html { redirect_to sale_types_url, notice: \"Sale type was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale.destroy\n respond_to do |format|\n format.html { redirect_to new_team_event_sale_path(active_event), notice: 'Sale was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def test_del\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 id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def destroy\n @purchase.destroy\n respond_to do |format|\n\n format.html { redirect_to sell_list_path, notice: '주문이 삭제되었습니다.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @investigated.destroy\n respond_to do |format| \n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t\t\t @store = Store.find(params[:id])\n\t\t\t\t @store.destroy\n\n\t\t\t\t respond_to do |format|\n\t\t\t\t format.html { redirect_to stores_url }\n\t\t\t\t format.json { head :no_content }\n\t\t\t\t end\n\t\t\t\t end",
"def destroy\n @sales_plan.destroy\n respond_to do |format|\n format.html { redirect_to sales_plans_url, notice: 'Sales plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hotsale.destroy\n respond_to do |format|\n format.html { redirect_to hotsales_url, notice: 'Hotsale ha sido eliminado' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @store = Store.find(params[:id])\n @store.destroy\n\n respond_to do |format|\n format.html { redirect_to stores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @store = Store.find(params[:id])\n @store.destroy\n\n respond_to do |format|\n format.html { redirect_to stores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @store = Store.find(params[:id])\n @store.destroy\n\n respond_to do |format|\n format.html { redirect_to stores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @store = Store.find(params[:id])\n @store.destroy\n\n respond_to do |format|\n format.html { redirect_to stores_url }\n format.json { head :no_content }\n end\n end"
] |
[
"0.7543942",
"0.7543942",
"0.7525767",
"0.7521719",
"0.7521719",
"0.72487503",
"0.7212534",
"0.7173833",
"0.7173833",
"0.7173833",
"0.7173833",
"0.7173833",
"0.7173833",
"0.7173833",
"0.7173833",
"0.7173833",
"0.71368027",
"0.71094704",
"0.7079158",
"0.7075881",
"0.70758647",
"0.7072191",
"0.70719653",
"0.70592993",
"0.70582587",
"0.69794375",
"0.69704485",
"0.69525295",
"0.6952459",
"0.6946784",
"0.69463235",
"0.6923892",
"0.68981266",
"0.687851",
"0.68715733",
"0.6846977",
"0.6821026",
"0.6779952",
"0.67769957",
"0.6771165",
"0.6768542",
"0.67612827",
"0.6749848",
"0.6746558",
"0.6746436",
"0.67367417",
"0.6733349",
"0.67026365",
"0.6699054",
"0.6675616",
"0.6672284",
"0.66698486",
"0.6669566",
"0.66672575",
"0.66661066",
"0.66604596",
"0.6659777",
"0.6658619",
"0.66464764",
"0.66450924",
"0.662859",
"0.661984",
"0.6610455",
"0.6603541",
"0.65988463",
"0.6594248",
"0.6578151",
"0.6572932",
"0.6568942",
"0.65675193",
"0.65661764",
"0.65582854",
"0.65582854",
"0.6558009",
"0.65570813",
"0.65570813",
"0.65570813",
"0.65570813",
"0.65570813",
"0.65552205",
"0.6552502",
"0.6548774",
"0.65467936",
"0.6546018",
"0.6541558",
"0.65332556",
"0.6526164",
"0.6523251",
"0.6516779",
"0.65128535",
"0.65061516",
"0.6501451",
"0.6497889",
"0.6487019",
"0.64869773",
"0.6486391",
"0.6484462",
"0.6484462",
"0.6484462",
"0.6484462"
] |
0.7151653
|
16
|
GET /pesos GET /pesos.xml
|
def index
@pesos = Peso.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @pesos }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @peeps = Peep.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @peeps }\n end\n end",
"def index\n @pagos = Pago.find(:all)\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pagos }\n end\n end",
"def index\n @pagos = Pago.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pagos }\n end\n end",
"def index\n @pecas = Peca.find :all, :order => :produto_id\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pecas }\n end\n end",
"def index\n @pos = Po.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pos }\n end\n end",
"def index\n @pacientes = Paciente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pacientes }\n end\n end",
"def index\n @ptos = Pto.all_by_date\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ptos }\n end\n end",
"def show\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pessoa }\n end\n end",
"def index\n @poblacionesespeciales = Poblacionesespecial.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @poblacionesespeciales }\n end\n end",
"def show\n @peso = Peso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @peso }\n end\n end",
"def index\n @progres = Progre.paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @progres }\n end\n end",
"def index\n @procesos = Proceso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @procesos }\n end\n end",
"def show\n @peep = Peep.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @peep }\n end\n end",
"def show\n @pessoa = Pessoa.find(params[:id])\n @listas = @pessoa.listas\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pessoa }\n end\n end",
"def index\n @ppos_prerequisites = PposPrerequisite.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ppos_prerequisites }\n end\n end",
"def show\n @promos = Promos.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @promos }\n end\n end",
"def index\n @st_pis = StPi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @st_pis }\n end\n end",
"def index\n @ingresos = Ingreso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ingresos }\n end\n end",
"def index\n @paciente = Paciente.find(params[:paciente_id])\n @visitas = @paciente.visitas\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @visitas }\n end\n end",
"def index\n @premios = Premio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @premios }\n end\n end",
"def index\n @puffin_orders = PuffinOrder.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @puffin_orders }\n end\n end",
"def show\n @nossos_servico = NossosServico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @nossos_servico }\n end\n end",
"def index\n @partido_politicos = PartidoPolitico.paginate(:per_page => 20, :page =>params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @partido_politicos }\n end\n end",
"def index\n @tipos_pagamentos = TiposPagamento.find(:all, :order => \"nome\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tipos_pagamentos }\n end\n end",
"def index\n @foros = Foro.paginate(:per_page => 20, :page => params[:page], :order => 'id DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @foros }\n end\n end",
"def index\n @profesors = Profesor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @profesors }\n end\n end",
"def index\n @search = Tso::Search.new(params[:search])\n @tsos = Tso.paginate(@search.find_options.merge(:page => params[:page]))\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tsos.to_xml(:except => [ :created_at, :updated_at ]) }\n end\n end",
"def index\n\n # wczesniejszy sposob wyswietlania wierszy\n # @poems = Poem.all\n \n # wyswietlani wierszy z paginacja\n @poems = Poem.paginate :page => params[:page], :order => 'created_at DESC'\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @poems }\n format.rss\n end\n end",
"def show\n @pto = Pto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pto }\n end\n end",
"def show\n @puesto = Puesto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @puesto }\n end\n end",
"def show\n @peca = Peca.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @peca }\n end\n end",
"def index\n @avisos = Aviso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @avisos }\n end\n end",
"def index\n @paquetes = Paquete.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @paquetes }\n end\n end",
"def index\n @eventos = Evento.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @eventos }\n end\n end",
"def index\n @omatsuris = Omatsuri.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @omatsuris }\n format.json { render :json => @omatsuris }\n end\n end",
"def index\n @procedures = Procedure.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @procedures }\n end\n end",
"def show\n @pago = Pago.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pago }\n end\n end",
"def serveOAI\n content_type 'text/xml;charset=utf-8'\n provider = EscholProvider.new\n provider.process_request(params)\n end",
"def index\n @csos = Cso.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @csos }\n end\n end",
"def index\n @paises = Paise.paginate(:per_page => 20, :page =>params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @paises }\n end\n end",
"def index\n @spielbegegnungs = Spielbegegnung.all\n #@spieler_tipps = current_user.tippgemeinschafts.first.tipps\n \n \n \n respond_to do |format|\n format.html # index.html.erb\n format.xml #{ render :xml => @spielbegegnungs }\n end\n end",
"def index\n @perfis = Perfil.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @perfis }\n end\n end",
"def index\n @pages = @offering.pages.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def index\n @exposures = Exposure.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @exposures }\n end\n end",
"def index\n @solicitudes = Solicitud.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @solicitudes }\n end\n end",
"def index\n @pesos = Peso.all\n end",
"def index\n @parcels = Parcel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @parcels }\n end\n end",
"def show\n @pulve = Pulve.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pulve }\n end\n end",
"def index\n @st_ipis = StIpi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @st_ipis }\n end\n end",
"def index\n @spots = Spot.find(:all) \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @spots }\n end\n end",
"def show\n @spouse = Spouse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @spouse }\n end\n end",
"def index\n @pm_elements = PmElement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pm_elements }\n end\n end",
"def get_xml\n response = @api.request(:get, @location, type: 'xml')\n response.body if response.status == 200\n end",
"def xml(options = {})\n http = Net::HTTP.new(Picasa.host, 443)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n path = Picasa.path(options)\n response = http.get(path, auth_header)\n if response.code =~ /20[01]/\n response.body\n elsif response.code.to_i == 403\n raise RubyPicasa::PicasaError, \"Authentication failed. You may need to refresh your access token.\"\n end\n end",
"def index\n @pieces_commandes = PiecesCommande.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pieces_commandes }\n end\n end",
"def list\n @oyoyos = Oyoyo.find (:all)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @oyoyo }\n end\n \nend",
"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 index\n @presses = Press.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @presses }\n end\n end",
"def index\n @viviendastipostramites = Viviendastipostramite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @viviendastipostramites }\n end\n end",
"def index\n @documentos = @externo.documentos.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @documentos }\n end\n end",
"def index\n @estatus = Estatu.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @estatus }\n end\n end",
"def index\n @search = Promocao.search(params[:search])\n @promocoes = @search.all.paginate(:page => params[:page])\n @sortear = params[\"sortear\"]\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @promocoes }\n end\n end",
"def index\n @sprints = @product.sprints\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sprints }\n end\n end",
"def show\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @premio }\n end\n end",
"def index\n @nodes = Node.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n end\n end",
"def index\n @nodes = Node.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n end\n end",
"def index\n @corporacion_policiacas = CorporacionPoliciaca.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @corporacion_policiacas }\n end\n end",
"def index\n @os_types = OsType.find(:all, :order => 'position')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @os_types }\n end\n end",
"def index\n @pizarras = Pizarra.paginate :page => params[:page],:per_page => 4\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pizarras }\n end\n end",
"def show\n @promocao = Promocao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @promocao }\n end\n end",
"def index\n @asistencias = Asistencia.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @asistencias }\n end\n end",
"def index\n\t\t# Mapeando Departamentos e Seções ativas\n\t\t@secoes = Section.where(\"ativo = 't'\")\n\t\t@departamentos = Departamento.where(\"ativo = 't'\")\n\n\t\t@pedidos = Venda.where(\"cliente = ?\",session[:logcli]).all\t\t# Aqui é a apresentação de todos os Registros dlo cliente logado...\n\n\t\t@totpedidos = @pedidos.size\n\t\t\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml {render :xml => @pedidos}\n\t\tend\n\tend",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @documentos }\n end\n end",
"def show\n @poem = Poem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @poem }\n end\n end",
"def show\n @poem = Poem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @poem }\n end\n end",
"def index\r\n @search = TransportationSlip.search(params[:search])\r\n @transportation_slips = @search.all(:order => \"id DESC\").paginate(:page => params[:page], :per_page => 50)\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @transportation_slips }\r\n end\r\n end",
"def index\n @descriptor_especificos = DescriptorEspecifico.paginate(:per_page => 20, :page =>params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @descriptor_especificos }\n end\n end",
"def index\n @promotion_boxes = PromotionBox.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @promotion_boxes }\n end\n end",
"def index\n @soaps = Soap.all\n end",
"def index\n @passages = Passage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @passages }\n end\n end",
"def show\n @partei = Partei.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @partei }\n end\n end",
"def index\n @permisos = Permiso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @permisos }\n end\n end",
"def index\n @novidades = Novidade.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @novidades }\n end\n end",
"def index\n @components_saddles = Components::Saddle.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @components_saddles }\n end\n end",
"def index\n @ventas_presupuestos = Ventas::Presupuesto.paginate(:page => params[:page], :per_page => 5)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ventas_presupuestos }\n end\n end",
"def index\n @positions = Position.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @positions }\n end\n end",
"def index\n @jidos = Jido.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @jidos }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def index\n @pages = Page.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def index\n @pages = Page.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def index\n @provisions = Provision.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @provisions }\n end\n end",
"def pacscl_xml\n document = Blacklight.default_index.search(q: \"id:#{params[:id]}\")&.dig(\"response\", \"docs\")&.first\n document = SolrDocument.new(document)\n document.suppress_xml_containers!\n respond_to do |format|\n format.xml do\n render xml: document.export_as_xml\n end\n end\n end",
"def index\n @frequencia_profissoes = Frequencia::Profissao.order('updated_at ASC').paginate :page => params[:page], :per_page => 10\n @total = Frequencia::Profissao.all.count\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @frequencia_profissoes }\n end\n end",
"def index\n @pages = Page.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def index\n @employees = $Vendor.employees.scopied.order(\"created_at desc\").page(params[:page]).per(25)\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @employees }\n end\n end",
"def index\n @prospective_users = ProspectiveUser.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @prospective_users }\n end\n end",
"def path\n \"/onca/xml\"\n end",
"def index\n @archivospazysalvos = Archivospazysalvo.find(:all, :order => \"created_at desc\")\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @archivospazysalvos }\n end\n end",
"def index\n @pedidos = Pedido.all(:order => \"fecha ASC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pedidos }\n end\n end",
"def index\r\n @doctipos = Doctipo.find(:all)\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @doctipos }\r\n end\r\n end"
] |
[
"0.68850297",
"0.6617565",
"0.65939",
"0.65918356",
"0.63723797",
"0.63382316",
"0.6282804",
"0.6265331",
"0.6242772",
"0.6152604",
"0.6128321",
"0.61254776",
"0.60904086",
"0.60746497",
"0.6066335",
"0.605559",
"0.6047051",
"0.60396016",
"0.60325354",
"0.60206825",
"0.6005128",
"0.5996007",
"0.5985892",
"0.59797263",
"0.5974009",
"0.5955209",
"0.5941413",
"0.59343827",
"0.5926834",
"0.59231204",
"0.590209",
"0.59003735",
"0.5874346",
"0.5853269",
"0.5841165",
"0.58348733",
"0.58310133",
"0.5829506",
"0.58287454",
"0.58277184",
"0.58252776",
"0.5819837",
"0.5816763",
"0.5815731",
"0.5813895",
"0.5813337",
"0.5791163",
"0.57770455",
"0.57770026",
"0.576674",
"0.5757674",
"0.5747852",
"0.57365334",
"0.57309663",
"0.5729973",
"0.5729421",
"0.5725651",
"0.5722846",
"0.57119447",
"0.5705451",
"0.5700988",
"0.5692677",
"0.56893164",
"0.56884325",
"0.56786215",
"0.56786215",
"0.5675907",
"0.5671967",
"0.56651765",
"0.56569266",
"0.56564134",
"0.56541073",
"0.5652585",
"0.56376946",
"0.56376946",
"0.56340486",
"0.56299716",
"0.562851",
"0.56271726",
"0.56195986",
"0.5619142",
"0.5618215",
"0.5618183",
"0.56167537",
"0.5615273",
"0.5615106",
"0.5612636",
"0.5608716",
"0.5603019",
"0.5603019",
"0.55935806",
"0.55890363",
"0.5578835",
"0.5576771",
"0.55690455",
"0.5561011",
"0.5559245",
"0.55573714",
"0.5555461",
"0.55554307"
] |
0.71547824
|
0
|
GET /pesos/1 GET /pesos/1.xml
|
def show
@peso = Peso.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @peso }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @pesos = Peso.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pesos }\n end\n end",
"def index\n @peeps = Peep.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @peeps }\n end\n end",
"def index\n @pecas = Peca.find :all, :order => :produto_id\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pecas }\n end\n end",
"def show\n @nossos_servico = NossosServico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @nossos_servico }\n end\n end",
"def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n end\n end",
"def index\n @pos = Po.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pos }\n end\n end",
"def show\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pessoa }\n end\n end",
"def index\n @pagos = Pago.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pagos }\n end\n end",
"def index\n @pagos = Pago.find(:all)\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pagos }\n end\n end",
"def show\n @peep = Peep.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @peep }\n end\n end",
"def show\n @pto = Pto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pto }\n end\n end",
"def index\n @progres = Progre.paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @progres }\n end\n end",
"def show\n @promos = Promos.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @promos }\n end\n end",
"def get_xml\n response = @api.request(:get, @location, type: 'xml')\n response.body if response.status == 200\n end",
"def index\n @ptos = Pto.all_by_date\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ptos }\n end\n end",
"def index\n @pacientes = Paciente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pacientes }\n end\n end",
"def api_xml(path,method=:get,options={})\n xml_message(amee,\"/data\"+path,method,options)\n end",
"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 index\n @st_pis = StPi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @st_pis }\n end\n end",
"def show\n @puesto = Puesto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @puesto }\n end\n end",
"def show\n @peca = Peca.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @peca }\n end\n end",
"def path\n \"/onca/xml\"\n end",
"def index\n @procesos = Proceso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @procesos }\n end\n end",
"def index\n @foros = Foro.paginate(:per_page => 20, :page => params[:page], :order => 'id DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @foros }\n end\n end",
"def index\n @ppos_prerequisites = PposPrerequisite.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ppos_prerequisites }\n end\n end",
"def index\n @poblacionesespeciales = Poblacionesespecial.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @poblacionesespeciales }\n end\n end",
"def show\n @pessoa = Pessoa.find(params[:id])\n @listas = @pessoa.listas\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pessoa }\n end\n end",
"def serveOAI\n content_type 'text/xml;charset=utf-8'\n provider = EscholProvider.new\n provider.process_request(params)\n end",
"def index\n @paciente = Paciente.find(params[:paciente_id])\n @visitas = @paciente.visitas\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @visitas }\n end\n end",
"def index\n @estatus = Estatu.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @estatus }\n end\n end",
"def show\n @spouse = Spouse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @spouse }\n end\n end",
"def index\n @ingresos = Ingreso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ingresos }\n end\n end",
"def pacscl_xml\n document = Blacklight.default_index.search(q: \"id:#{params[:id]}\")&.dig(\"response\", \"docs\")&.first\n document = SolrDocument.new(document)\n document.suppress_xml_containers!\n respond_to do |format|\n format.xml do\n render xml: document.export_as_xml\n end\n end\n end",
"def index\n @search = Tso::Search.new(params[:search])\n @tsos = Tso.paginate(@search.find_options.merge(:page => params[:page]))\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tsos.to_xml(:except => [ :created_at, :updated_at ]) }\n end\n end",
"def show\n @pago = Pago.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pago }\n end\n end",
"def index\n @eventos = Evento.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @eventos }\n end\n end",
"def index\n @perfis = Perfil.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @perfis }\n end\n end",
"def index\n @tipos_pagamentos = TiposPagamento.find(:all, :order => \"nome\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tipos_pagamentos }\n end\n end",
"def index\n @st_ipis = StIpi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @st_ipis }\n end\n end",
"def index\n @csos = Cso.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @csos }\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 @pulve = Pulve.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pulve }\n end\n end",
"def show\n @po = Po.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @po }\n end\n end",
"def show\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @premio }\n end\n end",
"def index\n @premios = Premio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @premios }\n end\n end",
"def index\n @partido_politicos = PartidoPolitico.paginate(:per_page => 20, :page =>params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @partido_politicos }\n end\n end",
"def index\n @avisos = Aviso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @avisos }\n end\n end",
"def index\n @solicitudes = Solicitud.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @solicitudes }\n end\n end",
"def index\n @procedures = Procedure.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @procedures }\n end\n end",
"def index\n @descriptor_genericos = DescriptorGenerico.paginate(:per_page => 20, :page =>params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @descriptor_genericos }\n end\n end",
"def show\n @precio = Precio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @precio }\n end\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 @os_type = OsType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @os_type }\n end\n end",
"def show\n @estagio = Estagio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estagio }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @documentos }\n end\n end",
"def index\n @profesors = Profesor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @profesors }\n end\n end",
"def show\n @silo = Silo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @silo }\n end\n end",
"def show\n @promocao = Promocao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @promocao }\n end\n end",
"def index\n @descriptor_especificos = DescriptorEspecifico.paginate(:per_page => 20, :page =>params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @descriptor_especificos }\n end\n end",
"def index\n @sprints = @product.sprints\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sprints }\n end\n end",
"def index\n @os_types = OsType.find(:all, :order => 'position')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @os_types }\n end\n end",
"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 index\n @puffin_orders = PuffinOrder.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @puffin_orders }\n end\n end",
"def index\n @spielbegegnungs = Spielbegegnung.all\n #@spieler_tipps = current_user.tippgemeinschafts.first.tipps\n \n \n \n respond_to do |format|\n format.html # index.html.erb\n format.xml #{ render :xml => @spielbegegnungs }\n end\n end",
"def show\n @periode = Periode.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @periode }\n end\n end",
"def index\n @omatsuris = Omatsuri.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @omatsuris }\n format.json { render :json => @omatsuris }\n end\n end",
"def index\n @documentos = @externo.documentos.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @documentos }\n end\n end",
"def ping\n @status = Status.find(:first)\n respond_to do |format|\n format.html\n format.xml { render :xml => @status }\n end \n end",
"def index\n @pages = @offering.pages.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def readSrepData(config_index)\n file_name = $srep_file_path + config_index.to_s() + \".xml\"\n f = File.open(file_name)\n doc = Nokogiri::XML(f)\n f.close\n return doc\nend",
"def list\n @oyoyos = Oyoyo.find (:all)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @oyoyo }\n end\n \nend",
"def show\n @poem = Poem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @poem }\n end\n end",
"def show\n @poem = Poem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @poem }\n end\n end",
"def index\n @exposures = Exposure.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @exposures }\n end\n end",
"def index\n @pieces_commandes = PiecesCommande.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pieces_commandes }\n end\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 @ep = Ep.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ep }\n end\n end",
"def index\n @especie = Especie.find(params[:especie_id])\n @especie_imagens = EspecieImagem.find(@especie.especie_imagens)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @especie_imagens }\n end\n end",
"def show\n @partei = Partei.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @partei }\n end\n end",
"def index\n\n @soaps = Soap.find(:all)\n @user = User.find(:first)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @purchase }\n end\n end",
"def show\n @pneighbour = Pneighbour.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pneighbour }\n end\n end",
"def index\n @eversions = Eversion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @eversions }\n end\n end",
"def index\n\n # wczesniejszy sposob wyswietlania wierszy\n # @poems = Poem.all\n \n # wyswietlani wierszy z paginacja\n @poems = Poem.paginate :page => params[:page], :order => 'created_at DESC'\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @poems }\n format.rss\n end\n end",
"def index\n @components_saddles = Components::Saddle.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @components_saddles }\n end\n end",
"def index\n @nodes = Node.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n end\n end",
"def index\n @nodes = Node.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n end\n end",
"def show\n @estatu = Estatu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estatu }\n end\n end",
"def show\n @poblacionesespecial = Poblacionesespecial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @poblacionesespecial }\n end\n end",
"def show\n @st_pi = StPi.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @st_pi }\n end\n end",
"def index\n @paises = Paise.paginate(:per_page => 20, :page =>params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @paises }\n end\n end",
"def index\n @viviendastipostramites = Viviendastipostramite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @viviendastipostramites }\n end\n end",
"def show\n @spiel = Spiel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @spiel }\n end\n end",
"def index\n @paquetes = Paquete.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @paquetes }\n end\n end",
"def show\n #NOT USING\n @puppy = Puppy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @puppy }\n end\n end",
"def index\n @installation = Installation.find(params[:installation_id]) \n @onposts = @installation.onposts \n \n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @onposts }\n end\n end",
"def show\n @serie = Serie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @serie }\n end\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 show\n @visaapp = Visaapp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @visaapp }\n end\n end",
"def show\n @lista_precio = ListaPrecio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lista_precio }\n end\n end",
"def index\n @pm_elements = PmElement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pm_elements }\n end\n end"
] |
[
"0.6677637",
"0.6426573",
"0.6210616",
"0.61761934",
"0.6127416",
"0.61191845",
"0.6109071",
"0.6105923",
"0.6090318",
"0.59915113",
"0.59711814",
"0.5955033",
"0.5937388",
"0.59240735",
"0.5921882",
"0.5879788",
"0.58701456",
"0.5864058",
"0.58522826",
"0.5846265",
"0.58453816",
"0.58382326",
"0.582691",
"0.58235306",
"0.58087593",
"0.5807549",
"0.5746357",
"0.5744453",
"0.57433695",
"0.57326645",
"0.5732358",
"0.5731606",
"0.57155246",
"0.5708763",
"0.57040805",
"0.5696179",
"0.5692399",
"0.56787264",
"0.56731665",
"0.56702876",
"0.5664301",
"0.56609267",
"0.5660594",
"0.56463486",
"0.56462294",
"0.564442",
"0.5633986",
"0.5632986",
"0.56232977",
"0.56152636",
"0.5612943",
"0.56096375",
"0.56094784",
"0.56015646",
"0.5601424",
"0.55985945",
"0.55888444",
"0.5587113",
"0.55845827",
"0.5580436",
"0.55795026",
"0.55687463",
"0.55642676",
"0.5558945",
"0.55574244",
"0.5546861",
"0.5546092",
"0.55455065",
"0.554418",
"0.55396277",
"0.55378157",
"0.5531942",
"0.5531942",
"0.5527891",
"0.551179",
"0.5503885",
"0.55027866",
"0.55008626",
"0.5499035",
"0.54931724",
"0.5492327",
"0.5489413",
"0.5487029",
"0.5486072",
"0.5484083",
"0.5484083",
"0.54813933",
"0.54764014",
"0.54740965",
"0.54727095",
"0.54712033",
"0.54685646",
"0.54660916",
"0.54576147",
"0.54485196",
"0.54427546",
"0.5439339",
"0.5437022",
"0.54307485",
"0.54249394"
] |
0.61061406
|
7
|
GET /pesos/new GET /pesos/new.xml
|
def new
@asignaturas = Asignatura.find(:all)
@peso = Peso.new
if !params[:id].nil?
@asignaturas = Asignatura.find_all_by_id(params[:id])
end
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @peso }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"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 @nossos_servico = NossosServico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nossos_servico }\n end\n end",
"def new\n @pessoa = Pessoa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pessoa }\n end\n end",
"def new\n @pessoa = Pessoa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pessoa }\n end\n end",
"def new\n @peca = Peca.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @peca }\n end\n end",
"def new\n @promos = Promos.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @promos }\n end\n end",
"def new\n @po = Po.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @po }\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 @puesto = Puesto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @puesto }\n end\n end",
"def new\n @precio = Precio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @precio }\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 @premio = Premio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @premio }\n end\n end",
"def new\n @spiel = Spiel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @spiel }\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 @peep = Peep.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @peep }\n end\n end",
"def new\n @promocao = Promocao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @promocao }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instituto }\n end\n end",
"def new\n @ponto = Ponto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ponto }\n end\n end",
"def new\n @pneighbour = Pneighbour.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pneighbour }\n end\n end",
"def new\n @silo = Silo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @silo }\n end\n end",
"def new\n @produto = ProdutoSimples.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @produto }\n end\n end",
"def new\n @page_id = \"services\"\n @service = Service.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @service }\n end\n end",
"def new\n @proceso = Proceso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @proceso }\n end\n end",
"def new\n @pulve = Pulve.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pulve }\n end\n end",
"def new\n @os_type = OsType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @os_type }\n end\n end",
"def new\n @st_pi = StPi.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @st_pi }\n end\n end",
"def new\n @service = Service.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml\n end\n end",
"def new\n @tiposproceso = Tiposproceso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tiposproceso }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nomina }\n end\n end",
"def new\n new_prc\n\n setup_campuses_and_semesters\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prc }\n end\n end",
"def new\n @pais = Pais.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pais }\n end\n end",
"def new\n @echo = Echo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @echo }\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 @estatu = Estatu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estatu }\n end\n end",
"def new\n @novel = Novel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @novel }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @system }\n end\n end",
"def new\n @ep = Ep.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ep }\n end\n end",
"def new\n @poblacionesespecial = Poblacionesespecial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @poblacionesespecial }\n end\n end",
"def new\n @estagio = Estagio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estagio }\n end\n end",
"def new\n @page = Page.new\n\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 respond_to do |format|\n format.html\n format.xml\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 @page_id = \"opinions\"\n @opinion = Opinion.new\n @agents = Agent.all.collect {|item| [ item.name, item.id ]}\n @services = Service.find(:all).collect {|item| [ item.name, item.id ]}\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @opinion }\n end\n end",
"def new\n @domino = Domino.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @domino }\n end\n end",
"def new\n @partei = Partei.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @partei }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml \n end\n end",
"def newX\n @server = Server.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @server }\n end\n end",
"def new\n @serie = Serie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @serie }\n end\n end",
"def new\n @prueba = Prueba.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prueba }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n \n end\n end",
"def new\n @protocolo = Protocolo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @protocolo }\n end\n end",
"def new\n @page = Page.new\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 @page = Page.new\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 @page = Page.new\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 @page = Page.new\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 @page = Page.new\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 @page = Page.new\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 @aviso = Aviso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @aviso }\n end\n end",
"def new\n @paciente = Paciente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @paciente }\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 @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 @patrimonio = Patrimonio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @patrimonio }\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 @sofa = Sofa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sofa }\n end\n end",
"def new\n @solicitud = Solicitud.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @solicitud }\n end\n end",
"def new\n @produto = Produto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @produto }\n end\n end",
"def new\n @produto = Produto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @produto }\n end\n end",
"def new\n @poem = Poem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @poem }\n end\n end",
"def new\n @poem = Poem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @poem }\n end\n end",
"def new\n @colo = Colo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @colo }\n end\n end",
"def new\n @plantilla = Plantilla.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @plantilla }\n end\n end",
"def new\n @documento = Documento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @documento }\n end\n end",
"def new\n @tipo_pago = TipoPago.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_pago }\n end\n end",
"def new\n @voto = Voto.new\n\n # respond_to do |format|\n # format.html # new.html.erb\n # format.xml { render :xml => @ponto }\n #end\n end",
"def new\n @pizarra = Pizarra.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pizarra }\n end\n end",
"def new\n @periode = Periode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @periode }\n end\n end",
"def new\n @ponto = Ponto.new\n @t = params[:estagiario_id]\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ponto }\n end\n end",
"def new\n @rssnew = Rssnews.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rssnew }\n end\n end",
"def new\n @tipos_pagamento = TiposPagamento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipos_pagamento }\n end\n end",
"def new\n @pdig = Pdig.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pdig }\n end\n end",
"def new\n @via = Via.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @via }\n end\n end",
"def new\n @tservicio = Tservicio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tservicio }\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_nonva_porca_pupazza\n @person= Person.new\n respond_to do |format|\n format.html\n format.xml { render :xml => @person }\n end\n end",
"def new\n @todos = Todos.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @todos }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ontology }\n end\n end",
"def new\n @evento = Evento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @evento }\n end\n end",
"def new\n @procedure = Procedure.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @procedure }\n end\n end",
"def new\n @pagina = Pagina.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pagina }\n end\n end",
"def new\n @partenaire = Partenaire.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @partenaire }\n end\n end",
"def new\n @partenaire = Partenaire.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @partenaire }\n end\n end",
"def new\n @tipo_proy = TipoProy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_proy }\n end\n end",
"def create\n @peso = Peso.new(params[:peso])\n p params[:peso]\n\n respond_to do |format|\n if @peso.save\n flash[:notice] = 'Peso was successfully created.'\n format.html { redirect_to(@peso) }\n format.xml { render :xml => @peso, :status => :created, :location => @peso }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @peso.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.xml { render :xml => @ciclo }\n end\n end",
"def new\n @ingreso = Ingreso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ingreso }\n end\n end",
"def new\n @platillo = Platillo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @platillo }\n end\n end",
"def new\n @pagamento = Pagamento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pagamento }\n end\n end",
"def new\n @photocontest = Photocontest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @photocontest }\n end\n end",
"def new\n @lore = Lore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lore }\n end\n end"
] |
[
"0.71352416",
"0.71166426",
"0.7100698",
"0.7100698",
"0.6975216",
"0.6911657",
"0.68823665",
"0.68492174",
"0.6799263",
"0.67971045",
"0.67512035",
"0.67460877",
"0.67408305",
"0.6739663",
"0.671748",
"0.66977686",
"0.66948956",
"0.6690016",
"0.66811204",
"0.6667047",
"0.6666604",
"0.6647539",
"0.6625503",
"0.66208065",
"0.66192615",
"0.6609591",
"0.66048944",
"0.6599412",
"0.658933",
"0.65856445",
"0.6583461",
"0.6556458",
"0.6551956",
"0.6551544",
"0.65505147",
"0.6550083",
"0.65454817",
"0.65418625",
"0.65396076",
"0.6527545",
"0.6527092",
"0.6522906",
"0.651448",
"0.6513909",
"0.65124184",
"0.6508354",
"0.6506856",
"0.6501672",
"0.6493847",
"0.64899474",
"0.648893",
"0.6488196",
"0.6486864",
"0.6481774",
"0.6481774",
"0.6481774",
"0.6481774",
"0.6481774",
"0.6481774",
"0.6476447",
"0.64737064",
"0.646689",
"0.64638054",
"0.64615613",
"0.6459558",
"0.64564157",
"0.6455782",
"0.6455133",
"0.6455133",
"0.645493",
"0.645493",
"0.64547414",
"0.64503175",
"0.64333993",
"0.64327496",
"0.6430343",
"0.6428241",
"0.6425271",
"0.6424123",
"0.64234287",
"0.6423283",
"0.6420006",
"0.6419029",
"0.64174074",
"0.64163345",
"0.6416022",
"0.64157385",
"0.641292",
"0.64122367",
"0.64103425",
"0.6409828",
"0.64094937",
"0.64094937",
"0.64093524",
"0.6408835",
"0.6406576",
"0.6406008",
"0.64041215",
"0.64014727",
"0.63998497",
"0.639848"
] |
0.0
|
-1
|
POST /pesos POST /pesos.xml
|
def create
@peso = Peso.new(params[:peso])
p params[:peso]
respond_to do |format|
if @peso.save
flash[:notice] = 'Peso was successfully created.'
format.html { redirect_to(@peso) }
format.xml { render :xml => @peso, :status => :created, :location => @peso }
else
format.html { render :action => "new" }
format.xml { render :xml => @peso.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @pessoa = Pessoa.new(params[:pessoa])\n\n respond_to do |format|\n if @pessoa.save\n flash[:notice] = 'Pessoa was successfully created.'\n format.html { redirect_to(@pessoa) }\n format.xml { render :xml => @pessoa, :status => :created, :location => @pessoa }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @pessoa.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @promos = Promos.new(params[:promos])\n\n respond_to do |format|\n if @promos.save\n flash[:notice] = 'Promos was successfully created.'\n format.html { redirect_to(@promos) }\n format.xml { render :xml => @promos, :status => :created, :location => @promos }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @promos.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end",
"def create\n @pessoa = Pessoa.new(params[:pessoa])\n respond_to do |format|\n if @pessoa.save\n format.html { redirect_to(@pessoa, :notice => 'Pessoa cadastrada com sucesso.') }\n format.xml { render :xml => @pessoa, :status => :created, :location => @pessoa }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @pessoa.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @puesto = Puesto.new(params[:puesto])\n\n respond_to do |format|\n if @puesto.save\n flash[:notice] = 'Puesto was successfully created.'\n format.html { redirect_to(@puesto) }\n format.xml { render :xml => @puesto, :status => :created, :location => @puesto }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @puesto.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def peso_params\n params.require(:peso).permit(:fecha, :peso, :usuario_id)\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 post(method, params = {})\n url = make_url method, params\n query = url.query\n url.query = nil\n\n req = Net::HTTP::Post.new url.path\n req.body = query\n req.content_type = 'application/x-www-form-urlencoded'\n\n res = Net::HTTP.start url.host, url.port do |http|\n http.request req\n end\n\n xml = Nokogiri::XML(res.body, nil, nil, 0)\n\n check_error xml\n\n parse_response xml\n rescue SystemCallError, SocketError, Timeout::Error, IOError,\n Nokogiri::XML::SyntaxError => e\n raise CommunicationError.new(e)\n rescue Net::HTTPError => e\n xml = Nokogiri::XML(e.res.body) { |cfg| cfg.strict }\n check_error xml\n raise CommunicationError.new(e)\n end",
"def create\n @nossos_servico = NossosServico.new(params[:nossos_servico])\n\n respond_to do |format|\n if @nossos_servico.save\n format.html { redirect_to(@nossos_servico, :notice => 'Nossos servico was successfully created.') }\n format.xml { render :xml => @nossos_servico, :status => :created, :location => @nossos_servico }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @nossos_servico.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @estagio = Estagio.new(params[:estagio])\n\n respond_to do |format|\n if @estagio.save\n flash[:notice] = 'Estagio was successfully created.'\n format.html { redirect_to(@estagio) }\n format.xml { render :xml => @estagio, :status => :created, :location => @estagio }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estagio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def store\n\n File.open(@sopm_file, 'w') { |file|\n file.write( @sopm.to_xml )\n }\n\n parse\n end",
"def create\n @peep = Peep.new(params[:peep])\n\n respond_to do |format|\n if @peep.save\n format.html { redirect_to(@peep, :notice => 'Peep was successfully created.') }\n format.xml { render :xml => @peep, :status => :created, :location => @peep }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @peep.errors, :status => :unprocessable_entity }\n end\n end\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 create\n @peca = Peca.new(params[:peca])\n\n respond_to do |format|\n if @peca.save\n flash[:notice] = 'Peça criada com sucesso.'\n format.html { redirect_to(@peca) }\n format.xml { render :xml => @peca, :status => :created, :location => @peca }\n else\n flash[:notice] = 'O formulário contém erros. Verifique os campos digitados e tente novamente.'\n format.html { render :action => \"new\" }\n format.xml { render :xml => @peca.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n cv = ChecklistenVorlage.new({\n objekt_id: cvNode.xpath('objekt_id').text.to_s, \n bezeichner: cvNode.xpath('bezeichner').text.to_s, \n version: cvNode.xpath('version').text.to_s.to_i, \n inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool \n })\n cv.save\n\n cvNode.xpath('checklisten_eintrags/checklisten_eintrag').each do |ceNode|\n ce = ChecklistenEintrag.new({\n checklisten_vorlage_id: cv.id,\n bezeichner: ceNode.xpath('bezeichner').text.to_s,\n was: ceNode.xpath('was').text.to_s,\n wann: ceNode.xpath('wann').text.to_s,\n typ: ceNode.xpath('typ').text.to_s.to_i,\n position: ceNode.xpath('position').text.to_s.to_i\n })\n ce.save\n end\n\n respond_to do |format|\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n end\n end",
"def create\n @premio = Premio.new(params[:premio])\n\n respond_to do |format|\n if @premio.save\n format.html { redirect_to(@premio, :notice => 'Premio was successfully created.') }\n format.xml { render :xml => @premio, :status => :created, :location => @premio }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @premio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @peso = Peso.new(peso_params)\n\n respond_to do |format|\n if @peso.save\n format.html { redirect_to @peso, notice: 'Peso was successfully created.' }\n format.json { render :show, status: :created, location: @peso }\n else\n format.html { render :new }\n format.json { render json: @peso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @pesos = Peso.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pesos }\n end\n end",
"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 create\n @paciente = Paciente.new(params[:paciente])\n\n respond_to do |format|\n if @paciente.save\n format.html { redirect_to(@paciente, :notice => 'El Paciente se creo exitosamente.') }\n format.xml { render :xml => @paciente, :status => :created, :location => @paciente }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @paciente.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @promocao = Promocao.new(params[:promocao])\n\n respond_to do |format|\n if @promocao.save\n format.html { redirect_to(@promocao, :notice => 'Promocção criada com sucesso!') }\n format.xml { render :xml => @promocao, :status => :created, :location => @promocao }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @promocao.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = \"application/x-www-form-urlencoded\"\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = \"spoonacular-recipe-food-nutrition-v1.p.rapidapi.com\"\n # body of the call with ingredients and servings\n request.body = \"ingredientList=#{encoded_ingr}&#{@recipe_hash[:servings]}\"\n # response\n response = http.request(request)\n end",
"def create\n @peso = Peso.new(params[:peso])\n\n respond_to do |format|\n if @peso.save\n format.html { redirect_to @peso, notice: 'Peso was successfully created.' }\n format.json { render json: @peso, status: :created, location: @peso }\n else\n format.html { render action: \"new\" }\n format.json { render json: @peso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def http_post(request, response)\n path = request.path\n\n # Only handling xml\n content_type = request.header('Content-Type')\n return nil unless content_type.index('application/xml') || content_type.index('text/xml')\n\n # Making sure the node exists\n begin\n node = @server.tree.node_for_path(path)\n rescue Dav::Exception::NotFound\n return nil\n end\n\n request_body = request.body_as_string\n\n # If this request handler could not deal with this POST request, it\n # will return 'null' and other plugins get a chance to handle the\n # request.\n #\n # However, we already requested the full body. This is a problem,\n # because a body can only be read once. This is why we preemptively\n # re-populated the request body with the existing data.\n request.body = request_body\n\n document_type_box = Box.new('')\n message = @server.xml.parse(request_body, request.url, document_type_box)\n document_type = document_type_box.value\n\n case document_type\n # Dealing with the 'share' document, which modified invitees on a\n # calendar.\n when \"{#{Plugin::NS_CALENDARSERVER}}share\"\n # We can only deal with IShareableCalendar objects\n return true unless node.is_a?(IShareableCalendar)\n\n @server.transaction_type = 'post-calendar-share'\n\n # Getting ACL info\n acl = @server.plugin('acl')\n\n # If there's no ACL support, we allow everything\n acl.check_privileges(path, '{DAV:}write') if acl\n\n node.update_shares(message.set, message.remove)\n\n response.status = 200\n # Adding this because sending a response body may cause issues,\n # and I wanted some type of indicator the response was handled.\n response.update_header('X-Sabre-Status', 'everything-went-well')\n\n # Breaking the event chain\n return false\n # The invite-reply document is sent when the user replies to an\n # invitation of a calendar share.\n when \"{#{Plugin::NS_CALENDARSERVER}}invite-reply\"\n\n # This only works on the calendar-home-root node.\n return true unless node.is_a?(CalendarHome)\n\n @server.transaction_type = 'post-invite-reply'\n\n # Getting ACL info\n acl = @server.plugin('acl')\n\n # If there's no ACL support, we allow everything\n acl.check_privileges(path, '{DAV:}write') if acl\n\n url = node.share_reply(\n message.href,\n message.status,\n message.calendar_uri,\n message.in_reply_to,\n message.summary\n )\n\n response.status = 200\n # Adding this because sending a response body may cause issues,\n # and I wanted some type of indicator the response was handled.\n response.update_header('X-Sabre-Status', 'everything-went-well')\n\n if url\n writer = @server.xml.writer\n writer.open_memory\n writer.start_document\n writer.start_element(\"{#{Plugin::NS_CALENDARSERVER}}shared-as\")\n writer.write(Dav::Xml::Property::Href.new(url))\n writer.end_element\n response.update_header('Content-Type', 'application/xml')\n response.body = writer.output_memory\n end\n\n # Breaking the event chain\n return false\n when \"{#{Plugin::NS_CALENDARSERVER}}publish-calendar\"\n # We can only deal with IShareableCalendar objects\n return true unless node.is_a?(IShareableCalendar)\n\n @server.transaction_type = 'post-publish-calendar'\n\n # Getting ACL info\n acl = @server.plugin('acl')\n\n # If there's no ACL support, we allow everything\n acl.check_privileges(path, '{DAV:}write') if acl\n\n node.publish_status = true\n\n # iCloud sends back the 202, so we will too.\n response.status = 202\n\n # Adding this because sending a response body may cause issues,\n # and I wanted some type of indicator the response was handled.\n response.update_header('X-Sabre-Status', 'everything-went-well')\n\n # Breaking the event chain\n return false\n when \"{#{Plugin::NS_CALENDARSERVER}}unpublish-calendar\"\n # We can only deal with IShareableCalendar objects\n return true unless node.is_a?(IShareableCalendar)\n\n @server.transaction_type = 'post-unpublish-calendar'\n\n # Getting ACL info\n acl = @server.plugin('acl')\n\n # If there's no ACL support, we allow everything\n acl.check_privileges(path, '{DAV:}write') if acl\n\n node.publish_status = false\n\n response.status = 200\n\n # Adding this because sending a response body may cause issues,\n # and I wanted some type of indicator the response was handled.\n response.update_header('X-Sabre-Status', 'everything-went-well')\n\n # Breaking the event chain\n return false\n end\n end",
"def create\n @pago = Pago.new(params[:pago])\n\n respond_to do |format|\n if @pago.save\n format.html { render :text => @pago.attributes.merge( :saldo => @pago.saldo ).to_json }\n format.xml { render :xml => @pago, :status => :created, :location => @pago }\n else\n format.html { render :action => \"new\", :status => :unprocessable_entity }\n format.xml { render :xml => @pago.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @cabo_eleitoral = CaboEleitoral.new(params[:cabo_eleitoral])\n @cabo_eleitoral.pessoa = Pessoa.new(params[:pessoa]) \n \n respond_to do |format|\n if @cabo_eleitoral.save\n format.html { redirect_to(@cabo_eleitoral, :notice => ' - Cabo eleitoral cadastrado com sucesso.') }\n format.xml { render :xml => @cabo_eleitoral, :status => :created, :location => @cabo_eleitoral }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @cabo_eleitoral.errors, :status => :unprocessable_entity }\n end\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 create\n @persosn = Persosn.new(persosn_params)\n\n respond_to do |format|\n if @persosn.save\n format.html { redirect_to @persosn, notice: 'Persosn was successfully created.' }\n format.json { render :show, status: :created, location: @persosn }\n else\n format.html { render :new }\n format.json { render json: @persosn.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @estatu = Estatu.new(params[:estatu])\n\n respond_to do |format|\n if @estatu.save\n format.html { redirect_to(@estatu, :notice => 'Registro creado correctamente.') }\n format.xml { render :xml => @estatu, :status => :created, :location => @estatu }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estatu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @precio = Precio.new(params[:precio])\n\n respond_to do |format|\n if @precio.save\n format.html { redirect_to(@precio, :notice => 'Precio was successfully created.') }\n format.xml { render :xml => @precio, :status => :created, :location => @precio }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @precio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @pto = Pto.new(params[:pto])\n\n respond_to do |format|\n if @pto.save\n format.html { redirect_to \"/thanks.html\", notice: 'Pto was successfully created.' }\n format.json { render json: @pto, status: :created, location: @pto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @peeps = Peep.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @peeps }\n end\n end",
"def create\n\n @prepagada = Prepagada.new({ :prepagada => params[:prepagada], :odontologo_id => params[:odontologo_id] })\n\n respond_to do |format|\n if @prepagada.save\n format.html { redirect_to @prepagada, notice: 'Prepagada was successfully created.' }\n format.json { render json: @prepagada, status: :created, location: @prepagada }\n else\n format.html { render action: \"new\" }\n format.json { render json: @prepagada.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @osoba = Osoba.new(params[:osoba])\n\n if @osoba.save\n render json: @osoba, status: :created, location: @osoba\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end",
"def create\n megam_rest.post_node(to_hash)\n end",
"def create\n @pedidos_has_prato = PedidosHasPrato.new(pedidos_has_prato_params)\n\n respond_to do |format|\n if @pedidos_has_prato.save\n format.html { redirect_to @pedidos_has_prato, notice: 'Pedidos has prato was successfully created.' }\n format.json { render :show, status: :created, location: @pedidos_has_prato }\n else\n format.html { render :new }\n format.json { render json: @pedidos_has_prato.errors, status: :unprocessable_entity }\n end\n end\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 create\n @tiposproceso = Tiposproceso.new(params[:tiposproceso])\n\n respond_to do |format|\n if @tiposproceso.save\n format.html { redirect_to(@tiposproceso, :notice => 'Tiposproceso was successfully created.') }\n format.xml { render :xml => @tiposproceso, :status => :created, :location => @tiposproceso }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tiposproceso.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def seo_submit\n for search_engine in ::Pingr::SUPPORTED_SEARCH_ENGINES\n ::Pingr::Request.new(search_engine, pages_url(format: :xml)).ping\n end\n \n redirect_to({:action => :index}, {:notice => '<strong>Yay!</strong> Sitemap XML has been submitted to all supported search engines!'.html_safe})\n end",
"def create\n @xpto = Xpto.new(params[:xpto])\n\n respond_to do |format|\n if @xpto.save\n format.html { redirect_to @xpto, notice: 'Xpto was successfully created.' }\n format.json { render json: @xpto, status: :created, location: @xpto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @xpto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @paroquia = Paroquia.new(params[:paroquia])\n\n respond_to do |format|\n if @paroquia.save\n flash[:notice] = 'Paroquia was successfully created.'\n format.html { redirect_to(@paroquia) }\n format.xml { render :xml => @paroquia, :status => :created, :location => @paroquia }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @paroquia.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @tipos_pagamento = TiposPagamento.new(params[:tipos_pagamento])\n\n respond_to do |format|\n if @tipos_pagamento.save\n flash[:notice] = 'TiposPagamento was successfully created.'\n format.html { redirect_to(@tipos_pagamento) }\n format.xml { render :xml => @tipos_pagamento, :status => :created, :location => @tipos_pagamento }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tipos_pagamento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @partei = Partei.new(params[:partei])\n\n respond_to do |format|\n if @partei.save\n flash[:notice] = 'Partei was successfully created.'\n format.html { redirect_to(@partei) }\n format.xml { render :xml => @partei, :status => :created, :location => @partei }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @partei.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @suplemento = Suplemento.new(suplemento_params)\n\n respond_to do |format|\n if @suplemento.save\n format.html { redirect_to @suplemento, notice: 'Suplemento was successfully created.' }\n format.json { render :show, status: :created, location: @suplemento }\n else\n format.html { render :new }\n format.json { render json: @suplemento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @estado_pedido = EstadoPedido.new(params[:estado_pedido])\n\n respond_to do |format|\n if @estado_pedido.save\n format.html { redirect_to(@estado_pedido, :notice => 'EstadoPedido was successfully created.') }\n format.xml { render :xml => @estado_pedido, :status => :created, :location => @estado_pedido }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estado_pedido.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @expedicao = Expedicao.new(params[:expedicao])\n\n respond_to do |format|\n if @expedicao.save\n flash[:notice] = 'Expedicao was successfully created.'\n format.html { redirect_to(@expedicao) }\n format.xml { render :xml => @expedicao, :status => :created, :location => @expedicao }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @expedicao.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n puts 'AQQQQQUUUUUUUIIIIII'\n json = ActiveSupport::JSON.decode(params[:pessoa])\n puts json\n @pessoa = Pessoa.new(json)\n # @address = Address.new(params[:address])\n\n # @client.addresses = @address\n\n respond_to do |format|\n if @pessoa.save\n format.html { redirect_to @pessoa, notice: 'Pessoa was successfully created.' }\n format.json { render json: @pessoa, status: :created, location: @pessoa }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pessoa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @director = Director.find(params[:director_id])\n @soaps = @director.soaps.create(soap_params)\n redirect_to director_path(@director)\n\n\n end",
"def create\n megam_rest.post_promos(to_hash) #WONT BE USED AS OF NOW\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 create\n @poto = Poto.new(poto_params)\n\n respond_to do |format|\n if @poto.save\n format.html { redirect_to @poto, notice: 'Poto was successfully created.' }\n format.json { render :show, status: :created, location: @poto }\n else\n format.html { render :new }\n format.json { render json: @poto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(resource, params)\n case resource\n when \"pedidos\", \"place_order\", \"new_order\" then url = \"/pedidos\"\n when \"envios\", \"shipping\" then url = \"/envios\"\n else url = \"/#{resource}\"\n end\n\n post_request(url, params)\n end",
"def create\n @poblacionesespecial = Poblacionesespecial.new(params[:poblacionesespecial])\n\n respond_to do |format|\n if @poblacionesespecial.save\n flash[:notice] = 'Poblacionesespecial was successfully created.'\n format.html { redirect_to(@poblacionesespecial) }\n format.xml { render :xml => @poblacionesespecial, :status => :created, :location => @poblacionesespecial }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @poblacionesespecial.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n #returning connection.post(collection_path, to_xml, self.class.headers) do |response|\n returning connection.post(collection_path, to_ssj, self.class.headers) do |response|\n self.id = id_from_response(response)\n load_attributes_from_response(response)\n end\n end",
"def create\n @espacio_deportivo = EspacioDeportivo.new(params[:espacio_deportivo])\n\n respond_to do |format|\n if @espacio_deportivo.save\n format.html { redirect_to root_url, :notice => \"Se hizo correctamente la creacion del espacio deportivo\" }\n format.json { render json: @espacio_deportivo, status: :created, location: @espacio_deportivo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @espacio_deportivo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @estadoproceso = Estadoproceso.new(estadoproceso_params)\n\n respond_to do |format|\n if @estadoproceso.save\n format.html { redirect_to @estadoproceso, notice: 'Estadoproceso was successfully created.' }\n format.json { render :show, status: :created, location: @estadoproceso }\n else\n format.html { render :new }\n format.json { render json: @estadoproceso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @estatuto = Estatuto.new(params[:estatuto])\n\n respond_to do |format|\n if @estatuto.save\n format.html { redirect_to @estatuto, notice: 'Estatuto was successfully created.' }\n format.json { render json: @estatuto, status: :created, location: @estatuto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @estatuto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @estagiarios = Estagiario.new(params[:estagiario])\n\n respond_to do |format|\n if @estagiarios.save\n flash[:notice] = 'ESTAGIÁRIO CADASTRADO COM SUCESSO.'\n format.html { redirect_to(@estagiarios) }\n format.xml { render :xml => @estagiarios, :status => :created, :location => @estagiarios }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estagiarios.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @puesto = Puesto.new(puesto_params)\n\n respond_to do |format|\n if @puesto.save\n format.html { redirect_to @puesto, notice: 'Puesto Creado.' }\n format.json { render :show, status: :created, location: @puesto }\n else\n format.html { render :new }\n format.json { render json: @puesto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @resultadoconsultum = Resultadoconsultum.new(resultadoconsultum_params)\n\t\n\n\trequire 'nokogiri'\n\t\n\t@doc = Nokogiri::XML(File.open(\"exemplos/emplo.xml\"))\n\n\tcar_tires = @doc.xpath(\"//firstname\")\n\t\n\tdoc = Nokogiri::XML(File.open(\"emplo.xml\"))\n\tdoc.xpath('firstname').each do\n\t\tcar_tires\n\tend\n\n\t \n respond_to do |format|\n if @resultadoconsultum.save\n format.html { redirect_to @resultadoconsultum, notice: car_tires }\n format.json { render :show, status: :created, location: @resultadoconsultum }\n else\n format.html { render :new }\n format.json { render json: @resultadoconsultum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @poem = Poem.new(params[:poem])\n\n respond_to do |format|\n if @poem.save\n format.html { redirect_to(@poem, :notice => 'Poem was successfully created.') }\n format.xml { render :xml => @poem, :status => :created, :location => @poem }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @poem.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @socio_serasa = SocioSerasa.new(socio_serasa_params)\n\n respond_to do |format|\n if @socio_serasa.save\n format.html { redirect_to @socio_serasa, notice: 'Socio serasa was successfully created.' }\n format.json { render action: 'show', status: :created, location: @socio_serasa }\n else\n format.html { render action: 'new' }\n format.json { render json: @socio_serasa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @placa_casa = PlacaCasa.new(params[:placa_casa])\n @placa_casa.pessoa = Pessoa.new(params[:pessoa]) \n @placa_casa.placa = Placa.new(params[:placa])\n\n respond_to do |format|\n if @placa_casa.save\n format.html { redirect_to(@placa_casa, :notice => ' - Placa cadastrada com sucesso.') }\n format.xml { render :xml => @placa_casa, :status => :created, :location => @placa_casa }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @placa_casa.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @domino = Domino.new(params[:domino])\n\n respond_to do |format|\n if @domino.save\n flash[:notice] = 'Domino was successfully created.'\n format.html { redirect_to(@domino) }\n format.xml { render :xml => @domino, :status => :created, :location => @domino }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @domino.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @niveis_ensino = NiveisEnsino.new(params[:niveis_ensino])\n\n respond_to do |format|\n if @niveis_ensino.save\n format.html { redirect_to(@niveis_ensino, :notice => 'Niveis ensino cadastrado com sucesso.') }\n format.xml { render :xml => @niveis_ensino, :status => :created, :location => @niveis_ensino }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @niveis_ensino.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @tipomensaje = Tipomensaje.new(params[:tipomensaje])\n\n respond_to do |format|\n if @tipomensaje.save\n flash[:notice] = 'Tipomensaje was successfully created.'\n format.html { redirect_to(@tipomensaje) }\n format.xml { render :xml => @tipomensaje, :status => :created, :location => @tipomensaje }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tipomensaje.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @pozi = Pozi.new(pozi_params)\n\n respond_to do |format|\n if @pozi.save\n format.html { redirect_to pozis_path, notice: 'Pozi was successfully created.' }\n format.json { render :show, status: :created, location: @pozi }\n else\n format.html { render :new }\n format.json { render json: @pozi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @nostro = Nostro.new(params[:nostro])\n\n respond_to do |format|\n if @nostro.save\n flash[:notice] = 'Nostro was successfully created.'\n format.html { redirect_to(@nostro) }\n format.xml { render :xml => @nostro, :status => :created, :location => @nostro }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @nostro.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_nodes_with_root\n serialize_service.post_nodes_serialized\n end",
"def create\n @ponte = Ponte.new(ponte_params)\n\n respond_to do |format|\n if @ponte.save\n format.html { redirect_to pontes_url, notice: 'Ponte criada com sucesso.' }\n format.json { render :show, status: :created, location: @ponte }\n else\n format.html { render :new }\n format.json { render json: @ponte.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @periode = Periode.new(params[:periode])\n\n respond_to do |format|\n if @periode.save\n format.html { redirect_to(@periode, :notice => 'Periode was successfully created.') }\n format.xml { render :xml => @periode, :status => :created, :location => @periode }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @periode.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @ep = Ep.new(params[:ep])\n\n respond_to do |format|\n if @ep.save\n flash[:notice] = 'Ep was successfully created.'\n format.html { redirect_to(@ep) }\n format.xml { render :xml => @ep, :status => :created, :location => @ep }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ep.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @paciente_reporte_rayos_x = PacienteReporteRayosX.new(paciente_reporte_rayos_x_params)\n @parte_rayos_x = ParteRayosX.find(params[:parte_rayos_x_id])\n if @paciente_reporte_rayos_x.save\n flash[:success] = \"Paciente agregado exitosamente.\"\n redirect_to \"/parte_rayos_xes/\"+@paciente_reporte_rayos_x.parte_rayos_x.id.to_s\n else\n flash[:danger] = \"Error al agregar paciente\"\n redirect_to parte_rayos_x_path(@parte_rayos_x)\n end\n end",
"def create\n @tipo_pago = TipoPago.new(params[:tipo_pago])\n\n respond_to do |format|\n if @tipo_pago.save\n format.html { redirect_to(@tipo_pago, :notice => 'TipoPago was successfully created.') }\n format.xml { render :xml => @tipo_pago, :status => :created, :location => @tipo_pago }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tipo_pago.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @possess = Possess.new(params[:possess])\n\n respond_to do |format|\n if @possess.save\n format.html { redirect_to @possess, notice: 'Possess was successfully created.' }\n format.json { render json: @possess, status: :created, location: @possess }\n else\n format.html { render action: \"new\" }\n format.json { render json: @possess.errors, status: :unprocessable_entity }\n end\n end\n end",
"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 @processo_seletivo = ProcessoSeletivo.new(processo_seletivo_params)\n\n respond_to do |format|\n if @processo_seletivo.save\n format.html { redirect_to @processo_seletivo, notice: 'Processo seletivo was successfully created.' }\n format.json { render :show, status: :created, location: @processo_seletivo }\n else\n format.html { render :new }\n format.json { render json: @processo_seletivo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n @onpost = Onpost.new(params[:onpost])\n respond_to do |format|\n if @onpost.save\n flash[:notice] = 'Onpost was successfully created.'\n format.html { redirect_to :back }\n format.xml { render :xml => @onpost, :status => :created, :location => @onpost }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @onpost.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def send_request( xml )\n write( xml )\n read\n end",
"def create\n @spiel = Spiel.new(params[:spiel])\n\n respond_to do |format|\n if @spiel.save\n format.html { redirect_to(@spiel, :notice => 'Spiel was successfully created.') }\n format.xml { render :xml => @spiel, :status => :created, :location => @spiel }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @spiel.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @exames_paciente = ExamesPaciente.new(exames_paciente_params)\n\n respond_to do |format|\n if @exames_paciente.save\n format.html { redirect_to @exames_paciente, notice: 'Exames paciente was successfully created.' }\n format.json { render :show, status: :created, location: @exames_paciente }\n else\n format.html { render :new }\n format.json { render json: @exames_paciente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_multipart(method, params = {})\n url = make_url method, {}\n url.query = nil\n\n boundary, data = make_multipart params\n\n req = Net::HTTP::Post.new url.path\n req.content_type = \"multipart/form-data; boundary=#{boundary}\"\n req.body = data\n\n res = Net::HTTP.start url.host, url.port do |http|\n http.request req\n end\n\n xml = Nokogiri::XML(res.body, nil, nil, 0)\n\n check_error xml\n\n parse_response xml\n rescue SystemCallError, SocketError, Timeout::Error, IOError,\n Nokogiri::XML::SyntaxError => e\n raise CommunicationError.new(e)\n rescue Net::HTTPError => e\n xml = Nokogiri::XML(e.res.body, nil, nil, 0)\n check_error xml\n raise CommunicationError.new(e)\n end",
"def create\r\n @sivic_pessoa = SivicPessoa.new(sivic_pessoa_params)\r\n\r\n respond_to do |format|\r\n if @sivic_pessoa.save\r\n format.html { redirect_to @sivic_pessoa, notice: 'Registro inserido com sucesso.' }\r\n format.json { render action: 'show', status: :created, location: @sivic_pessoa }\r\n else\r\n format.html { render action: 'new' }\r\n format.json { render json: @sivic_pessoa.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def post_config(url_prefix, xml)\n post_data(url_prefix, xml, 'application/xml;charset=UTF-8')\n end",
"def create\n @nippou = Nippou.new(nippou_params)\n\n respond_to do |format|\n if @nippou.save\n format.html { redirect_to @nippou, notice: 'Nippou was successfully created.' }\n format.json { render action: 'show', status: :created, location: @nippou }\n else\n format.html { render action: 'new' }\n format.json { render json: @nippou.errors, status: :unprocessable_entity }\n end\n end\n end",
"def process(xml)\n timeout(TIMEOUT) do\n url = URI.parse(webservices_url)\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n http.start {\n request = Net::HTTP::Post.new(url.to_s)\n request.body = xml\n response = http.request(request)\n response.body\n }\n end\n end",
"def create\n @suministro = Suministro.new(params[:suministro])\n\n respond_to do |format|\n if @suministro.save\n format.html { redirect_to(@suministro, :notice => 'Suministro was successfully created.') }\n format.xml { render :xml => @suministro, :status => :created, :location => @suministro }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @suministro.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def body\n xml = Builder::XmlMarkup.new( :indent => 2 )\n xml.instruct! :xml, :encoding => \"UTF-8\"\n xml.dataroot do |dataroot|\n dataroot.typvyplatneho options.postage_type\n dataroot.typtisku options.print_type\n dataroot.tiskpoukazky options.coupon_type\n dataroot.typods options.sender_type\n dataroot.typadr options.recipient_type\n dataroot.odsid nil\n dataroot.odsobrazek nil\n dataroot.odsfirma nil\n dataroot.odsosoba nil\n dataroot.odsulice nil\n dataroot.odscp nil\n dataroot.odsco nil\n dataroot.odsobec nil\n dataroot.odspsc nil\n dataroot.adrosloveni nil\n dataroot.adrfirma nil\n dataroot.adrosoba nil\n dataroot.adrulice nil\n dataroot.adrcp nil\n dataroot.adrco nil\n dataroot.adrobec nil\n dataroot.adrpsc nil\n dataroot.adriso nil\n dataroot.soubory do |soubory|\n soubory.soubor(:mimeType => \"\", :name => @pdf_file_path.split(\"/\").last) do |soubor|\n soubor.dataSoubor Base64.encode64(File.read(@pdf_file_path))\n end\n end\n end\n\n xml_file = Tempfile.new([\"DopisOnlineNew_1_1\", \".xml\"])\n xml_file.write xml.target!\n xml_file.flush\n xml_file.rewind\n\n {\n :user => DopisOnlineClient.username,\n :password => DopisOnlineClient.password,\n :soubor => xml_file\n }\n end",
"def create\n @psa = Psa.new(params[:psa])\n\n respond_to do |format|\n if @psa.save\n format.html { redirect_to @psa, notice: 'Psa was successfully created.' }\n format.json { render json: @psa, status: :created, location: @psa }\n else\n format.html { render action: \"new\" }\n format.json { render json: @psa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @paciente = Paciente.find(params[:paciente_id])\n @visita = Visita.new(params[:visita])\n @visita.paciente = @paciente\n\n respond_to do |format|\n if @visita.save\n format.html { redirect_to(paciente_visitas_url, :notice => 'La Visita se creo exitosamente.') }\n format.xml { render :xml => @visita, :status => :created, :location => @visita }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @visita.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @pex = Pex.new(pex_params)\n\n respond_to do |format|\n if @pex.save\n format.html { redirect_to @pex, notice: 'Pex was successfully created.' }\n format.json { render :show, status: :created, location: @pex }\n else\n format.html { render :new }\n format.json { render json: @pex.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pouzivatel = Pouzivatel.new(pouzivatel_params)\n\n respond_to do |format|\n if @pouzivatel.save\n format.html { redirect_to @pouzivatel, notice: 'Pouzivatel was successfully created.' }\n format.json { render :show, status: :created, location: @pouzivatel }\n else\n format.html { render :new }\n format.json { render json: @pouzivatel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @soiree = Soiree.new(soiree_params)\n\n respond_to do |format|\n if @soiree.save\n format.html { redirect_to @soiree, notice: 'Votre évènement a bien été créé.' }\n format.json { render :show, status: :created, location: @soiree }\n else\n format.html { render :new }\n format.json { render json: @soiree.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @produto = Produto.create(produto_params)\n respond_with @produto\n end",
"def create\n @paise = Paise.new(params[:paise])\n\n respond_to do |format|\n if @paise.save\n flash[:notice] = 'Paise se ha creado con exito.'\n format.html { redirect_to(admin_paises_url) }\n format.xml { render :xml => @paise, :status => :created, :location => @paise }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @paise.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @soiree = Soiree.new(params[:soiree])\n\n respond_to do |format|\n if @soiree.save\n format.html { redirect_to @soiree, notice: 'Soiree was successfully created.' }\n format.json { render json: @soiree, status: :created, location: @soiree }\n else\n format.html { render action: \"new\" }\n format.json { render json: @soiree.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @st_pi = StPi.new(params[:st_pi])\n\n respond_to do |format|\n if @st_pi.save\n flash[:notice] = 'PIS criado.'\n format.html { redirect_to(@st_pi) }\n format.xml { render :xml => @st_pi, :status => :created, :location => @st_pi }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @st_pi.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post endpoint, data\n do_request :post, endpoint, data\n end",
"def create\n @especificacao = Especificacao.new(params[:especificacao])\n\n respond_to do |format|\n if @especificacao.save\n flash[:notice] = 'Especificacao was successfully created.'\n format.html { redirect_to(@especificacao) }\n format.xml { render :xml => @especificacao, :status => :created, :location => @especificacao }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @especificacao.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @estoques = Estoque.new(params[:estoque])\n\n respond_to do |format|\n if @estoques.save\n flash[:notice] = 'ESTOQUE CADASTRADO COM SUCESSO.'\n format.html { redirect_to(@estoques) }\n format.xml { render :xml => @estoques, :status => :created, :location => @estoques }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estoques.errors, :status => :unprocessable_entity }\n end\n end\n end"
] |
[
"0.5834183",
"0.5735111",
"0.57249564",
"0.5712944",
"0.568782",
"0.55784583",
"0.5570673",
"0.5525284",
"0.5525211",
"0.54763055",
"0.5461402",
"0.54522914",
"0.5448426",
"0.54192966",
"0.53675365",
"0.53547615",
"0.5323479",
"0.5317466",
"0.52981263",
"0.5286932",
"0.52744305",
"0.52736115",
"0.5256429",
"0.52479374",
"0.5243392",
"0.5236398",
"0.5229893",
"0.5228322",
"0.5211293",
"0.52079415",
"0.5207625",
"0.52054864",
"0.52044487",
"0.5203879",
"0.51999706",
"0.5194577",
"0.5189582",
"0.518732",
"0.5168766",
"0.5168756",
"0.51668626",
"0.51642615",
"0.51628864",
"0.5160959",
"0.5160148",
"0.51548326",
"0.5150583",
"0.514522",
"0.51394695",
"0.5138835",
"0.5138022",
"0.5121409",
"0.51210505",
"0.5114646",
"0.51092255",
"0.5105557",
"0.5102082",
"0.5089581",
"0.5088192",
"0.5087745",
"0.5078313",
"0.507554",
"0.5066419",
"0.50635535",
"0.5063292",
"0.5062199",
"0.50592875",
"0.50473106",
"0.50467324",
"0.50426596",
"0.5041245",
"0.5034021",
"0.50292957",
"0.50248873",
"0.50237864",
"0.50193995",
"0.5017401",
"0.5017336",
"0.501407",
"0.50121945",
"0.50103617",
"0.5009686",
"0.5007795",
"0.50071937",
"0.5005333",
"0.50034076",
"0.49956667",
"0.4993668",
"0.4993207",
"0.49887466",
"0.49856406",
"0.4984755",
"0.49832982",
"0.4983046",
"0.49799007",
"0.49760854",
"0.49732342",
"0.49694455",
"0.49678472",
"0.49653882"
] |
0.5883147
|
0
|
PUT /pesos/1 PUT /pesos/1.xml
|
def update
@peso = Peso.find(params[:id])
respond_to do |format|
if @peso.update_attributes(params[:peso])
flash[:notice] = 'Peso was successfully updated.'
format.html { redirect_to(@peso) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @peso.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\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 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 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 put(*args)\n request :put, *args\n end",
"def update\n @nossos_servico = NossosServico.find(params[:id])\n\n respond_to do |format|\n if @nossos_servico.update_attributes(params[:nossos_servico])\n format.html { redirect_to(@nossos_servico, :notice => 'Nossos servico was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @nossos_servico.errors, :status => :unprocessable_entity }\n end\n end\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 put!\n request! :put\n end",
"def put(path = '/files/', params = {})\n request :put, path, params\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 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 update\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n if @pessoa.update_attributes(params[:pessoa])\n flash[:notice] = 'Pessoa was successfully updated.'\n format.html { redirect_to(@pessoa) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pessoa.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @spouse = Spouse.find(params[:id])\n\n respond_to do |format|\n if @spouse.update_attributes(params[:spouse])\n flash[:notice] = 'Spouse was successfully updated.'\n format.html { redirect_to(@spouse) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @spouse.errors, :status => :unprocessable_entity }\n end\n end\n end",
"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 update\n @inventario = Inventario.find(params[:id])\n @foto = @inventario.foto\n \n @service = InventarioService.new(@inventario, @foto)\n respond_to do |format|\n\n if @inventario.update_attributes(params[:inventario],params[:foto_file])\n format.html { redirect_to(@inventario, :notice => 'Inventario was successfully updated.') }\n format.xml { head :ok }\n else\n\t @foto = @service.foto\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @inventario.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @promos = Promos.find(params[:id])\n\n respond_to do |format|\n if @promos.update_attributes(params[:promos])\n flash[:notice] = 'Promos was successfully updated.'\n format.html { redirect_to(@promos) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @promos.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(*args)\n request(:put, *args)\n end",
"def put(uri, doc = nil, options = {})\n execute(uri, :put, options, doc)\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"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 update\n respond_to do |format|\n if @solexame.update(solexame_params)\n flash[:notice] = 'Solicitação foi alterada com sucesso.'\n format.html { redirect_to(@solexame) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @solexame.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(path, doc = nil, options = {})\n execute('PUT', path, options, doc)\n end",
"def update\n @estagio = Estagio.find(params[:id])\n\n respond_to do |format|\n if @estagio.update_attributes(params[:estagio])\n flash[:notice] = 'Estagio was successfully updated.'\n format.html { redirect_to(@estagio) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estagio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @xpto = Xpto.find(params[:id])\n\n respond_to do |format|\n if @xpto.update_attributes(params[:xpto])\n format.html { redirect_to @xpto, notice: 'Xpto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @xpto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @pto = Pto.find(params[:id])\n\n respond_to do |format|\n if @pto.update_attributes(params[:pto])\n format.html { redirect_to(@pto, :notice => 'Pto was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pto.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params)\n request(:put, path, params)\n end",
"def update\n @orc_suplementacao = OrcSuplementacao.find(params[:id])\n\n respond_to do |format|\n if @orc_suplementacao.update_attributes(params[:orc_suplementacao])\n flash[:notice] = 'SALVO COM SUCESSO.'\n format.html { redirect_to(@orc_suplementacao) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @orc_suplementacao.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def update\n @puesto = Puesto.find(params[:id])\n\n respond_to do |format|\n if @puesto.update_attributes(params[:puesto])\n flash[:notice] = 'Puesto was successfully updated.'\n format.html { redirect_to(@puesto) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @puesto.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n connection.put(element_path, to_xml)\n end",
"def put(*args)\n prepare_request(:put, args)\n @@client.add(:put, @path, *args)\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\n @office.update(office_params)\n head :no_content\n end",
"def update\n respond_to do |format|\n if @apoio.update(apoio_params)\n format.html { redirect_to @apoio, notice: 'Apoio was successfully updated.' }\n format.json { render :show, status: :ok, location: @apoio }\n else\n format.html { render :edit }\n format.json { render json: @apoio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def poteti_put(action, parameters = nil, session = nil, flash = nil)\n process_action(action, parameters, session, flash, 'PUT')\n end",
"def put(path, options={})\n request :put, path, options\n end",
"def put endpoint, data\n do_request :put, endpoint, data\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def put payload, path = \"\"\n make_request(path, \"put\", payload)\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 put(path, parameters = {})\n request(:put, path, parameters)\n end",
"def update\n @tso = Tso.find(params[:id])\n\n respond_to do |format|\n if @tso.update_attributes(params[:tso])\n flash[:notice] = 'Tso was successfully updated.'\n format.html { redirect_to(@tso) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tso.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(path, params={})\n RestClient.put request_base+path, params\n end",
"def update\n @sofa = Sofa.find(params[:id])\n\n respond_to do |format|\n if @sofa.update_attributes(params[:sofa])\n flash[:notice] = 'Sofa was successfully updated.'\n format.html { redirect_to(@sofa) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @sofa.errors, :status => :unprocessable_entity }\n end\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\n @peep = Peep.find(params[:id])\n\n respond_to do |format|\n if @peep.update_attributes(params[:peep])\n format.html { redirect_to(@peep, :notice => 'Peep was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @peep.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @tiposproceso = Tiposproceso.find(params[:id])\n\n respond_to do |format|\n if @tiposproceso.update_attributes(params[:tiposproceso])\n format.html { redirect_to(@tiposproceso, :notice => 'Tiposproceso was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tiposproceso.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @peca = Peca.find(params[:id])\n\n respond_to do |format|\n if @peca.update_attributes(params[:peca])\n flash[:notice] = 'Peça atualizada com sucesso.'\n format.html { redirect_to(@peca) }\n format.xml { head :ok }\n else\n flash[:notice] = 'O formulário contém erros. Verifique os campos digitados e tente novamente.'\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @peca.errors, :status => :unprocessable_entity }\n end\n end\n end",
"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 @supervisor_estagio = SupervisorEstagio.find(params[:id])\n\n respond_to do |format|\n if @supervisor_estagio.update_attributes(params[:supervisor_estagio])\n flash[:notice] = 'Supervisor de Estagio atualizado com sucesso.'\n format.html { redirect_to(@supervisor_estagio) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @supervisor_estagio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(path, data=nil)\n request(:put, path, data)\n end",
"def update\n @oase = Oasis.find(params[:id])\n\n respond_to do |format|\n if @oase.update_attributes(params[:oase])\n format.html { redirect_to @oase, notice: 'Oasis was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @oase.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @opo.update(opo_params)\n format.html { redirect_to @opo, notice: 'Opo was successfully updated.' }\n format.json { render :show, status: :ok, location: @opo }\n else\n format.html { render :edit }\n format.json { render json: @opo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @spi.update(spi_params)\n format.html { redirect_to @spi, notice: 'Spi was successfully updated.' }\n format.json { render :show, status: :ok, location: @spi }\n else\n format.html { render :edit }\n format.json { render json: @spi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put\n RestClient.put(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def api_put(path, data = {})\n api_request(:put, path, :data => data)\n end",
"def update\n @os_type = OsType.find(params[:id])\n\n respond_to do |format|\n if @os_type.update_attributes(params[:os_type])\n format.html { redirect_to @os_type, notice: 'Os type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @os_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put_request(path, params={}, options={})\n request(:put, path, params, options)\n end",
"def put(path, opts = {})\n request(:put, path, opts).body\n end",
"def save(request)\n raise ArgumentError, \"PUT does not accept options\" unless request.options.empty?\n update(request) || create(request)\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 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 update\n @ventas_presupuesto = Ventas::Presupuesto.find(params[:id])\n\n respond_to do |format|\n if @ventas_presupuesto.update_attributes(params[:ventas_presupuesto])\n format.html { redirect_to @ventas_presupuesto, notice: 'Presupuesto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ventas_presupuesto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_putpoi_delete_not_found\n changeset = create(:changeset)\n cs_id = changeset.id\n user = changeset.user\n\n amf_content \"putpoi\", \"/1\", [\"#{user.email}:test\", cs_id, 1, 999999, 0, 0, {}, false]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 3, result.size\n assert_equal -4, result[0]\n assert_equal \"node\", result[1]\n assert_equal 999999, result[2]\n end",
"def update_xml\n self.xml= dumpRouteAsXml\n self.save\n end",
"def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end",
"def put(uri, params = {})\n send_request(uri, :put, params)\n end",
"def override\n document_id = params[:document_id]\n document = params[:document]\n document_type = params[:document_type]\n ticket = Document.ticket(Alfresco::Document::ALFRESCO_USER, Alfresco::Document::ALFRESCO_PASSWORD)\n\n builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.entry(:xmlns => \"http://www.w3.org/2005/Atom\",\n \"xmlns:cmisra\" => \"http://docs.oasis-open.org/ns/cmis/restatom/200908/\",\n \"xmlns:cmis\" => \"http://docs.oasis-open.org/ns/cmis/core/200908/\") {\n xml.title document.original_filename if document\n xml.summary document_type\n if document\n xml.content(:type => document.content_type) {\n xml.text Base64.encode64(document.read)\n }\n end\n }\n end\n\n url = Document::PATH + \"cmis/i/#{document_id}?alf_ticket=\" + ticket\n\n begin\n RestClient.put url, builder.to_xml, {:content_type => 'application/atom+xml;type=entry'}\n rescue => e\n Rails.logger.info \"#\"*50\n Rails.logger.info \"Error updating file\"\n Rails.logger.info e.message\n Rails.logger.info \"#\"*50\n end\n\n redirect_to :controller => 'related_service_requests', :action => 'show', :anchor => 'documents', :service_request_id => params[:friendly_id], :id => params[:ssr_id]\n end",
"def put(path, options = {})\n request(:put, path, options)\n end",
"def put(path, options = {})\n request(:put, path, options)\n end",
"def put(path, params={}, options={})\n request(:put, api_path(path), params, options)\n end",
"def put(path, data, params = {}, request_options = {})\n request(:put, path, data, params)\n end",
"def update\n @spiel = Spiel.find(params[:id])\n\n respond_to do |format|\n if @spiel.update_attributes(params[:spiel])\n format.html { redirect_to(@spiel, :notice => 'Spiel was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @spiel.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def http_put(request, response)\n body = request.body_as_stream\n path = request.path\n\n # Intercepting Content-Range\n if request.header('Content-Range')\n # An origin server that allows PUT on a given target resource MUST send\n # a 400 (Bad Request) response to a PUT request that contains a\n # Content-Range header field.\n #\n # Reference: http://tools.ietf.org/html/rfc7231#section-4.3.4\n fail Exception::BadRequest, 'Content-Range on PUT requests are forbidden.'\n end\n\n # Intercepting the Finder problem\n expected = request.header('X-Expected-Entity-Length').to_i\n if expected > 0\n # Many webservers will not cooperate well with Finder PUT requests,\n # because it uses 'Chunked' transfer encoding for the request body.\n #\n # The symptom of this problem is that Finder sends files to the\n # server, but they arrive as 0-length files in PHP.\n #\n # If we don't do anything, the user might think they are uploading\n # files successfully, but they end up empty on the server. Instead,\n # we throw back an error if we detect this.\n #\n # The reason Finder uses Chunked, is because it thinks the files\n # might change as it's being uploaded, and therefore the\n # Content-Length can vary.\n #\n # Instead it sends the X-Expected-Entity-Length header with the size\n # of the file at the very start of the request. If this header is set,\n # but we don't get a request body we will fail the request to\n # protect the end-user.\n\n # Only reading first byte\n first_byte = body.read(1)\n unless first_byte\n fail Exception::Forbidden, 'This server is not compatible with OS/X finder. Consider using a different WebDAV client or webserver.'\n end\n\n # The body needs to stay intact, so we copy everything to a\n # temporary stream.\n\n new_body = StringIO.new\n new_body.write(first_byte)\n IO.copy_stream(body, new_body)\n new_body.rewind\n\n body = new_body\n end\n\n if @server.tree.node_exists(path)\n node = @server.tree.node_for_path(path)\n\n # If the node is a collection, we'll deny it\n unless node.is_a?(IFile)\n fail Exception::Conflict, 'PUT is not allowed on non-files.'\n end\n\n etag = Box.new\n return false unless @server.update_file(path, body, etag)\n etag = etag.value\n\n response.update_header('Content-Length', '0')\n response.update_header('ETag', etag) if etag\n response.status = 204\n else\n # If we got here, the resource didn't exist yet.\n etag = Box.new\n unless @server.create_file(path, body, etag)\n # For one reason or another the file was not created.\n return false\n end\n etag = etag.value\n\n response.update_header('Content-Length', '0')\n response.update_header('ETag', etag) if etag\n response.status = 201\n end\n\n # Sending back false will interupt the event chain and tell the server\n # we've handled this method.\n false\n end",
"def update\n @st_pi = StPi.find(params[:id])\n\n respond_to do |format|\n if @st_pi.update_attributes(params[:st_pi])\n flash[:notice] = 'PIS atualizado.'\n format.html { redirect_to(@st_pi) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @st_pi.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @oasis_page = OasisPage.find(params[:id])\n\n respond_to do |format|\n if @oasis_page.update_attributes(params[:oasis_page])\n format.html { redirect_to @oasis_page, notice: 'Oasis page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @oasis_page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, data = {})\n request 'PUT', path, body: data.to_json\n end",
"def update\r\n respond_to do |format|\r\n if @sivic_pessoa.update(sivic_pessoa_params)\r\n format.html { redirect_to @sivic_pessoa, notice: 'Registro alterado com sucesso.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { render json: @sivic_pessoa.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def put(path, params)\n parse_response @client[path].put(params)\n end",
"def update\n respond_to do |format|\n if @socio_serasa.update(socio_serasa_params)\n format.html { redirect_to @socio_serasa, notice: 'Socio serasa was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @socio_serasa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_putpoi_delete_already_deleted\n nd = create(:node, :deleted)\n cs_id = nd.changeset.id\n user = nd.changeset.user\n\n amf_content \"putpoi\", \"/1\", [\"#{user.email}:test\", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, false]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 3, result.size\n assert_equal -4, result[0]\n assert_equal \"node\", result[1]\n assert_equal nd.id, result[2]\n end",
"def update\n @sitio = Sitio.find(params[:id])\n\n respond_to do |format|\n if @sitio.update_attributes(params[:sitio])\n format.html { redirect_to(@sitio, :notice => 'Sitio was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @sitio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n name = Server.find(params[:id]).name\n n = Neography::Node.find('servers', 'name', name)\n n.name = server_params[:name]\n n.add_to_index('servers', 'name', server_params[:name]) #TODO: is this necessary?\n if @server.update(server_params)\n format.html { redirect_to @server, notice: 'Server was successfully updated.' }\n format.json { render :show, status: :ok, location: @server }\n else\n format.html { render :edit }\n format.json { render json: @server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @peso = Peso.find(params[:id])\n\n respond_to do |format|\n if @peso.update_attributes(params[:peso])\n format.html { redirect_to @peso, notice: 'Peso was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @peso.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 test_put_expenses_1_xml\n @parameters = {:expense => {:description => 'NewDescription'}}\n if ActiveRecord::VERSION::MAJOR < 4\n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/expenses/1.xml',\n {:expense => {:description => 'NewDescription'}},\n {:success_code => :ok})\n end\n\n assert_no_difference('Expense.count') do\n put '/expenses/1.xml', @parameters, credentials('admin')\n end\n\n expense = Expense.find(1)\n assert_equal \"NewDescription\", expense.description\n end"
] |
[
"0.6661412",
"0.664163",
"0.5964857",
"0.5961045",
"0.5849469",
"0.5831766",
"0.58210844",
"0.5813749",
"0.5797514",
"0.57647663",
"0.5675787",
"0.5674316",
"0.5646873",
"0.56171507",
"0.5595597",
"0.55874884",
"0.55798835",
"0.5577576",
"0.5573669",
"0.55506444",
"0.55295277",
"0.5529343",
"0.55260724",
"0.5525048",
"0.5505289",
"0.54828167",
"0.5479696",
"0.5479696",
"0.5479696",
"0.54271156",
"0.5425207",
"0.5419956",
"0.5419956",
"0.5419956",
"0.5419956",
"0.5419956",
"0.5419956",
"0.5419956",
"0.5419956",
"0.54119956",
"0.5405725",
"0.5394767",
"0.53930175",
"0.538133",
"0.53788215",
"0.53786135",
"0.53786135",
"0.53733116",
"0.5354495",
"0.5343374",
"0.53426427",
"0.53308964",
"0.53294533",
"0.5327432",
"0.5322982",
"0.53204376",
"0.53116596",
"0.53031117",
"0.5298925",
"0.5296144",
"0.52956927",
"0.5294262",
"0.5288107",
"0.52862823",
"0.52853227",
"0.5276799",
"0.5270682",
"0.5261954",
"0.5260168",
"0.5246774",
"0.52397716",
"0.5237156",
"0.5235247",
"0.5229104",
"0.5221761",
"0.5216693",
"0.52135056",
"0.5210057",
"0.52097714",
"0.5201864",
"0.5200981",
"0.52008593",
"0.5199915",
"0.5199915",
"0.51996094",
"0.51994205",
"0.51978743",
"0.5197795",
"0.51967794",
"0.5194041",
"0.5193984",
"0.5188891",
"0.51852924",
"0.51821876",
"0.51811296",
"0.5180782",
"0.5174014",
"0.51728636",
"0.51717687",
"0.51702905"
] |
0.5655564
|
12
|
DELETE /pesos/1 DELETE /pesos/1.xml
|
def destroy
@peso = Peso.find(params[:id])
@peso.destroy
respond_to do |format|
format.html { redirect_to(pesos_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 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()\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 response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @child_dupa2 = ChildDupa2.find(params[:id])\n @child_dupa2.destroy\n\n respond_to do |format|\n format.html { redirect_to(child_dupa2s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @pessoa = Pessoa.find(params[:id])\n @pessoa.destroy\n\n respond_to do |format|\n format.html { redirect_to(pessoas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @pto = Pto.find(params[:id])\n @pto.destroy\n\n respond_to do |format|\n format.html { redirect_to(ptos_url) }\n format.xml { head :ok }\n end\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 @domino = Domino.find(params[:id])\n @domino.destroy\n\n respond_to do |format|\n format.html { redirect_to(dominos_url) }\n format.xml { head :ok }\n end\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 @peca = Peca.find(params[:id])\n @peca.destroy\n flash[:notice] = 'Peça excluída com sucesso.'\n\n respond_to do |format|\n format.html { redirect_to(pecas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @promos = Promos.find(params[:id])\n @promos.destroy\n\n respond_to do |format|\n format.html { redirect_to(promos_url) }\n format.xml { head :ok }\n end\n end",
"def delete(slide)\n # ./_rels/presentation.xml.rels\n # Update Relationship ids\n # Insert a new one slideRef\n @doc.edit_xml @doc.presentation.rels.path do |xml|\n # Calucate the next id\n # next_id = xml.xpath('//xmlns:Relationship[@Id]').map{ |n| n['Id'] }.sort.last.succ\n # TODO - Figure out how to make this more MS idiomatic up 9->10 instead of incrementing\n # the character....\n # Insert that into the slide and crakc open the presentation.xml file\n\n target = slide.path.relative_path_from(@doc.presentation.path.dirname)\n relationship = xml.at_xpath(\"/xmlns:Relationships/xmlns:Relationship[@Type='#{Slide::REL_TYPE}' and @Target='#{target}']\")\n # ./presentation.xml\n # Update attr\n # p:notesMasterId\n # Insert attr\n # p:sldId, increment, etc.\n @doc.edit_xml '/ppt/presentation.xml' do |xml|\n xml.at_xpath(\"/p:presentation/p:sldIdLst/p:sldId[@r:id='#{relationship['Id']}']\").remove\n end\n relationship.remove\n end\n\n # Delete slide link and slideNotes link from ./[Content-Types].xml \n @doc.edit_xml @doc.content_types.path do |xml|\n xml.at_xpath(\"/xmlns:Types/xmlns:Override[@ContentType='#{Slide::CONTENT_TYPE}' and @PartName='#{slide.path}']\").remove\n xml.at_xpath(\"/xmlns:Types/xmlns:Override[@ContentType='#{Notes::CONTENT_TYPE}' and @PartName='#{slide.notes.path}']\").remove\n end\n\n # Update ./ppt\n # !!! DESTROY !!!\n # ./slides\n # Delete files\n # ./_rels/notesSlide(\\d+).xml.rels\n @doc.delete slide.notes.rels.path\n # ./notesSlide(\\d+).xml file\n @doc.delete slide.notes.path\n # ./_rels/slide(\\d+).xml.rels\n @doc.delete slide.rels.path\n # ./slide(\\d+).xml file\n @doc.delete slide.path\n # ./notesSlides\n # Delete files\n\n # Hooray! We're done! Ummm, what should we return though? can't be the slide since\n # its destroyed and there's no practical way to keep it around in memory.\n end",
"def destroy\n @documento = @externo.documentos.find(params[:id])\n @documento.destroy\n\n respond_to do |format|\n format.html { redirect_to(documentos_url(@externo)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @estatu = Estatu.find(params[:id])\n @estatu.destroy\n\n respond_to do |format|\n format.html { redirect_to(estatus_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @elemento = Elemento.find(params[:id])\n @elemento.destroy\n\n respond_to do |format|\n format.html { redirect_to(elementos_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete_all(xpath); end",
"def destroy\n @puesto = Puesto.find(params[:id])\n @puesto.destroy\n\n respond_to do |format|\n format.html { redirect_to(puestos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @po = Po.find(params[:id])\n @po.destroy\n\n respond_to do |format|\n format.html { redirect_to(pos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @nossos_servico = NossosServico.find(params[:id])\n @nossos_servico.destroy\n\n respond_to do |format|\n format.html { redirect_to(nossos_servicos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @documento = Documento.find(params[:id])\n @documento.destroy\n\n respond_to do |format|\n format.html { redirect_to(documentos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tiposproceso = Tiposproceso.find(params[:id])\n @tiposproceso.destroy\n\n respond_to do |format|\n format.html { redirect_to(tiposprocesos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @xpto = Xpto.find(params[:id])\n @xpto.destroy\n\n respond_to do |format|\n format.html { redirect_to xptos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @expedicao = Expedicao.find(params[:id])\n @expedicao.destroy\n\n respond_to do |format|\n format.html { redirect_to(expedicoes_url) }\n format.xml { head :ok }\n end\n end",
"def delete(*uris); end",
"def destroy\n @peep = Peep.find(params[:id])\n @peep.destroy\n\n respond_to do |format|\n format.html { redirect_to(peeps_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 destroy1\n @todo = Todo.find(params[:id])\n @todo.destroy\n\n respond_to do |format|\n format.html { redirect_to(todos_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 delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def destroy\n @solexame.destroy\n\n respond_to do |format|\n format.html { redirect_to paciente_url(@solexame.paciente) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @echo = Echo.find(params[:id])\n @echo.destroy\n\n respond_to do |format|\n format.html { redirect_to(echoes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dupa = Dupa.find(params[:id])\n @dupa.destroy\n\n respond_to do |format|\n format.html { redirect_to(dupas_url) }\n format.xml { head :ok }\n end\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 @estagio = Estagio.find(params[:id])\n @estagio.destroy\n\n respond_to do |format|\n format.html { redirect_to(estagios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @periode = Periode.find(params[:id])\n @periode.destroy\n\n respond_to do |format|\n format.html { redirect_to(periodes_url) }\n format.xml { head :ok }\n end\n end",
"def delete(id)\r\n connection.delete(\"/#{@doctype}[@ino:id=#{id}]\")\r\n end",
"def destroy\n @segmento = Segmento.find(params[:id])\n @segmento.destroy\n\n respond_to do |format|\n format.html { redirect_to(segmentos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @calidadtiposdocumento = Calidadtiposdocumento.find(params[:id])\n @calidadtiposdocumento.destroy\n\n respond_to do |format|\n format.html { redirect_to(calidadtiposdocumentos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @suministro = Suministro.find(params[:id])\n @suministro.destroy\n\n respond_to do |format|\n format.html { redirect_to(suministros_url) }\n format.xml { head :ok }\n end\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def destroy\n @dossier = Dossier.find(params[:id])\n @dossier.destroy\n\n respond_to do |format|\n format.html { redirect_to(\"/\") }\n format.xml { head :ok }\n end\n end",
"def delete_by_id id, opts = {}\n update opts.merge(:data => xml.delete_by_id(id))\n end",
"def destroy\n @aviso = Aviso.find(params[:id])\n @aviso.destroy\n\n respond_to do |format|\n format.html { redirect_to(avisos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @colonoscopytest = Colonoscopytest.find(params[:id])\n @colonoscopytest.destroy\n\n respond_to do |format|\n format.html { redirect_to(colonoscopytests_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 @pdig = Pdig.find(params[:id])\n @pdig.destroy\n\n respond_to do |format|\n format.html { redirect_to(pdigs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tipo_de_documento = TipoDeDocumento.find(params[:id])\n @tipo_de_documento.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipos_de_documento_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n start { |connection| connection.request http :Delete }\n end",
"def test_putpoi_delete_already_deleted\n nd = create(:node, :deleted)\n cs_id = nd.changeset.id\n user = nd.changeset.user\n\n amf_content \"putpoi\", \"/1\", [\"#{user.email}:test\", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, false]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 3, result.size\n assert_equal -4, result[0]\n assert_equal \"node\", result[1]\n assert_equal nd.id, result[2]\n end",
"def destroy\n @pago = Pago.find(params[:id])\n @pago.destroy\n \n respond_to do |format|\n format.html { redirect_to(pagos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @adjunto = Adjunto.find(params[:id])\n @adjunto.destroy\n\n respond_to do |format|\n format.html { redirect_to(adjuntos_url) }\n format.xml { 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 @pessoa = Pessoa.find(params[:id])\n @pessoa.destroy\n respond_to do |format|\n format.html { redirect_to(:back,:notice=>\"Apagado com sucesso\") }\n format.xml { head :ok }\n end\n end",
"def destroy\n @estudiante = Estudiante.find(params[:id])\n @estudiante.destroy\n\n respond_to do |format|\n format.html { redirect_to(estudiantes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @estudiante = Estudiante.find(params[:id])\n @estudiante.destroy\n\n respond_to do |format|\n format.html { redirect_to(estudiantes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @precio = Precio.find(params[:id])\n @precio.destroy\n\n respond_to do |format|\n format.html { redirect_to(precios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sofa = Sofa.find(params[:id])\n @sofa.destroy\n\n respond_to do |format|\n format.html { redirect_to(sofas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @supervisor_estagio = SupervisorEstagio.find(params[:id])\n @supervisor_estagio.destroy\n\n respond_to do |format|\n format.html { redirect_to(supervisor_estagios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @pago = Pago.find(params[:id])\n @pago.destroy\n\n respond_to do |format|\n format.html { redirect_to(pagos_url) }\n format.xml { head :ok }\n end\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 @especificacao = Especificacao.find(params[:id])\n @especificacao.destroy\n\n respond_to do |format|\n format.html { redirect_to(especificacaos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @relatorios = Relatorio.find(params[:id])\n @relatorios.destroy\n\n respond_to do |format|\n format.html { redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ponto = Ponto.find(params[:id])\n @ponto.destroy\n\n respond_to do |format|\n format.html { redirect_to(pontos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @estacion = Estacion.find(params[:id])\n @estacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(estaciones_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @poblacionesespecial = Poblacionesespecial.find(params[:id])\n @poblacionesespecial.destroy\n\n respond_to do |format|\n format.html { redirect_to(poblacionesespeciales_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ppos_prerequisite = PposPrerequisite.find(params[:id])\n @ppos_prerequisite.destroy\n\n respond_to do |format|\n format.html { redirect_to(ppos_prerequisites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tso = Tso.find(params[:id])\n @tso.destroy\n\n respond_to do |format|\n format.html { redirect_to(tsos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @promocao = Promocao.find(params[:id])\n @promocao.destroy\n\n respond_to do |format|\n format.html { redirect_to(promocoes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @reputacao_veiculo = ReputacaoVeiculo.find(params[:id])\n @reputacao_veiculo.destroy\n\n respond_to do |format|\n format.html { redirect_to(reputacao_veiculos_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n Iterable.request(conf, base_path).delete\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 @leilao = Leilao.find(params[:id])\n @leilao.destroy\n\n respond_to do |format|\n format.html { redirect_to(leilaos_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 @tipo_pago = TipoPago.find(params[:id])\n @tipo_pago.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipo_pagos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @proceso = Proceso.find(params[:id])\n @proceso.destroy\n\n respond_to do |format|\n format.html { redirect_to(procesos_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 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 arquivo = Arquivo.find(@pregoestitulosgrafico.arquivo_id)\n\n File.delete(arquivo.caminho)\n\n pregoestitulo = Pregoestitulo.find(@pregoestitulosgrafico.pregoestitulo_id)\n \n @pregoestitulosgrafico.destroy\n respond_to do |format|\n format.html { redirect_to pregoestitulo, notice: 'Arquivo excluído com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prestamo = Prestamo.find(params[:id])\n @prestamo.destroy\n\n respond_to do |format|\n format.html { redirect_to(prestamos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @siaikekka = Siaikekka.find(params[:id])\n @siaikekka.destroy\n\n respond_to do |format|\n format.html { redirect_to(siaikekkas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @premio = Premio.find(params[:id])\n @premio.destroy\n\n respond_to do |format|\n format.html { redirect_to(premios_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n delete_from_server single_url\n end",
"def destroy\n @spiel = Spiel.find(params[:id])\n @spiel.destroy\n\n respond_to do |format|\n format.html { redirect_to(spiels_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_xmls_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end",
"def destroy\n @cso = Cso.find(params[:id])\n @cso.destroy\n\n respond_to do |format|\n format.html { redirect_to(csos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @certidao = Certidao.find(params[:id])\n @certidao.destroy\n\n respond_to do |format|\n format.html { redirect_to(certidaos_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",
"def destroy\r\n @doctipo = Doctipo.find(params[:id])\r\n @doctipo.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(doctipos_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n @dossier = Dossier.find(params[:id])\n @dossier.destroy\n\n respond_to do |format|\n format.html { redirect_to(dossiers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @t1 = T1.find(params[:id])\n @t1.destroy\n\n respond_to do |format|\n format.html { redirect_to(t1s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @osoba = Osoba.find(params[:id])\n @osoba.destroy\n\n head :no_content\n end",
"def delete path\n make_request(path, \"delete\", {})\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 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 destroy\n @contactos = Contactos.find(params[:id])\n @contactos.destroy\n\n respond_to do |format|\n format.html { redirect_to(contactos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ep = Ep.find(params[:id])\n @ep.destroy\n\n respond_to do |format|\n format.html { redirect_to(eps_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @visaapp = Visaapp.find(params[:id])\n @visaapp.destroy\n\n respond_to do |format|\n format.html { redirect_to(visaapps_url) }\n format.xml { head :ok }\n end\n end",
"def delete(path = '/files/', params = {})\n request :delete, path, params\n end"
] |
[
"0.6671789",
"0.661132",
"0.6493594",
"0.64110684",
"0.6334526",
"0.63034177",
"0.6281847",
"0.628123",
"0.62612796",
"0.62409",
"0.62383366",
"0.62358946",
"0.6210749",
"0.6186779",
"0.6173958",
"0.61483586",
"0.61473674",
"0.6144997",
"0.6136554",
"0.6125848",
"0.6107607",
"0.6092433",
"0.6089907",
"0.6088426",
"0.6087053",
"0.6086092",
"0.60817164",
"0.6075223",
"0.60704994",
"0.6070288",
"0.60651726",
"0.6064941",
"0.6063409",
"0.60633385",
"0.6037715",
"0.60345906",
"0.6031385",
"0.6027042",
"0.60269463",
"0.6020482",
"0.6019634",
"0.60195595",
"0.6009092",
"0.6004401",
"0.60032034",
"0.60000557",
"0.59952253",
"0.5991048",
"0.59874684",
"0.59865165",
"0.5980439",
"0.59710395",
"0.5968776",
"0.59661216",
"0.5963583",
"0.5958161",
"0.5957716",
"0.59553355",
"0.59441125",
"0.5940773",
"0.5939242",
"0.5937274",
"0.5934405",
"0.5928334",
"0.59247845",
"0.59212977",
"0.59180146",
"0.5911473",
"0.5909561",
"0.5908139",
"0.590773",
"0.5905184",
"0.5899853",
"0.58972883",
"0.58964354",
"0.5895503",
"0.58950347",
"0.5891861",
"0.58903337",
"0.5890201",
"0.5889511",
"0.5888297",
"0.588775",
"0.58867663",
"0.5886755",
"0.5886352",
"0.58853126",
"0.58833516",
"0.5882932",
"0.5882617",
"0.58821094",
"0.58795583",
"0.58783174",
"0.5878023",
"0.5874939",
"0.5874233",
"0.5872727",
"0.5871959",
"0.58674747",
"0.5864988"
] |
0.6451022
|
3
|
POST /api/login This action handles a POST request for login if the user data is right it will respond the request with an auth token and the user data as JSON
|
def authenticate_user
user = User.where(email: params[:email]).first
if user.password == params[:password]
render json: payload(user)
else
render json: {errors: ['Invalid Password']}, status: :unauthorized
end
rescue NoMethodError
render_not_found "Email not registered"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def login\n @user = User.authenticate credentials[:email], credentials[:password]\n if @user # serializer makes it easier to return json, in this case the token\n render json: @user, serializer: LoginUserSerializer, root: 'user'\n else\n head :unauthorized # if authentication case this is executed\n end\n end",
"def login\n user = User.find_by(email: user_login_params[:email])\n\n if user && user.authenticate(user_login_params[:password])\n token = create_token(user.id)\n render json: {\n user: user.attributes.except(\"password_digest\"),\n token: token,\n }, status: :ok\n else\n render json: {error: \"unauthorized\"}, status: :unauthorized\n end\n end",
"def login\n user = User.find_by(email: user_login_params[:email])\n\n if user && user.authenticate(user_login_params[:password])\n token = create_token(user.id)\n render json: {\n user: user.attributes.except(\"password_digest\"),\n token: token,\n }, status: :ok\n else\n render json: {error: \"unauthorized\"}, status: :unauthorized\n end\n end",
"def login\n user = User.find_by(username: auth_params[:username])\n if user && user.authenticate(auth_params[:password])\n payload = {user_id: user.id}\n token = encode_token(payload)\n render json: {jwt: token, userid: user.id, admin: user.admin}\n else\n render json: {failure: \"login failed\"}\n end\n end",
"def login\n user = User.find_by(username: user_params[:username])\n if user && user.authenticate(user_params[:password])\n\n render json: {user: UserSerializer.new(user), token: encode_token(user.id)}\n else\n render json: {errors: 'Please enter the correct username and/or password'}, status: :unauthorized\n end\n end",
"def login\n auth_token =\n AuthenticateUser.new(auth_params[:email], auth_params[:phone_number], auth_params[:password]).call\n response = { message: Message.successful_login, auth_token: auth_token }\n json_response(response)\n end",
"def login\n user = User.find_by(username: params[:user][:username])\n # authenticate method from has_secure_password in user model\n if user && user.authenticate(params[:user][:password])\n token = create_token(user.id, user.username)\n render json: {status: 200, token: token, user: user}\n else\n render json: {status: 401, message: \"Unauthorized\"}\n end\n end",
"def login\n if @user\n render_json 'Signed in Successfully', true, @user, :ok, [:api_v1, user]\n else\n render_json 'Unable to Signed in: wrong email or password', false, {}, :unauthorized\n end\n end",
"def login\n user = User.find_by(email: params[:email])\n return render json: { message: ['Email does not exist'] }, status: 422 unless user\n return render json: { message: ['Password not valid'] }, status: 422 unless user.valid_password?(params[:password])\n\n token = user.tokens.create\n render json: { auth_token: token.auth_token }, status: :ok\n end",
"def login\n # @user = User.find_by(username: params[:username])\n @user = User.find_by(email: params[:email])\n\n if @user && @user.authenticate(params[:password])\n token = encode_token({user_id: @user.id})\n render json: {user: @user, token: token}\n else\n render json: {error: \"Invalid username or password\"}\n end\n end",
"def process_login\n user = User.where(login: params[:user][:login], password: params[:user][:password]).first\n respond_with :api, json:!user.nil?\n end",
"def login(user)\n post '/api/v1/login', params: {email: user.email, password: user.password}\n return json['auth_token']\n end",
"def login\n puts '--- LOGIN ---'\n puts username: params[:user][:username]\n puts password: params[:user][:password]\n # = 'escape'\n user = User.find_by(username: params[:user][:username])\n if user && user.authenticate(params[:user][:password])\n token = create_token(user.id, user.username)\n render json: {status: 200, token: token, user: user}\n else\n render json: {status: 401, message: \"Unauthorized - Login\"}\n end\n end",
"def login\n\n if params[:username] && params[:token]\n @user = token_based_login\n end\n\n if @user\n set_session_headers\n render json: { username: @user.username, auth_token: get_md5_digest(params[:username]), logged_in: true }\n else\n render json: { logged_in: false }, status: 401\n end\n end",
"def login(email, password)\n post api_v1_user_session_path, \n headers: { 'CONTENT_TYPE' => 'application/json', 'ACCEPT' => 'application/json' },\n params: { email: email, password: password }.to_json\nend",
"def login_api\n @user = User.find_for_database_authentication({:username => params[:username].downcase})\n\n if ([email protected]?)\n if ([email protected]_password?(params[:password]))\n @user = nil\n end\n end\n\n if (@user.nil?)\n @user = User.find_by_auth_token(params[:auth_token]) unless params[:auth_token].nil?\n else\n @user.generate_auth_token\n end\n\n if @user.nil?\n # Do nothing\n error \"Your username or password was incorrect.\"\n else\n render json: @user\n end\n end",
"def login_api\n @user = User.find_for_database_authentication({:username => params[:username].downcase})\n\n if ([email protected]?)\n if ([email protected]_password?(params[:password]))\n @user = nil\n end\n end\n\n if (@user.nil?)\n @user = User.find_by_auth_token(params[:auth_token]) unless params[:auth_token].nil?\n else\n @user.generate_auth_token\n end\n\n if @user.nil?\n # Do nothing\n error \"Your username or password was incorrect.\"\n else\n render json: @user\n end\n end",
"def login\n @user = User.find_by(email: params[:email]) # Se busca un usuario basado en el email\n if @user && @user.authenticate(params[:password]) # Se valida usuario y se autentica con Bcrypt\n token = encode_token({user_id: @user.id}) # Si el usuario y password es correcto, entonces se crea token\n render json: {token: token}, status: :accepted\n else\n render status: :bad_request\n end\n end",
"def login\n return @token if @token or @auth_method == :api_key\n request = Request.new(\"Post\", \"#{@config[:base_url]}/user/login\")\n\n request.add_multipart_body ({\n name: @config[:username],\n pass: @config[:password],\n form_id: \"user_login\",\n op: \"Log in\",\n })\n\n response = request.perform\n @token = response['Set-Cookie'].split(\";\")[0] if response and response['Set-Cookie']\n @token\n end",
"def login\n user = User.find_by(email: params[:email])\n if (user && user.authenticate(params[:password]))\n render json: {user: user.user_information, token: JWT.encode({userId: user.id}, 'secret')}\n else\n render json: {errors: \"Invalid email/password combination. Please try again or register if you do not already have an account.\"}\n end\n end",
"def login\n\t\t@user = User.where(:email => params[:email]).first\n\t\t@response = Hash.new\n\n\t\tif @user\n\t\t\tif @user.valid_password?(params[:password])\n\t\t\t\t@response[:auth_token] = @user.authentication_token\n\t\t\telse\n\t\t\t\t@response[:error] = \"incorrect_password\"\n\t\t\tend\n\t\telse\n\t\t\t@response[:error] = \"incorrect_email\"\n\t\tend\n\n\t\trespond_with(@response, :location => nil)\n\tend",
"def login\n status = 200\n result = {}\n\n if @errors.empty?\n user = User.find_by(id: @user_id)\n if user.nil?\n @errors[:user_id] = 'is invalid'\n result[:success] = false\n result[:errors] = @errors\n status = 400\n else\n if user.authenticate(@password)\n result[:success] = true\n result[:access_token] = user.access_token\n else\n @errors[:password] = 'is invalid'\n result[:success] = false\n result[:errors] = @errors\n status = 400\n end\n end\n else\n result[:success] = false\n result[:errors] = @errors\n status = 400\n end\n render status: status, json: result\n end",
"def create\n user = User.find_by(email: login_params[:email])\n if user && user.authenticate(login_params[:password])\n session[:user_id] = user.id\n render json: { logged_in: true, user: UserSerializer.new(user) }, status: 200\n else\n \n render json: {errors: ['invalid email or password']}, status: 401\n end\n end",
"def login \n isPasswordCorrect = AuthenticationHelper::Auth.instance.checkPassword( request.body )\n params = JSON.parse( request.body.read )\n emailParams = params[\"email\"]\n \n if ( isPasswordCorrect )\n token = AuthenticationHelper::Auth.instance.generateJWT( emailParams )\n render json: token, status: :ok\n else \n render json: :nothing, status: :not_found\n end\n end",
"def login \n user = User.find_by(username: params[:formData][:username])\n if user && user.authenticate(params[:formData][:password])\n wristband = encode_token({user_id: user.id})\n render json: {user: UserSerializer.new(user), token: wristband}\n else\n render json: {error: \"incorrect username or password\"}\n end\n end",
"def login\n response = @session.create\n @auth_token = response[\"token\"]\n @rest.default_headers = { 'Content-Type' => 'application/json', 'Auth-Token' => @auth_token }\n response\n end",
"def login\n @user = User.find_by(username: params[:username])\n # Make sure user exists and password is correct\n if @user && @user.authenticate(params[:password])\n new_access_token = create_access_token(@user.id)\n new_refresh_token = create_refresh_token(@user.id)\n render json: {user: @user, auth: {accessToken: new_access_token.jwt, accessTokenExpiration: new_access_token.expiration, refreshToken: new_refresh_token.jwt, refreshTokenExpiration: new_refresh_token.expiration }}\n else # User didn't exist or password was incorrect\n render json: {error: \"Invalid username or password\"}\n end\n end",
"def login\n user = User.authenticate(params[:email], params[:password])\n if user\n response = { :success => true, :user_id => user.id }\n else\n response = { :success => false, :user_id => nil }\n end\n \n render json: response\n end",
"def login\n\n=begin\n :: Expected Params ::\n\n Constants::REQUEST_PARAM_USERNAME => Username\n Constants::REQUEST_PARAM_USERPASSWORD => UserPassword\n\n=end\n\n # Look up for User in database\n find_user\n\n if @user\n @user.signin!(request)\n\n render json: {status: status_code(:ok), message: '', data: @user.as_signin_json}\n \n end\n\n end",
"def login\n user = User.find_by(username: user_params[:username])\n if user && user.authenticate(user_params[:password])\n render json: user, except: [:password_digest, :created_at, :updated_at]\n else\n render json: {errors: \"Wrong Username or Password!\"}\n end\n end",
"def login_for_test\n create_user_for_test\n post \"/api/v1/auth/login\",\n { username: \"TestUser\",\n email: \"[email protected]\",\n password: \"password\" }.to_json,\n \"Accept\" => Mime::JSON, \n \"Content-Type\" => Mime::JSON.to_s\n token = JSON.parse(response.body)\n token[\"auth_token\"]\n end",
"def login\n \n user = User.find_by(username: params[:username])\n if user\n if user.authenticate(params[:password])\n render json: user.to_json(serialized_data)\n else\n render json: {\n error: true,\n message: \"Incorrect User or password!\"\n }, status: :unauthorized\n end\n else\n render json: {\n error: true,\n message: \"Incorrect User or password!\"\n }, status: :payment_required\n end\n end",
"def login\n if params[:token]==md5(params[:email].to_s+\"fuckch0p\")\n @user = User.authenticate params[:email], params[:password]\n if @user\n @r = MobileApiResponse.new\n @r.user_id = @user.id\n @r.token = md5(@user.id.to_s + \"g04ts\")\n else\n @r = MobileApiError.new 3\n end\n else\n @r = MobileApiError.new 1\n end\n render :json => @r\n end",
"def login\n user = User.find_by_email(params[:email])\n\n if user && user.authenticate(params[:password])\n new_token = JsonWebToken.encode(email: user.email)\n render json: { auth_token: new_token }\n else\n render json: { error: 'Can not authenticate this user!' }, status: :unauthorized\n end\n end",
"def login\n user = User.find_by(username: params[\"username\"])\n if user && user.authenticate(params[\"password\"])\n session[:current_user_id] = user.id\n render json: User.to_hash(user)\n else\n render json: nil\n end\n end",
"def api_login\n creator = Creator.find_by(name: request.headers['name'])\n if creator && creator.authenticate(request.headers['password'])\n encode = encodeJWT(creator)\n selected_format({jwt: encode,creator_id: creator.id,name: creator.name,submits:creator.submits},:ok)\n else\n selected_format({ error: 'Invalid username or password' },:unauthorized)\n end\n end",
"def login\n @user = User.find_by(email: params[:email])\n if @user\n if @user.authenticate(params[:password])\n render json: @user, serializer: CurrentUserSerializer\n else\n @error = {error: \"Email and/or password does not exist, please try again\"}\n render json: @error, status: 403\n end\n else\n @error = {error: \"Email and/or password does not exist, please try again\"}\n render json: @error, status: 403\n end\n end",
"def login\n @user = User.find_by_username(params[:username])\n if @user&.authenticate(params[:password])\n token = JsonWebToken.encode(id: @user.id)\n time = Time.now #+ 24.hours.to_i\n render json: { token: token, last_login_time: time.strftime(\"%m-%d-%Y %H:%M\"),\n user: @user}, status: :ok\n # comment: @user.comment şu şekilde diğerleride çağrılabilir.\n else\n render json: { error: 'Login Unsuccessfull(Invalid username / password)' }, status: :unauthorized\n end\n end",
"def create\n # login\n user = User.authenticate(params[:user][:email], params[:user][:password])\n\n respond_to do |format|\n if user\n # Create an api token for this user.\n user.enable_api!\n format.json { render :json => user }\n else\n format.json { head :unauthorized }\n end\n end\n end",
"def create\n # Find the user by the params sent in through the login fetch params \n @user = User.find_by(username: user_login_params[:username])\n \n # User authenticate is a built in method that comes from BCrypt.\n # This next line checks if the user exists, and also if the password given allows access\n if @user && @user.authenticate(user_login_params[:password])\n # encode_token method comes from ApplicationController (which we are inheriting from on line 1).\n #this creates a variable with the value of our token \n @token = encode_token({ user_id: @user.id })\n \n # UserSerializer is a serializer in the serializers folder. To use this the active_model_serializers gem is needed.\n # This helps clean the data that is sent out to limited attributes you want listed\n render json: { user: UserSerializer.new(@user), jwt: @token }, status: :accepted\n \n # Without a serializer or status the following line would suffice\n # render json: { user: @user, jwt: @token}\n \n else\n # Vague error message for user security (never tell someone they got a specific input incorrect), adding a status code \n render json: { message: 'Invalid username or password' }, status: :unauthorized\n end\n end",
"def login\n debug 'Trying to login'\n _response = self.signed_request '/api/v1/login', 'POST', {\n user: $config.get_username,\n password: $config.get_password\n }\n\n if _response['status'] != 'success'\n puts 'Unable to login!'\n exit 1\n else\n debug 'Signed in successfully'\n end\n\n @auth_token = _response['data']['authToken']\n @user_id = _response['data']['userId']\n end",
"def login\n capture_session(self.class.post( \"/api/login\", {:body => {:user => @user, :passwd => @password, :api_type => 'json'}, :debug_output => @debug} ) )\n logged_in?\n end",
"def login\n admin = Admin.find_by(email: params[:email])\n puts admin\n if admin && admin.authenticate(params[:password])\n token = encode_token({admin_id: admin.id})\n render json: {admin: admin, token: token} \n else\n render json: {errors: \"Invalid email/password combination\"}\n end\n end",
"def login\n mandatory_keys = [:app_id, :user_name, :password, :sign]\n if params.slice(*mandatory_keys).values.any?(&:nil?)\n render json: to_response('Some params are lost') and return\n elsif @service_provider.nil?\n render json: to_response('ServiceProvider error') and return\n elsif not CommonUtils.valid_sign?(params[:app_id], params[:user_name], params[:password], @service_provider.credential, params[:sign])\n render json: to_response('Invalid request: parameter error') and return\n end\n\n user = User.find_by_user_name(params[:user_name])\n if user && user.authenticate(params[:password])\n render json: (user.invalid_role? ? to_response('User needs to be activated') : to_response('success', user))\n elsif user.nil?\n render to_response \"User not exist:#{params[:user_name]}\"\n else\n render to_response 'Password error'\n end\n end",
"def auto_login\n render json: @user\n end",
"def login\n if params[:user] && params[:pass]\n @user = User.find_by_username(params[:user])\n if @user\n if @user.password == params[:pass]\n @json = {:status => \"success\", :id => @user.id}\n render json: @json\n else\n send_error(\"invalid password\")\n end\n else\n send_error(\"user not found\") \n end\n else\n send_error(\"bad parameters\")\n end\n end",
"def login\n #handle unexpected error with status code 500\n begin\n if request.env['CONTENT_TYPE'].include?('application/json') \n @client = Client.new\n errCode = @client.login(params[:user], params[:password])\n if errCode > 0\n dic = {:errCode => 1, :count => errCode}\n respond_to do |format|\n format.json { render json: dic, :status => 200 }\n end\n else\n dic = {:errCode => errCode}\n respond_to do |format|\n format.json { render json: dic, :status => 200 }\n end\n end\n else\n render :json => { :errors => \"Wrong Content-Type on Request'\" }, :status => 500\n end\n rescue\n render :json => { :errors => \"Unknown Errors\" }, :status => 500\n end\n end",
"def create\n if @user = login(params[:email], params[:password], params[:remember])\n render json: {:ok => true, :user => {:id => @user.id, :username => @user.username, :email => @user.email}}\n else\n render json: {:ok => false}, status: :unprocessable_entity\n end\n end",
"def login\n @rest.headers[:content_type] = \"application/json\"\n\n response = api_request { @rest[\"login\"].post({:username => @username, :password => @password}) }\n\n @rest.headers[:x_opsview_token] = response[:token]\n @rest.headers[:x_opsview_username] = @username\n\n response\n end",
"def login\n #localhost:3000/api/login -u 'admin:password'\n authenticate_or_request_with_http_basic do |username, password|\n if username.include? '%40'\n email = username.gsub('%40','@');\n @user = User.find_by_email(email.downcase)\n else\n @user = User.find_by_username(username.downcase)\n end\n\n if @user && @user.authenticate(password)\n remember_token = RememberToken.create(token: User.encrypt(User.new_remember_token), user_id: @user.id, accessed_at: Time.now)\n respond_to do |format|\n format.json { render :json => remember_token }\n end\n end\n end\n end",
"def login\n if params[:email]\n email = params[:email]\n resource = User.where(:email => email).first\n if !resource.nil? && resource.valid_password?(params[:password])\n sign_in(resource)\n else\n return head :forbidden\n end\n elsif current_user\n resource = current_user\n else\n return head :bad_request\n end\n\n resource.ensure_authentication_token!\n render json: {\n :id => resource.id.to_s,\n :email => resource.email,\n :auth_token => resource.authentication_token,\n :permissions => resource.permissions,\n :expiry_ts => (Time.now + Devise.timeout_in).to_i\n }\n end",
"def auto_login\n render json: @user\n end",
"def auto_login\n render json: @user\n end",
"def auto_login\n render json: @user\n end",
"def login\n @user = User.find_by(name: params[:name])\n\n if @user && @user.authenticate(params[:password])\n @now=DateTime.now\n token = encode_token({user_id: @user.id, name:@user.name, iat: @now.to_time.to_i,exp:(@now+15.minutes).to_time.to_i })\n render json: {token: token}\n else\n render json: {error: \"Invalid username or password\"}\n end\n end",
"def auto_login\n @token = params[:token]\n # byebug\n user = User.find(JWT.decode(@token, \"put your secret password here\", true, algorithm: 'HS256')[0][\"user_id\"])\n render json: user\n end",
"def login\n user = User.find_by_email(params[:username])\n if user.nil? || (user && user.authenticate(params[:password]) == false) || user.deleted\n render status: 400, json: nil \n else\n session[:user_id] = user.id\n session[:username] = user.username\n session[:email] = user.email\n session[:verified] = user.verified\n user.last_ip_login = request.remote_ip\n user.save\n render status: 200, json: session\n end\n end",
"def login_user(user)\n post sessions_path, params: { email: user.email, password: user.password }\n end",
"def login\n # Clean this code\n @username = User.find_by username:params['username']\n @email = User.find_by email:params['email']\n if @username\n @username.authenticate(params['password']) ? (render json: @username) : (render :json => {:error => \"Unauthorized\"}.to_json, :status => 401)\n elsif @email\n render json: @email\n else\n set_user_from_facebook\n @user = User.new(user_params)\n @user.token = Digest::MD5.hexdigest(params[:token])\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end\n end",
"def login\n @user = users(:user1)\n post user_session_path, params: { 'user[email]' => @user.email, 'user[password]' => 'password' }\n end",
"def login\n user = User.last\n login!(user)\n ses = session[:session_token]\n render json: {\"ses\": ses}\n end",
"def api_user_login(email, password)\n url = user_session_url\n params = {\n email: email,\n password: password\n }\n page.driver.submit :post, url, params\n @api_user_headers = page.response_headers\n end",
"def create\n @user = User.new(user_params)\n if @user.save\n login(@user)\n render :show\n else\n render json: @user.errors.full_messages, status: 422\n end\n\n end",
"def send_token_for_valid_login_of(user)\n\t\trender json: {token: user.auth_token }\n\tend",
"def user_login(email, password, opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: UserApi#user_login ...\"\n end\n\n # verify the required parameter 'email' is set\n fail \"Missing the required parameter 'email' when calling user_login\" if email.nil?\n\n # verify the required parameter 'password' is set\n fail \"Missing the required parameter 'password' when calling user_login\" if password.nil?\n\n # resource path\n path = \"/user/login\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json', 'application/xml', 'text/xml', 'application/javascript', 'text/javascript']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json', 'application/x-www-form-urlencoded']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n form_params[\"email\"] = email\n form_params[\"password\"] = password\n form_params[\"token\"] = opts[:'token'] if opts[:'token']\n\n # http body (model)\n post_body = nil\n\n\n auth_names = []\n result = @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 :return_type => 'AccessToken')\n if Configuration.debugging\n Configuration.logger.debug \"API called: UserApi#user_login. Result: #{result.inspect}\"\n end\n return result\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n #If successful, login as new registered user\n log_in @user\n render json: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def autologin\n token = request.headers['Authorization']\n user_id = JWT.decode(token, 'secret')[0][\"userId\"]\n user = User.find(user_id)\n render json: user.user_information\n end",
"def mob_login\n token_manager = API::Concerns::TokenManager.new(params[:email], params[:password], params[:access_token])\n current_user = token_manager.current_user\n if !current_user.nil?\n render json: JSON.parse(current_user.to_json).except('id', 'password', 'pass_salt', 'updated_at')\n else\n render json: JSON.parse(token_manager.token.to_json)\n end\n end",
"def api_auth\n creator = Creator.find_by(username: request.headers[:username])\n if creator && creator.authenticate(request.headers[:password])\n render json: { auth_token: encodeJWT(creator) }\n else\n render json: { error: 'Invalid username or password' }, status: :unauthorized\n end\n end",
"def authenticate\n #render :text => params[:action]\n if (params[:controller] != \"api/sessions\")\n if (params[:controller] == \"api/users\" && params[:action] == \"create\")\n return\n end\n user = User.find_by(token: params[:token])\n if !user || user.valid_up < DateTime.now\n render json: '{\"error\":\"Unauthorized\"}', status: 401\n end\n end\n if (params[:controller] == \"api/sessions\" && params[:action] == \"chekToken\")\n user = User.find_by(token: params[:token])\n if !user || user.valid_up < DateTime.now\n render json: '{\"error\":\"Unauthorized\"}', status: 401\n end\n end\n #\"controller\":\"users\",\"action\":\"show\",\"id\":\"login\" si se va a registrar dejar pasar\n #@product = '[{\"mytoken\":\"'+params[:token]+'\"}]'\n # if !User.find_by(token: params[:token])\n # #render json: '[{\"error\":\"Unauthorized\"}]', status: 401\n # end\n end",
"def auto_login\n render json: logged_in_user\n end",
"def login\n @user = User.new\n\n # when there is a cookie or token, try the login\n if ( ( cookies[:user] && !cookies[:user].empty? ) || params[:token] )\n return( redirect_to( :action => \"do_login\" ) )\n end\n end",
"def create\n # Validations\n if request.format != :json\n render( status: 406, json: { success: false, message: I18n.t(\"api.errors.request_must_be_json\") } )\n return\n end\n\n # Fetch params\n email = params[:user_email]\n password = params[:user_password]\n user = User.find_for_database_authentication( email: email ) if email.presence\n\n if email.nil? or password.nil?\n render( status: 400, json: { success: false, message: I18n.t(\"api.errors.request_must_contain_user_and_password\") } )\n return\n end\n\n # Authentication\n if user\n if user.valid_password?( password )\n # FIXME was: user.reset_authentication_token!\n# user.authentication_token = nil\n# user.save!\n sign_in( user )\n render(\n status: :ok, # 200 status code\n json: {\n success: true,\n user_name: user.name,\n user_token: user.authentication_token,\n message: I18n.t(\"api.errors.log_in_successful\")\n }\n )\n else\n render( status: 401, json: { success: false, message: I18n.t(\"api.errors.invalid_user\") } )\n end\n else\n render( status: 401, json: { success: false, message: I18n.t(\"api.errors.invalid_user\") } )\n end\n end",
"def create\n @user = User.new(user_params)\n if @user.save\n login!\n #send this data back Home.jsx's post request\n render json: {\n status: :created,\n user: @user\n }\n else\n render json: {\n status: 500,\n errors: @user.errors.full_messages\n }\n end\n end",
"def create\n self.resource = warden.authenticate!(auth_options)\n sign_in(resource_name, resource)\n respond_to do |format|\n format.json {\n render :json => {\n :user => Api::V1::LoginUserSerializer.new(current_user, root: false),\n :status => :ok,\n :authentication_token => current_user.authentication_token\n }\n }\n end\n end",
"def login\n if User.find_by(email: user_params[:email]).try(:authenticate, user_params[:password])\n puts \"GOTIT \", user_params[:email], \"dssdf\"\n render json: User.find_by(email: user_params[:email])\n else\n puts \"MISSEDIT \", user_params[:email], \"dssdf\"\n render json: \"false\"\n end\n end",
"def login\n if session[:user] != nil then\n logged_in_home_page = home_index_path\n respond_to do |format|\n format.html { redirect_to logged_in_home_page}\n format.json { head :no_content }\n end\n return\n end\n\n @user = User.new\n \n respond_to do |format|\n format.html # login.html.erb\n format.json { render json: @user }\n end\n end",
"def login\n\t\t# Checks if there's a user associated\n\t\t# with the given email.\n\t\tu = User.find_by_email(params[:email])\n\n\t\t# If we find an email and the user\n\t\t# supplied the correct password we \n\t\t# login the user by starting a session.\n\t\t# We also redirect the user to the\n\t\t# control panel.\n\t\tif u && u.authenticate(params[:password])\n\t\t\t@id = u.id\n\t\t\t@token = Base64.encode64(params[:email] + ':' + params[:password])[0..-2]\n\n\t\t\tsession[:userid] = u.id\n\t\t\trender :template => 'api/v1/login/success'\n\t\telse\n\t\t\trender :status => 401, :template => 'api/v1/login/failure'\n\t\tend\n\tend",
"def login_for_second_test\n create_user_for_test\n post \"/api/v1/auth/login\",\n { username: \"SecondTestUser\",\n email: \"[email protected]\",\n password: \"secondpassword\" }.to_json,\n \"Accept\" => Mime::JSON,\n \"Content-Type\" => Mime::JSON.to_s\n token = JSON.parse(response.body)\n token[\"auth_token\"]\n end",
"def login_post\n @user = User.find_by_username(params[:user][:username])\n \n if @user == nil or not @user.password_valid?(params[:user][:password]) then\n respond_to do |format|\n format.html { redirect_to login_users_path, notice: \"Either the username or password is invalid. Please try again.\"}\n format.json { head :no_content }\n end\n return\n else\n session[:user] = @user\n\n if session[:previous_page] then\n respond_to do |format| \n session[:no_back] = true\n format.html { redirect_to session[:previous_page] }\n format.json { head :no_content }\n end\n\n session[:previous_page] = nil\n return\n end\n \n logged_in_home_page = users_path + '/' + session[:user][:id].to_s\n respond_to do |format|\n format.html { redirect_to gardens_path}\n format.json { head :no_content }\n end\n return\n end\n end",
"def login\n if( params[:email].present? && params[:password].present? )\n user = User.where(\"lower(email)=?\",params[:email].downcase).first\n if user && user.valid_password?(params[:password])\n render json: user\n else\n render json: \"error\"\n end\n else\n render json: \"error\"\n end\n end",
"def login \n render json: User.first\n end",
"def login()\n uri = URI('http://54.252.241.122:8000/users/authenticate')\n http = Net::HTTP.new(uri.host, uri.port)\n req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json')\n req.body = {email: '[email protected]', password: '*********'}.to_json\n res = http.request(req)\n tkn=JSON.parse(res.body)\n return tkn['result']['token']\nend",
"def login #i guess with an iPhone app you never really have to log in because your app \n\t\t\t #maintains state and logins in at every call\n\t\t#@user = \"if you can see this you called the login action\"\n\t\t#render :json => @user\n\t\trender \"login\"\n\tend",
"def create\n unless params[:format] == \"json\"\n super\n return\n end\n \n user = User.find_by_email(params[:username])\n \n puts \"Email = #{params[:username]}\"\n puts \"Password = #{params[:password]}\"\n \n if user.nil? || !user.valid_password?(params[:password])\n result = Result::LOGIN_FAIL\n else\n result = Result::LOGIN_SUCCESS\n result[:message] = user.authentication_token\n end\n \n puts \"JSON = #{result.to_json}\"\n\n render :json => result.to_json\n end",
"def create\n user = User.find_by_username(params[:username])\n if user && user.authenticate(params[:password])\n session[:user_id] = user.id\n response.status=(200)\n render json: {status: \"Success\", message: [\"Log in Successful!\"], userid: user.id, username: user.username}\n else \n # Error handling\n response.status=(401)\n render json: {status: \"Error\", message: [\"Username or password invalid\"]}\n end\n end",
"def authenticate\n auth_token = AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n user = User.find_by_email(auth_params[:email])\n render json: user.attributes.merge!({ token: auth_token, role: Role.find(user.role_id) })\n end",
"def login\n RestClient.post(\"#{base_url}/j_spring_security_check\", {:j_username => username, :j_password => password}) do |response, request, result, &block|\n @cookies = response.cookies\n @cookies.delete('Path')\n if [301, 302, 307].include? response.code\n response\n else\n response.return!(request, result, &block)\n end\n end\n end",
"def login\n @user = ::Accounts::Account.find_for_database_authentication(mobile: \n params.require(:data).require(:mobile))\n\n if @user && @user.valid_password?(\n params.require(:data).require(:password))\n sign_in(@user)\n # @user.reset_authentication_token! # make sure the user has a token generated\n @user.ensure_authentication_token!\n render_create_success @user, :with_token\n else\n warden.custom_failure!\n render_error t('devise.failure.invalid'), :unauthorized\n end\n end",
"def create\n # strip fields and downcase email\n prepare_params_for_login\n \n user = User.authenticate(params[:email],\n params[:password])\n \n if user.nil?\n respond_to do |format|\n error_message = \"Invalid login credentials.\"\n format.html { flash[:error] = error_message; redirect_to :login }\n format.json { render :json => { :success => false,\n :message => error_message,\n :user_id => false }, \n :status => :unauthorized }\n end\n else\n sign_in user\n respond_to do |format|\n format.html { redirect_back_or user_stream_path(current_user) }\n format.json { render :json => { :success => true,\n :message => nil,\n :user_id => user.id }, \n :status => :created }\n end\n end\n end",
"def authenticate\n user = User.find_by(email: params[:email].to_s.downcase)\n\n if user && user.authenticate(params[:password])\n auth_token = JsonWebToken.encode({user_id: user.id})\n render json: {auth_token: auth_token, user: user}, status: :ok\n else\n render json: {error: 'Invalid username / password'}, status: :unauthorized\n end\n end",
"def sign_in\n @user = User.find_by_email(params[:auth][:email])\n if @user && @user.authenticate(params[:auth][:password])\n auth_token = Knock::AuthToken.new payload: { sub: @user.id }\n render json: { username: @user.username, jwt: auth_token.token, moderator: [email protected] }, status: 200\n else \n render json: { error: 'incorrect details entered' }, status: 404\n end\nend",
"def login\n res = @cloud.api.post('account/login-api', { Email: @email, ApiKey: @api_key }.to_json)\n @token = res['access_token']\n @created_at = DateTime.parse(res['.issued'])\n @expire_at = DateTime.parse(res['.expires'])\n @token\n end",
"def login\n user_password = params[:user][:password]\n user_email = params[:user][:email]\n user = User.find_by_email(user_email)\n respond_to do |format|\n if user_email.present? && user.present?\n if user.valid_password? user_password\n sign_in user, store: false\n user.save\n format.html { redirect_to api_users_path, notice: 'User was login successfully' }\n format.json { render json: user, status: 200 }\n else\n format.html { redirect_to api_users_path, notice: 'User was login successfully' }\n render json: { errors: \"Invalid email or password\" }, status: 422\n end\n else\n format.html { redirect_to api_users_path, notice: 'Invalid Registration' }\n render json: {errors: \"Invalid Registration\"}, status: 422\n end\n end\n\n end",
"def login\n session[:user_id] = nil\n if request.post?\n user = User.authenticate(params[:user][:username], params[:user][:password])\n if user\n session[:user_id] = user.id\n redirect_to :action => \"index\"\n else\n flash[:notice] = \"Nome de usuário/senha inválidos\"\n render :action => \"login\"\n return\n end\n else\n @user = User.new\n render :action => \"login\"\n end\n end",
"def login(email, password)\n request(\n __method__,\n :post,\n \"#{api_base}/auth/login\",\n email: email,\n password: password\n )\n end",
"def login(email, password)\n request(\n __method__,\n :post,\n \"#{api_base}/auth/login\",\n email: email,\n password: password\n )\n end",
"def login_user(options = {})\n options[:email] = options[:email] || $settings.customer_service_email\n options[:password] = options[:password] || 'foobar'\n\n json = post_api '/api/session/login', {\n 'username' => options[:email] || options[:phone],\n 'password' => options[:password]\n }\n assert_equal 200, json['status'], json['message']\n json['meta']\n end",
"def api_login\n employee = Employee.find_by(IDnum: params[:IDnum])\n if employee && employee.authenticate(params[:password])\n \tif employee.status = \"Active\"\n \t\ttoken = employee.generate_api_token\n \tdistribute_api_token(employee.IDnum, token)\n \trender(json: {\"api_token\" => employee.api_token}.to_json, status: 201)\n \telse\n \t\tmsg = { :status => \"ERROR\", :message => \"Access Denied: No longer active employee\" }\n \trender :json => msg, status: :forbidden\n \tend\n else\n msg = { :status => \"ERROR\", :message => \"Invalid ID number and password combination\" }\n render :json => msg, status: :forbidden\n end\n end",
"def create \n user = User.find_by(username: params[\"user\"][\"username\"]).try(:authenticate, params[\"user\"][\"password\"])\n\n if user \n session[:user_id] = user.id\n render json: {\n status: :created,\n logged_in: :true,\n user: user\n }\n else\n render json: { status: 401 }\n end\n\n end",
"def create\n if SessionService.authenticate(@user, params[:password])\n # TODO Add successful log in message\n logger.debug \"#{@user.email} is trying to create a API session\"\n root_path\n else\n logger.error \"** Failure** Attempt to login as #{params[:user_name]} - rejected\"\n render text: 'Login failed', status: :unauthorized\n end\n end"
] |
[
"0.81219393",
"0.79458225",
"0.79458225",
"0.7886533",
"0.7785839",
"0.7766426",
"0.7722319",
"0.7700962",
"0.76733536",
"0.76645887",
"0.7624446",
"0.75697726",
"0.74979335",
"0.74785095",
"0.7459051",
"0.74497986",
"0.74497986",
"0.7445827",
"0.7438828",
"0.74110883",
"0.7410887",
"0.74097115",
"0.7405286",
"0.73556906",
"0.73402286",
"0.7338333",
"0.7309238",
"0.73062503",
"0.7301899",
"0.7292425",
"0.72911286",
"0.7291108",
"0.72827137",
"0.7236521",
"0.7211274",
"0.7200763",
"0.7154231",
"0.71467024",
"0.71455175",
"0.710154",
"0.7077805",
"0.7076243",
"0.7068682",
"0.7067129",
"0.70614606",
"0.70518273",
"0.7038308",
"0.7035506",
"0.70334804",
"0.70323586",
"0.70083946",
"0.70036507",
"0.7001251",
"0.7001251",
"0.7000342",
"0.69826317",
"0.69640714",
"0.6961711",
"0.69586265",
"0.69433475",
"0.6940882",
"0.693743",
"0.6932179",
"0.6889068",
"0.6885889",
"0.6874533",
"0.68626934",
"0.6858148",
"0.6855035",
"0.683626",
"0.68328035",
"0.6824735",
"0.68059504",
"0.67949945",
"0.6789347",
"0.6776738",
"0.6773739",
"0.6770963",
"0.67690474",
"0.67649704",
"0.6738497",
"0.6719391",
"0.6697837",
"0.669151",
"0.66813886",
"0.66636926",
"0.66526496",
"0.66481864",
"0.66329676",
"0.66288877",
"0.66246384",
"0.6620288",
"0.66052526",
"0.6592369",
"0.65881455",
"0.6582223",
"0.6582223",
"0.65749115",
"0.65742946",
"0.6572258",
"0.6565402"
] |
0.0
|
-1
|
GET /api/ping This action is used just to check if the service is alive
|
def ping
render json: {logged_in: true, user: current_user.id}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def ping\n return true unless active? && heartbeat_path.present?\n\n resp = http_get(uri: \"#{api_base_url}#{heartbeat_path}\")\n resp.present? && resp.code == 200\n end",
"def ping\n return true unless active && heartbeat_path.present?\n\n resp = http_get(uri: \"#{api_base_url}#{heartbeat_path}\")\n resp.present? && resp.code == 200\n end",
"def ping\n get('')\n end",
"def ping\n RestClient.get $api +'v1/upstart', { params: { keepalive: 1 } } rescue nil\n end",
"def ping\n TaxCloud::Responses::Ping.parse request(:ping)\n end",
"def ping\n response, body = send_request :get, '', :binary\n true\n end",
"def ping() path = \"/api/v2/utilities/ping\"\n get(path, {}, AvaTax::VERSION) end",
"def ping\n client.ping\n end",
"def perform\n @client.rest_get_with_token('/ping', {}, {})\n end",
"def ping_api\n res=api_call('PingAPI')\n if res[:data]==1\n res=true\n else\n res=false\n end\n res\n end",
"def ping\n response = connection.get(get_ping_url)\n if response.success?\n PingResponse.new(response.body)\n end\n end",
"def ping\n return_code, response = send_command(\"ping\")\n return_code == \"200\"\n end",
"def ping(*args)\n get '/invoke/wm.server/ping'\n end",
"def ping(options = {})\n client = extract_client!(options)\n !!client.get(\"/api/system/ping\")\n rescue Error::ConnectionError\n false\n end",
"def ping?\n rpc.request Util::MessageCode::PING_REQUEST\n\n return rpc.status\n end",
"def ping\n render json: {\n message: \"OK\",\n time: DateTime.current.strftime(\"%Q\")\n }\n end",
"def ping\n end",
"def ping\n stats\n true\n rescue Errno::ECONNREFUSED\n false\n end",
"def ping\n true\n end",
"def ping\n with_client do |client|\n client.ping\n end\n end",
"def ping\n send_command(\"ping\")\n end",
"def ping\n @conn.ping\n end",
"def ping?\n base_url = url.end_with?(\"/\") ? url[0..-2] : url\n\n if normalized_api_version.nil?\n # for v4\n base_url = url.end_with?(\"/\") ? url[0..-2] : url\n public_url = \"#{base_url}/index.html\"\n else\n # for v5\n public_url = \"#{base_url}/api/v1/status/public\"\n end\n\n http = Net::Ping::HTTP.new(public_url)\n\n # use GET for v5\n http.get_request = true if normalized_api_version\n\n http.ping?\n end",
"def status\n service.get(\"\")\n end",
"def ping\n uri = _parse_uri('/ping')\n headers = _get(uri)\n Ping.new.tap do |model|\n model.status = 'ok'\n model.build = headers['X-Influxdb-Build']\n model.version = headers['X-Influxdb-Version']\n model.message = 'ready for queries and writes'\n end\n rescue StandardError => e\n Ping.new.tap do |model|\n model.status = 'fail'\n model.message = e.message\n end\n end",
"def ping\n sanity_check\n @handle.ping\n end",
"def ping!\n @session.ping!\n end",
"def ping\n http_get('/') == 'Consul Agent'\n rescue\n false\n end",
"def update_ping\n put 'ping'\n end",
"def ping\n @ping = Time.now\n end",
"def ping\n if ActiveRecord::Base.connection.active?\n render text: 'pong'\n else\n render status: 500\n end\n end",
"def status\n get('/api/status')\n end",
"def ping()\n #This is a stub, used for indexing\n end",
"def ping; end",
"def is_alive?\n res = @http_client.get_response( URI.parse(\"#{@url}/admin/ping?wt=ruby\") )\n \n if res.code != \"200\"\n raise IndexUnavailableError, \"Index HTTP error #{res.code}\"\n else\n data = eval(res.body)\n if data[\"status\"] === \"OK\"\n return true\n else\n raise IndexUnavailableError, \"Index Error: #{res.body}\"\n end\n end\n end",
"def ping\n @status = Status.find(:first)\n respond_to do |format|\n format.html\n format.xml { render :xml => @status }\n end \n end",
"def ping()\n #This is a stub, used for indexing\n end",
"def ping() \n \"Pong from #{Socket.gethostname}\"\n end",
"def ping()\n # Use the activity client 'client' to invoke the say_hello activity\n pong=client.ping()\n \"Got #{pong}\"\n end",
"def healthcheck\n url = \"#{self.url}/heartbeat\"\n status, _ = rest_get( url )\n return( status )\n end",
"def healthcheck\n url = \"#{self.url}/heartbeat\"\n status, _ = rest_get( url )\n return( status )\n end",
"def ping(opts = {})\n data, _status_code, _headers = ping_with_http_info(opts)\n data\n end",
"def ping\n @client.peek( name )\n return true\n end",
"def ping\n t = Time.now\n @response = Net::HTTP.get_response(uri)\n rescue Errno::ECONNREFUSED\n rescue Exception => e\n STDERR.puts \"Error fetching #{@url}: #{e}\"\n ensure\n @time = Time.now-t\n @response\n end",
"def ping\n check_connection\n @protocol.ping_command\n self\n end",
"def ping\n 'pong'\n end",
"def ping(req)\n Lynr.metrics.time('time.render:ping') do\n Rack::Response.new('PONG', 200, headers)\n end\n end",
"def create_ping\n post 'ping'\n end",
"def test_can_get_ping\n get '/ping'\n assert last_response.ok?\n assert_equal 'PONG', last_response.body\n end",
"def ping?\n tcp_ping.ping?\n end",
"def status\n debug { \"status\" }\n verify_response { Remote.get('/status', :api_key => api_key ) }\n end",
"def ping(&blk)\n if block_given?\n websocket.subscribe :ping, &blk\n else\n http.get :ping\n end\n end",
"def ping(options = Options::Ping::DEFAULT)\n resp = @backend.ping(@name, options.to_backend)\n PingResult.new do |res|\n res.version = resp[:version]\n res.id = resp[:id]\n res.sdk = resp[:sdk]\n resp[:services].each do |type, svcs|\n res.services[type] = svcs.map do |svc|\n PingResult::ServiceInfo.new do |info|\n info.id = svc[:id]\n info.state = svc[:state]\n info.latency = svc[:latency]\n info.remote = svc[:remote]\n info.local = svc[:local]\n info.error = svc[:error]\n end\n end\n end\n end\n end",
"def ping(t)\n \n end",
"def ping()\n _params = {}\n return @master.call 'users/ping2', _params\n end",
"def ping(ip)\n @logger.debug(\"ping from #{ip}\")\n \"pong\"\n end",
"def ping?\n response = perform_request\n !!(response =~ Regexp.union(%r(<str name=\"status\">OK</str>), %r(\"status\":\"OK\")))\n end",
"def health\n response, success = ::Portus::Health.check\n render json: response, status: success ? :ok : :service_unavailable\n end",
"def ping()\n\n ip = Resolv.getaddress(@host)\n puts ('ip: ' + ip.inspect).debug if @debug\n valid = pingecho(ip)\n puts ('valid: ' + valid.inspect).debug if @debug \n \n @results[:ping] = if valid then\n a = [valid]\n 4.times {sleep 0.01; a << pingecho(ip)}\n (a.min * 1000).round(3)\n else\n nil\n end\n\n end",
"def ping?\n false\n end",
"def ping(request)\n if request.message =~ /PING$/i\n request.answer 'PONG'\n end\n end",
"def healthcheck\n url = \"#{self.url}/healthcheck\"\n status, _ = rest_get( url )\n return( status )\n end",
"def healthcheck\n url = \"#{self.url}/healthcheck\"\n status, _ = rest_get( url )\n return( status )\n end",
"def ping\n raise NotImplementedError\n end",
"def status\n request :get, \"_status\"\n end",
"def ping\n\t\tputs \"Pinging #{@ip} ...\"\n\t\tsystem \"ping #{ip_string}\"\n\tend",
"def on_ping(x)\n end",
"def ping\n self.last_ping = Time.now\n end",
"def ping\n @redis.ping\n end",
"def ping\n begin \n @connection = $redis.ping\n rescue => e\n @connection = {status: 500, message: e.message }\n end\n\n respond_to do |format|\n format.json { render json: @connection }\n end\n end",
"def ping_is_pending?\n return @ping_request\n end",
"def status\n {\n 'body' => 'Service is up!'\n }\n end",
"def ping\n response = self.class.post('/', :body => self.class.build_XML_request('Session.Ping', self))\n self.class.response_valid? response\n response['YourMembership_Response']['Session.Ping'] == '1'\n end",
"def status\n dist_service( service_name, 'status' )\n end",
"def get_ping(data)\n end",
"def ping(nonce = SecureRandom.hex)\t\n\t\t\tbegin\n\t\t\t\tresponse = RestClient.get(build_url(\"ping\") + \"?echo=#{nonce}\")\n\t\t\t\tresponse = JSON.parse(response)\n\n\t\t\t\tresponse[\"echo\"] == nonce\n\t\t\trescue => e\n\t\t\t\treturn false\n\t\t\tend\n\t\tend",
"def ping!\n send_message [IGNORE, 4, \"ping\"].pack(\"cNA4\")\n end",
"def test(*args)\n client.ping\n\n { success: true, result: 'Checked API endpoint' }\n rescue Gitlab::PrometheusError => err\n { success: false, result: err }\n end",
"def ping\n exit unless status[1].to_i > 4*60 # only display if more than 5 minutes have passed\n exit if File.exists?(Path + \"/noremind\")\n\n fmt = format_status\n today = daily_tot_current_cat\n\n growl(fmt, today) if fmt.size > 0 && status[1] >> 4\nend",
"def reachable?\n ping\n true\n rescue Orocos::ComError\n false\n end",
"def ping\n data = params[:data] || ''\n render json: { data: data }\n end",
"def ping?(host = @host, options = {})\n ping(host, options).status_code == 0\n end",
"def do_ping\n\t\t\tstatus=`initctl status #{@job_name}`\n\t\t\tstatus.include?(\"running\") ? :up : :down\n\t end",
"def get_status\n @connection.get(\"/\").body\n end",
"def is_alive_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AdminApi.is_alive ...'\n end\n # resource path\n local_var_path = '/health/alive'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'InlineResponse200'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || []\n\n new_options = opts.merge(\n :operation => :\"AdminApi.is_alive\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AdminApi#is_alive\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def local_ping(body)\n @var[:ping_request] = Time.now\n body = @var[:our_name] unless _user_keyhash(body)\n _remote_control(body, 'ping', 'empty')\nend",
"def ping_request(ping, opts = {})\n data, _status_code, _headers = ping_request_with_http_info(ping, opts)\n data\n end",
"def health_check\n JSON.parse(@client.get('status').body)\n end",
"def status\n get_request_without_headers(endpoint_uri('status'))\n end",
"def valid?\n ping\n end",
"def check\n tcp_socket_request\n mark_message \"Ping check to #{host}:#{port} successful\"\n rescue => e\n mark_message \"Error: '#{e}'\"\n mark_failure\n end",
"def ping\n if god?\n tries = 3\n begin\n @server.ping\n rescue Exception => e\n retry if (tries -= 1) > 1\n raise e, \"The server is not available (or you do not have permissions to access it)\"\n end\n end\n end",
"def ping(host = @host, options = {})\n super(host)\n\n lhost = Socket.gethostname\n\n cs = \"winmgmts:{impersonationLevel=impersonate}!//#{lhost}/root/cimv2\"\n wmi = WIN32OLE.connect(cs)\n\n query = \"select * from win32_pingstatus where address = '#{host}'\"\n\n unless options.empty?\n options.each{ |key, value|\n if value.is_a?(String)\n query << \" and #{key} = '#{value}'\"\n else\n query << \" and #{key} = #{value}\"\n end\n }\n end\n\n status = Struct::PingStatus.new\n\n wmi.execquery(query).each{ |obj|\n status.address = obj.Address\n status.buffer_size = obj.BufferSize\n status.no_fragmentation = obj.NoFragmentation\n status.primary_address_resolution_status = obj.PrimaryAddressResolutionStatus\n status.protocol_address = obj.ProtocolAddress\n status.protocol_address_resolved = obj.ProtocolAddressResolved\n status.record_route = obj.RecordRoute\n status.reply_inconsistency = obj.ReplyInconsistency\n status.reply_size = obj.ReplySize\n status.resolve_address_names = obj.ResolveAddressNames\n status.response_time = obj.ResponseTime\n status.response_time_to_live = obj.ResponseTimeToLive\n status.route_record = obj.RouteRecord\n status.route_record_resolved = obj.RouteRecordResolved\n status.source_route = obj.SourceRoute\n status.source_route_type = obj.SourceRouteType\n status.status_code = obj.StatusCode\n status.timeout = obj.Timeout\n status.timestamp_record = obj.TimeStampRecord\n status.timestamp_record_address = obj.TimeStampRecordAddress\n status.timestamp_record_address_resolved = obj.TimeStampRecordAddressResolved\n status.timestamp_route = obj.TimeStampRoute\n status.time_to_live = obj.TimeToLive\n status.type_of_service = obj.TypeOfService\n }\n\n status.freeze # Read-only data\n end",
"def get_service_status\n operation('GetServiceStatus')\n run\n end",
"def get_service_status\n operation('GetServiceStatus')\n run\n end",
"def get_service_status\n operation('GetServiceStatus')\n run\n end",
"def get_service_status\n operation('GetServiceStatus')\n run\n end",
"def get_service_status\n operation('GetServiceStatus')\n run\n end",
"def get_service_status\n operation('GetServiceStatus')\n run\n end",
"def get_service_status\n operation('GetServiceStatus')\n run\n end"
] |
[
"0.8104569",
"0.80859345",
"0.80433947",
"0.8007063",
"0.79521704",
"0.7846848",
"0.7734219",
"0.76513505",
"0.7620497",
"0.7562051",
"0.7559663",
"0.75245416",
"0.7430376",
"0.74293625",
"0.7420223",
"0.7329871",
"0.7303183",
"0.72903526",
"0.7264185",
"0.7261014",
"0.7239065",
"0.72078764",
"0.7144028",
"0.7139678",
"0.71091807",
"0.71001625",
"0.7078609",
"0.7074267",
"0.70693386",
"0.7011201",
"0.69935745",
"0.69561017",
"0.69492847",
"0.6932739",
"0.69288874",
"0.68957424",
"0.686342",
"0.6836421",
"0.68188584",
"0.67885274",
"0.67885274",
"0.67694867",
"0.67680806",
"0.67656446",
"0.6753101",
"0.6746137",
"0.6721656",
"0.67187685",
"0.6696138",
"0.6690805",
"0.66721004",
"0.6664831",
"0.66592246",
"0.6653368",
"0.66461617",
"0.6641651",
"0.6635003",
"0.6625171",
"0.6623767",
"0.66022253",
"0.6583272",
"0.65792423",
"0.65792423",
"0.6576214",
"0.65527624",
"0.65277976",
"0.6512644",
"0.64909583",
"0.6453659",
"0.6453411",
"0.6446129",
"0.64343804",
"0.6420478",
"0.64200824",
"0.64156646",
"0.64135313",
"0.6328078",
"0.6320557",
"0.6316182",
"0.63140607",
"0.63061273",
"0.6298905",
"0.6293127",
"0.6284328",
"0.62776685",
"0.6277506",
"0.6273547",
"0.6238595",
"0.6237911",
"0.62198895",
"0.6218729",
"0.6208439",
"0.6204033",
"0.6194942",
"0.6194942",
"0.6194942",
"0.6194942",
"0.6194942",
"0.6194942",
"0.6194942"
] |
0.63123935
|
80
|
Reads given number of bytes with an optional timeout
|
def read_fully(count, timeout = nil)
value = ''
begin
loop do
value << read_nonblock(count - value.bytesize)
break if value.bytesize >= count
end
rescue EOFError
# JRuby specific fix via https://github.com/jruby/jruby/issues/1694#issuecomment-54873532
IO.select([self], nil, nil, timeout)
retry
rescue *READ_RETRY_EXCEPTION_CLASSES
if IO.select([self], nil, nil, timeout)
retry
else
raise Timeout::Error, "IO timeout when reading #{count} bytes"
end
end
value
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def timed_read(length = nil, wait = def_read_timeout, opts = {})\n if (wait and wait > 0)\n Timeout.timeout(wait) {\n return read(length, opts)\n }\n else\n return read(length, opts)\n end\n end",
"def read_timeout=(sec); end",
"def read_timeout; end",
"def read_timeout; end",
"def read_timeout; end",
"def read_timeout; end",
"def read_timeout; end",
"def read_timeout; end",
"def read_timeout; end",
"def read_timeout; end",
"def timed_read( length=65535, timeout=def_read_timeout )\n\t\tresult = ''\n\n\t\tbegin\n\t\t\tTimeout.timeout( timeout ) {\n\t\t\t\twhile( true )\n\t\t\t\t\tif( @datagrams.empty? )\n\t\t\t\t\t\tRex::ThreadSafe.sleep( 0.2 )\n\t\t\t\t\t\tnext\n\t\t\t\t\tend\n\t\t\t\t\tresult = self.read( length )\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\t}\n\t\trescue Timeout::Error\n\t\t\tresult = ''\n\t\tend\n\n\t\treturn result\n\tend",
"def timed_read(length = 65535, timeout=def_read_timeout)\n begin\n if ((rv = ::IO.select([ fd ], nil, nil, timeout)) and\n (rv[0]) and (rv[0][0] == fd)\n )\n return read(length)\n else\n return ''\n end\n rescue Exception\n return ''\n end\n end",
"def read_timeout=(_arg0); end",
"def read_timeout=(_arg0); end",
"def read_timeout=(_arg0); end",
"def readpartial(size)\n reset_timer\n\n loop do\n result = socket.read_nonblock(size, :exception => false)\n if result.nil?\n return :eof\n elsif result != :wait_readable\n return result\n end\n\n IO.select([socket], nil, nil, time_left)\n log_time\n end\n end",
"def recvn(num_bytes, timeout: nil)\n @timer.countdown(timeout) do\n fillbuffer while @timer.active? && @buffer.size < num_bytes\n @buffer.size >= num_bytes ? @buffer.get(num_bytes) : ''\n end\n end",
"def read(length=99, buf=\"buffer\") end",
"def readpartial(size, buffer = nil)\n timeout = false\n loop do\n result = @socket.read_nonblock(size, buffer, :exception => false)\n\n return :eof if result.nil?\n return result if result != :wait_readable\n\n raise TimeoutError, \"Read timed out after #{@read_timeout} seconds\" if timeout\n\n # marking the socket for timeout. Why is this not being raised immediately?\n # it seems there is some race-condition on the network level between calling\n # #read_nonblock and #wait_readable, in which #read_nonblock signalizes waiting\n # for reads, and when waiting for x seconds, it returns nil suddenly without completing\n # the x seconds. In a normal case this would be a timeout on wait/read, but it can\n # also mean that the socket has been closed by the server. Therefore we \"mark\" the\n # socket for timeout and try to read more bytes. If it returns :eof, it's all good, no\n # timeout. Else, the first timeout was a proper timeout.\n # This hack has to be done because io/wait#wait_readable doesn't provide a value for when\n # the socket is closed by the server, and HTTP::Parser doesn't provide the limit for the chunks.\n timeout = true unless @socket.to_io.wait_readable(@read_timeout)\n end\n end",
"def read_fully(count, timeout = nil)\n return nil if @__bunny_socket_eof_flag__\n\n value = ''\n begin\n loop do\n value << read_nonblock(count - value.bytesize)\n break if value.bytesize >= count\n end\n rescue EOFError => e\n @__bunny_socket_eof_flag__ = true\n rescue OpenSSL::SSL::SSLError => e\n if e.message == \"read would block\"\n if IO.select([self], nil, nil, timeout)\n retry\n else\n raise Timeout::Error, \"IO timeout when reading #{count} bytes\"\n end\n else\n raise e\n end\n rescue *READ_RETRY_EXCEPTION_CLASSES => e\n if IO.select([self], nil, nil, timeout)\n retry\n else\n raise Timeout::Error, \"IO timeout when reading #{count} bytes\"\n end\n end\n value\n end",
"def read_until([email protected])\n start = Time.now\n loop do\n if block_given?\n result = yield and\n return result\n end\n\n return if @eof_found\n\n # select treats 0 as infinity, so clamp it just above 0\n timeout_remaining = [timeout - (Time.now - start), 0.00001].max\n IO.select([@stream], [], [], timeout_remaining) or\n raise Timeout, \"timeout exceeded\"\n\n read_chunk\n end\n end",
"def get(timeout = nil, ltimeout = def_read_loop_timeout, opts = {})\n # For those people who are used to being able to use a negative timeout!\n if (timeout and timeout.to_i < 0)\n timeout = nil\n end\n\n # No data in the first place? bust.\n if (has_read_data?(timeout) == false)\n return nil\n end\n\n buf = \"\"\n lps = 0\n eof = false\n\n # Keep looping until there is no more data to be gotten..\n while (has_read_data?(ltimeout) == true)\n # Catch EOF errors so that we can handle them properly.\n begin\n temp = read(def_block_size)\n rescue EOFError\n eof = true\n end\n\n # If we read zero bytes and we had data, then we've hit EOF\n if (temp and temp.length == 0)\n eof = true\n end\n\n # If we reached EOF and there are no bytes in the buffer we've been\n # reading into, then throw an EOF error.\n if (eof)\n # If we've already read at least some data, then it's time to\n # break out and let it be processed before throwing an EOFError.\n if (buf.length > 0)\n break\n else\n raise EOFError\n end\n end\n\n break if (temp == nil or temp.empty? == true)\n\n buf += temp\n lps += 1\n\n break if (lps >= def_max_loops)\n end\n\n # Return the entire buffer we read in\n return buf\n end",
"def read_timeout=(read_timeout); end",
"def read_n_bytes_from_remote(start_at, n_bytes)\n range = (start_at..(start_at + n_bytes - 1))\n request_range(range)\n end",
"def read_nonblock(maxlen=99, buf=\"buffer\") end",
"def read timeout = DEFAULT_READ_TIMEOUT\n return @responses.shift unless @responses.empty?\n\n results = select([ @socket ], nil, nil, timeout)\n\n @buff += @socket.recv(4 * 1024) if (results and results[0].include? @socket) # results nil on timeout\n\n if @buff =~ /^(.*\\r\\n)(.*)$/m # network responses can split at odd boundries; check for completed messages ending with \\r\\n.\n @buff = $2 # save potential partial response for later..\n @responses += $1.split(/\\r\\n/) # and sock away all of the completed responses\n end\n\n @responses.shift # return next queued message or nil if we've timed out\n end",
"def read(io, size)\n io.read_nonblock(size)\n rescue IO::WaitReadable\n IO.select([io])\n retry\n rescue EOFError\n nil\n end",
"def received_n_timeout(sizemax,timeout_ms,&b)\n timeout(timeout_ms/1000.0) {\n ret=receive_n_bytes(sizemax,false,&b)\n return ret\n }\n rescue Timeout::Error\n return nil\n rescue Exception => e\n $stdout.puts \"#{e} :\\n #{e.backtrace.join(\"\\n \")}\"\n end",
"def read(num_bytes)\n buffer = String.new\n\n until buffer.length >= num_bytes\n begin\n # Unlike plain TCP sockets, SSL sockets don't support IO.select\n # properly.\n # Instead, timeouts happen on a per read basis, and we have to\n # catch exceptions from read_nonblock and gradually build up\n # our read buffer.\n buffer << @ssl_socket.read_nonblock(num_bytes - buffer.length)\n rescue IO::WaitReadable\n if select_with_timeout(@ssl_socket, :read)\n retry\n else\n raise Errno::ETIMEDOUT\n end\n rescue IO::WaitWritable\n if select_with_timeout(@ssl_socket, :write)\n retry\n else\n raise Errno::ETIMEDOUT\n end\n end\n end\n\n buffer\n end",
"def read_timeout\n @read_timeout\n end",
"def def_read_timeout\n 10\n end",
"def def_read_timeout\n 10\n end",
"def read_blocking(count)\n bytes = ''\n while bytes.length < count\n bytes += read_non_blocking(count).to_s\n sleep 0.001\n end\n bytes\n end",
"def pread_pass_through(nbytes:, offset:, buffer:, timeout:)\n invalidate!\n @io.__pread__(nbytes: nbytes, offset: offset, buffer: buffer, timeout: timeout)\n end",
"def _read maxlen = DEFAULT_MAXLEN\n begin\n data = nil\n\n loop do\n data = read_from_socket maxlen\n case data\n when :wait_readable\n IO.select selector\n when NilClass\n break\n else\n begin\n @client << data\n rescue HTTP2::Error::ProtocolError => pe\n STDERR.puts \"protocol error: #{pe.message}\"\n STDERR.puts pe.backtrace.map {|l| \"\\t\" + l}\n end\n end\n end\n\n rescue IOError, Errno::EBADF\n close\n ensure\n unblock!\n end\n end",
"def read_from_socket maxlen\n socket.read_nonblock maxlen\n rescue IO::WaitReadable\n :wait_readable\n end",
"def readpartial(maxlen=99, buf=\"buffer\") end",
"def readpartial(size)\n rescue_readable do\n socket.read_nonblock(size)\n end\n end",
"def read_more(size); end",
"def read_timeout(timeout = nil)\n timeout.nil? ? @read_timeout || DEFAULT_READ_TIMEOUT : @read_timeout = timeout\n end",
"def read( bytes_to_read )\n begin\n client = TCPSocket.new( @ip_address, @port )\n read_bytes = client.read( bytes_to_read )\n puts \"Read #{read_bytes.length}:\"\n print_bytes( read_bytes )\n return read_bytes\n rescue Errno::ETIMEDOUT\n return -1\n end\n end",
"def recv(n)\n until(buffer.length >= n)\n read_stream\n sleep(0.1) unless buffer.length >= n\n end\n buffer.slice!(0, n)\n end",
"def read(length = nil, opts = {})\n synchronize_access {\n begin\n return fd.read_nonblock( length )\n rescue ::Errno::EAGAIN, ::Errno::EWOULDBLOCK\n return nil if self.close_resource\n # Sleep for a half a second, or until we can read again\n Rex::ThreadSafe.select( [ fd ], nil, nil, 0.5 )\n # Decrement the block size to handle full sendQs better\n retry\n rescue ::IOError, ::Errno::EPIPE\n return nil\n end\n }\n end",
"def read(n)\n end",
"def read_wait(timeout: nil)\n !!IO.select([io], [], [], timeout)\n end",
"def __read(buffer_length, buffer = nil)\n @io.read_nonblock(buffer_length, buffer)\n rescue Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::EINTR\n Minx.yield\n retry\n end",
"def read!(handle, offset, length, &callback)\n wait_for(read(handle, offset, length, &callback), :data)\n end",
"def read(length = 65535)\n if length < 0\n length = 65535\n end\n return sysread(length)\n end",
"def read maxlen = DEFAULT_MAXLEN\n main = Thread.current\n @reader = Thread.new do\n @read_gate.block!\n begin\n _read maxlen\n rescue => e\n main.raise e\n end\n end\n end",
"def recv(num_bytes = nil, timeout: nil)\n return '' if @buffer.empty? && !fillbuffer(timeout: timeout)\n\n @buffer.get(num_bytes)\n end",
"def readpartial(maxlen, outbuf=nil)\n read_nonblock(maxlen, outbuf)\n rescue IO::WaitReadable\n block_until_readable\n retry\n end",
"def def_read_loop_timeout\n 0.1\n end",
"def read\n serial_port.read_nonblock(4096)\n rescue EOFError\n end",
"def recvall(timeout: nil)\n recvn(1 << 63, timeout: timeout)\n rescue ::Pwnlib::Errors::EndOfTubeError, ::Pwnlib::Errors::TimeoutError\n @buffer.get\n end",
"def read(length=16384, timeout=nil)\n data = \"\"\n data.force_encoding(\"BINARY\") if data.respond_to?(:force_encoding)\n have_pushback = !@pushback_buffer.empty?\n if have_pushback\n data << @pushback_buffer\n @pushback_buffer = \"\"\n # We have data 'now' so don't wait.\n timeout = 0\n end\n\n if readable?(timeout)\n begin\n # Read at most 'length' data, so read less from the socket\n # We'll read less than 'length' if the pushback buffer has\n # data in it already.\n @socket.sysread(length - data.length, @read_buffer)\n data << @read_buffer\n return data\n rescue EOFError => e\n @socket.close\n @connected = false\n raise e\n end\n else\n if have_pushback\n return data\n else\n raise ReadTimeout.new\n end\n end\n end",
"def read(n=nil)\n if @response == nil\n raise IOError, \"No response available.\"\n end\n return @remaining_body.read(n)\n end",
"def readWithTimeout(socket, length, timeout)\n rc = IO.select([socket], nil, nil, timeout)\n if ! rc\n raise \"Waiting for response from UDP tracker #{@host}:#{@trackerPort} timed out after #{@timeout} seconds\"\n elsif rc[0].size > 0\n socket.recvfrom(length)[0]\n else\n raise \"Error receiving response from UDP tracker #{@host}:#{@trackerPort}\"\n end\n end",
"def wait_readable_or_timeout; end",
"def readpartial(size, buffer = T.unsafe(nil)); end",
"def readpartial(size, buffer = T.unsafe(nil)); end",
"def readpartial(size, buffer = T.unsafe(nil)); end",
"def sysread(amt=99) end",
"def read(length=4096,buffer='')\n @socket.read(length,buffer)\n end",
"def read_bytes(sd, n)\n\n out = []\n\n while (n > out.size) \n data = sd.read_bytes(n - out.size)\n break unless data\n out = out + data\n end\n\n return out\nend",
"def read(byte_count)\n buffer = @current_io.read(byte_count)\n if !buffer\n select_next_io\n @current_io.read(byte_count)\n else\n buffer\n end\n end",
"def read(bytes)\n @reader.read_nonblock(bytes)\n rescue Errno::EAGAIN\n # it simply means that there's nothing in\n # the output buffer.\n rescue Errno::EIO => msg\n @pid = nil\n rescue EOFError => msg\n @pid = nil\n end",
"def read(maxbytes=1024)\n \"\"\"Buffered read from node, non-blocking.\n maxbytes: maximum number of bytes to return\"\"\"\n count = @readbuf.length\n if count < maxbytes\n data = File.new(@stdout.fileno(), \"r\").sysread(maxbytes - count)\n puts data\n @readbuf += data\n end \n\n if maxbytes >= @readbuf.length\n result = @readbuf\n @readbuf = ''\n else\n puts 'entered'\n result = @readbuf[0..maxbytes]\n @readbuf = @readbuf[[email protected]]\n end\n\n return result\n end",
"def read_until_eof(timeout) #:nodoc:\n read_until(timeout){@eof_found}\n end",
"def thread_read(timeout)\n deadline = Time.now + timeout\n raw_last_sample = nil\n while data = raw_read_new # sync call from bg thread\n raw_last_sample = data\n event :raw_data, data\n # TODO just emit raw_data and convert it to ruby\n # if someone is listening to (see PortProxy)\n event(:data) { [Typelib.to_ruby(data)] }\n break if Time.now > deadline\n end\n raw_last_sample\n end",
"def get_once(length = -1, timeout = def_read_timeout)\n\n if (has_read_data?(timeout) == false)\n return nil\n end\n\n bsize = (length == -1) ? def_block_size : length\n data = read(bsize)\n raise EOFError if data.nil?\n data\n end",
"def read(n)\n Buffer.new(slice!(0, n))\n end",
"def ssl_socket_read(ssl_socket, bytes)\n log.chunder('ssl_socket_read')\n\n begin\n return ssl_socket.read_nonblock(bytes)\n rescue IO::WaitReadable\n log.chunder('WaitReadable') # XXX\n IO.select([ssl_socket.io])\n log.chunder('WaitReadable retry') # XXX\n retry\n rescue IO::WaitWritable\n log.chunder('WaitWritable') # XXX\n IO.select(nil, [ssl_socket.io])\n log.chunder('WaitWritable retry') # XXX\n retry\n end\n\n ensure\n log.chunder('done ssl_socket_read')\n end",
"def recvExactNBytes(n)\n buffer = \"\" ;\n while(buffer.size < n)\n IO::select([@socket]) ;\n buf = @socket.recv(n-buffer.size) ;\n if(buf == \"\") # in the case of EOF\n raise SumoException.new(\"TCP socket return EOF\",\n { :n => n }) ;\n end\n buffer << buf ;\n end\n return buffer ;\n end",
"def read(count = T.unsafe(nil), _buffer = T.unsafe(nil)); end",
"def read(n_bytes = nil)\n @remote_size ||= request_object_size\n\n # If the resource is empty there is nothing to read\n return nil if @remote_size.zero?\n\n maximum_avaialable = @remote_size - @pos\n n_bytes ||= maximum_avaialable # nil == read to the end of file\n return '' if n_bytes.zero?\n raise ArgumentError, \"No negative reads(#{n_bytes})\" if n_bytes < 0\n\n n_bytes = clamp(0, n_bytes, maximum_avaialable)\n\n read_n_bytes_from_remote(@pos, n_bytes).tap do |data|\n if data.bytesize != n_bytes\n raise \"Remote read returned #{data.bytesize} bytes instead of #{n_bytes} as requested\"\n end\n @pos = clamp(0, @pos + data.bytesize, @remote_size)\n end\n end",
"def rx_waitfor(n_packets, timeout_seconds = 1.0)\n t0 = Time.now.to_f\n while true\n rxc = rx_counter\n return rxc if rxc >= n_packets\n return nil if (Time.now.to_f - t0) >= timeout_seconds\n sleep(1.0/25)\n end\n end",
"def read(maxlen = nil, buf = nil, buffer_pos = 0)\n return readpartial(maxlen, buf, buffer_pos) if buf\n\n buf = +''\n return readpartial(maxlen, buf) if maxlen\n\n readpartial(4096, buf, -1) while true\n rescue EOFError\n buf\n end",
"def read_timeout= secs\n if secs\n @read_timeout = secs\n @read_timeout_ms = secs * 1000\n else\n @read_timeout = @read_timeout_ms = nil\n end\n end",
"def read_timeout\n @agent.read_timeout\n end",
"def timedout_read(duration)\n begin \n timeout(duration) do\n @sock.wait_readable\n end\n rescue Celluloid::TaskTimeout\n return true\n end\n false\n end",
"def read_bytes(count)\n result = new_buffer\n result << read_outstanding(0, count)\n @outstanding = read_outstanding(count..-1)\n result << read_bytes!(count - result.size) until result.size == count\n result\n ensure\n @recent << result\n end",
"def read_available(length = T.unsafe(nil)); end",
"def read(timeout = TIMEOUT, str = \"\")\n while true\n Timeout::timeout(timeout) do\n str << output.readline\n break if output.eof?\n end\n end\n\n return str\n rescue Timeout::Error, EOFError, Errno::EIO\n return str\n end",
"def wait_for_data(timeout)\n return if timeout == -1\n\n ready = false\n begin\n ready = IO.select([self], nil, [self], timeout)\n rescue IOError => exception\n logger.warn \"#read Connection failure while waiting for data: #{exception.class}: #{exception.message}\"\n close if close_on_error\n raise Net::TCPClient::ConnectionFailure.new(\"#{exception.class}: #{exception.message}\", address.to_s, exception)\n rescue Exception\n # Close the connection on any other exception since the connection\n # will now be in an inconsistent state\n close if close_on_error\n raise\n end\n\n unless ready\n close if close_on_error\n logger.warn \"#read Timeout after #{timeout} seconds\"\n raise Net::TCPClient::ReadTimeout.new(\"Timedout after #{timeout} seconds trying to read from #{address}\")\n end\n end",
"def read_loop(maxlen = 8192)\n while (data = sysread(maxlen))\n yield data\n end\n end",
"def read_timeout_exceeded?\n @read_timeout_ms && duration_since_received > @read_timeout_ms\n end",
"def read(length = nil, offset = 0)\n if (length == nil)\n data = ''\n fptr = offset\n ok = self.client.read(self.file_id, fptr, self.chunk_size)\n while (ok and ok['Payload'].v['DataLenLow'] > 0)\n buff = ok.to_s.slice(\n ok['Payload'].v['DataOffset'] + 4,\n ok['Payload'].v['DataLenLow']\n )\n data << buff\n if ok['Payload'].v['Remaining'] == 0\n break\n end\n fptr += ok['Payload'].v['DataLenLow']\n\n begin\n ok = self.client.read(self.file_id, fptr, self.chunk_size)\n rescue XCEPT::ErrorCode => e\n case e.error_code\n when 0x00050001\n # Novell fires off an access denied error on EOF\n ok = nil\n else\n raise e\n end\n end\n end\n\n return data\n else\n ok = self.client.read(self.file_id, offset, length)\n data = ok.to_s.slice(\n ok['Payload'].v['DataOffset'] + 4,\n ok['Payload'].v['DataLenLow']\n )\n return data\n end\n end",
"def read_data_available?(timeout = 0)\n (rh, wh, eh) = IO::select([@io], nil, nil, timeout)\n ! rh.nil?\n end",
"def long_read_len()\n #This is a stub, used for indexing\n end",
"def wait_readable(timeout = nil)\n return self if @read_buffer && !@read_buffer.empty?\n\n if timeout\n move_on_after(timeout) do\n Polyphony.backend_wait_io(self, false)\n self\n end\n else\n Polyphony.backend_wait_io(self, false)\n self\n end\n end",
"def recv_raw(numbytes)\n raise ::Pwnlib::Errors::EndOfTubeError if @conn.nil?\n\n @serial_timer.countdown do\n data = ''\n begin\n while @serial_timer.active?\n data += @conn.read(numbytes - data.length)\n break unless data.empty?\n\n sleep 0.1\n end\n # XXX(JonathanBeverley): should we reverse @convert_newlines here?\n return data\n rescue RubySerial::Error\n close\n raise ::Pwnlib::Errors::EndOfTubeError\n end\n end\n end",
"def read(size)\n ret = @io.read(size)\n raise EOFError if ret.nil? || size && ret.bytesize < size\n\n ret\n end",
"def read(len)\r\n buf = \"\\0\" * len\r\n Win32API.new(\"msvcrt\", \"_read\", \"lpl\", \"l\").call(@fd, buf, len)\r\n buf\r\n end",
"def read_till(prompt: current_prompt, timeout: read_till_timeout, hard_timeout: read_till_hard_timeout, hard_timeout_factor: read_till_hard_timeout_factor, **_opts)\n raise Error::UndefinedMatch, 'no prompt given or default_prompt defined' unless prompt\n hard_timeout = (read_till_hard_timeout_factor * timeout) if timeout and hard_timeout == true\n hard_timeout = nil if hard_timeout == true\n\n with_prompt(prompt) do\n ::Timeout.timeout(hard_timeout, Error::ReadTillTimeout, \"#{current_prompt.inspect} didn't match on #{stdout.inspect} within #{hard_timeout}s\") do\n soft_timeout = Time.now + timeout if timeout\n until prompt_in_stdout? do\n if timeout and soft_timeout < Time.now\n raise Error::ReadTillTimeout, \"#{current_prompt.inspect} didn't match on #{stdout.inspect} within #{timeout}s\"\n end\n process\n sleep 0.01 # don't race for CPU\n end\n end\n end\n read\n end",
"def read(length = bytes_remaining)\n value = @data.byteslice(@pos, length)\n @pos += length\n value\n end",
"def readpartial(maxlen, outbuf = \"\")\n data = @socket.readpartial(maxlen, outbuf)\n log :read, data\n data\n end",
"def read(len)\n data = ''\n while data.bytesize < len\n data << @client.kgio_read!(len - data.bytesize)\n end\n data\n end",
"def read_neverblock(*args)\r\n\t\tres = \"\"\n\t\tbegin\n\t\t\traise Timeout::Error if Fiber.current[:exceeded_timeout]\n\t\t\t@immediate_result = read_nonblock(*args)\n\t\t\tres << @immediate_result\n\t\trescue Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::EINTR\n \t\tattach_to_reactor(:read)\n \t\tretry\r\n\t\tend\n\t\tres\r\n end",
"def receive_n_bytes(sizemax,looping=false,&b)\n s=sizemax\n if self.data_readed.size>=sizemax\n buff,self.data_readed=self.data_readed[0..sizemax-1],self.data_readed[sizemax..-1]\n buff=b.call(buff) if block_given?\n return buff unless looping\n end\n s=sizemax-self.data_readed.size\n loop do\n #p [\"waiting \",s,data_readed]\n sd=s>1024 ? 1024 : s\n data=(self.recv(sd) rescue (p $!;nil))\n #p \"nrec: w#{sizemax}/ rec:#{(data||'').size} / #{sd} old=#{data_readed.size} /// #{(data||'').size<70 ? data : \".\"}\"\n if data && data.size>0\n self.data_readed=self.data_readed+data\n s=sizemax-self.data_readed.size\n if s<=0\n buff,self.data_readed=self.data_readed,\"\"\n s=sizemax\n buff=b.call(buff) if block_given?\n return buff unless looping\n end\n else\n close rescue nil\n break # socket close\n end\n end #loop\n end",
"def fill\n begin\n @buffer << @io.read_nonblock(@buffer_size)\n rescue ::IO::WaitReadable\n IO.select([@io], nil, nil, @read_timeout) ? retry : (raise ::Timeout::Error)\n rescue ::IO::WaitWritable\n IO.select(nil, [@io], nil, @read_timeout) ? retry : (raise ::Timeout::Error)\n end\n end"
] |
[
"0.77515435",
"0.7417895",
"0.7264305",
"0.7264305",
"0.7264305",
"0.7264305",
"0.7264305",
"0.7264305",
"0.7264305",
"0.7264305",
"0.72280395",
"0.7190883",
"0.7177787",
"0.7177787",
"0.7177787",
"0.71326977",
"0.7122137",
"0.7007506",
"0.6994811",
"0.6972871",
"0.6943312",
"0.6838922",
"0.6833737",
"0.68228364",
"0.6813253",
"0.6809298",
"0.6807732",
"0.6802212",
"0.67428756",
"0.67268395",
"0.6701997",
"0.6701997",
"0.6700741",
"0.6662745",
"0.66533047",
"0.6640358",
"0.66291875",
"0.65940166",
"0.6562313",
"0.65036255",
"0.64740574",
"0.6470175",
"0.64651763",
"0.64368385",
"0.6432296",
"0.64167917",
"0.63659924",
"0.6315418",
"0.62892234",
"0.6288943",
"0.628634",
"0.62736017",
"0.6266928",
"0.6266071",
"0.6259858",
"0.6252706",
"0.6244834",
"0.6233693",
"0.6224695",
"0.6224695",
"0.6224695",
"0.62208056",
"0.62047666",
"0.62027997",
"0.61845124",
"0.61406404",
"0.611791",
"0.61067814",
"0.6104176",
"0.6091031",
"0.6057612",
"0.6044308",
"0.60433877",
"0.60390973",
"0.60287464",
"0.6028096",
"0.60247093",
"0.6012999",
"0.5990448",
"0.59688175",
"0.59643435",
"0.5962692",
"0.59612745",
"0.5958509",
"0.59551775",
"0.5948043",
"0.59395033",
"0.59394747",
"0.5919179",
"0.59164816",
"0.5893664",
"0.58830255",
"0.5863468",
"0.5845725",
"0.5842745",
"0.58423537",
"0.5840398",
"0.58104384",
"0.5807063",
"0.5806602"
] |
0.7133221
|
15
|
and determine if it is an acceptable sequence by either returning the string true or false. The str parameter will be composed of + and = symbols with several letters between them (ie. ++d+===+c++==a) and for the string to be true each letter must be surrounded by a + symbol. So the string to the left would be false. The string will not be empty and will have at least one letter.
|
def all_letters(str)
# Use 'str[/[a-zA-Z]*/] == str' to let all_letters
# yield true for the empty string
str[/[a-zA-Z]+/] == str
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def decide string\n @current_state = @start_state\n string.each_char do |c|\n if [email protected]? c then\n return false\n end\n transition = false\n @transition_rules.each do |rule|\n if rule.input_char === c && rule.current_state === @current_state then\n transition = rule\n break\n end\n end\n if !transition then \n return false\n else\n @current_state = transition.end_state\n end\n end\n\n if @accept_states.include? @current_state then\n return true\n else\n return false\n end\n end",
"def prad_valid? str\n return false unless str\n !!parse(str)\n end",
"def SimpleSymbols(str)\n\n #1. surround the string by ='s\n #2. begin looping\n #3. look for letters\n #4. check if letters surround by a + on both sides\n #5. return false if they aren't\n #6. end loop\n #7. return true\n\n str = '=' + str + '='\n\n (0..str.length-1).each do |i|\n if /[a-zA-Z]/.match(str[i])\n if str[i-1] != '+' or str[i+1] != '+'\n return false\n end\n end\n end\n return true\n\nend",
"def ABCheck(str)\n\n return \"true\" if str=~(/a...b/) or str=~(/b...a/)\n return \"false\"\n \nend",
"def valid_string?(string)\n if string.match(/[a-z]/).present? || string.match(/[0-9]/).present?\n @valid = false\n return \"No pongas otro caracter que no sean llaves, corchetes o parentesis\"\n else\n #assume validity\n @valid = true\n #empty array will be populated inside the loop\n @open_characters = []\n #set up a hash to translate the open character to a closing character\n translate_open_closed = {\"{\" => \"}\",\"[\"=>\"]\",\"(\"=>\")\"}\n #create an array from the string loop through each item \n string.split('').each do |e| \n #adding it to the open_characters array if it is an opening character\n @open_characters << e if e=~ /[\\[\\{\\(]/\n #if it is a closing character then translate the last open_character to \n #a closing character and compare them to make sure characters are closed in order\n #the result of this comparison is applied to the valid variable\n @valid &= e == translate_open_closed[@open_characters.pop] if e=~ /[\\]\\}\\)]/\n end\n #return validity and make sure all open characters have been matched\n @valid &= @open_characters.empty?\n return @valid\n end \n end",
"def SimpleSymbols(str)\n if str =~ /[a-zA-Z]/ && str != \"\"\n \ti = 1\n \twhile i < str.length\n \t if str[i-1] != \"+\" || str[i + 1] != \"+\"\n \t \treturn false\n else\n \t \treturn true \n \t end\n \t i += 1\n # code goes here\n end\n end\nend",
"def SimpleSymbols(str)\n things = str.split(\"\")\n\n things.each_with_index do |unit, idx|\n if unit =~ /[a-z]/\n return false if things[idx - 1] != \"+\" || things[idx + 1] != \"+\"\n end\n end\n\n true\nend",
"def SimpleSymbols(str)\n alphabet = ('a'..'z').to_a\n str_array = str.split(//)\n str_array.each_with_index do |i, index|\n if alphabet.include?(i)\n return false if index == 0 || index == str_array.count-1\n return false if (str_array[index-1] != '+') || (str_array[index+1] != '+')\n end\n end\n true\nend",
"def yours?(str)\n str[0..1] == 'BA'\n end",
"def validity_check\n\n if strand == '+'\n\n codon = ref_seq[0..2].map(&:last).join\n return true if codon.include?('N')\n codon == 'ATG'\n\n elsif strand == '-'\n\n codon = ref_seq[-3..-1].map(&:last).join\n return true if codon.include?('N')\n codon == 'CAT'\n\n end\n\n end",
"def abCheck(str)\n\treturn false if(str.include?('a') == false || str.include?('b') == false || str.rindex('b') < str.rindex('a'))\n\treturn str.rindex('b') - str.rindex('a') == 4\n\t\nend",
"def ABCheck(str)\n\n i = 0\n while i < str.length\n puts str[i]\n while str[i] == 'a' && str[i + 4] == 'b' || str[i] == 'b' && str[i +4] == 'a'\n \tputs str[i]\n \treturn 'true'\n end\n i += 1\n end\n return 'false'\nend",
"def accept?(str)\n raise(\"no final state\") if @final.nil?\n cursor = @initial\n str.each_char { |chr|\n transition = self.follow(cursor, chr)\n return false unless transition\n cursor = transition\n }\n cursor == @final\n end",
"def check_string( str )\r\n result = false\r\n return result unless validate_string(str)\r\n\r\n if str.include?( self.pattern )\r\n result = true\r\n end\r\n return result\r\n end",
"def can_encode?(str)\n str.nil? || !(GSM_REGEX =~ str).nil?\n end",
"def is? str\n !!match(str)\n end",
"def validate()\n if (sequenz?)\n @string.each_char do |char|\n if([email protected](/#{char}+/))\n raise \"String alphabet is not correct\\nChar: #{char}\\nString: #{@string}\" \n end\n end\n end\n end",
"def ABCheck(str)\n\n counter = 0\n str.each_char do |x|\n if(x == 'a' && counter + 4 < str.length && str.chars.to_a[counter + 4] == 'b')\n return true\n end\n counter += 1\n end\n return false \n \nend",
"def valid?(str)\r\n if str =~ /^([^2]*(13|31)|[^4]*(17|71)|[^6]*(39|93)|[^8]*(79|97)|\r\n [^5]*(46|64|28|82|19|91|37|73)).*\\z/x\r\n false\r\n else\r\n true\r\n end\r\n end",
"def complete_expression?(str); end",
"def valid(str)\n direction = Hash.new(0)\n str.each_char do |ch|\n direction[ch] += 1\n end\n if (direction['n'] == direction['s'] && direction['e'] == direction['w'])\n print true\n else\n print false\n end\n\n\nend",
"def simpleSymbols(str)\n\tstr = str.split('')\n\tstr.map.with_index{|char,i| \n\t\tif(char =~ /[a-zA-Z]/)\n\t\t\treturn false if str.index(char) == 0\n\t\t\tif(str[i - 1] != \"+\" || str[i + 1] != \"+\")\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\t}\n\treturn true\nend",
"def validate_string(string)\n stack = []\n lookup = { '(' => ')', '[' => ']', '{' => '}', '<' => '>' }\n left = lookup.keys\n right = lookup.values\n\n string.each_char do |char|\n if left.include? char\n stack << char\n elsif right.include? char\n return false if stack.empty? || (lookup[stack.pop] != char)\n end\n end\n\n return stack.empty?\nend",
"def validate_string( str )\r\n if str.kind_of?(String)\r\n return true\r\n else\r\n puts \"#{self.class}:check_string: Error: Input must be a string.\"\r\n return false\r\n end\r\n end",
"def valid_parentheses(str)\n balance = 0\n str.each_char do |chr|\n case chr\n when \"(\" then balance += 1\n when \")\" then balance -= 1\n end\n return false if balance < 0\n end\n balance == 0\nend",
"def checkValidString(str)\n balance_count = 0\n right_paren = 0\n left_paren = 0\n star_count = 0\n diff = ''\n current_str = ''\n mapIt = true\n arr = str.split('')\n while mapIt\n mapIt = false\n arr.map!.with_index do |char, i|\n char if char == '' || char == '*'\n if char == '(' && arr[i + 1] == ')'\n mapIt = true\n arr[i + 1] = ''\n ''\n else\n char\n end\n end\n arr.delete('')\n end\n return arr\n if left_paren == right_paren\n return true\n else\n diff = (left_paren - right_paren).abs\n return true if diff <= star_count\n end\n return false\nend",
"def check_string(str)\n str = str.strip\n\n return false if str =~ /<>{}/\n return false if str.length == 0\n\n return true\n end",
"def code?(str)\n return false unless str =~ /`/\n return false unless str[0] == '`' && str[-1] == '`'\n\n # let's make sure there aren't more ` in the middle\n return false if str[1 .. -2] =~ /`/\n\n true\nend",
"def string_check(elem)\n (('a'..'z').to_a + ('A'..'Z').to_a).each { |k| return true if elem.include?(k) }\n false\n end",
"def ABcheck(str)\ncounter = 0 \nstr.each_char.do |x|\nif( x == 'a' && counter + 4 < str.length str.chars.to_a[counter + 4] =='b'\nreturn true\nend",
"def SimpleSymbols(str)\n\n # code goes here\n possible = str.scan(/.?[a-z]./)\n matches = str.scan(/\\+[a-z]\\+/)\n if possible == matches\n true\n else\n false \n end\nend",
"def SimpleSymbols(str)\n letters = str.scan(/[a-z]/)\n str.scan(/\\+[a-z]\\+/).count == letters.size ? true : false\nend",
"def is_valid(s)\n return false unless s\n\n mapping = {\n ')': 'C',\n '}': '{',\n ']': '['\n }\n\n stack = []\n\n s.each_char do |c|\n if !mapping[c.to_sym]\n stack << c\n elsif mapping[c.to_sym] != stack.pop\n return false\n end\n end\n\n stack.empty? ? true : false\nend",
"def string_has_all_letters(str)\n result = {}\n str.each_char do |c|\n return true if result.length == 26\n if c == \" \"\n next\n elsif !result.include?(c)\n result[c] = c\n end\n end\n result.length == 26 ? true : false\nend",
"def ABCheck(str)\n str =~ /a...b/ || str =~ /b...a/ ? true : false\nend",
"def SimpleSymbols(str)\n return false if !str.index(/[A-Za-z]/) or str.empty?\n str.gsub!(/(\\+[A-Za-z])+\\+/,'')\n return false if str.index(/[A-Za-z]/)\n return true\nend",
"def valid?\n invalid_strings = %w[ab cd pq xy]\n invalid_strings.each do |x|\n return false if include?(x)\n end\n\n true\n end",
"def check_str(str,s)\n if str.include?s\n puts \"true\"\n else\n puts \"false\"\n end\nend",
"def acceptable_serial( str )\n # no more than two repeating characters\n return true\n end",
"def check_repeated_char(str)\n\tprev = str[0]\n for i in 1..str.length\n \tif prev == str[i]\n \t\treturn true\n \telse\n \t\tprev = str[i]\n \tend\n end\n\n return false\nend",
"def invalid_string(str)\n return true if str.strip! == ''\n return true unless str[0] =~ /[0-9\\+\\-]/\n false\nend",
"def operator?(str)\n if str == \"+\" || str == \"-\" || str == \"*\" || str == \"/\" || str == \"%\" || str == \"^\"\n\t\t\treturn true\n\t\tend\n\n\t\treturn false\n end",
"def correct?(str)\n str = str.is_a?(String) ? str : str.to_s\n str == (@answer.is_a?(String) ? @answer : @answer.to_s) # don't change @answer type\n end",
"def repeating_letters?(str)\n dStr = str.downcase.chars\n checkStr = \"\"\n\n dStr.each do |char|\n if checkStr.index(char) != nil\n return true\n else\n checkStr += char\n end\n end\n false\nend",
"def valid_play?(string)\n unless (\"a\"..\"z\").to_a.include?(string)\n return false\n end\n\n newFragment = @fragment + string\n\n # if @dictionary.empty?\n # dictionary\n # end\n\n wordIncludeFragment = dictionary.any? do |word|\n # debugger\n # puts '#{word}'\n word.start_with?(newFragment)\n end\n\n if wordIncludeFragment\n return true\n end\n\n false\n end",
"def validate_string(arg)\n arg.split(\"\").each do |i|\n if(i != '0' && i !='1')\n puts \"The input argument contain(s) characters other than 0 and 1. Please correct!\"\n return false\n end\n end\n end",
"def can_encode?(str, charset: BASIC_CHARSET)\n !str || !!(regex(charset) =~ str)\n end",
"def step1(str)\n r1,r2 = r12(str)\n r1_text = str[r1..-1]\n r2_text = str[r2..-1]\n\n case r2_text\n when /(anzas?|ic[oa]s?|ismos?|[ai]bles?|istas?|os[oa]s?|[ai]mientos?)$/i\n str[%r{#$&$}]=''\n return true\n when /(ic)?(ador([ae]s?)?|aci[óÓ]n|aciones|antes?|ancias?)$/ui\n str[%r{#$&$}]=''\n return true\n when /log[íÍ]as?/ui\n str[%r{#$&$}]='log'\n return true\n when /(uci([óÓ]n|ones))$/ui\n str[%r{#$&$}]='u'\n return true\n when /(encias?)$/i\n str[%r{#$&$}]='ente'\n return true\n end\n\n if r2_text =~ /(ativ|iv|os|ic|ad)amente$/i or r1_text =~ /amente$/i\n str[%r{#$&$}]=''\n return true\n end\n\n case r2_text\n when /((ante|[ai]ble)?mente)$/i, /((abil|i[cv])?idad(es)?)$/i, /((at)?iv[ao]s?)$/i\n str[%r{#$&$}]=''\n return true\n end\n false\n end",
"def step2a(str)\n rv_pos = rv(str)\n idx = str[rv_pos..-1] =~ /(y[oóÓ]|ye(ron|ndo)|y[ae][ns]?|ya(is|mos))$/ui\n\n return false unless idx\n\n if 'u' == str[rv_pos+idx-1].downcase\n str[%r{#$&$}] = ''\n return true\n end\n false\n end",
"def step0(str)\n return false unless str =~ /(se(l[ao]s?)?|l([aeo]s?)|me|nos)$/i\n\n suffix = $&\n rv_text = str[rv(str)..-1]\n\n case rv_text\n when %r{((?<=i[éÉ]ndo|[áÁ]ndo|[áéíÁÉÍ]r)#{suffix})$}ui\n str[%r{#$&$}]=''\n str.replace(remove_accent(str))\n return true\n when %r{((?<=iendo|ando|[aei]r)#{suffix})$}i\n str[%r{#$&$}]=''\n return true\n end\n\n if rv_text =~ /yendo/i and str =~ /uyendo/i\n str[suffix]=''\n return true\n end\n false\n end",
"def all_letters? str\r\n str[/[a-zA-z]+/] == str\r\nend",
"def valid_char?(char, prev, prev2)\n return false if char.nil?\n\n # take care of nasty edge case first\n return true if char == \"+\" && prev == \" \" && prev2.match(/\\w/)\n\n return false if char == \" \"\n return false if [char, prev, prev2].all? { |a| [' ', \"\\n\", \"\\t\"].any? {|ch| a == ch} }\n return true\n end",
"def check_valid_string(s)\n\treturn true if s.empty?\n\tlow = 0\n\thigh = 0\n\tfor i in 0..s.size-1 do\n\t\tif s[i] == '('\n\t\t\tlow = low+1\n\t\t\thigh = high+1\n\t\telsif s[i] == ')'\n\t\t\tif low > 0\n\t\t\t\tlow = low-1\n\t\t\tend\t\n\t\t\thigh = high-1\n\t\telse\n\t\t\tif low > 0\n\t\t\t\tlow = low-1\n\t\t\tend\n\t\t\thigh = high+1\n\t\tend\n\t\tif high < 0\n\t\t\treturn false\n\t\tend\n\tend\n\tlow == 0\nend",
"def verify_choice_ok (choice)\r\n if \"adehlnq+?\".include? (choice)\r\n return true\r\n else\r\n return false\r\n end\r\nend",
"def str_chars_unique? str\n checker = {}\n str.codepoints.each do |c|\n if checker[c] == nil\n checker[c] = true\n else\n return false\n end\n end\n return true\nend",
"def string_is_valid(string)\n # Use lookahead to check for valid string\n string.match \"^(?=.*\\\\D)[#{@characters.join('|')}]+$\"\n end",
"def isIdentifier(str)\n digitsOfAlphabet = getAlphabet[0] # if its a digit\n charsOfAlphabet = getAlphabet[1] # if a letter\n\n # first character in name cannot be digit\n if digitsOfAlphabet.include?(str[0])\n return false\n end\n\n # if keyword includes str\n if getKeywords.include?(str)\n return false\n end\n\n # check is in the alphabet\n for i in 1..str.size-1\n character = str[i]\n\n unless digitsOfAlphabet.include?(character) or charsOfAlphabet.include?(character)\n return false\n end\n end\n\n return true\nend",
"def check(str)\n [*str].each { |s| @parts.push(check: s) }\n end",
"def single_segment?(str)\n raise InvalidGSMString unless can_encode?(str)\n\n extended_chars = str.gsub(GSM_NOT_EXTENDED_REGEX, '').length\n (str.length + extended_chars) <= GSM_SEGMENT_LENGTH\n end",
"def SimpleSymbols(str)\n values = str.scan(/\\+\\w\\+/)\n if values.count > 0\n puts true\n else\n puts false\n end\nend",
"def operator?(str)\n return ['+', '-', '*', '/', '%', '^'].include?(str)\n end",
"def valid_syntax(str_sample)\n stack = []\n opener_pairs = {\n \"{\"=>\"}\",\n \"(\"=>\")\",\n \"[\"=>\"]\"\n}\n str_sample.each_char do |char|\n if char == \"[\" || char == \"{\" || char == \"(\"\n stack.push(char)\n elsif char == \"]\" || char == \"}\" || char == \")\"\n opener = stack.pop\n return false if opener_pairs[opener] != char\n end\n end\n stack.empty?\nend",
"def f_alter_not_start_end?(str, b, e, j)\n e[j] + 1 < str.length && b[0].positive?\n end",
"def forward_strand?\n @strand == '+'\n end",
"def is_valid(str)\n stack = []\n\n return false unless str.length % 2 == 0\n\n str.each_char do |c|\n case c\n when '{', '(', '['\n stack << c\n when '}'\n return false unless stack.pop == '{'\n when ')'\n return false unless stack.pop == '('\n when ']'\n return false unless stack.pop == '['\n end\n end\n stack.empty?\nend",
"def is_id? str\n match = [KVP,DELIM]\n return false if match.any? {|w| str.include? w}\n return true\n end",
"def valid_looking_string?(str)\n str =~ /\\d/\n end",
"def has_operators?(str)\n true if /[*\\-\\+\\/]/ =~ str\n end",
"def hackerrankInString(str)\n expected_chars = %w[h a c k e r r a n k]\n input_chars = str.chars\n\n str.chars.each do |char|\n # Thought so, apparently not: Edge case: there should be no more chars after the last 'k' in hackerrank.\n # break if expected_chars.empty?\n\n input_chars.shift\n expected_chars.shift if char == expected_chars[0]\n end\n\n expected_chars.empty? && input_chars.empty? ? 'YES' : 'NO'\nend",
"def ABCheck(str)\n\n new_str = str.split(\"\")\n index = 0 \n value = false\n \n while index < new_str.length\n if new_str[index] == 'a' and new_str[index+4] == 'b'\n value = true\n end\n index += 1\n end\n \n \n # code goes here\n return value \n \nend",
"def matched?(str)\r\n # puts \">>> #{self.matcher.source}\"\r\n # puts \">>> #{str}\"\r\n return false if (!self.implicit && str[0] != \"!\")\r\n if (self.matcher =~ str) != nil\r\n $bot.last_match = $~\r\n $log.info(\"/#{self.matcher.source}/ matched #{str}\")\r\n return true\r\n end\r\n false\r\n end",
"def valid?(string)\n scanner = UnicodeScanner.new(string)\n\n first_left_brace_match = scanner.scan_until(UNESCAPED_LEFT_BRACE)\n return true unless first_left_brace_match\n\n until scanner.eos?\n # Make sure there's a right brace to match with the left one.\n right_brace_match = scanner.scan_until(UNESCAPED_RIGHT_BRACE)\n return false unless right_brace_match\n\n right_brace_index = scanner.pos\n scanner.unscan # Reset to last time we saw a left brace.\n\n # If there are no more left braces, we're good.\n left_brace_match = scanner.scan_until(UNESCAPED_LEFT_BRACE)\n return true unless left_brace_match\n\n # Make sure the next right brace happens before the next left brace.\n left_brace_index = scanner.pos\n return false if left_brace_index < right_brace_index\n end\n end",
"def is_op(str)\n\t['+', '-', '^', '=', '<', '>'].include?(str)\nend",
"def balancer(str)\n open_idx = 0\n closed_idx = 0\n\n chars = str.chars\n\n total_open = chars.count('(')\n total_closed = chars.count(')')\n\n return false if total_open != total_closed\n\n chars.each_with_index do |chr, idx|\n if chr == '('\n open_idx = idx\n elsif chr == ')'\n closed_idx = idx\n end\n return false if open_idx > closed_idx\n end\n\n open_idx < closed_idx ? true : puts(\"no parentheses in the string\")\nend",
"def balancer(str)\n return false unless str.count('(') == str.count(')')\n\n count = 0\n\n str.each_char do |char|\n if char == '('\n count += 1\n elsif char == ')'\n count -=1\n end\n return false if count < 0\n end \n \n true\nend",
"def pangram?(str)\n letters = \"abcdefghijklmnopqrstuvwxyz\".split(\"\")\n\n str.downcase!\n\n letters.all? { |letter|\n str.include? (letter)\n }\nend",
"def apply?(str)\n !!(regexp.match(str))\n end",
"def ABCheck(str)\n str.match?(/a.{3}b/) || str.match?(/b.{3}a/)\nend",
"def in_both?(string)\n\t\t[\"elsif\",\"else\",\"when\",\"rescue\",\"ensure\"].each{|x|\n\t\treturn true if string.lstrip.slice(/^#{x}/)\n\t\t}\n\t\tfalse\n\tend",
"def is_number(str)\n\t\tif !str.nil? && !str.blank?\n\t\t\tchrs = ('a'..'z').to_a\n\t\t\tchrs << \" \"\n\t\t\tstr.split(\"\").each do |n|\n\t\t\t\treturn false if chrs.include? n\n\t\t\tend\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend",
"def Starts_whit(string1,character)\n return string1[0] == character\nend",
"def has_special_ch?(str)\n (str =~ @@regex)?true:false\n end",
"def can_be_palindrome?(str)\n\tstr.gsub!(/\\s+/, \"\")\n\tletter_count = {}\n\tfor i in 0..str.length-1\n\t\tif letter_count[str[i]]\n\t\t\tletter_count[str[i]] += 1\n\t\telse\n\t\t\tletter_count[str[i]] = 1\n\t\tend\n\tend\n\todd_count = 0\n\tletter_count.each do |k,v|\n\t\tif v % 2 != 0\n\t\t\todd_count += 1\n\t\tend\n\tend\n\n\tif str.length % 2 != 0 && odd_count == 1\n\t\treturn true\n\telsif str.length % 2 == 0 && odd_count == 0\n\t\treturn true\n\tend\n\tfalse\nend",
"def strCheck(arr, str)\n arr.each do |i|\n if str == i\n return true\n end\n end\n return false\nend",
"def mutation?(str_one, str_two)\n str_two.chars.all? {|char| str_one.include? char}\nend",
"def g_happy(str)\n i = 0\n g = 0\n while i < str.size\n if str[i] == \"g\"\n g = 1\n if str[i - 1] != \"g\" && str[i + 1] != \"g\"\n return false\n end\n end\n i += 1\n end\n if g == 1\n return true\n end\nend",
"def triplet_true?(str)\n str.each_char.with_index do |char, idx|\n return true if char == str[idx+1] && char == str[idx+2]\n end\n false\nend",
"def good(str = '')\n show(\"Good for #{str}\")\n true\n end",
"def is_valid(s)\n valid_chars = {'(' => ')', '{' => '}', '[' => ']'}\n characters = s.split(\"\")\n characters.each do |char|\n if char != valid_chars[char]\n end \nend\n\np is_valid(\"([])\")",
"def alnum?(str)\n\t\t\tstr.match /^[[:alnum:]]$/\n\t\tend",
"def block_word?(str)\n return false unless str.chars.uniq.size == str.size\n char_arr = str.upcase.chars\n char_arr.none? { |char| char_arr.include?(BLOCK_PAIRS[char]) }\nend",
"def balanced?(str)\n parentheses = ['(', ')']\n paren_ary = str.chars.select {|char| char if parentheses.include?(char)}\n index = 0\n loop do\n break if index == paren_ary.size\n # paren_ary.each do |char|\n p paren_ary\n if paren_ary[index] == '('\n if paren_ary.include?(')')\n paren_ary.slice!(paren_ary.index(')'))\n paren_ary.slice!(paren_ary.index('('))\n else\n return false\n end\n else\n return false\n end\n end\n paren_ary.empty? #|| paren_ary == parentheses\nend",
"def danglers?\n !valid_word?(@str[@first_letter..@last_letter]) && @last_letter == @str.length && @words.join.length < @str.length\n end",
"def str_to_bool(str)\n if str.size > 0 and str[0].chr == '!'\n command = str[1, str.length]\n value = `#{command}`\n else\n value = str\n end\n\n case value.downcase.strip\n when \"false\", \"0\", \"nil\", \"\", \"no\", \"off\"\n nil\n when \"true\", \"1\", \"yes\", \"on\"\n true\n else\n value\n end\n end",
"def is_string_contains_another_string?(char_string, char_set)\n (char_string.sub(char_set, '**').index('**') ? true : false) if(valid_strings?(char_string, char_set))\nend",
"def can_show? str\n \treturn not(str.nil? || str === \"\")\n end",
"def has_duplicate(str)\n\tset = Set.new\n\tstr.chars do |char|\n\t\treturn true if set.include? char\n\t\tset << char\n\tend\n\tfalse\nend",
"def balanced_adv?(str)\n str = str.gsub(/(\\w)'(\\w)/, '\\1\\2') # get rid of apstrophies\n char_set = ['\\(\\)', '\\{\\}', '\\[\\]', '\\'\\'', '\\\"\\\"'] # regex needs \\ to escape\n str.gsub!(/[^#{char_set.join}]/, '') # get rid of anything not in char_set\n loop do\n len = str.length\n char_set.each do |cset|\n str.gsub!(/#{cset}/, '')\n end\n new_len = str.length\n break if len == new_len # no further shortening\n end\n str.empty?\nend",
"def valid?\n @chars.all? { |c| c.ord >= A && c.ord <= Z }\n end",
"def letter(input)\n\t(/[a-zA-Z]{2,}(\\,)\\s?[A-Z]{2}(\\s)([0-9]{5}|[0-9]{5}(\\-)?[0-9]{4}|[a-zA-Z]{1}[0-9]{1}[a-zA-Z]{1}(\\s|\\-)?[0-9]{1}[a-zA-Z]{1}[0-9]{1})}/i =~ input)? \"true\" : \"false\"\nend",
"def valid_parentheses?(str)\n while str.gsub!(/\\([^()]*\\)/, ''); end\n !(str.include?('(') || str.include?(')'))\nend"
] |
[
"0.7180241",
"0.7093229",
"0.69580936",
"0.6824745",
"0.6745694",
"0.6710106",
"0.6622905",
"0.66172737",
"0.6574937",
"0.65705025",
"0.65278745",
"0.6479232",
"0.64635676",
"0.6460873",
"0.64479464",
"0.64079344",
"0.64004344",
"0.6399191",
"0.63957524",
"0.63809025",
"0.6372377",
"0.6309008",
"0.63065606",
"0.6298163",
"0.627962",
"0.62711346",
"0.62657696",
"0.6211741",
"0.619306",
"0.61922896",
"0.61780065",
"0.61770403",
"0.61723685",
"0.6170379",
"0.61674446",
"0.6155719",
"0.6154591",
"0.6150411",
"0.6148017",
"0.6134158",
"0.61295897",
"0.61274624",
"0.61015534",
"0.6082749",
"0.6075761",
"0.60754436",
"0.6070967",
"0.60699546",
"0.6067457",
"0.6051291",
"0.6028284",
"0.60114",
"0.6008123",
"0.60026145",
"0.59996045",
"0.5994629",
"0.5985228",
"0.5961113",
"0.5952735",
"0.5948841",
"0.5942913",
"0.59356314",
"0.5929141",
"0.5900207",
"0.58989245",
"0.58983076",
"0.5895008",
"0.58909535",
"0.58900505",
"0.58885485",
"0.58860683",
"0.588482",
"0.5877765",
"0.5864063",
"0.58597237",
"0.5855633",
"0.5852241",
"0.5847073",
"0.58327913",
"0.58267677",
"0.58232933",
"0.5819143",
"0.5812456",
"0.5811",
"0.5799789",
"0.57944936",
"0.5793323",
"0.5792841",
"0.578663",
"0.57771283",
"0.5773104",
"0.5765309",
"0.5761968",
"0.5758458",
"0.5757723",
"0.57505196",
"0.5747486",
"0.5739918",
"0.5739215",
"0.5737459",
"0.57332635"
] |
0.0
|
-1
|
before_action :set_kloop, only: [:kloop] before_action :set_kloop, only: [:kloop] before_action :set_kloop, only: [:kloop]
|
def kloop
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def before_action \n end",
"def preloop\n end",
"def before_run; end",
"def pre_loop; end",
"def action_hook; end",
"def before_bootstrap; end",
"def postloop\n end",
"def before_bootstrap\n end",
"def before\n end",
"def post_loop; end",
"def kopal_layout_before_page_front\n\n end",
"def action_run\n end",
"def define_action_hook; end",
"def around_hooks; end",
"def set_control_loop\n @control_loop = ControlLoop.find(params[:id])\n end",
"def before_request\n end",
"def InitializeHooks\n end",
"def before_perform\n end",
"def before\n\t\t\ttrue\n\t\tend",
"def on_pre_request( request )\n end",
"def on_pre_request( request ); end",
"def run_actions; end",
"def set_kaction\n @kaction = Kaction.find(params[:id])\n end",
"def set_loop\n @loop = Loop.find(params[:id])\n end",
"def before_dispatch(env); end",
"def setup_loop\n return TSBS.error(@acts[0], 2, @used_sequence) if @acts.size < 3\n count = @acts[1]\n action_key = @acts[2]\n is_string = action_key.is_a?(String)\n count.times do\n if is_string\n @acts = [:action, action_key]\n execute_sequence\n break if @break_action\n else\n begin\n action_key.each do |action|\n @acts = action\n execute_sequence\n break if @break_action\n end\n rescue\n ErrorSound.play\n text = \"Wrong [:loop] parameter!\"\n msgbox text\n exit\n end\n end\n break if @break_action\n end\n end",
"def before_running(*args); end",
"def before_container\r\n\t\t\t''\r\n\t\tend",
"def before_setup; end",
"def before() ; end",
"def kopal_layout_after_page_front\n\n end",
"def onStart\r\n end",
"def before\n end",
"def setup_loop\n return unless PONY::ERRNO::check_sequence(current_act)\n count = @acts[1]\n action_key = @acts[2]\n is_string = action_key.is_a?(String)\n count.times do\n if is_string\n @acts = [:action, action_key]\n execute_sequence\n break if @break_sequence\n else\n begin\n action_key.each do |action|\n @acts = action\n execute_sequence\n break if @break_sequence\n end\n rescue\n ErrorSound.play\n text = \"Wrong [:loop] parameter!\"\n msgbox text\n exit\n end\n end # if is_string\n break if @break_sequence\n end # count.times\n end",
"def before(delayed_job)\n end",
"def before_run(&block)\n @before_run_block = block\n end",
"def after_products\n logger.info 'Heyy!! This is a controller hook provided by sweeper'\n end",
"def setup(&block)\n before(:each, &block)\n end",
"def keppler\n end",
"def before_filter; end",
"def before() nil ; end",
"def before_start(&block)\n @before_start_hooks << block\n end",
"def hooks\n # ???\n end",
"def action_enable\n end",
"def pre_connect_hooks; end",
"def pre_connect_hooks; end",
"def autostart=(_arg0); end",
"def pre_block\n end",
"def pre_block\n end",
"def before_action verb = nil, &block\n playbook.before_action verb, &block\n end",
"def on_before_load\n end",
"def before_processing\n end",
"def after_cycle\n end",
"def run_before_each_hooks( env )\n env[:hooks][:before_each].each { |hook| hook.call }\n end",
"def post_init\n\tend",
"def manager_home_setup\n\n @sort_order = {:priority => 'DESC'}\n @sort_order.default = 'ASC'\n flash[:sort_order] = @sort_order\n \n design_reviews = get_active_reviews\n\n # TODO: These sorts are expensive. Make this faster.\n @active_reviews = design_reviews[:active].sort_by { |dr| [dr[:review].age] }.reverse\n @inactive_reviews = design_reviews[:inactive].sort_by { |dr| [dr[:review].priority.value, dr[:review].age] }\n\n @submissions = BoardDesignEntry.submission_count\n session[:return_to] = {:controller => 'tracker', :action => 'index'}\n\n end",
"def index\n @control_loops = ControlLoop.all\n end",
"def before; end",
"def application_before\n run_event(:application_before)\n end",
"def before_hooks\n options[:before]\n end",
"def before_dispatch(_env)\n end",
"def before\n return nil if blue_prints.before.empty?\n\n hook_action = HookAction.new(driver,\n blue_prints.before,\n :hook_action, self, location + '[hook_action]')\n\n hook_action.run\n end",
"def before_tours; end",
"def show\n add_breadcrumb \"<i class='fa fa-home fa-lg'></i>\".html_safe, :root_path\n unless params[:from_search].blank?\n add_breadcrumb \"Search '#{params[:from_search]}'\".html_safe, kite_general_search_kites_path(:text => params[:from_search])\n end\n add_breadcrumb (current_user && (@kite.user.id == current_user.id)) ? \"My Kites\" : \"#{@kite.user.KosherUsername}'s Kites\", userPublicKitesIndex_kites_path(:username => @kite.user.username)\n add_breadcrumb @kite.Description.html_safe, :kite_path\n\n #Queue up a proto-comment\n @comment = Comment.new\n @comments = @kite.comments.order(\"created_at DESC\").paginate(:page => params[:commentpage], :per_page => COMMENTS_PER_PAGE)\n\n #Queue up a proto-kitepost\n @kitePost = KitePost.new\n @kitePosts = @kite.kitePosts.order(\"created_at DESC\").paginate(:page => params[:postpage], :per_page => KITE_POSTS_PER_PAGE)\n\n @showComments = params.has_key?(:showComments)\n @showPosts = params.has_key?(:showPosts)\n @showFollowings = params.has_key?(:showFollowings)\n\n\n unless @kite.UserCanView(current_user)\n redirect_to(current_user, :error => \"The kite you have selected is private and cannot be viewed.\")\n end\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @kite }\n format.js { render :template => 'kites/show' }\n end\n end",
"def run_loop\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def before_players_ready\r\n end",
"def index\n @kactions = Kaction.all\n end",
"def before_shell\n end",
"def action_start\n proxy_action(:start)\n end",
"def hook_controllers!\n ActionController::Base.extend Storehouse::Controller\n end",
"def setup(_context)\n end",
"def after_view_setup\n end",
"def pre_init(&block)\n @hooks[:pre_init] = block\n end",
"def after( controller )\n\n end",
"def prepare_for_action\n # #don't save stuff between requests\n NotRelational::RepositoryFactory.instance.clear_session_cache\n @@page_blurbs =Set.new\n @renderer_params={}\n $current_weblab=nil\n @current_user=nil\n @displayed_blurb_names=Set.new\n # if BannedIp.is_banned?(request.remote_ip)\n # head(401)\n # return\n # end\n\n prepare_language_for_action\n prepare_powerbar_for_action\n prepare_rendermode_for_action\n prepare_weblab_for_action\n\n\n self.page_title=\"Rengine\"\n self.no_wrap=false\n return true\n end",
"def testloop\n \n end",
"def before_run(ant)\n end",
"def before_image_product_index(image,categories,products,notice)\n before_image_view_helper(image,categories,products)\n get 'index', :image_id => image.id\n assigns[:reorder_url].should == reorder_image_products_url(image)\n assert_list_present(products,:products,notice)\n assert_flash(notice)\nend",
"def after_init\n end",
"def pre_task\n end",
"def post_init\n end",
"def setup\n TestUtils.set_workday_default\n TestUtils.enable_module_on_project 1\n @request.session[:user_id] = 1\n @rc_cfg = Red_Counter::Config.new\n end",
"def actions; end",
"def define_kl_do\nend",
"def startup_hook; end",
"def after_play\n\n end",
"def start_handler\n\tend",
"def autostart; end",
"def before_each\n super if defined?(super)\n end",
"def skip_actions; end",
"def pre_hook_send(handler); end",
"def before_product_image_index(product,categories,images,suppliers,notice)\n before_product_view_helper(product,categories,images,suppliers)\n get 'index', :product_id => product.id\n assigns[:reorder_url].should == reorder_product_images_url(product)\n assert_list_present(images,:images,notice)\n assert_flash(notice)\nend",
"def before_perform_on_forward\n end",
"def setup_handler\n end",
"def set_common\n @body_id = controller_name + '_' + action_name\n #@memories = Memory.has_images.order(\"created_at DESC\").page(params[:page]).per(CONFIG[:custom_per_page])\n #@random = Memory.random\n \n #Temporary load of images for slider\n \n \n # Switching off since its not being used at now (The Slider)\n \n # if params[:controller] == \"home\" && params[:action] == \"index\"\n # # Switching off since its not being used at now\n # # @slider = true\n # # sliderTop = 48\n # # @slider_memories = nil#Memory.find(:all, :joins => :categories, :group => :category_id, :order => \"categories.name ASC, memories.created_at DESC\") \n # \n # #Memory.joins(:categories).group(:category_id).order(\"memories.created_at DESC, categories.name ASC\")\n # \n # \n # #Memory.joins(:categories).find(:all, :order => \"categories.name ASC\", :group => :category_id)\n # \n # #Memory.scoped.order(\"created_at DESC\").limit(sliderTop)\n # \n # \n # \n # ##PREVIOUS SLIDER OPTIONS FOR BIRTH YEAR INPUT\n # # if session[:birthyear]\n # # birth_year = session[:birthyear]\n # # @slider_memories = Memory.suggested_memories_for_guess(birth_year).order(\"created_at DESC\").limit(sliderTop)\n # # else\n # # @slider_memories = Memory.scoped.order(\"created_at DESC\").limit(sliderTop)\n # # end\n # end\n end",
"def before_load(o={}, &block) \n end",
"def before_embedded(record, action); end",
"def hook1; end",
"def before_setup\n # do nothing by default\n end"
] |
[
"0.62606055",
"0.61961037",
"0.6096894",
"0.6020932",
"0.5954378",
"0.586444",
"0.5850464",
"0.5824824",
"0.574142",
"0.56976867",
"0.569165",
"0.56908166",
"0.56829125",
"0.5653636",
"0.56353396",
"0.55980605",
"0.5558376",
"0.55526406",
"0.5550697",
"0.550531",
"0.5495044",
"0.5484153",
"0.54827625",
"0.5461272",
"0.5451449",
"0.5450928",
"0.5437893",
"0.5427765",
"0.54130954",
"0.54090893",
"0.5408352",
"0.54074246",
"0.53924435",
"0.5369333",
"0.5342012",
"0.533372",
"0.53325003",
"0.5321313",
"0.5320051",
"0.5306996",
"0.52952313",
"0.5294882",
"0.52426857",
"0.5226503",
"0.5224839",
"0.5224839",
"0.5216856",
"0.52108335",
"0.52108335",
"0.5209938",
"0.52034587",
"0.5197843",
"0.5189643",
"0.5160559",
"0.5155723",
"0.51511055",
"0.5143802",
"0.51322246",
"0.51320964",
"0.5125891",
"0.5121256",
"0.51117104",
"0.5107645",
"0.51069474",
"0.51055366",
"0.5104781",
"0.50982636",
"0.5091834",
"0.5083132",
"0.50824326",
"0.5071316",
"0.50657153",
"0.5063534",
"0.5059206",
"0.504414",
"0.50398624",
"0.5037842",
"0.5037105",
"0.50300354",
"0.5019272",
"0.5015071",
"0.50084686",
"0.5002266",
"0.50008225",
"0.49986216",
"0.49850178",
"0.4983524",
"0.4975154",
"0.49739474",
"0.49694636",
"0.49559805",
"0.49543092",
"0.49514943",
"0.49503082",
"0.49484044",
"0.49422148",
"0.49390724",
"0.49376726",
"0.4936419",
"0.49286997"
] |
0.6304675
|
0
|
Path to the "home" directory for the tests
|
def home_path
result = tmp_path.join("home")
FileUtils.mkdir_p(result)
result
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def home_path\n File.expand_path(\"~\")\n end",
"def home\n @home ||= File.expand_path('~')\n end",
"def home(user=nil)\n File.expand_path(Dir.home(user))\n end",
"def work_dir\n AYTests.work_dir\n end",
"def default_test_base_path\n File.join(kitchen_root, Kitchen::DEFAULT_TEST_DIR)\n end",
"def user_directory\n File.expand_path('~')\n end",
"def home_basedir\n if platform_family?('mac_os_x')\n '/Users'\n elsif platform_family?('solaris2')\n '/export/home'\n else\n '/home'\n end\n end",
"def server_home\n FilePath.new(@build_dir, \"homes\", \"server\").ensure_directory\n end",
"def home\n ENV['HOME'] || File.expand_path('~')\n end",
"def scratch_folder()\n return File.expand_path(File.join(File.dirname(__dir__), \"tmp\", \"scratch-folder-for-testing\"))\nend",
"def home\n env.home\n end",
"def test_path\n File.join(root_path, \"test\")\n end",
"def home_path\n @ssh_home\n end",
"def base_dir\n AYTests.base_dir\n end",
"def tests_dir\n Pathname.new(path) + \"test\"\n end",
"def home_dir(name=nil)\n username = (name || self.username)\n if (username == \"root\")\n \"/root\"\n else\n \"/home/#{username}\"\n end\n end",
"def tools_home\n FilePath.new(@build_dir, \"homes\", \"tools\").ensure_directory\n end",
"def test_folder\n config[:test_folder].nil? ? config[:test_base_path] : absolute_test_folder\n end",
"def user_install_dir\n eval_path(find_val('user_install_dir') || home_dir)\n end",
"def default_or_home_directory\n hd = TyrantManager.home_dir\n begin\n hd = TyrantManager.default_directory\n rescue => e\n # yup, using home\n end\n return hd\n end",
"def modules_home\n FilePath.new(@build_dir, \"modules\").ensure_directory\n end",
"def home\n Pathname.new(node.chopped.nginx.nginx_home)\n end",
"def test_to_bash_replaces_user_home_with_home_environment_variable\n path = Pathname.new( '~/Developer/SDKs' )\n assert_equal( '$HOME/Developer/SDKs', path.to_bash )\n end",
"def setup_home_path\n\t\t\tsuper\n\n\t\t\tAWS_SUBDIRS.each do |dir|\n\t\t\t\tpath = aws_home_path.join(dir)\n\t\t\t\tnext if File.directory?(path)\n\t\t\t\t\n\t\t\t\tbegin\n\t\t\t\t\[email protected](\"Creating: #{dir}\")\n\t\t\t\t\tFileUtils.mkdir_p(path)\n\t\t\t\trescue Errno::EACCES\n\t\t\t\t\traise Errors::HomeDirectoryNotAccessible, :home_path\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def home(subcomponent = \"\")\n File.expand_path(\"#{@basepath}/#{subcomponent}\")\n end",
"def hours_folder\n TEST_HOURS_FOLDER\n end",
"def work_dir; end",
"def get_home_path(dependency)\n dep_home = ENV[\"#{dependency.upcase}_HOME\"] ||\n @config.xpath(\"deps/dep[@name = '#{dependency}']/home/text()\").first\n raise %Q{Please specify the home directory for #{dependency} by using\n <dep name=\\\"#{dependency}\\\">\n <home>#{File.join(\"path\", \"to\", dependency, \"home\")}</home>\n </dep>} unless dep_home\n missing_error = \"Directory #{dep_home}, to which #{dependency.capitalize} home is set, doesn't exist.\"\n raise missing_error unless File.directory? dep_home\n dep_home\n end",
"def home\n @home ||= ENV.fetch(\"HOME\").tr(\"\\\\\", \"/\")\nend",
"def default_path\n Gem.default_path + [@home]\n end",
"def local_yay_path\n\t\t\traise \"ENV[HOME] not found!\" unless ENV['HOME']\n\t\t\treturn \"#{ENV['HOME']}/.yay\"\n\t\tend",
"def home_file(*path)\n File.join(ENV['HOME'], *path)\nend",
"def home_file(*path)\n File.join(ENV['HOME'], *path)\nend",
"def folder\n @folder ||= './.tests_cli'\n end",
"def base_path\n Dir.pwd + \"/\"\n end",
"def workdir\n result = base.join('cache')\n result.mkpath\n result\n end",
"def test_results_dir\n dir = \"#{@base_dir}/test_results\"\n FileUtils.mkdir_p dir unless Dir.exist? dir\n\n return dir\n end",
"def user_config_dir\n File.expand_path('~/.vgh')\n end",
"def system_home\n ENV.fetch(\"HOME\").tr(\"\\\\\", \"/\")\nend",
"def app_dir\n File.join(home_dir, \"#{sanitized_app_name}.#{name}\")\n end",
"def getOtherLocation\n return \"#{Dir.tmpdir}/RDITest\"\n end",
"def keys_file_path_relative_to_home\n return \"~/#{keys_file_path_from_home}\"\n end",
"def path\n @path ||= begin\n dir = File.join Dir.home, \".relaton\", \"iec\"\n FileUtils.mkdir_p dir\n File.join dir, \"index.yaml\"\n end\n end",
"def get_homedir(user)\n begin\n Etc.getpwnam(\"#{user}\")[\"dir\"].chomp\n # or with dscl\n #homedir = %x(dscl . -read /users/#{user} NFSHomeDirectory).gsub(/NFSHomeDirectory: /,\"\")\n rescue Exception => e\n end \n end",
"def detect_home(set_if_missing=false)\n if(ENV['HOME'] && Pathname.new(ENV['HOME']).absolute?)\n ENV['HOME']\n else\n home = File.directory?('/root') && File.writable?('/root') ? '/root' : '/tmp'\n if(set_if_missing)\n ENV['HOME'] = home\n end\n home\n end\n end",
"def root_path\n Pathname.new(File.expand_path(File.join(__dir__, '..', '..')))\nend",
"def root_dir\n __FILE__.match(%r{.*(appium-test-runner)}).to_s\n end",
"def keys_file_path_from_home\n return \".fastlane/ci/.keys\"\n end",
"def lock_dir\n File.join(Dir.home, \"tmp\")\n end",
"def data_root\n File.expand_path(\"spec/data\", Dir.pwd)\n end",
"def tmp_path\n Berkshelf.root.join(\"spec/tmp\")\n end",
"def workspace_folder\n @pwd\n end",
"def work_dir\n # The directory is not stored in a variable so it can be overridden\n # in specs.\n File.join(base_dir, \"ruby-#{RUBY_VERSION}\", \"rbs-#{RBS::VERSION}\", \"solargraph-#{Solargraph::VERSION}\")\n end",
"def base\n result = sphere.cache_path.join('chef')\n result.mkpath\n result\n end",
"def root_dir\n 'gen_passwd'\n end",
"def base_dir; end",
"def base_dir; end",
"def base_dir; end",
"def base_dir; end",
"def base_dir; end",
"def base_dir; end",
"def base_dir; end",
"def roby_app_fixture_path\n File.expand_path(\n File.join(\"..\", \"..\", \"..\", \"test\", \"app\", \"fixtures\"),\n __dir__\n )\n end",
"def infer_homedir(username)\n\t# mitigate blank username rm -rf /network/home/\n\tif username.blank?\n\t\traise(\"Username cannot be empty!\")\n\t# mitigate path traversal rm -rf /network/home/../../etc/shadow\n\telsif username !~ /\\A[\\w\\.-]+\\z/\n\t\traise(\"Invalid format of username\")\n\tend\n\n\tFile.join($home_base, username)\nend",
"def gitpusshuten_root\n File.expand_path(File.join(Dir.pwd, '.gitpusshuten'))\n end",
"def fixture_dir\n runtime_config.fixture_dir\n end",
"def path\n Pathname.new(\n File.expand_path(\n File.join(Gem.user_home, \".bowline\")\n )\n )\n end",
"def plugin_app_root\n \"#{plugin_test_root}/app_root\"\n end",
"def keys_file_path\n return File.join(Dir.home, keys_file_path_from_home)\n end",
"def saving_path\n path = home_path + '/.gitstagram'\n \n Dir.mkdir(path) unless Dir.exists?(path)\n path\n end",
"def web_users_path\n verify_path WEB_USERS_PATH\n File.join @tar_contents_path, WEB_USERS_PATH\n end",
"def plugin_test_root\n \"#{plugin_root}/test\"\n end",
"def root\n Pathname.new(File.dirname(__dir__))\n end",
"def tmp_dir\n File.expand_path(self.relative_tmp_dir, @options[:root_dir])\n end",
"def fixture_path\n File.join(__dir__, '../chef/fixtures')\n end",
"def autoproj_gem_home; @private_autoproj || Gem.user_dir end",
"def root_dir\n ManageIQ::Providers::Lenovo::Engine.root.join(\"content/ansible_runner\")\n end",
"def working_dir\n ENV['PWD'] || Dir.pwd\n end",
"def temporary_directory\n \"#{ROOT}/spec/tmp\"\n end",
"def chef_repo_path\n File.join(ENV['HOME'], '.kitchen', \"pantry_#{config[:port]}\")\n end",
"def sandbox_root\n Pathname.new File.join(File.dirname(__FILE__), \"sandbox\")\n end",
"def __path__\n File.join(root, 'tmp', 'build')\n end",
"def suite_test_folder\n @suite_test_folder ||= File.join(test_folder, config[:suite_name])\n end",
"def integration_cwd\n root.to_s\n end",
"def full_test_dir\n @full_test_dir ||= full_class_dir.gsub(src_dir, model.spec_dir)\n end",
"def get_script_path(name)\n res = ENV['TEST_DIR'] + '/' + name\n\n if !File.exist?(res)\n res = ENV['APP_DIR'] + '/' + name\n end\n\n if !File.exist?(res)\n $stderr.puts \"ERROR: '#{name}' script doesn't exist neither in TEST_DIR or APP_DIR\"\n exit 7\n end\n \n return res\nend",
"def create_test_directories\n\t\ttrace \"Creating test directory #{TEST_DATADIR}\"\n\t\tTEST_DATADIR.mkpath\n\t\treturn TEST_WORKDIR\n\tend",
"def current_working_directory; @rye_current_working_directory; end",
"def siteroot\n \"/var/www/gforge-projects\"\n end",
"def root\n Dir.pwd\n end",
"def cache_path\n home = ENV['HOME']!=nil ? ENV['HOME'] : ''\n return \"#{home}/.jx/repository/#{to_s}/\"\n end",
"def clean_dir_root\n File.join(root_dir, \"test\", \"tmp\", \"cleanreps\")\n end",
"def test_directories(suite)\n absolute_paths_for(\"spec/#{suite}\")\n end",
"def test_it_should_know_its_gem_path_with_a_default_location\n ENV.delete \"INSPEC_CONFIG_DIR\"\n ENV[\"HOME\"] = File.join(@config_dir_path, \"fakehome\")\n expected = File.join(ENV[\"HOME\"], \".inspec\", \"gems\", @ruby_abi_version)\n assert_equal expected, @installer.gem_path\n end",
"def abspath path\n if path[0] != '/'\n @homedir + '/' + path\n else\n path\n end\n end",
"def nailgun_home\n ENV['NAILGUN_HOME'] || File.expand_path('tool/nailgun', jruby_home)\n end",
"def temp_dir\n name = 'tmp_' + rand.to_s.gsub(/\\D/, '')\n File.join(@temp_root, name)\n end",
"def dir\n ENV['XDG_CONFIG_HOME'] || File.join(home, '.config')\n end",
"def root\n File.expand_path(File.dirname(File.dirname(File.dirname(__dir__))))\n end",
"def git_root_till_home\n Pathname.new(Dir.pwd).ascend do |dir_pathname|\n return dir_pathname if File.directory?(\"#{dir_pathname}/.git\")\n return nil if dir_pathname.to_s == home_dir\n end\n end"
] |
[
"0.7896779",
"0.763959",
"0.75113726",
"0.7429605",
"0.7404336",
"0.7370275",
"0.734122",
"0.73298526",
"0.73093563",
"0.7283261",
"0.7244976",
"0.72113353",
"0.7143765",
"0.7136335",
"0.70532644",
"0.70117176",
"0.6924994",
"0.6874664",
"0.6782933",
"0.67555016",
"0.6669151",
"0.665997",
"0.66567373",
"0.6650337",
"0.6638119",
"0.66270506",
"0.65814996",
"0.65799475",
"0.6577154",
"0.6576817",
"0.6502648",
"0.6493457",
"0.6493457",
"0.6483872",
"0.64412546",
"0.64145505",
"0.6387779",
"0.6384301",
"0.63753897",
"0.63655204",
"0.6344875",
"0.6318913",
"0.63057935",
"0.6280851",
"0.62658226",
"0.6265104",
"0.6262954",
"0.62569714",
"0.6253855",
"0.6248872",
"0.62483317",
"0.6236929",
"0.6225871",
"0.621972",
"0.6212253",
"0.62083375",
"0.62083375",
"0.62083375",
"0.62083375",
"0.62083375",
"0.62083375",
"0.62083375",
"0.6198361",
"0.6185633",
"0.61832607",
"0.61816174",
"0.61731935",
"0.6163357",
"0.61605954",
"0.6160267",
"0.6159369",
"0.61467445",
"0.61463594",
"0.61457795",
"0.6142913",
"0.613817",
"0.6127014",
"0.6126724",
"0.6117155",
"0.61052036",
"0.60933614",
"0.6090655",
"0.6089045",
"0.6088417",
"0.60859096",
"0.60836875",
"0.6056014",
"0.6055979",
"0.6055576",
"0.60533065",
"0.6052335",
"0.6046769",
"0.6043298",
"0.60421234",
"0.60357517",
"0.6031518",
"0.6023147",
"0.60161644",
"0.6013489",
"0.60095584"
] |
0.80462754
|
0
|
Cleans all the test temp paths
|
def clean_paths
FileUtils.rm_rf(tmp_path)
FileUtils.mkdir_p(tmp_path)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def clean_up\n FileUtils.rm_rf @temp_root\n end",
"def clear\n raise \"unsafe test stage directory -- #{Dir.pwd}\" unless /#{Dir.tmpdir}/ =~ Dir.pwd\n Dir['*'].each do |path|\n FileUtils.rm_r(path)\n end\n end",
"def clean_tests\n puts \"Removing generated tests from '#{Settings[:test_dir]}'...\"\n Dir.foreach(Settings[:test_dir]) do |dir|\n path = Pathname.new(Settings[:test_dir]) + dir\n next if dir == '.' or dir == '..' or dir == 'support' or not path.directory?\n FileUtils.rm_rf(path)\n end\nend",
"def clean_test_dir!\n FileUtils.remove_entry_secure test_dir\n end",
"def teardown\n Dir.chdir '..'\n FileUtils.rm_rf @tempdirname\n end",
"def cleanup\n remove_files(TEST_INPUT_DIR)\n remove_files(TEST_OUTPUT_DIR)\nend",
"def clean(paths)\n paths.uniq!\n paths.compact!\n populate_test_files\n paths = paths.select { |p| test_file?(p) }\n clear_tests_files_list\n paths\n end",
"def teardown\n FileUtils.chdir(@default_folder)\n FileUtils.rm_r('tmp')\n\n assert_false(File.exists?('tmp'))\n end",
"def clean_up\n Dir.foreach(Dir.pwd) do |f|\n if !f.start_with?('tmp_') then next\n elsif File.directory?(f) then FileUtils.rm_rf(f)\n else FileUtils.rm(f)\n end\n end\nend",
"def cleanup\n File.delete(temp_file_path)\n end",
"def cleanup_files\n FileUtils.rm_rf(File.join(Rails.root, \"tmp\"))\n end",
"def teardown\n FileUtils.remove_dir(File.expand_path(TEST_DIR), true)\n end",
"def cleanup_tmpdirs\n FileUtils.rm_r @tmpdir if @tmpdir\n end",
"def clean()\n\t\ttmpdir = Dir.open(@tmpout) do |dir|\n\t\t\tdir.each do |file|\n\t\t\t\tif file != \".\" and file != \"..\" then\n\t\t\t\t\tFile.unlink(@tmpout + \"/\" + file)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\tDir.rmdir @tmpout\n\tend",
"def clean_up\n puts \"Run the following commands to clean up your test data:\"\n puts \"oc delete pv --all\"\n puts \"oc delete pvc --all\"\n puts \"Deleting temporary test files\"\n `rm -rf #{$templates_path}/*`\nend",
"def clean_tmp_dir\n system \"rm -rf #{TMP_PATH}\"\n system \"mkdir #{TMP_PATH}\"\n yield\n system \"rm -rf #{TMP_PATH}\"\n system \"mkdir #{TMP_PATH}\"\n end",
"def teardown\n [\"file1\", \"file2\", \"file3\"].each {|f| FileUtils.rm f}\n Dir[\"test/backup/file*\"].each {|f| FileUtils.rm f}\n Dir[\"test/backup/*.tar.gz\"].each {|f| FileUtils.rm f}\n Dir.rmdir \"test/backup\" if File.exists? \"test/backup\"\n end",
"def cleanup\n tmpdir = File.join(OBS_BUILD_DIR,OBS_LOCAL_TMP)\n if File.exists?(tmpdir)\n FileUtils.rm_rf(tmpdir)\n end\n end",
"def clean_dir_root\n File.join(root_dir, \"test\", \"tmp\", \"cleanreps\")\n end",
"def cleanTmp\n ts_str = \"/tmp/d\" + Date.today.strftime(\"%Y%m%d\") + \"-*\"\n Gitchefsync.logger.info \"clean up of #{ts_str}\"\n FS.cmdNoError \"sudo rm -fr #{ts_str}\"\n end",
"def clean_up\n FileUtils.rm_rf \"#{@path}\" unless create_in_current_directory?\n FileUtils.rm_rf \"#{@cache}\"\n end",
"def teardown\n FileUtils.remove_dir(TEMP_SITE_PATH, true) if Dir.exists? TEMP_SITE_PATH\n Ruhoh::Manager.reset\nend",
"def cleanup\n FileUtils.rm(@out_filename)\n\n # XXX: could be rm-rf, but be safe for now. Might have\n # problems if app creates files in $PWD\n FileUtils.rmdir(@opts[:tmpdir])\n end",
"def delete_temporary_files\n\t\t`rm -fr tmp/*`\n\tend",
"def teardown\n FileUtils.remove_entry @tmpdir\n end",
"def cleanupTestFiles\n ('A' .. 'F').each { |del| FileUtils.rm(\"#{folder}HR3-Room#{del}.csv\", force: true) } \n end",
"def teardown!\n FileUtils.rm_rf(@tmpdir) if File.exist?(@tmpdir)\n end",
"def teardown\n FileUtils.rm_r(test_log_directory) if File.directory?(test_log_directory)\n end",
"def teardown\n FileUtils.rm_r(test_log_directory) if File.directory?(test_log_directory)\n end",
"def teardown\n return unless File.directory?(RESULTS_ROOT)\n FileUtils.rm_rf(\"#{RESULTS_ROOT}/.\", secure: true)\n end",
"def cleanall\n FileUtils.rm_r(OUTPUT_DIR, force: true, verbose: true)\n end",
"def cleanup_dirs\n @cleanup_dirs ||= ['.']\n end",
"def delete_temp_dir\n\t\tself.rm_str(\" -rf \", @@dir_temp)\n\tend",
"def clean_environment\n `rm -rf /tmp/#{@upload_id}` # all sliced pages of the source file\n end",
"def teardown\n FileUtils.rm_rf(data_path)\n end",
"def teardown\n FileUtils.rm_rf(\"test/resources/IncludesSinceTestRepository\")\n end",
"def cleanUpWorkingFiles()\n system(\"rm -f #{@tripFile} #{routeFile} #{routeAltFile}\") ;\n end",
"def tmp\n announcing \"Removing temporary files from #{$chrootname}\" do\n if File.exists?(\"#{$chrootdir}\") then\n FileUtils.rm_rf(Dir.glob(\"#{$chrootdir}/tmp/*\"), :verbose => $verbose)\n FileUtils.rm_rf(Dir.glob(\"#{$chrootdir}/var/tmp/*\"), :verbose => $verbose)\n FileUtils.rm_rf(Dir.glob(\"#{$chrootdir}/usr/portage/distfiles/*\"), :verbose => $verbose)\n FileUtils.rm_rf(\"#{$chrootdir}/scripts/\", :verbose => $verbose)\n end\n end\n end",
"def clear_tempdir\n FileUtils.rm_rf(tempdir)\n @tmpdir = nil\nend",
"def remove_temp_files\n @task.shell.mute do\n @task.remove_dir ::File.join(@project.package_path, @package_name)\n @task.remove_file ::File.join(@project.package_path, \"#{@package_name}.tmp\")\n end\n end",
"def cleanup\n cleanup_unpack_path\n cleanup_download_path\n end",
"def spec_clean\n Dir.chdir(project_root) do\n Debug.log(\"cd to #{project_root}\")\n fixtures = File.join(profile_path, 'spec', 'fixtures', 'modules')\n modules = File.join(project_root, 'modules')\n\n abort if fixtures == '' || !fixtures\n abort if modules == '' || !modules\n\n FileUtils.rm_rf(fixtures)\n FileUtils.rm_rf(modules)\n end\n Debug.log \"cd to #{Dir.pwd}\"\n end",
"def cleanup\n # the state file, if any, is always temporary.\n if @state_file_path && ::File.file?(@state_file_path)\n ::File.unlink(@state_file_path)\n end\n\n # remove any directories listed as temporary by config.\n (config.cleanup_dirs || []).each do |dir|\n ::FileUtils.rm_rf(dir) if ::File.directory?(dir)\n end\n true\n end",
"def clean_installation\n clean_paths.each { |path| FileUtils.rm_rf(path) }\n end",
"def clean\n #rm_r(srcdir)\n rm_r(blddir)\n #rm_r(libdir)\n end",
"def cleanup\n File.delete(@path) if @path.is_a?(String) && File.exist?(@path)\n end",
"def clean_test_case\n if File.exists?(@local_file_download_destination)\n File.delete(@local_file_download_destination)\n end\n end",
"def clean_up\n @files.each {|file| FileUtils.remove(file.path)}\n end",
"def clear_temp_hieradata\n if @temp_hieradata_dirs && !@temp_hieradata_dirs.empty?\n @temp_hieradata_dirs.each do |data_dir|\n if File.exist?(data_dir)\n FileUtils.rm_r(data_dir)\n end\n end\n end\nend",
"def remove_old_tests\n remove_dir('test')\n remove_dir('spec')\n end",
"def cleanup\n File.delete(@tmp_state) rescue nil\n end",
"def teardown\n FileUtils.rm_rf(\"test/resources/pac-test-repo\")\n end",
"def teardown\n FakeFS::FileSystem.clear # wipe file system for new test\n end",
"def clean_up\n pathname.delete if pathname.exist?\n end",
"def clean_tmp_upload_dir\n FileUtils.rm_r(tmp_upload_dir) if self.tmp_upload_dir && File.directory?(self.tmp_upload_dir)\n end",
"def cleanIntermediateFiles()\n puts \"Deleting intermediate files\"\n deleteTempFilesCmd = \"rm *.sam *.sai\"\n `#{deleteTempFilesCmd}`\n\n # Be careful here, delete only _sorted.bam\n puts \"Deleting intermediate BAM file\"\n deleteTempBAMFileCmd = \"rm *_sorted.bam\"\n `#{deleteTempBAMFileCmd}`\n\n makeDirCmd = \"mkdir casava_fastq\"\n `#{makeDirCmd}`\n moveCmd = \"mv *.fastq.gz ./casava_fastq\"\n `#{moveCmd}`\n end",
"def cleanIntermediateFiles()\n puts \"Deleting intermediate files\"\n deleteTempFilesCmd = \"rm *.sam *.sai\"\n `#{deleteTempFilesCmd}`\n\n # Be careful here, delete only _sorted.bam\n puts \"Deleting intermediate BAM file\"\n deleteTempBAMFileCmd = \"rm *_sorted.bam\"\n `#{deleteTempBAMFileCmd}`\n\n makeDirCmd = \"mkdir casava_fastq\"\n `#{makeDirCmd}`\n moveCmd = \"mv *.fastq.gz ./casava_fastq\"\n `#{moveCmd}`\n end",
"def clean!\n stop\n FileUtils.remove_entry(download_path) if File.exists? download_path\n FileUtils.remove_entry(tmp_save_dir, true) if File.exists? tmp_save_dir\n FileUtils.remove_entry(instance_dir, true) if File.exists? instance_dir\n FileUtils.remove_entry(md5sum_path) if File.exists? md5sum_path\n FileUtils.remove_entry(version_file) if File.exists? version_file\n end",
"def clean!\n stop\n FileUtils.remove_entry(download_path) if File.exists? download_path\n FileUtils.remove_entry(tmp_save_dir, true) if File.exists? tmp_save_dir\n FileUtils.remove_entry(instance_dir, true) if File.exists? instance_dir\n FileUtils.remove_entry(md5sum_path) if File.exists? md5sum_path\n FileUtils.remove_entry(version_file) if File.exists? version_file\n end",
"def teardown\n FileUtils.rm_rf(\"test/resources/idReportTestRepository\")\n end",
"def teardown\n FileUtils.rm_rf(\"test/resources/idReportTestRepository\")\n end",
"def clean!\n FileUtils.rm_rf(dir)\n end",
"def cleanup\n if File.exist?(@scalerui_dir)\n print \"Cleaning up directories...\"\n FileUtils.rm_r(@scalerui_dir)\n puts \"done\"\n else\n puts \"Nothing to clean up!\"\n end\n end",
"def clean_dir\n\n path = self.get_dir\n _clean_dir(path)\n end",
"def cleanup()\n @definition.temporary_files.each do |file|\n if File.exists?(file) && File.writable?(file)\n File.delete(file)\n end\n end\n if @environment.verbose\n puts \"========== END #{@definition.name} ============\"\n end\n end",
"def remove_dirs()\n puts \"Removing test directories...\"\n \n if File::exist?(\"tmp\") && File::directory?(\"tmp\")\n FileUtils.rm_rf(\"tmp\") \n end\n exit 0\nend",
"def clean\n cache = Cache.instance\n # remove all built files\n cache.targets(false).each do |target|\n cache.remove_target(target)\n FileUtils.rm_f(target)\n end\n # remove all created directories if they are empty\n cache.directories(false).sort {|a, b| b.size <=> a.size}.each do |directory|\n cache.remove_directory(directory)\n next unless File.directory?(directory)\n if (Dir.entries(directory) - ['.', '..']).empty?\n Dir.rmdir(directory) rescue nil\n end\n end\n cache.write\n end",
"def clean\n FileUtils.remove_dir(@log_dir, true)\n end",
"def remove_tmp_files\n %x{ rm #{File.join(tmp_path, '*')} }\n end",
"def cleanup\n FileUtils.rm_rf(sfx_cache_path)\n end",
"def tidy_up\n return if DEBUG\n\n puts heading(\"Tidying up PWD\")\n\n FileUtils.remove(Dir[\"#{FileUtils.pwd}/bugsnag-*.tgz\"])\nend",
"def _write_failed_paths_in_tmp\n FileUtils.mkdir_p('tmp')\n File.open('./tmp/rspec_guard_result','w') do |f|\n f.puts _failed_paths.join(\"\\n\")\n end\n rescue\n # nothing really we can do, at least don't kill the test runner\n end",
"def clean!\n stop\n remove_instance_dir!\n FileUtils.remove_entry(config.download_path) if File.exists?(config.download_path)\n FileUtils.remove_entry(config.tmp_save_dir, true) if File.exists? config.tmp_save_dir\n md5.clean!\n FileUtils.remove_entry(config.version_file) if File.exists? config.version_file\n end",
"def teardown\n if File.exist?(modelPath())\n FileUtils.rm(modelPath())\n end\n if File.exist?(reportPath())\n FileUtils.rm(reportPath())\n end \n end",
"def clean_app()\n wd = FileUtils.pwd()\n FileUtils.rm_f( [\n '/app/assets/*',\n '/app/components/*',\n '/app/controllers/*',\n '/app/helpers/*',\n '/app/models/*',\n '/app/views/*'\n ].collect!{|e| Dir.glob(wd + e)}.flatten.compact )\n end",
"def clear_tests_files_list\n @tests_files = nil\n end",
"def reset\n FileUtils.rmtree SPEC_TMP\n FileUtils.cp_r SPEC_MOCKS, SPEC_TMP, :preserve => true\n end",
"def destroy(_)\n paths = [\n instance.provisioner[:root_path], instance.verifier[:root_path]\n ]\n paths.each do |p|\n FileUtils.rm_rf(p)\n logger.info(\"[Localhost] Deleted temp dir '#{p}'.\")\n end\n self.class.unlock!\n end",
"def teardown()\n # See 6. Disabling the gadget\n # ~ equiv to: echo \"\" > UDC\n System.write(File.join(path_prefix, \"UDC\"), \"\\n\")\n sleep(0.1)\n\n # See 7. Cleaning up\n System.delete(*Dir.glob(File.join(path_prefix, \"configs/*/*\")))\n System.delete(*Dir.glob(File.join(path_prefix, \"configs/*/strings/*\")))\n System.delete(*Dir.glob(File.join(path_prefix, \"configs/*\")))\n System.delete(*Dir.glob(File.join(path_prefix, \"functions/*\")))\n System.delete(*Dir.glob(File.join(path_prefix, \"strings/*\")))\n System.delete(path_prefix)\n end",
"def cleanup(test_configuration)\n if test_configuration[:unit]\n # copy main package.json from project directory in order to use it in the unit-test\n # docker container\n FileUtils.rm_rf(\"#{@test_dir}/unit/package.json\")\n end\n end",
"def clear!\n \n # Removes old files in the test directory\n ['to', 'from'].each do |folder|\n Dir.glob(File.expand_path(File.dirname(__FILE__) + \"/data/#{folder}/*\")).each do |file|\n FileUtils.rm(file)\n end\n end\n \n {'some_zip_files.zip' => 'zip_real', 'test_package.rar' => 'rar_real'}.each_pair do |first, last|\n\n # Removes old files in the test directory\n Dir.glob(File.expand_path(File.dirname(__FILE__) + \"/data/#{last}/*\")).each do |file|\n FileUtils.rm(file) if Mimer.identify(file).text?\n end\n\n src = File.expand_path(File.dirname(__FILE__) + \"/data/o_files/#{first}\")\n dest = File.expand_path(File.dirname(__FILE__) + \"/data/#{last}/#{first}\")\n FileUtils.copy_file(src, dest)\n end\n\n # Removes old files in the test directory\n Dir.glob(File.expand_path(File.dirname(__FILE__) + \"/data/movie_to/*\")).each do |file|\n FileUtils.rm(file) if Mimer.identify(file).text?\n end\n \n {'test_package.rar' => 'to', 'some_zip_files.zip' => 'to'}.each do |first,last|\n src = File.expand_path(File.dirname(__FILE__) + \"/data/o_files/#{first}\")\n dest = File.expand_path(File.dirname(__FILE__) + \"/data/from/#{first}\")\n FileUtils.copy_file(src, dest)\n end\nend",
"def teardown\n restore_system_files(\"TestTaskScheduler\")\n FileUtils.rm_r @dir if File.exists? @dir\n end",
"def teardown\n FileUtils.rm_rf(File.join('/tmp', @uuid))\n end",
"def clean_files\n ck_valid\n File.unlink(pid_file) if File.exists?(pid_file)\n File.unlink(prof_file) if File.exists?(prof_file)\n File.unlink(socket_file) if File.exists?(socket_file)\n end",
"def test_clean\n # Standard stuff\n assert_equal('/a/b/c', Pathname.new('/a/b/c').cleanpath)\n assert_equal('b/c', Pathname.new('./b/c').cleanpath)\n assert_equal('a', Pathname.new('a/.').cleanpath) # ***\n assert_equal('a/c', Pathname.new('a/./c').cleanpath)\n assert_equal('a/b', Pathname.new('a/b/.').cleanpath) # ***\n assert_equal('.', Pathname.new('a/../.').cleanpath) # ***\n assert_equal('/a', Pathname.new('/a/b/..').cleanpath)\n assert_equal('/b', Pathname.new('/a/../b').cleanpath)\n assert_equal('d', Pathname.new('a/../../d').cleanpath) # ***\n\n # Edge cases\n assert_equal('', Pathname.new('').cleanpath)\n assert_equal('.', Pathname.new('.').cleanpath)\n assert_equal('..', Pathname.new('..').cleanpath)\n assert_equal('/', Pathname.new('/').cleanpath)\n assert_equal('/', Pathname.new('//').cleanpath)\n\n assert_non_destructive\n end",
"def clear\n Dir[File.join(@output_dir, '*')].each do |path|\n File.delete(path)\n end\n end",
"def reset_signup_folder\n FileUtils.rm_rf('./tmp/signup')\nend",
"def stage_clear\n stage_safe!\n Dir['*'].each do |path|\n #p path\n FileUtils.rm_r(path)\n end\n end",
"def teardown\n FileUtils.rm_rf(File.join('/tmp', @uuid))\n end",
"def cleanup\n\tsh 'del /F /Q .\\_site\\*'\n\t# sh 'rm -rf ./_site'\nend",
"def clean\n FileUtils.rm_rf(\"#{ROOT_DATA_FOLDER}/.\", secure: true)\n unless File.directory?(ROOT_DATA_FOLDER)\n FileUtils.mkdir_p(ROOT_DATA_FOLDER)\n end\n end",
"def clean\n @paths = {}\n @paths[''] = Path.new(self, '')\n @prepares = []\n self\n end",
"def destroy\n File.delete(temp_path)\n end",
"def tidy_up\n Dir[\"*nin\"].each do |file|\n File.delete(file)\n end\n Dir[\"*nhr\"].each do |file|\n File.delete(file)\n end\n Dir[\"*nsq\"].each do |file|\n File.delete(file)\n end\n Dir[\"*blast\"].each do |file|\n File.delete(file)\n end\n end",
"def clean_up(cmd = nil)\n FileUtils.rm(\n Dir.glob('build/{src,lib}.{rb,c,js}') +\n Dir.glob('build/ruby2d-opal.{rb,js}') +\n Dir.glob('build/app.c')\n )\n if cmd == :all\n puts \"cleaning up...\"\n FileUtils.rm_f 'build/app'\n FileUtils.rm_f 'build/app.js'\n FileUtils.rm_f 'build/app.html'\n FileUtils.rm_rf 'build/ios'\n FileUtils.rm_rf 'build/tvos'\n end\nend",
"def cleanup\n FileUtils.rm_f(@path)\n delete\n end",
"def close\n FileUtils.rm_rf @temp_dir\n end",
"def cleanup(build_dir)\n build_dir = Pathname(build_dir)\n tmp_build_dir = Pathname('.temp-build')\n\n # copy over files we need to keep\n if File.directory?(build_dir)\n build_dir.glob(\"**/all-product-headers.yaml\").each do |file|\n intermediate = Pathname(file).relative_path_from(build_dir).dirname\n destination_dir = tmp_build_dir + intermediate\n\n FileUtils.mkdir_p(destination_dir)\n FileUtils.mv(file, destination_dir)\n end\n\n build_dir.rmtree if build_dir.directory?\n FileUtils.mv(tmp_build_dir, build_dir)\n end\nend",
"def cleanup\n\n # ----------------------------------------------\n account_name = 'your account name' # <-- change this!\n project_name = 'your project name' # <-- change this!\n # ----------------------------------------------\n\n project_dir = \"/home/#{account_name}/www\"\n Dir.chdir(project_dir)\n\n Dir.entries(project_name).select do |entry1|\n\n dir1 = File.join(project_name,entry1) #dir2 = \"#{project_name}/#{entry1}\"\n if is_directory?(dir1)\n Dir.entries(dir1).select do |entry2|\n \n dir2 = File.join(dir1,entry2) #dir2 = \"#{project_name}/#{entry1}/#{entry2}\"\n if is_directory?(dir2)\n Dir.entries(dir2).select do |entry3|\n \n dir3 = File.join(dir2,entry3) #dir3 = \"#{project_name}/#{entry1}/#{entry2}/#{entry3}\"\n if is_directory?(dir3)\n Dir.entries(dir3).select do |entry4|\n delete_file(File.join(dir3,entry4))\n end\n end\n\n delete_file(dir3)\n delete_dir(dir3)\n end\n end\n\n delete_file(dir2)\n delete_dir(dir2)\n end\n end\n\n delete_file(dir1)\n delete_dir(dir1)\n end\n\n delete_dir(project_name)\nend",
"def cleanup_paths(*paths)\n #.gsub(%r{#{@locations[:root]}/#{@locations[:root]}}, @locations[:root])\n paths.join('/').gsub(/[\\/]{2,}/,'/')\n end"
] |
[
"0.7960962",
"0.7735496",
"0.7696412",
"0.76498467",
"0.75925183",
"0.75817835",
"0.753316",
"0.74772394",
"0.74495965",
"0.7394642",
"0.7344968",
"0.7343906",
"0.7326218",
"0.7322757",
"0.7306103",
"0.7286782",
"0.71753603",
"0.71587837",
"0.71212155",
"0.71131825",
"0.7088287",
"0.7066721",
"0.7051012",
"0.7007567",
"0.69837695",
"0.69832987",
"0.6962224",
"0.6956521",
"0.6956521",
"0.6950853",
"0.6928222",
"0.6912246",
"0.68783027",
"0.68776196",
"0.68663865",
"0.6833482",
"0.6814353",
"0.6811016",
"0.6799129",
"0.675239",
"0.6750111",
"0.6712014",
"0.6704992",
"0.6703103",
"0.6702043",
"0.6681334",
"0.6673231",
"0.66608536",
"0.664992",
"0.6644233",
"0.6641342",
"0.66086245",
"0.66069883",
"0.6600275",
"0.6583434",
"0.6545145",
"0.6545145",
"0.6527262",
"0.6527262",
"0.65237075",
"0.65237075",
"0.65134645",
"0.6497603",
"0.64920413",
"0.6491109",
"0.64800936",
"0.6465534",
"0.64607894",
"0.64582574",
"0.64360404",
"0.64346135",
"0.64302874",
"0.6429036",
"0.6418269",
"0.63915217",
"0.63914883",
"0.63866115",
"0.63493544",
"0.634606",
"0.63251716",
"0.63199943",
"0.63106936",
"0.63094777",
"0.6301138",
"0.62853515",
"0.62783587",
"0.6272761",
"0.6265806",
"0.62652355",
"0.62578684",
"0.6255287",
"0.62391883",
"0.62093043",
"0.6197311",
"0.6192589",
"0.61910844",
"0.61904985",
"0.6168762",
"0.6160937",
"0.61482215"
] |
0.8034484
|
0
|
HEADER ATTRIBUTES sets the types, and fields we can have processing based on line.
|
def initialize(args)
self.fields = []
raise "no text provided" unless args[:text]
if args[:text]
args[:text].split(/\|/).each do |field|
self.fields << field
end
end
detect_type
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def parse_header(line)\n case line\n when /^#%checkm/\n match = /^#%checkm_(\\d+)\\.(\\d+)/.match line\n @version = \"#{match[1]}.#{match[2]}\" if match\n when /^#%eof/\n @eof = true\n when /^#%fields/\n list = line.split('|')\n list.shift\n @fields = list.map { |v| v.strip.downcase }\n when /^#%prefix/, /^#%profile/\n # do nothing\n end\n end",
"def make_load_header(text_line)\n EdiHelper::edi_log.write \"LI PreProcessor: Creating missing LH record from LD record...\",0\n\n detail_data = RawFixedLenRecord.new('LI', 'LD', text_line)\n header_data = RawFixedLenRecord.new('LI', 'LH')\n ignore_fields = ['load_date', 'instruction_quantity']\n line = header_data.populate_with_values_from( detail_data, ignore_fields )\n\n EdiHelper::edi_log.write \"LI PreProcessor: Created missing LH record from LD record.\",0\n line\n end",
"def parse_header\n @snp, @line, @type, @in, @polymorphism, @chromosome, @orientation = self.sequence_id.split(\" \") \n @type = @type.to_sym\n if @in\n @in = @in.to_sym == :exon \n else\n @exon = false\n end\n\n if @polymorphism.to_sym == :homoeologous\n @homoeologous = true\n else\n @homoeologous = false\n end\n @parsed = true\n @orientation = @orientation.to_sym\n end",
"def parse_header(line)\n if (match = line.match(/^(.+?):\\s*(.+)#{@nl}$/))\n key = match[1].downcase\n set_header_special_values(key, match[2])\n parse_normal_header(line, key, match[1], match[2])\n elsif (match = line.match(/^HTTP\\/([\\d\\.]+)\\s+(\\d+)\\s+(.+)$/))\n @response.code = match[2]\n @response.http_version = match[1]\n @http2.on_content_call(@args, line)\n else\n raise \"Could not understand header string: '#{line}'.\"\n end\n end",
"def parse_header line, samples, options\n header = VcfHeader.new(options[:debug])\n header.add(line)\n print line if not options[:skip_header]\n STDIN.each_line do | headerline |\n if headerline !~ /^#/\n # If no records in VCF, we never get here\n line = headerline\n break # end of header\n end\n header.add(headerline)\n if not options[:skip_header]\n if headerline =~ /^#CHR/\n # The header before actual data contains the sample names, first inject the BioVcf meta information\n print header.tag(options),\"\\n\" if options[:tag] and not options[:skip_header]\n # Then the additional filter(s)\n # ##FILTER=<ID=LowQual,Description=\"Low quality\">\n add_filter = options[:add_filter]\n if add_filter\n print \"##FILTER=<ID=\",add_filter,\",Description=\\\"\",options[:filter],\"\\\">\\n\"\n end\n \n selected = header.column_names\n if samples\n newfields = selected[0..8]\n samples.each do |s|\n newfields << selected[s+9] \n end\n selected = newfields\n end\n print \"#\",selected.join(\"\\t\"),\"\\n\"\n else\n print headerline\n end\n end\n end\n print header.printable_header_line(options[:set_header]),\"\\n\" if options[:set_header]\n VcfRdf::header if options[:rdf]\n if line =~ /^#/\n # We did not read a record\n line = nil\n end\n return header,line\nend",
"def header=(_arg0); end",
"def cgi_parse_header(line); end",
"def parse_header_lines\n if @parsed_values[\"\"].nil? || @parsed_values[\"\"][1].nil?\n @parsed_values[\"\"] = {}\n return\n end\n\n headers = {}\n # Heading lines may have escaped newlines in them\n @parsed_values[\"\"][1].split(/\\\\n/).each do |line|\n next if line.size == 0\n\n if line =~ /(.*?):(.*)/\n key, value = $1, $2\n if headers[key] && headers[key].size > 0\n @errors << [\"Duplicate header line: #{line}\"]\n elsif key =~ /#-#-#-#-#/\n @errors << [\"Marker in header line: #{line}\"]\n else\n headers[key] = value\n end\n else\n @errors << [\"Malformed header #{line}\"]\n end\n end\n\n @parsed_values[\"\"] = headers\n end",
"def parse_header(line, opts = {})\n host = opts[:host]\n if host\n line = line.gsub(/^(Host:\\s+).*$/, \"\\\\1#{host}\")\n line = line.gsub(/^(Referer:\\s+https?:\\/\\/)[^\\/]*(.*)$/, \"\\\\1#{host}\\\\2\")\n end\n @headers << line\n line = line.downcase\n if line.start_with? 'content-length: '\n @content_length = line.gsub(/^\\S+\\s+(\\d+)\\s*$/, '\\1').to_i\n elsif line.start_with? 'transfer-encoding: '\n encodings = line.gsub(/^\\S+\\s+(.*)$/, '\\1')\n @transfer_encodings = encodings.split(/\\s*,\\s*/).map {|e| e.strip.to_sym}\n end\n end",
"def parse_header(raw)\n header = {}\n field = nil\n\n raw.each_line do |line|\n case line\n when /^([A-Za-z0-9!\\#$%&'*+\\-.^_`|~]+):\\s*(.*?)\\s*\\z/om\n field, value = $1, $2\n header[field] = value\n when /^\\s+(.*?)\\s*\\z/om\n value = $1\n fail \"bad header '#{line}'.\" unless field\n\n header[field][-1] << ' ' << value\n else\n fail \"bad header '#{line}'.\"\n end\n end\n\n header.each do |key, value|\n value.strip!\n value.gsub!(/\\s+/, ' ')\n end\n\n header\n end",
"def parse_header(header_line)\n entries = delete_special_chars(header_line)\n # switch entries for geo coordinates since latitude comes before longitude\n geo_coordinate = Entity::Coordinate.new(entries[6].to_f, entries[5].to_f)\n @grid_data = Entity::GridPoint.new(entries[8].to_f, entries[9].to_f,\n entries[12].to_f, entries[11].to_f)\n # special case for multi word locations\n station_name = entries[0].sub(\"_\", \" \")\n @station = Entity::Station.new(station_name, entries[3], entries[13].to_f,\n geo_coordinate)\n nil\n end",
"def consume_header_line(line, column_mappings)\n columns = column_names(column_mappings)\n\n header_guess = line.map { |column| column.to_s.downcase }\n\n # The \"best guess\" is only if/when the header eventually deemed to be\n # invalid - in which case, it builds the informative error message.\n @header_best_guess = header_guess if header_guess.any?(&:present?)\n @header_valid = true if header_guess == columns\n end",
"def parse_header\n header.each do |field, value|\n self.instance_variable_set(\"@#{field}\", value) if HEADER_FIELDS.include? field\n end\n end",
"def start_header(attributes)\n @element_stack << :header\n end",
"def start_header(attributes)\n @element_stack << :header\n end",
"def set_chart_headers(line_array)\n headers_in_order = ['title', 'composer'] \n headers_in_order.each do |header|\n line_array[0] = line_array[0].strip\n if line_array[0].downcase.start_with? \"#{header}:\"\n # Set header instance variable to appropriate content\n send \"#{header}=\", line_array[0].split(/#{Regexp.quote(header)}:/i)[1].strip \n line_array.shift\n end\n\n end\n line_array\n end",
"def parse_header_contents; end",
"def header_fields\n header.fields\n end",
"def parse_line(line)\n ln, fn, mi, sex, fav_color, dob = line.split(' | ')\n LineParser.to_h(fn, ln, mi, sex, fav_color, parse_dob(dob))\n end",
"def setup_header(dat)\n @headers = { to: to }\n dat.each do |key, val|\n key = key.to_s.downcase\n raise \"invalid field #{key}\" unless valid_fields.include?(key)\n @headers[key.to_sym] = val unless val.nil?\n end\n end",
"def parse_header(header_line)\n check_element_size(header_line.length)\n\n @name = header_line[0]\n @domain_x = DataDomain.new(header_line[1], header_line[2], \\\n header_line[3], header_line[4])\n @domain_y = DataDomain.new(header_line[5], header_line[6], \\\n header_line[7], header_line[8])\n\n check_and_create_third_domain(header_line)\n end",
"def parse_setext_header; end",
"def actual_header\n data.lines.first.chomp\n end",
"def getHeader() @header1 end",
"def header; end",
"def header; end",
"def header; end",
"def carma_facs_parse_header(line, id_map)\n m = line.match(/=(\\d+)/) \n if m.nil?\n STDERR.puts \"No id found\"\n exit 1\n end \n id = m[1]\n m = line.match (/SOURCE_1=\\\"(.*)\\\"/) \n if m.nil?\n STDERR.puts \"No name found\"\n exit 1\n end \n name=m[1]\n identifier_map(id, name, id_map)\nend",
"def header_fields\n @csv.headers\n end",
"def header\n end",
"def read_group_file_headers(line)\n data = strip_and_split(line)\n\n header_cols = Hash.new\n\n data.each_with_index do |header, i|\n if header =~ /group/i\n header_cols[:group] = i\n elsif header =~ /color/i\n header_cols[:color] = i\n elsif header =~ /avg pheno/i\n header_cols[:phenoavg] = i\n elsif header =~ /std dev/i\n header_cols[:stddev] = i\n elsif header =~ /samples/i\n header_cols[:samples] = i\n elsif header =~ /Median/i\n header_cols[:median] = i\n elsif header =~ /25/i\n header_cols[:percent25] = i\n elsif header =~ /75/i\n header_cols[:percent75] = i\n elsif header =~ /Min/i\n header_cols[:min] = i\n elsif header =~ /Max/i\n header_cols[:max] = i\n end\n end\n\n return header_cols\nend",
"def fill_hash_record_from_line(column_names, headers, line)\n hash_record = {}\n fields = line.split(@sep)\n\n fields.each_with_index do |field, field_id|\n hash_record[headers[field_id]] = field if column_names.include?(headers[field_id])\n end\n\n hash_record\n end",
"def header(h, buffer = \"\")\n rep = HEADREP[h[:type]]\n\n if h[:type] == :indexed\n buffer << integer(h[:name], rep[:prefix])\n\n else\n if h[:name].is_a? Integer\n buffer << integer(h[:name]+1, rep[:prefix])\n else\n buffer << integer(0, rep[:prefix])\n buffer << string(h[:name])\n end\n\n if h[:type] == :substitution\n buffer << integer(h[:index], 0)\n end\n\n if h[:value].is_a? Integer\n buffer << integer(h[:value], 0)\n else\n buffer << string(h[:value])\n end\n end\n\n # set header representation pattern on first byte\n fb = buffer[0].unpack(\"C\").first | rep[:pattern]\n buffer.setbyte(0, fb)\n\n buffer\n end",
"def split_header\n self.fields = raw_source.split(HEADER_SPLIT)\n end",
"def initialize category\n #\n # array of header lines\n @header = []\n #\n # hash of header keys => [ index into @header, start pos of value ]\n @headerpos = {}\n \n @category = category\n\n end",
"def parse_headers(row = nil)\n if @headers.nil? # header row\n @headers = case @use_headers # save headers\n # Array of headers\n when Array then @use_headers\n # HBCSV header String\n when String\n self.class.parse_line( @use_headers,\n col_sep: @col_sep,\n row_sep: @row_sep,\n quote_char: @quote_char )\n # first row is headers\n else row\n end\n\n # prepare converted and unconverted copies\n row = @headers if row.nil?\n @headers = convert_fields(@headers, true)\n @headers.each { |h| h.freeze if h.is_a? String }\n\n if @return_headers # return headers\n return self.class::Row.new(@headers, row, true)\n elsif not [Array, String].include? @use_headers.class # skip to field row\n return shift\n end\n end\n\n self.class::Row.new(@headers, convert_fields(row)) # field row\n end",
"def header\n header = \"%FDF-1.2\\n\\n1 0 obj\\n<<\\n/FDF << /Fields 2 0 R\"\n # /F\n header << \"/F (#{options[:file]})\" if options[:file]\n # /UF\n header << \"/UF (#{options[:ufile]})\" if options[:ufile]\n # /ID\n header << \"/ID[\" << options[:id].join << \"]\" if options[:id]\n header << \">>\\n>>\\nendobj\\n2 0 obj\\n[\"\n return header\n end",
"def header_build\n header = \"customer name\" + @delimiter + \"gender\" + @delimiter\n header += \"age\" + @delimiter + \"birthday\" + @delimiter + \"cpf\" + @delimiter + \"id\" + @delimiter\n header += \"state\" + @delimiter + \"city\" + @delimiter + \"street\" + @delimiter + \"zip_code\" + @delimiter\n header += \"company name\" + @delimiter + \"industry\" + @delimiter + \"cnpj\"\n header\nend",
"def headers=(_arg0); end",
"def headers=(_arg0); end",
"def headers=(_arg0); end",
"def headers=(_arg0); end",
"def build_header_output\n output = []\n\n @header.each do |line|\n _data = []\n line.each do |h|\n _data << {:value => h, :color => @style[:header]}\n end\n output << _data\n end\n output\n end",
"def header(h, buffer = Buffer.new)\n rep = HEADREP[h[:type]]\n\n if h[:type] == :indexed\n buffer << integer(h[:name], rep[:prefix])\n\n else\n if h[:name].is_a? Integer\n buffer << integer(h[:name]+1, rep[:prefix])\n else\n buffer << integer(0, rep[:prefix])\n buffer << string(h[:name])\n end\n\n if h[:type] == :substitution\n buffer << integer(h[:index], 0)\n end\n\n if h[:value].is_a? Integer\n buffer << integer(h[:value], 0)\n else\n buffer << string(h[:value])\n end\n end\n\n # set header representation pattern on first byte\n fb = buffer[0].unpack(\"C\").first | rep[:pattern]\n buffer.setbyte(0, fb)\n\n buffer\n end",
"def meta\n @meta ||= begin\n arr = @header_str.split(/\\r?\\n/)\n arr.shift\n arr.inject({}) do |hash, hdr|\n key, val = hdr.split(/:\\s+/, 2)\n hash[key.downcase] = val\n hash\n end\n end\n end",
"def parse_header_line(header_str)\n @headers = header_str.split(',')\n @headers.map! do |h|\n h.gsub!('\"','')\n h.strip!\n h.underscore.to_sym\n end\n @headers\n end",
"def parse_line(line)\n ln, fn, sex, fav_color, dob = line.split(', ')\n LineParser.to_h(fn, ln, nil, sex, fav_color, parse_dob(dob))\n end",
"def line_headings\n {\n :controller_files => \"Controllers\",\n :model_files => \"Models\",\n :view_files => \"Views\",\n :lib_files => \"Libraries\",\n :plugin_files => \"Plugins\",\n :controller_specs => \"Controller Specs\",\n :model_specs => \"Model Specs\",\n :view_specs => \"View Specs\"\n }\n end",
"def header_fields\n IO.binread(@path, HEADER_SIZE, 0).unpack(\"N5C1\")\n end",
"def initialize line\n attributes = [:hostname_or_IP, :location, :name, :clients_connection_allowed, :type_of_voice_server]\n\n line_split = line.split(\":\")\n\n attributes.each_with_index.map { |attribute, index|\n instance_variable_set(\"@#{attribute}\", line_split[index]) if self.respond_to?(attribute)\n }\n end",
"def grab_header\n return @header if (@header and [email protected]?)\n @file.rewind\n fields.each_with_index do |field_name, i|\n @header[i]= field_name.strip\n end\n @header\n end",
"def get_header_info\n @data.rewind\n \n #column_count_offset = 33, record_count_offset = 24, record_length_offset = 36\n @record_count, @data_offset, @record_length = data.read(HEADER_LENGTH).unpack(\"@24 I x4 I I\")\n @column_count = (@data_offset-400)/200\n end",
"def validate_header!\n [:date, :from].each do |field|\n raise \"No '#{field}' header field provided\" unless self.send(field)\n end\n end",
"def header= h\n @header = if h.is_a? Numeric\n self[h]\n else\n h\n end\n end",
"def eh_request(*args)\n n=0\n spec = line_part_spec\n @page_headers[0][n] = spec\n end",
"def set_header_fields(request)\n request.smb2_header.tree_id = id\n request.smb2_header.credits = 256\n request\n end",
"def header(format, ntrks, division)\n end",
"def header_signature=(_arg0); end",
"def import_hdr\n if @hdr_reader == nil\n case @file_type\n when \"pfile\" then printraw_summary_import\n when \"scan_archive_h5_json\" then printraw_scan_archive_h5_json\n end\n else\n raise(IndexError, \"No Header Data Available.\") if @hdr_data == nil\n case @hdr_reader\n when \"rubydicom\" then rubydicom_hdr_import\n when \"dicom_hdr\" then dicom_hdr_import\n when \"printraw\" then printraw_import\n when \"rdgehdr\" then rdgehdr_import\n when \"cat\" then printraw_summary_import\n end\n end\n end",
"def oh_request(*args)\n n=0\n spec = line_part_spec\n @page_headers[1][n] = spec\n end",
"def headers=(hash); end",
"def headers=(hash); end",
"def header(*args, &block)\n if block_given?\n block = capture(&block)\n @header_line.add_cell(@collection.first, args, nil, block)\n else\n @header_line.add_cell(@collection.first, args)\n end\n nil\n end",
"def parse_atx_header; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def transform_headers( str, rs )\n\t\t\[email protected] \" Transforming headers\"\n\n\t\t\t# Setext-style headers:\n\t\t\t#\t Header 1\n\t\t\t#\t ========\n\t\t\t#\n\t\t\t#\t Header 2\n\t\t\t#\t --------\n\t\t\t#\n\n\t\t\tsection_numbers = [nil, nil, nil, nil, nil]\n\n\t\t\tstr.\n\t\t\t\tgsub( HeaderRegexp ) {|m|\n\t\t\t\t\tif $1 then\n\t\t\t\t\t\[email protected] \"Found setext-style header\"\n\t\t\t\t\t\ttitle, id, hdrchar = $1, $2, $3\n\n\t\t\t\t\t\tcase hdrchar\n\t\t\t\t\t\twhen '='\n\t\t\t\t\t\t\tlevel = 1\n\t\t\t\t\t\twhen '-'\n\t\t\t\t\t\t\tlevel = 2\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\[email protected] \"Found ATX-style header\"\n\t\t\t\t\t\thdrchars, title, id = $4, $5, $6\n\t\t\t\t\t\tlevel = hdrchars.length\n\n\t\t\t\t\t\tif level >= 7 then\n\t\t\t\t\t\t\trs.warnings << \"illegal header level - h#{level} ('#' symbols are too many)\"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\tprefix = ''\n\t\t\t\t\tif rs.numbering? then\n\t\t\t\t\t\tif level >= rs.numbering_start_level and level <= 6 then\n\t\t\t\t\t\t\tdepth = level - rs.numbering_start_level\n\n\t\t\t\t\t\t\tsection_numbers.each_index do |i|\n\t\t\t\t\t\t\t\tif i == depth and section_numbers[depth] then\n\t\t\t\t\t\t\t\t\t# increment a deepest number if current header's level equals last header's\n\t\t\t\t\t\t\t\t\tsection_numbers[i] += 1\n\t\t\t\t\t\t\t\telsif i <= depth then\n\t\t\t\t\t\t\t\t\t# set default number if nil\n\t\t\t\t\t\t\t\t\tsection_numbers[i] ||= 1\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t# clear discardeds\n\t\t\t\t\t\t\t\t\tsection_numbers[i] = nil\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\tno = ''\n\t\t\t\t\t\t\t(0..depth).each do |i|\n\t\t\t\t\t\t\t\tno << \"#{section_numbers[i]}.\"\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\tprefix = \"#{no} \"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\ttitle_html = apply_span_transforms( title, rs )\n\n\t\t\t\t\tunless id then\n\t\t\t\t\t\tcase rs.header_id_type\n\t\t\t\t\t\twhen HeaderIDType::ESCAPE\n\t\t\t\t\t\t\tid = escape_to_header_id(title_html)\n\t\t\t\t\t\t\tif rs.headers.find{|h| h.id == id} then\n\t\t\t\t\t\t\t\trs.warnings << \"header id collision - #{id}\"\n\t\t\t\t\t\t\t\tid = \"bfheader-#{Digest::MD5.hexdigest(title)}\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tid = \"bfheader-#{Digest::MD5.hexdigest(title)}\"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\ttitle = \"#{prefix}#{title}\"\n\t\t\t\t\ttitle_html = \"#{prefix}#{title_html}\"\n\n\n\t\t\t\t\tunless id =~ IdRegexp then\n\t\t\t\t\t\trs.warnings << \"illegal header id - #{id} (legal chars: [a-zA-Z0-9_-.] | 1st: [a-zA-Z])\"\n\t\t\t\t\tend\n\n\t\t\t\t\tif rs.block_transform_depth == 1 then\n\t\t\t\t\t\trs.headers << RenderState::Header.new(id, level, title, title_html)\n\t\t\t\t\tend\n\n\t\t\t\t\tif @use_header_id then\n\t\t\t\t\t\t%{<h%d id=\"%s\">%s</h%d>\\n\\n} % [ level, id, title_html, level ]\n\t\t\t\t\telse\n\t\t\t\t\t\t%{<h%d>%s</h%d>\\n\\n} % [ level, title_html, level ]\n\t\t\t\t\tend\n\t\t\t\t}\n\t\tend",
"def record_header(cursor)\n origin = cursor.position\n header = RecordHeader.new\n cursor.backward.name(\"header\") do |c|\n case page_header.format\n when :compact\n # The \"next\" pointer is a relative offset from the current record.\n header.next = c.name(\"next\") { origin + c.read_sint16 }\n\n # Fields packed in a 16-bit integer (LSB first):\n # 3 bits for type\n # 13 bits for heap_number\n bits1 = c.name(\"bits1\") { c.read_uint16 }\n header.type = RECORD_TYPES[bits1 & 0x07]\n header.heap_number = (bits1 & 0xfff8) >> 3\n when :redundant\n # The \"next\" pointer is an absolute offset within the page.\n header.next = c.name(\"next\") { c.read_uint16 }\n\n # Fields packed in a 24-bit integer (LSB first):\n # 1 bit for offset_size (0 = 2 bytes, 1 = 1 byte)\n # 10 bits for n_fields\n # 13 bits for heap_number\n bits1 = c.name(\"bits1\") { c.read_uint24 }\n header.offset_size = (bits1 & 1).zero? ? 2 : 1\n header.n_fields = (bits1 & (((1 << 10) - 1) << 1)) >> 1\n header.heap_number = (bits1 & (((1 << 13) - 1) << 11)) >> 11\n end\n\n # Fields packed in an 8-bit integer (LSB first):\n # 4 bits for n_owned\n # 4 bits for flags\n bits2 = c.name(\"bits2\") { c.read_uint8 }\n header.n_owned = bits2 & 0x0f\n header.info_flags = (bits2 & 0xf0) >> 4\n\n case page_header.format\n when :compact\n record_header_compact_additional(header, cursor)\n when :redundant\n record_header_redundant_additional(header, cursor)\n end\n\n header.length = origin - cursor.position\n end\n\n header\n end",
"def process(&block)\n @parser.on_headers_complete = block\n end",
"def parse_header(string)\n {\n # identificação do registro header (conteúdo 0)\n :tipo_registro => string[0..0].to_i,\n # identificação do arquivo retorno\n :codigo_retorno => string[1..1],\n # identificação por extenso do tipo de movimento\n :literal_retorno => string[2..8],\n # identificação do tipo de serviço\n :codigo_servico => string[9..10],\n # identificação por extenso do tipo de serviço\n :literal_servico => string[11..25],\n # código da empresa no bradesco\n :codigo_empresa => string[26..45].strip,\n # razão social da empresa\n :razao_social => string[46..75],\n # número do banco na câmara de compensação\n :codigo_banco => string[76..78],\n # nome por extenso do banco cobrador\n :nome_banco => string[79..93].strip,\n # data de geração do arquivo\n :data_geracao => convert_date(string[94..99]),\n # brancos\n #:brancos1 => string[100..107],\n # número aviso bancário\n :numero_aviso_bancario => string[108..112],\n # brancos\n #:brancos2 => string[113..378],\n # data de crédito dos lançamentos\n :data_credito => convert_date(string[379..384]),\n # brancos\n #:brancos3 => string[385..393],\n # número sequencial do registro no arquivo\n :numero_sequencial => string[394..399]\n }\n end",
"def set_attributes_from_header(page, filepath)\n template = Locomotive::Mounter::Utils::YAMLFrontMattersTemplate.new(filepath)\n\n if template.attributes\n attributes = template.attributes.clone\n\n # set the editable elements\n page.set_editable_elements(attributes.delete('editable_elements'))\n\n # set the content type\n if content_type_slug = attributes.delete('content_type')\n attributes['templatized'] = true\n attributes['content_type'] = self.mounting_point.content_types.values.find { |ct| ct.slug == content_type_slug }\n end\n\n page.attributes = attributes\n end\n\n page.template = template\n end",
"def method_missing(name, *args, &block)\n #:nodoc:\n # Only take the structured fields, as we could take _anything_ really\n # as it could become an optional field... \"but therin lies the dark side\"\n field_name = underscoreize(name).chomp(\"=\")\n if Mail::Field::KNOWN_FIELDS.include?(field_name)\n if args.empty?\n header[field_name]\n else\n header[field_name] = args.first\n end\n else\n super # otherwise pass it on\n end\n #:startdoc:\n end",
"def is_header?(fields)\n # parsing should ignore...\n # lines that are completely blank\n # lines that appear to be entirely delimiters\n\n return true if fields.empty?\n\n line = fields.join\n\n # these are probably horizontal markers between any header text and the actual data\n return true if line =~ /^[-=*_\\s]*$/\n\n return true unless line =~ /\\d/\n\n return true if line =~ /^\\s*[A-Za-z ]+$/\n\n # this line looks significant, keep it in.\n false\n end",
"def normalize_header!\n @gsi.dsc = HeaderOption::DSC::TELETEXT_LEVEL_2\n @gsi.lc = @gsi.lc.to_i.to_s.rjust(2,'0')\n @gsi.tnb = @gsi.tnb.to_i.to_s.rjust(5,'0')\n @gsi.tns = @gsi.tns.to_i.to_s.rjust(5,'0')\n @gsi.tng = @gsi.tng.to_i.to_s.rjust(3,'0')\n @gsi.tcp = @gsi.tcp[0..1].to_i.to_s.ljust(2,'0') + \n @gsi.tcp[2..3].to_i.to_s.ljust(2,'0') +\n @gsi.tcp[4..5].to_i.to_s.ljust(2,'0') +\n @gsi.tcp[6..7].to_i.to_s.ljust(2,'0')\n @gsi.tcf = @gsi.tcf[0..1].to_i.to_s.ljust(2,'0') +\n @gsi.tcf[2..3].to_i.to_s.ljust(2,'0') +\n @gsi.tcf[4..5].to_i.to_s.ljust(2,'0') +\n @gsi.tcf[6..7].to_i.to_s.ljust(2,'0')\n @gsi.co = @gsi.co.upcase\n end",
"def parse!\n if /^(?<key>.*?):(?<value>.*)/m =~ @raw\n @key = key.strip\n @value = value.strip\n else\n raise \"Unable to parse Header: #{@raw}\"\n end\n end",
"def headers\n fields.map(&:name).map(&:to_sym)\n end",
"def line_parse(validated_line)\n return unless validated_line\n row = validated_line.split(',')\n return unless row.any?\n if @headers.empty?\n @headers = row\n else\n @data_hash.merge!(row_to_hsh(row))\n @valid_rows << @data_hash\n end\n end",
"def header_parameters\n return @header_parameters unless @header_parameters.nil?\n io = header_parameters_with_io._io\n _pos = io.pos\n io.seek(0)\n @header_parameters = HeaderParameters.new(io, self, @_root)\n io.seek(_pos)\n @header_parameters\n end",
"def header\n @header ||= Header.new(\n column_definitions: config.column_definitions,\n column_names: csv.header\n )\n end",
"def parse\n @lines.each do |line|\n if m = line.match(R_ATTRIBUTE)\n @attrs << {:name => m[1].strip, :type => m[2].strip, :desc => m[4].strip}\n elsif m = line.match(R_ATTRIBUTE_NEXT_LINE)\n @attrs[-1][:desc] += \" #{m[1].strip}\"\n end\n end\n end",
"def header(name, value)\n har_headers << [name, value]\n super(name, value)\n end",
"def header(_content)\n raise NotImplementedError\n end",
"def header(h, buffer = Buffer.new)\n rep = HEADREP[h[:type]]\n\n case h[:type]\n when :indexed\n buffer << integer(h[:name] + 1, rep[:prefix])\n when :changetablesize\n buffer << integer(h[:value], rep[:prefix])\n else\n if h[:name].is_a? Integer\n buffer << integer(h[:name] + 1, rep[:prefix])\n else\n buffer << integer(0, rep[:prefix])\n buffer << string(h[:name])\n end\n\n buffer << string(h[:value])\n end\n\n # set header representation pattern on first byte\n fb = buffer.ord | rep[:pattern]\n buffer.setbyte(0, fb)\n\n buffer\n end",
"def parse_first_header(line)\n\n # split the line into: METHOD URI PROTOCOL\n # eg: GET / HTTP/1.1\n parsed = line.split(' ')\n\n # a correct request has three parts\n return bad_parsing unless parsed.size == 3\n\n @http_request_method, uri, @http_protocol = parsed\n\n # optional query string\n @http_request_uri, @http_query_string = uri.split('?')\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 cgi_parse_header(line)\n parts = _cgi_parseparam(';' + line)\n key = parts.next\n pdict = {}\n\n begin\n while p = parts.next\n i = p.index('=')\n if i\n name = p[0...i].strip.downcase\n value = p[i+1..-1].strip\n if value.length >= 2 && value[0] == '\"' && value[-1] == '\"'\n value = value[1...-1]\n value = value.gsub('\\\\\\\\', '\\\\').gsub('\\\\\"', '\"')\n end\n pdict[name] = value\n end\n end\n rescue StopIteration\n end\n\n [key, pdict]\n end",
"def process_line(line)\n @line = line\n if line =~ /^=/ then\n process_heading_line(line)\n elsif (listtype = special_list_line_type(line)) then\n special_list_line(listtype, line)\n elsif line =~ /^\\s*:/ then\n special_list_continuation_line(line)\n else\n @interp.normal_line(line)\n end\n end",
"def parse_header(string)\n {\n # identificação do registro header\n :tipo_registro => string[0..0].to_i,\n # identificação do arquivo retorno\n :codigo_retorno => string[1..1],\n # identificação por extenso do tipo de movimento\n :literal_retorno => string[2..8],\n # identificação do tipo de serviço\n :codigo_servico => string[9..10],\n # identificação por extenso do tipo de serviço\n :literal_servico => string[11..25],\n # agência mantenedora da conta\n :agencia => string[26..29],\n # complemento de registro\n :zeros => string[30..31],\n # número da conta corrente da empresa\n :conta => string[32..36],\n # dígito de auto-conferência ag/conta empresa\n :dac => string[37..37],\n # complemento do registro\n #:brancos1 => string[38..45],\n # nome por extenso da \"empresa mãe\"\n :nome_empresa => string[46..75],\n # número do banco na câmara de compensação\n :codigo_banco => string[76..78],\n # nome por extenso do banco cobrador\n :nome_banco => string[79..93].strip,\n # data de geração do arquivo\n :data_geracao => string[94..99],\n # unidade de densidade\n :densidade => string[100..104],\n # densidade de gravação do arquivo\n :unidade_densidade => string[105..107],\n # número sequencial do arquivo retorno\n :numero_sequencial_arquivo_retorno => string[108..112],\n # data de crédito dos lançamentos\n :data_credito => string[113..118],\n # complemento do registro\n #:brancos2 => string[119..393],\n # número sequencial do registro no arquivo\n :numero_sequencial => string[394..399]\n }\n end",
"def initialize(lines, options = {})\n if lines.is_a?(String)\n lines = lines.split(\"\\n\")\n end\n self.meta = {}\n in_meta = true\n while in_meta and line = lines.shift do\n line.strip!\n matches = line.match /^([^:]+):\\s+(.+)/\n if matches\n if matches[1] =~ /(Chapter|Number|Position)/i and matches[2] =~ /\\d+/ and number.nil?\n self.number = matches[2].strip.to_i\n end\n self.meta[matches[1].downcase.to_sym] = matches[2]\n else\n lines = [line] + lines if line\n in_meta = false \n end\n end\n self.meta.merge!(options)\n self.file_name = self.meta[:file_name]\n self.content = lines.join\n end",
"def header_style(header); end",
"def prepare(line)\n @logger.debug \"Looking at #{line.paragraph_type}: #{line.to_s}\"\n if not should_accumulate_output?(line) then\n flush!\n maintain_list_indent_stack(line)\n @output_type = line.paragraph_type \n end\n push_mode(:inline_example) if line.inline_example? and current_mode != :inline_example\n pop_mode(:inline_example) if current_mode == :inline_example && !line.inline_example?\n push_mode(:table) if enter_table?\n pop_mode(:table) if exit_table?\n @buffered_lines.push(line)\n end",
"def he_request(*args)\n n=0\n spec = line_part_spec\n @page_headers[0][n] = @page_headers[1][n] = spec\n end",
"def csv_headers\n raise NotImplementedError\n end"
] |
[
"0.7158671",
"0.6814251",
"0.67607427",
"0.6586612",
"0.6395828",
"0.6366807",
"0.6364845",
"0.63492525",
"0.6332957",
"0.625593",
"0.62114173",
"0.616929",
"0.61192423",
"0.6030263",
"0.6030263",
"0.60243523",
"0.60147315",
"0.6013139",
"0.6000098",
"0.5984581",
"0.59844637",
"0.59761024",
"0.59301853",
"0.59093285",
"0.59071743",
"0.59071743",
"0.59071743",
"0.5906666",
"0.59034294",
"0.5899176",
"0.5863434",
"0.5846985",
"0.5844154",
"0.58418816",
"0.58296955",
"0.5828053",
"0.5820606",
"0.5815392",
"0.58023053",
"0.58023053",
"0.58023053",
"0.58023053",
"0.5798573",
"0.57781774",
"0.576798",
"0.57481277",
"0.5746831",
"0.5733975",
"0.57319576",
"0.5714861",
"0.57132304",
"0.5707717",
"0.570183",
"0.56836116",
"0.56740713",
"0.5666294",
"0.5656486",
"0.5653585",
"0.5653438",
"0.56485265",
"0.5642348",
"0.5642348",
"0.56371564",
"0.56339747",
"0.5633446",
"0.5633446",
"0.5633446",
"0.5633446",
"0.5633446",
"0.5633446",
"0.5633446",
"0.5633446",
"0.5633446",
"0.5633446",
"0.5632304",
"0.56298965",
"0.56297374",
"0.5627059",
"0.56238294",
"0.56192905",
"0.5606509",
"0.5605976",
"0.56045246",
"0.56009096",
"0.55992156",
"0.5587443",
"0.55836236",
"0.55824435",
"0.5577069",
"0.557066",
"0.5565439",
"0.5564049",
"0.5562613",
"0.5556927",
"0.5548494",
"0.5548036",
"0.5542125",
"0.5540295",
"0.5540156",
"0.55371225",
"0.55294096"
] |
0.0
|
-1
|
Get a single user
|
def user(user=nil)
if user
get("/users/#{user}", {}, 3)
else
get("/user", {}, 3)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_user(user_id)\n return User.find(user_id)\n end",
"def retrieve(user_id:)\n User.new get_request(\"users/#{user_id}\").body.dig(\"user\")\n end",
"def user(id = 'self')\n get(\"users/#{id}\").user\n end",
"def get(user_id)\n User.find user_id\n end",
"def get_user(id)\n @users[id]\n end",
"def get_user\n @user = User.find(params[:user_id])\n end",
"def user(id)\n self.class.get(\"/user/#{id}\", @options).parsed_response\n end",
"def user(user_id = nil)\n user_id = username if user_id.nil? || user_id == \"\"\n if user_id.to_i.to_s == user_id.to_s\n users = connection.get(connection.build_url('users', :userids => user_id)).body\n else\n users = connection.get(connection.build_url('users', :logins => user_id)).body\n end\n users.map!{|hash| hash.values.first}\n users.first\n end",
"def get_user(user_id:)\n parse(JSON.parse(connection.get(\"users/#{user_id}\").body))\n end",
"def user(user_id)\n response = connection.get do |req|\n req.url \"/user/#{user_id}\", simple_params\n end\n response.body[0]\n end",
"def get_user_by_id(id)\n resp = request('getUserByID', {:userID => id})['user']\n resp['username'].empty? ? nil : User.new(self, resp)\n end",
"def get_user id, options={}, headers={}\n @connection.get \"users/#{id}.json\", options, headers\n end",
"def find_user(user_id)\n user = User.find(user_id)\n user\n end",
"def get_user(id)\n conn = @client.get do |req|\n req.url \"/api/v2/user/#{id}\"\n req.headers[\"Authorization\"] = @token\n end\n conn.body\n end",
"def get_user_byid(id)\n @user = User.find_by_id(id)\n end",
"def get_user(user_id)\n request(Route.new(:GET, '/users/%{user_id}', user_id: user_id))\n end",
"def get_user(id)\n @client.raw('get', \"/config/users/#{id}\")\n end",
"def get_user\n \n # Retrieve user id if stored in a cookies\n # @TODO Secure ID when stored in cookies\n if cookies[:user]\n return User.find(cookies[:user])\n\n # Retrieve user id if stored in session\n elsif session[:user]\n return User.find(session[:user])\n\n # No user logged in\n else\n return nil\n end\n\n end",
"def get_user\n @user = User.find(params[:user_id])\n end",
"def get_user(user_name:)\n validate_user_name(:user_name, user_name)\n\n wrap_response(@connection.get(user_path(user_name))).fmap { |r|\n SftpgoClient::User.new(r.body)\n }\n end",
"def user\n @user ||= User.find(\n params[:user_id] ) # needs to raise exception if user not found\n end",
"def user\n return User.current unless user_id\n user = User.get_from_cache(user_id)\n user || User.first({:id => user_id})\n end",
"def get_user\n @user = User.find_by_id(params[:id])\n if @user \n return @user\n else \n render json: {\"message\": {\"type\": \"error\", \"content\": \"The user could not be found!\"}}\n end\n end",
"def get_user(id, &block)\n get(\"#{@base_url}/user/#{id}/json\", user_mapping, block)\n end",
"def get_user \n @user = User.find(params[:id])\n end",
"def user\n User.get user_id || User.new\n end",
"def user\n UserRepository.find(user_id)\n end",
"def user(user_id_or_url = nil, options = {})\n options = make_options(:user_id, user_id_or_url, options)\n get(options)\n end",
"def fetch_user(id)\n client.user(id)\n end",
"def user(id:)\n User.find(id)\n end",
"def user(user_id, params = {})\n make_get_request(\"/users/#{user_id}\", params)\n end",
"def get_user_or_404(id)\n @user = get_or_404(User, id)\n end",
"def get_user \n\t\treturn User.find(self.user_id)\n\tend",
"def user\n Webmetrics.users.find_one('_id' => id)\n end",
"def user(id = nil)\n id.to_i.zero? ? get('/user') : get(\"/users/#{id}\")\n end",
"def get_user(id)\n begin\n user = JSON.parse(RestClient.get construct_url(\"user/#{id}\"))\n rescue RestClient::ResourceNotFound => e\n @last_error = e.http_body\n @last_error_code = e.http_code\n false\n end\n end",
"def user_management_get_single_user id\n # the base uri for api requests\n query_builder = Configuration.BASE_URI.dup\n\n # prepare query string for API call\n query_builder << \"/v1/users/{id}\"\n\n # process optional query parameters\n query_builder = APIHelper.append_url_with_template_parameters query_builder, {\n \"id\" => id,\n }\n\n # process optional query parameters\n query_builder = APIHelper.append_url_with_query_parameters query_builder, {\n \"client_id\" => @client_id,\n \"client_secret\" => @client_secret,\n }\n\n # validate and preprocess url\n query_url = APIHelper.clean_url query_builder\n\n # prepare headers\n headers = {\n \"user-agent\" => \"IAMDATA V1\",\n \"accept\" => \"application/json\"\n }\n\n # invoke the API call request to fetch the response\n response = Unirest.get query_url, headers:headers\n\n # Error handling using HTTP status codes\n if response.code == 401\n raise APIException.new \"Unauthorized\", 401, response.raw_body\n elsif response.code == 404\n raise APIException.new \"Not Found\", 404, response.raw_body\n elsif !(response.code.between?(200,206)) # [200,206] = HTTP OK\n raise APIException.new \"HTTP Response Not OK\", response.code, response.raw_body\n end\n\n response.body\n end",
"def find_user_by_id(id)\n User.find(id)\n end",
"def get_user_byid(id)\n # accept an id input parameter\n # use the User Model class to get the User associated with the `id` primary key\n # return the User instance that matches the provided id\n @user = User.find_by(:id => id)\n @user\n end",
"def get_user(name)\n User.where(name:).first\n end",
"def user\n return unless user_id && user_type\n return @user if instance_variable_defined?('@user')\n\n @user = user_type.constantize.find_by(id: user_id)\n end",
"def get_user\n\t\tif !session[:user_id]\n\t\t\t@user = nil\n\t\telse\n\t\t\t@user = User.find(session[:user_id])\n\t end\n\tend",
"def user\n User.where(id: object.user_id)[0]\n end",
"def get_user(id)\r\n # Prepare query url.\r\n _path_url = '/users/{id}'\r\n _path_url = APIHelper.append_url_with_template_parameters(\r\n _path_url,\r\n 'id' => id\r\n )\r\n _query_builder = Configuration.get_base_uri\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n CustomHeaderAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n UserDetail.from_hash(decoded)\r\n end",
"def show(id)\n response = request(:get, \"/users/#{id}.json\")\n response[\"user\"]\n end",
"def get_user()\n user = User.first(:id => self.user_id)\n if !user\n user = User.new\n user.login = \"anon\"\n end\n return user\n end",
"def get_user_by_id(id)\n $r.hgetall(\"user:#{id}\")\n end",
"def user(id)\n Bibliovore::User.new(\n get_endpoint(\"users/#{id}\", 'user'), self\n )\n end",
"def user(id_or_username = \"my\", params = {})\n if id_or_username.is_a?(Fixnum) || id_or_username == 'my'\n find_user_by_id id_or_username, params\n else\n find_user_by_username id_or_username, params\n end\n end",
"def user(user=nil, options = {})\n get User.path(user), options\n end",
"def user(id)\n target = \"#{self.base_url}/user/#{id.to_s}/\"\n self.class.get(target, {basic_auth: self.auth})\n end",
"def show\n @user = UserService.getUserById(params[:id])\n end",
"def user\n # 自インスタンスのuser_idの値に紐付くuserインスタンスを戻り値として返す\n return User.find(self.user_id)\n end",
"def find_user_by_id(id)\n users.find_by_id(id)\n end",
"def get_user(name)\n @model.find_by(name: name)\n end",
"def find_user\n results = @ldap.search( :base => options[:ldap][:base], :filter => user_filter)\n return results.first\n end",
"def user; User.find_by_id(user_id); end",
"def get_user\n return if @user # no extra http calls\n url = URI.escape(\"#{@options[:cas_server]}/#{@options[:uid]}.#{@options[:format]}\")\n response = Casport.get(url)\n if response.success?\n @user = response.parsed_response\n else\n @user = nil\n end\n end",
"def get(user_id:)\n path = '/users/{userId}'\n .gsub('{userId}', user_id)\n\n if user_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"userId\"')\n end\n\n params = {\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'GET',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::User\n )\n end",
"def get(user_id)\n get_request(t_url(:user, user_id))\n end",
"def get_user_from_id(user_id)\n \t\tuser = nil\n \t\tunless user_id.blank?\n\t \t\tcol = :email\n\t \t\tif CONFIG[:enable_username?]\n\t \t\t\tunless is_email(user_id)\n\t \t\t\t\tcol = :username\n\t \t\t\tend\n\t \t\tend\n#\t \t\tp \"Finding user by col: #{col}, user_id = #{user_id}\"\n\t \t\tuser = User.find_by(col => user_id.downcase)\n\t \tend\n\t \tuser\n \tend",
"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 get_user(id, accountId, options={}) path = \"/api/v2/accounts/#{accountId}/users/#{id}\"\n get(path, options, AvaTax::VERSION) end",
"def user\n @user ||= User.find(user_id)\n end",
"def find_user\n User.find(params.fetch(:id))\n end",
"def user(reload = false)\n self.cache(CostAgent::User, self.username, reload) do\n data = self.client(\"verify\").get.headers\n [User.new(\n :id => data[:user_id],\n :permissions => data[:user_permission_level],\n :company_type => data[:company_type])]\n end.first\n end",
"def user\n User.load(self.user_id)\n end",
"def user(user_id)\n params = {\n :client_id => Swiftype.platform_client_id,\n :client_secret => Swiftype.platform_client_secret\n }\n get(\"users/#{user_id}.json\", params)\n end",
"def get_user_by_username(name)\n resp = request('getUserByUsername', {:username => name})['user']\n resp['username'].empty? ? nil : User.new(self, resp)\n end",
"def account_user(id)\n get(\"accountuser/#{id}\")\n end",
"def user\n @user = User.find_by(id: params[:user_id]) || render_404\n end",
"def load_user\n if (params[:id].blank?)\n @user = nil\n return @user\n end\n\n @user = User.where(:_id => params[:id]).first\n\n if (@user.blank?)\n # If not found, show an error and redirect\n flash[:error] = t(\"users.error.not_found\")\n redirect_to users_path()\n end\n\n return @user\n end",
"def show\n @user = User.get(params[:id]) \n end",
"def user\n if users.size == 1\n users.first\n else\n nil\n end\n end",
"def get_user\n unless session[:drupal_user_id].nil?\n uid = session[:drupal_user_id]\n @user = User.find_by_uid(uid)\n end\n\n @user || nil\n end",
"def show\n # loads one user in the database\n @user = User.find(params[:id])\n end",
"def show(id)\n response = request(:get, \"/users/#{id}.json\")\n response.first[1]\n end",
"def user(id:, **args)\n params = parameters(args) do\n optional_params\n end\n request(:get, \"users/#{id}\", params)\n end",
"def user\n User.find(self[:user_id])\n end",
"def find_user\n\n @user = User.using_client_shard(client: @client).get_from_memcache(@user_id)\n\n return error_with_data(\n 'sm_gud_fu_1',\n 'Invalid user id',\n 'Invalid user id',\n GlobalConstant::ErrorAction.default,\n {},\n {}\n ) if @user.blank? || @user.client_id != @client_id\n\n success\n end",
"def get_user(uid)\n @inv = User.find_by_id(uid)\n end",
"def get_user(uri = nil, data = nil)\n\n # Return the user from the cache if available\n user = self.users[uri]\n return user if user\n\n # Get user from the JSON API and add to the cache\n #json = self.api.call(\"users/#{id_from_uri(uri)}\")\n #if json\n # user = User.new(uri, self, self.email_selector, self.ldap_lookup, json: json)\n # self.users[user.uri] = user\n # user\n #else\n # # TODO: this is a hack, just return the URI for now if the lookup fails\n # uri\n #end\n nil\n\n end",
"def get_user(users, id)\n user = users.select { |f| f[:id] == id }\n user.first\n end",
"def find_user\n @user = User.with_username(params[:id]).first\n end",
"def get_user(handle)\n request(Net::HTTP::Get, \"/api/#{API_VERSION}/user/#{handle}\", nil, nil, false)\n end",
"def user\n @user ||= ::User.find_by(id: user_id)\n end",
"def find_user\n return User.all if params[:user_id].nil?\n\n User.find(params[:user_id])\n end",
"def user_by_username(username)\n get(\"/v1/users/find\", username: username)\n end",
"def user(user_name)\n OctocatHerder::User.fetch(user_name, connection)\n end",
"def get\n\t\t\t\tparams.required(:id)\t\n\n\t\t\t\t# Grab the service that is trying to authenticate\n unathenticated_error unless @api_consumer.is_a? Service\n service = @api_consumer\n\n\t\t\t\t@user = service.users.find params[:id]\n\t\t\tend",
"def find_user_by_id(id = 'my', params = {})\n object_from_response(Code42::User, :get, \"user/#{id}\", params)\n end",
"def find_user\n @user= User.where(id: params[:id]).first\n end",
"def find_user\n @user = User.find(params[:id])\n end",
"def user user_id, options = {}\n perform_get_with_object(\"/users/#{user_id}\", options, Vimeo::Entities::User)\n end",
"def getUser\n \t\tuser_id = Course.where(\"id = '#{self.course_id}'\").first.user_id\n \t\treturn User.where(\"id = '#{user_id}'\").first\n \tend",
"def find_user\n raise ExceptionTypes::BadRequestError.new(\"user_id must be present\") unless params[:user_id].present?\n \n @user = User.find(params[:user_id])\n end",
"def user\n user_id.get_object\n end",
"def user\n batch_load_one(object.user_id, 'User')\n end",
"def user_by_id(user_id)\n Egi::Fedcloud::Vmhound::Log.debug \"[#{self.class}] Picking user ID #{user_id.inspect} from pool\"\n users.select { |user| user[:id] == user_id.to_i }.first\n end"
] |
[
"0.8438886",
"0.8203915",
"0.8077506",
"0.80690503",
"0.79840463",
"0.7983078",
"0.79479164",
"0.7943967",
"0.79149514",
"0.7910885",
"0.7866714",
"0.7854816",
"0.78389114",
"0.78370005",
"0.78252226",
"0.7809548",
"0.7793258",
"0.7791225",
"0.77765685",
"0.77507347",
"0.77489",
"0.7748766",
"0.7726234",
"0.77252835",
"0.7722026",
"0.7721634",
"0.7696684",
"0.7695426",
"0.7694168",
"0.7650568",
"0.7636268",
"0.7634071",
"0.7610887",
"0.7605912",
"0.7600889",
"0.7576154",
"0.75613016",
"0.75598556",
"0.75559413",
"0.7554261",
"0.7511202",
"0.7511125",
"0.7485885",
"0.7484378",
"0.7483629",
"0.7450043",
"0.74498",
"0.7395065",
"0.73890007",
"0.73827916",
"0.7359608",
"0.7340963",
"0.7336343",
"0.73283297",
"0.7327032",
"0.7326632",
"0.73229367",
"0.73098576",
"0.73049533",
"0.7302531",
"0.7292913",
"0.7292308",
"0.7292308",
"0.7280888",
"0.7257458",
"0.72369975",
"0.7236356",
"0.72287756",
"0.7217624",
"0.7215396",
"0.7204633",
"0.71958715",
"0.7191256",
"0.7189731",
"0.71882355",
"0.7184016",
"0.71792877",
"0.71567374",
"0.71431875",
"0.7139972",
"0.71384424",
"0.7136834",
"0.71307516",
"0.71179354",
"0.7116666",
"0.7112947",
"0.7112242",
"0.7094996",
"0.7081368",
"0.7077754",
"0.7073879",
"0.7069219",
"0.70642185",
"0.7064033",
"0.7056942",
"0.70530075",
"0.7049277",
"0.7042545",
"0.70347416",
"0.70261693"
] |
0.743144
|
47
|
Update the authenticated user
|
def update_user(options)
patch("/user", options, 3)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_user\n end",
"def update\n if current__user.isAdmin || current__user == @user\n if @user.update(user_update_params)\n # setToken\n # UserNotifierMailer.send_signup_email(@user).deliver\n render :show, status: :ok\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n else\n render json: 'Sorry you are not allowed to perform this operation.', status: :unprocessable_entity\n end\n end",
"def update\n @current_user.update user_params\n redirect_to root_path\n end",
"def update\n if not check_logged_in then\n return\n end\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @current_user = User.find( params[:id] )\n @current_user.update!( user_params )\n redirect_to user_path( @current_user.id )\n end",
"def update\n if params[:id] != current_user.id && current_user.is_admin == false\n \traise \"You are not authorized to access this function\"\n end \n @user = current_user\n @user.update_attributes(params[:user])\n respond_with(@user)\n end",
"def update\n @user = current_user\n @user.update_attributes(user_params)\n redirect_to root_path\n end",
"def update\n @user = current_user\n if @user.update(update_user_params)\n render 'api/v1/users/show'\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n # @user is already set by correct_user\n # @user = User.find(params[:id])\n if @user.update_attributes(params[:user])\n # Handle a successful update.\n flash[:success] = \"Profile updated\"\n # log_in here makes sure token in cookie gets updated\n # If someone is using hijacked cookie, token gets updated and results in stole token not working\n log_in @user\n redirect_to @user\n else\n render 'edit'\n end\n end",
"def update_user\n user = current_user\n if user.update(update_params)\n render json: { status: { updated: \"Ok\" } }\n else\n render json: user.errors.full_messages\n end\n end",
"def update\n if params[:id]\n @user = User.find(params[:id])\n else\n @user = current_user\n end\n\n respond_to do |format|\n if @user.id == current_user.id and @user.update_attributes(User.from_params(params))\n format.json { head :no_content }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\tget_current_user\n\t\t@user = User.find(params[:id])\n\n\t\treturn (render json: {errors: [\"Je bent niet geauthoriseerd om dit te doen\"]}, status: :unprocessable_entity) unless (@current_user.isAdmin || @current_user.id == @user.id)\n\n\t respond_to do |format|\n\t if @user.update_attributes(params[:user])\n\t \tnew_remember_token(@user) if @current_user.isStudent\n\t format.json { head :no_content }\n\t else\n\t format.json { render json: {errors: @user.errors.full_messages}, status: :unprocessable_entity }\n\t end\n\t end\n\tend",
"def update\n @user = User.find(params[:id])\n if @user.update_attributes(params[:user])\n sign_in @user\n flash[:success]= \"Profile Updated\"\n redirect_to @user\n else\n render 'edit'\n end\n end",
"def update\n @user = current_user\n if @user.update(user_params)\n redirect_to root_url\n else\n render 'edit'\n end\n end",
"def update\n @user = User.find(session[:uid])\n @user.update_attribute :auth_token, session[:auth_token]\n @user.update_attribute :auth_secret, session[:auth_secret]\n @user.save!\n\n redirect_to home_index_url\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user.update_attributes!(user_params)\n \n render nothing: true, status: :no_content\n end",
"def update\n @user = current_user\n @user.update(user_params)\n render_wizard @user\n end",
"def update\n authorize! if @user != current_user\n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @user.update_attributes(params[:user])\n flash[:success] = \"Profile Updated!\"\n sign_in @user\n redirect_to @user\n else\n render 'edit'\n end\n end",
"def update\n modified_params = user_params\n modified_params.delete(\"password\") if modified_params[\"password\"].empty?\n if @user.update(modified_params)\n @users = current_user.users\n end\n end",
"def update\n if @auth_user.update(auth_user_params)\n render :show, status: :ok, location: @auth_user\n else\n render json: @auth_user.errors, status: :unprocessable_entity\n end\n end",
"def update \n @current_user.update(user_params)\n render json: @current_user\n end",
"def update\n @user = User.find(current_user.id)\n if @user.update_attributes(user_params)\n redirect_to account_url, flash: { success: t(:update_user_success) }\n else\n render 'edit'\n end\n end",
"def updateUser\n options = {\n :body => params.to_json,\n :headers => {\n 'Content-Type' => 'application/json',\n 'Authorization' => request.headers['Authorization']\n }\n }\n results = HTTParty.put(\"http://192.168.99.101:4051/users/\"+@current_user[\"id\"].to_s, options)\n render json: results.parsed_response, status: results.code\n end",
"def update\n @user = current_user \n if @user.update_attributes(params[:user])\n flash[:notice] = 'User was successfully updated.'\n redirect_to root_url\n else\n render :action => \"edit\"\n end\n end",
"def update\n puts \"current user\"\n puts @user.id\n puts current_user.id\n if current_user.admin || @user.id == current_user.id\n if user_params['is_disabled']\n @user.tokens = nil\n end\n if @user.update(user_params)\n render json: @user\n else\n puts @user.errors.full_messages\n render json: @user.errors, status: :unprocessable_entity\n end\n else\n render json: @user.errors, status: :bad_request\n end\n end",
"def update\n\n @user = self.current_user\n @user.update_attributes(params)\n \n rescue => ex\n @user.reload\n handle_exception(ex)\n ensure\n respond_to do |format|\n format.json \n end\n end",
"def update\n authorize @user\n if @user.update_attributes(user_params)\n redirect_to core_user_path(@user)\n else\n render :edit\n end\n end",
"def update\n if current_user.id == params[:id].to_i\n @user = User.find(params[:id])\n @user.update(user_params)\n redirect_to root_path\n else\n redirect_to :back\n end\n end",
"def update\n respond_to do |format|\n if current_user.update(user_params)\n format.json {\n render json: {\n status: 'success',\n data: current_user\n },\n status: :ok\n }\n else\n format.json { render json: current_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @user\n @user.update(user_params)\n render json: @user, serializer: UserSerializer, message: 'user succefully update', status: 200\n else\n render json: { error: 'unable update' }, status: 400\n end\n end",
"def update_user\n current_user.update_last_access if current_user && signed_in?\n end",
"def update\n\t\tif !current_user\n\t\t\tredirect_to '/'\n\t\t\treturn\n\t\tend\n\t\trespond_to do |format|\n\t\t\tif current_user && is_this_user && @user.update(user_params)\n\t\t\t\tformat.html { redirect_to @user, notice: '<span class=\"alert alert-success\">User was successfully updated.</span>' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @user }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @user.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n @user = User.find(params[:id])\n if @user.update_attributes(params[:user])\n flash[:success] = \"Profile updated\"\n sign_in @user\n redirect_to @user\n else\n render 'edit'\n end\n end",
"def update\n @user = User.find(params[:id])\n if @user.update_attributes(params[:user])\n flash[:success] = \"Profile updated\"\n sign_in @user\n redirect_to @user\n else\n render 'edit'\n end\n end",
"def update\n @user.update(user_params_update)\n json_response(@user)\n end",
"def update\n @update_success = @user.update(user_params)\n super\n end",
"def update\n @user = User.find(params[:id]).decorate\n return if unauthorized_user!\n @user.update_attributes(params[:user])\n respond_with @user\n end",
"def update\n user = find_user\n user.update!(user_params)\n render json: user\n end",
"def update\n @user = User.find(params[:id])\n if @user == current_user\n @user.update_attributes user_params\n redirect_to user_path(@user)\n else\n flash[:alert] = \"You do not have permission to edit this account\"\n redirect_to posts_path\n end\n end",
"def update\n @user = User.find(params[:id])\n if @user.update_attributes(params[:user])\n # Handle a successful update.\n flash[:success] = \"Profile updated\"\n sign_in @user\n redirect_to @user\n else\n # Si no se pudo actualizar el usuario\n render 'edit'\n end\n end",
"def update\n if (current_user?(User.find(params[:id])) || is_admin?)\n @user = User.find(params[:id])\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to(@user, :notice => 'User was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to user_path, notice: \"Access Denied\"\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n sign_in @user\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @current_user.update(user_params)\n render json: { message: 'success' }, status: :ok\n else\n render json: { message: @current_user.errors.full_messages }, status: 422\n end\n end",
"def update\n # require password to change account information\n if @currentUser && @currentUser.authenticate(user_params[:password])\n\n updatedParams = user_params\n\n updatedParams[:password] = updatedParams[:new_password]\n updatedParams.delete(:new_password)\n\n if @currentUser.update_attributes(updatedParams)\n head :no_content\n else\n render json: { errors: @currentUser.errors.messages }, status: 422\n end\n else\n render json: { errors: @currentUser.errors.messages }, status: 401\n end\n end",
"def custom_update\n user = User.find(params[:id])\n user.update_attributes(params[:user])\n render :text => true\n end",
"def update\n if @user.update_attributes(user_params)\n head :ok\n else\n head :internal_server_error\n end\n end",
"def update\n @user = User.find(params[:id])\n @user.update(user_params)\n render json: @current_user\n end",
"def update\n respond_to do |format|\n if current_user.update(user_params)\n format.html { redirect_to edit_user_path(current_user), notice: \"Your account was successfully updated.\" }\n format.json { render :show, status: :ok, location: @current_user }\n else\n format.html { render :edit }\n format.json { render json: current_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update, @user\n respond_to do |format|\n if @user.update(user_params)\n sign_in(@user == current_user ? @user : current_user, :bypass => true)\n format.html { redirect_to @user, notice: 'Your profile was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n id = user_is_admin? ? params[:id] : session[:current_user_id]\n @user = User.find(id)\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to(@user, :notice => 'User was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @user.update_attributes(params[:user])\n flash[:success] = \"Profil mis à jour\"\n sign_in @user\n redirect_to @user\n else\n render 'edit'\n end\n end",
"def update\n if @user.update_attributes(user_params)\n flash[:success] = \"Profile updated\"\n sign_in @user\n redirect_to @user\n else\n render 'edit'\n end\n end",
"def update\n @user = User.find_by_id(params[:id])\n @current_user = User.find_by_id(session[:user_id])\n if @user.update(user_params)\n redirect_to user_path, notice: 'Successfully updated!'\n else\n redirect_to edit_user_path, notice: \"An error prevented update: #{@user.errors.full_messages}\"\n end\n end",
"def update\n @user = current_user\n if @user.update_attributes params[:user]\n flash[:notice] = t \"flash.saved_user\"\n redirect_to root_url\n else\n render :action => \"edit\"\n end\n end",
"def self_update\n @current_user.update(user_params_update)\n json_response(@current_user)\n end",
"def update\n @user = User.find(params[:id])\n authorize! :update, @user, :message => 'You are not authorized to perform this operation.'\n if @user.update_attributes(params[:user])\n redirect_to user_path(@user), :notice => \"You updated your account successfully. #{undo_link}\"\n else\n redirect_to user_path(@user), :alert => \"Unable to update user.\"\n end\n end",
"def update\n @user = User.find(self.current_user.id)\n if @user.update_attributes(params[:user])\n flash[:notice] = 'User was successfully updated.'\n redirect_to :action => 'profile'\n else\n render :action => 'edit'\n end\n end",
"def update\n authorize! :edit, User\n @user = User.find(params[:id])\n return_url = users_url(:use_session => true)\n respond_to do |format|\n if @user.update_attributes(params[:user])\n do_extra_actions\n format.html { redirect_to return_url }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors.to_xml }\n end\n end\n end",
"def update\n check_user\n if @user.update(user_params)\n redirect_to @user, notice: 'User was successfully updated.' and return\n end\n end",
"def update\n if @current_user && @current_user.update(user_params)\n flash[:success] = \"Saved\"\n redirect_to edit_user_path(@current_user.id)\n else\n flash.now[:warning] = 'Please fill in all fields.'\n render :edit, status: :bad_request\n end\n end",
"def update\n if check_user_write_access\n respond_to do |format|\n if user.update_attributes(params[:user])\n format.html { redirect_to user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: user.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def update\n if current_user.update(user_params)\n redirect_to user_path(current_user), notice: 'Your profile was successfully updated.'\n else\n render :edit\n end\n end",
"def update\n if current_user != @user\n redirect_to users_path\n end\n\n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \t@user = current_user\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to admin_user_path(current_user), notice: '<strong>Success!</strong> Your profile was updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if current_user.update(user_params)\n format.html { redirect_to dashboard_path, notice: \"User was successfully updated.\" }\n format.json { render :show, status: :ok, location: current_user }\n else\n format.html { render :edit }\n format.json { render json: current_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user=User.find(params[:id])\n if @user.update_attributes(params[:user])\n sign_in @user\n redirect_to @user , :notice => \"Profile Updated\" #, notice: \"User was successfully updated\" }\n else render 'edit'\n\n end\n end",
"def update\n authorize! :update, @user\n if @user.update(user_params)\n flash.now[:notice] = '@user was successfully updated.'\n else\n flash.now[:alert] = @user.errors.full_messages.first\n end\n end",
"def update\n\n if @user.update(username: params[:username], email: params[:email], password: params[:password])\n render json: {status: 'SUCCESS', message: 'Account successfully updated', accessToken: @user.access_token}.to_json\n else\n render json: { errors: ['Update unsuccessful!'], status: 422 }.to_json\n end\n\n end",
"def update\n current_user.update_attributes! user_params\n redirect_back fallback_location: root_url\n end",
"def update\n current_user.update_attributes! user_params\n redirect_back fallback_location: root_url\n end",
"def update\n # @user = User.find(params[:id])\n @user = current_user # makes our views \"cleaner\" and more consistent\n params[:user][:existing_identity_attrs] ||= {}\n unless configatron.user_can_change_login\n params[:user].delete(:login)\n @user_login_is_readonly = true\n end\n \n respond_to do |format|\n if @user.update_attributes(params[:user])\n flash[:notice] = \"Account updated!\"\n format.html { redirect_to account_url }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(current_identity.user_id)\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n result = Users::UpdateCommand.new(current_user: current_user).call(update_user_params)\n\n render(json: result.value.as_json, status: :created)\n end",
"def update\n user = self.resource = User.to_adapter.get!(send(:\"current_user\").to_key)\n\n if user.update_with_password(resource_params)\n set_flash_message :notice, :updated\n sign_in resource_name, user, :bypass => true\n respond_with user, :location => after_update_path_for(user)\n else\n clean_up_passwords user\n respond_with user\n end\n end",
"def update\n if @user.update(user_params)\n render json: {user: @user, token: @token}\n else\n frender json: @user.errors, status: :unprocessable_entity \n end\n end",
"def update\n \n if current_user.update(user_params)\n Rails.cache.write(current_user.id,current_user)\n redirect_to users1_got_profile_path\n\n end\n end",
"def update\n authorize @user\n respond_to do |format|\n if @user.update(permitted_attributes(@user))\n format.html { redirect_to edit_user_path(@user), notice: 'User was successfully updated.' }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = @current_user\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to(@user, :notice => 'Account updated!') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.update(params[:user])\n end",
"def update\n @user = current_user\n if @user.update_attributes(params[:user])\n flash[:notice] = \"Profile update successful.\"\n redirect_to root_url\n else\n render :action => \"edit\"\n end\n end",
"def update\n if @user.id == current_api_user.id\n if @user.update(user_params)\n render json: @user.as_json(except: [:updated_at]), status: :ok\n else\n render json: @user.errors, status: :bad_request\n end\n else\n render json: '', status: :forbidden\n end\n end",
"def update\n @user = get_user(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to root_url, notice: \"User #{@user.login_name} was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = current_user\n if @user.update(user_params)\n # flash success\n redirect_to current_user\n else\n # hanle error\n render 'edit'\n end\n end",
"def update_current_user(user)\n @current_user = user if user\n end",
"def update\n @user = User.find(params[:id])\n\n unless current_user_or_admin\n flash[:warning] = 'Not signed in correctly'\n redirect_to root_url\n else\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def update\n\t\t@user = User.find(params(:id))\n\t\[email protected](user_params)\n\tend",
"def update\n @user = User.find(session[:user])\n\n respond_to do |format|\n if @user.update_attributes(user_params)\n session[:anon_user] = false\n format.html { redirect_to homepage_path, notice: 'Successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = current_user\n if @user.update_attributes(params[:user])\n flash[:notice] = 'Your profile has been successfully updated.'\n redirect_to user_path(@user)\n else\n render :action => 'edit'\n end\n end",
"def update\n if current_user.update_attributes(user_params)\n redirect_to current_user, notice: 'Profile successfully updated.'\n else\n render 'edit'\n end\n end",
"def update\n @user = User.find(params[:id])\n success = false\n if (session[:user] == @user || session[:user].admin == 1)\n success = @user.update_attributes(params[:user])\n if (success && session[:user].id == @user.id)\n session[:user] = @user\n end\n end\n \n respond_to do |format|\n if success\n flash[:notice] = \"User was successfully updated.\"\n if (session[:user] == @user)\n format.html { redirect_to (posts_url) }\n else\n format.html { redirect_to (users_url) }\n end\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @user.update_attributes(params[:user])\n if params[:user][:password].present?\n # this logic needed b/c devise wants to log us out after password changes\n user = Spree::User.reset_password_by_token(params[:user])\n sign_in(@user, :event => :authentication, :bypass => !Spree::Auth::Config[:signout_after_password_change])\n end\n if request.xhr?\n render \"spree/shared/close_dialog\"\n else\n redirect_to spree.account_url, :notice => Spree.t(:account_updated) \n end\n else\n render :edit\n end\n end",
"def update\n authorize User\n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # @user = User.find(params[:id]) - Now defined in authenticate function\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to(@user, :notice => 'User was successfully updated.') }\n format.xml { head :ok }\n else\n @title = \"Edit Profile\"\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @user.update(user_params)\n render json: @user, status: :ok, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @user.update_attributes params[:user]\n if @user.id == current_user.id\n flash[:notice] = \"Your account was successfully updated.\"\n else\n flash[:notice] = \"#{@user.full_name} account was successfully updated.\"\n end\n if current_user.administrator?\n redirect_to users_path\n else\n redirect_to dashboard_path\n end\n else\n render :action => :edit\n end\n end",
"def update\n if @user.update(user_params)\n respond_with(@user, location: users_url, notice: 'User was successfully updated.')\n else\n respond_with(@user)\n end\n end",
"def update\n @user = User.find(params[:id])\n redirect_to root_path unless current_user?(@user)\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { flash[:notice] = t('users.update.success'); redirect_to @user }\n format.json { head :no_content }\n else\n format.html { redirect_to edit_user_path }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @auth_user.update(auth_user_params)\n format.html { redirect_to @auth_user, notice: 'Auth user was successfully updated.' }\n format.json { render :show, status: :ok, location: @auth_user }\n else\n format.html { render :edit }\n format.json { render json: @auth_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\tif @user.update(user_params)\n\t\t\trender :show, status: :ok, location: @user\n\t\telse\n\t\t\trender json: @user.errors, status: :unprocessable_entity\n\t\tend\n\tend"
] |
[
"0.821561",
"0.79548657",
"0.79492974",
"0.79178166",
"0.7905321",
"0.78437024",
"0.78396714",
"0.7821266",
"0.7804185",
"0.7783493",
"0.77081215",
"0.7701761",
"0.7695824",
"0.76957476",
"0.76924604",
"0.7688464",
"0.7686972",
"0.76818967",
"0.76792693",
"0.7676387",
"0.76653266",
"0.7653759",
"0.765195",
"0.76471096",
"0.7633365",
"0.7629615",
"0.7616689",
"0.76147676",
"0.76064533",
"0.76029986",
"0.7602706",
"0.7602506",
"0.75995123",
"0.7598532",
"0.7598532",
"0.75970966",
"0.75887954",
"0.75883174",
"0.7580484",
"0.75688934",
"0.7561061",
"0.7545535",
"0.7544625",
"0.7542752",
"0.7541423",
"0.7536019",
"0.75350785",
"0.75325555",
"0.75305223",
"0.752413",
"0.7523961",
"0.75235474",
"0.7523113",
"0.751745",
"0.75156826",
"0.75089425",
"0.7507717",
"0.7504673",
"0.74913275",
"0.7480394",
"0.7478645",
"0.7467996",
"0.7467085",
"0.7461262",
"0.7455888",
"0.7452482",
"0.7451827",
"0.7451105",
"0.74497116",
"0.7449116",
"0.7449116",
"0.74449486",
"0.74429125",
"0.7438903",
"0.74321264",
"0.74283415",
"0.7428051",
"0.7427318",
"0.74247766",
"0.74209946",
"0.74172604",
"0.74141926",
"0.74127084",
"0.74080944",
"0.7402811",
"0.7402574",
"0.7401461",
"0.73996454",
"0.7393788",
"0.7387911",
"0.73750407",
"0.73748434",
"0.73725766",
"0.73719996",
"0.73714364",
"0.73695457",
"0.7367611",
"0.7366621",
"0.7363425",
"0.7361327"
] |
0.74866927
|
59
|
Not yet supported: get a single key, update an existing key
|
def keys(options={})
get("/user/keys", options, 3)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def updateKey; @key = getKey; self end",
"def new_key(old_key)\n key_store[old_key] || old_key\n end",
"def update\n if @key.update(key_params)\n render json: @key\n else\n render json: @key.errors, status: :unprocessable_entity\n end\n end",
"def set_key\n @key = Key.find(params[:id])\n end",
"def put(key, value)\n \n end",
"def get_and_set(key, value); end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n end",
"def put(key, value)\n obj = KeyValue.find_by_key(key)\n if obj\n KeyValue.update(obj.id, :value=>value)\n else\n KeyValue.create(:key=>key, :value=>value)\n end\n end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def put(key, value); end",
"def update(key, ctx); end",
"def update\n @key = Key.find(params[:id])\n\n respond_to do |format|\n if @key.update_attributes(params[:key])\n format.html { redirect_to @key, notice: 'Key was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @key.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get(key)\n end",
"def get(key)\n \n end",
"def get(key)\n end",
"def fetch(key); end",
"def put(key, value)\n @first.put(key, value)\n end",
"def rekey_as_needed; end",
"def put(key, value)\n\n # FIXME: insert code that connects to the backend and affects the put\n # operation\n #\n # - This delete should be done atomically\n # - Convert any exceptions into a failed status result with a meaningful\n # error message.\n #\n\n { :result => false, :err_msg => 'FIXME: not implemented' }\n end",
"def key=(key); end",
"def update!(**args)\n @key_id = args[:key_id] if args.key?(:key_id)\n @private_key = args[:private_key] if args.key?(:private_key)\n @team_id = args[:team_id] if args.key?(:team_id)\n end",
"def update!(**args)\n @key_id = args[:key_id] if args.key?(:key_id)\n @private_key = args[:private_key] if args.key?(:private_key)\n @team_id = args[:team_id] if args.key?(:team_id)\n end",
"def update!(**args)\n @key_id = args[:key_id] if args.key?(:key_id)\n @signature = args[:signature] if args.key?(:signature)\n end",
"def update!(**args)\n @key_id = args[:key_id] if args.key?(:key_id)\n @signature = args[:signature] if args.key?(:signature)\n end",
"def key=(new_key)\n @key = new_key\n end",
"def get key; call key; end",
"def key\n refresh_key unless key_valid?\n @key\n end",
"def for_key(key)\n begin\n raw = bucket.get(key)\n data = raw.data\n result = from_hash(data)\n result.key = key\n result\n rescue Riak::HTTPFailedRequest\n return nil\n end\n end",
"def reserve_key(key); end",
"def lookup_apiweb_key key\n apiweb_key_table_exists!\n \n entry = DB[:apiweb_key][:key => key]\n ## check project_id and user_id\n \n if Time.now > entry[:expiration]\n ## remove the entry?\n return nil ## what effect does this have on the client side?\n end\n \n entry\n end",
"def stored_key(key)\n h(key)\n end",
"def request_apiweb_key entry = {}\n apiweb_key_table_exists!\n \n entry[:expiration] ||= Time.now + 24*60*60 ## ?\n \n fields = DB.schema(:apiweb_key).map {|a|a.first}\n \n i = 0\n loop do\n i += 1\n key = digest(Time.now.to_f + i, *entry.values)\n \n if not DB[:apiweb_key][:key => key]\n entry[:key] = key\n \n e = {}\n fields.each do |field|\n e[field] = entry[field]\n end\n \n DB[:apiweb_key].insert e\n return key\n end\n end\n end",
"def incr(key); end",
"def incr(key); end",
"def write_key(*key); end",
"def update_api_key(key, object, validity = 0, max_queries_per_IP_per_hour = 0, max_hits_per_query = 0, request_options = {})\n if object.instance_of?(Array)\n params = { :acl => object }\n else\n params = object\n end\n\n params['validity'] = validity.to_i if validity != 0\n params['maxHitsPerQuery'] = max_hits_per_query.to_i if max_hits_per_query != 0\n params['maxQueriesPerIPPerHour'] = max_queries_per_IP_per_hour.to_i if max_queries_per_IP_per_hour != 0\n\n client.put(Protocol.index_key_uri(name, key), params.to_json, :write, request_options)\n end",
"def update!(**args)\n @key_id = args[:key_id] if args.key?(:key_id)\n @signed_jwt = args[:signed_jwt] if args.key?(:signed_jwt)\n end",
"def persist(key); end",
"def persist(key); end",
"def set_keyvalue\n @keyvalue = Keyvalue.find(params[:id])\n end",
"def new_key(school,key,value)\n school[key.to_sym] = value\nend",
"def read_key; end",
"def update_ssh_key(key)\n remove_ssh_key(key.name)\n add_ssh_key(key)\n end",
"def update!(**args)\n @key_type = args[:key_type] if args.key?(:key_type)\n @key_value = args[:key_value] if args.key?(:key_value)\n end",
"def update!(**args)\n @key_algorithm = args[:key_algorithm] if args.key?(:key_algorithm)\n @private_key_type = args[:private_key_type] if args.key?(:private_key_type)\n end",
"def update!(**args)\n @crypto_key = args[:crypto_key] if args.key?(:crypto_key)\n end",
"def update!(**args)\n @crypto_key = args[:crypto_key] if args.key?(:crypto_key)\n end",
"def invoke_write_key(key)\n write_key(key)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @security_origin = args[:security_origin] if args.key?(:security_origin)\n @value = args[:value] if args.key?(:value)\n end",
"def update_api_key!(key, opts = {})\n response = update_api_key(key, opts)\n\n response.wait(opts)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def key(options:, device: nil)\n get_device(device: device) do |device|\n oldId = dev_id(device: device)\n\n raise ExecutionError, \"No Key Found For Stage #{options[:stage]}\" unless @config.key\n\n # upload new key with password\n payload = {\n mysubmit: \"Rekey\",\n passwd: @config.key[:password],\n archive: Faraday::UploadIO.new(@config.key[:keyed_pkg], 'application/octet-stream')\n }\n multipart_connection(device: device) do |conn|\n conn.post \"/plugin_inspect\", payload\n end\n\n # check key\n newId = dev_id(device: device)\n @logger.info(\"Key did not change\") unless newId != oldId\n @logger.debug(oldId + \" -> \" + newId)\n end\n end",
"def update!(**args)\n @kms_key_name = args[:kms_key_name] if args.key?(:kms_key_name)\n end",
"def update!(**args)\n @kms_key_name = args[:kms_key_name] if args.key?(:kms_key_name)\n end",
"def update!(**args)\n @key_algorithm = args[:key_algorithm] if args.key?(:key_algorithm)\n @key_origin = args[:key_origin] if args.key?(:key_origin)\n @key_type = args[:key_type] if args.key?(:key_type)\n @name = args[:name] if args.key?(:name)\n @private_key_data = args[:private_key_data] if args.key?(:private_key_data)\n @private_key_type = args[:private_key_type] if args.key?(:private_key_type)\n @public_key_data = args[:public_key_data] if args.key?(:public_key_data)\n @valid_after_time = args[:valid_after_time] if args.key?(:valid_after_time)\n @valid_before_time = args[:valid_before_time] if args.key?(:valid_before_time)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def key2\n self.key('key2')\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def upgrade_api_key_for(user)\n user.update(api_key: 2)\n end",
"def [](key)\n key = lookup_key(key)\n return @new_info[key.to_s] if @new_info.has_key?(key.to_s)\n ensure_loaded\n @info[key.to_s]\n end",
"def update!(**args)\n @resource_key = args[:resource_key] if args.key?(:resource_key)\n end",
"def [](key)\n\t\tget key\n\tend",
"def update(key, value)\n set(key.to_sym => value)\n end",
"def exchange_keys; end",
"def exchange_keys; end",
"def put(key,value)\n open\n db[key] = value\n close \n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @type = args[:type] if args.key?(:type)\n end",
"def update\n @key_pair = KeyPair.find(params[:id])\n\n respond_to do |format|\n if @key_pair.update_attributes(params[:key_pair])\n format.html { redirect_to @key_pair, notice: 'Key pair was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @key_pair.errors, status: :unprocessable_entity }\n end\n end\n end",
"def [](key)\n @keychain[key]\n end"
] |
[
"0.7417697",
"0.68909425",
"0.6802164",
"0.6772694",
"0.67699873",
"0.6767558",
"0.6647971",
"0.6647971",
"0.66438013",
"0.6562377",
"0.6562377",
"0.6562377",
"0.6562377",
"0.65022016",
"0.6500539",
"0.64465487",
"0.63860345",
"0.63802797",
"0.6363611",
"0.6360637",
"0.63194793",
"0.6300854",
"0.62919855",
"0.6291743",
"0.62808967",
"0.62808967",
"0.6264609",
"0.6264609",
"0.6231284",
"0.6208745",
"0.61875933",
"0.6165155",
"0.6133435",
"0.61280024",
"0.611685",
"0.6098364",
"0.60760903",
"0.60760903",
"0.60745317",
"0.60693777",
"0.6034214",
"0.60258466",
"0.60258466",
"0.6018202",
"0.5998675",
"0.5993801",
"0.59841245",
"0.5979784",
"0.5976039",
"0.5975308",
"0.5975308",
"0.59748125",
"0.5960863",
"0.59604025",
"0.59489596",
"0.59489596",
"0.59489596",
"0.59489596",
"0.59489596",
"0.59489596",
"0.59489596",
"0.59489596",
"0.59489596",
"0.59489596",
"0.59489596",
"0.59489596",
"0.59489596",
"0.59489596",
"0.59489596",
"0.59489596",
"0.59489596",
"0.59489596",
"0.59489596",
"0.59489596",
"0.59489596",
"0.59489596",
"0.59489596",
"0.5947328",
"0.59434956",
"0.5933311",
"0.5933311",
"0.5931419",
"0.59116095",
"0.5910704",
"0.59098625",
"0.59098625",
"0.59098625",
"0.59098625",
"0.59098625",
"0.59098625",
"0.59004164",
"0.58928335",
"0.5892765",
"0.58794796",
"0.58775705",
"0.58744514",
"0.58744514",
"0.58671737",
"0.5865291",
"0.5855534",
"0.5854624"
] |
0.0
|
-1
|
Update properties of this object
|
def update!(**args)
@clusters = args[:clusters] unless args[:clusters].nil?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def refresh\n self.class.base_properties.each_with_index do |prop, prop_id|\n @properties[prop] = get_property(prop_id)\n end\n refresh_features\n refresh_status\n refresh_config\n self\n end",
"def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end",
"def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update_properties!(branch_id=nil)\n properties = fetch_properties(false, branch_id)\n length = properties.length\n counter = 0\n properties.each do |property|\n counter += 1\n if Vebra.debugging?\n puts \"[Vebra]: #{counter}/#{length}: live updating property with Vebra ref: #{property.attributes[:vebra_ref]}\"\n end\n live_update!(property)\n Vebra.set_last_updated_at(Time.now) if counter == length\n end\n end",
"def update_self obj\n obj.each do |k,v|\n instance_variable_set(\"@#{k}\", v) if v\n end\n end",
"def update_attributes(properties_hash)\n self.class.get_class_properties.each do |property|\n key = property[:name].to_sym\n if properties_hash.has_key? key\n self.setValue(properties_hash[key], forKey:key)\n end\n end\n end",
"def update\n # TODO: implement update\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @states = args[:states] if args.key?(:states)\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end",
"def update!(**args)\n @property = args[:property] if args.key?(:property)\n @total_value_count = args[:total_value_count] if args.key?(:total_value_count)\n @value = args[:value] if args.key?(:value)\n @value_status = args[:value_status] if args.key?(:value_status)\n end",
"def update\n \n end",
"def refresh\n set_attributes\n end",
"def update(attrs)\n @attrs.update(attrs)\n self\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @source = args[:source] if args.key?(:source)\n end",
"def update_resource object, attributes\n object.update attributes\n end",
"def update(attrs)\n @attrs ||= {}\n @attrs.update(attrs)\n self\n end",
"def update\n \n end",
"def update!(**args)\n @property = args[:property] if args.key?(:property)\n @schema = args[:schema] if args.key?(:schema)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def update(attributes = {})\n super(attributes)\n retrieve!\n self\n end",
"def update\n @objects.map(&:update);\n end",
"def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end",
"def update\n raise NotImplementedError\n end",
"def update\n raise NotImplementedError\n end",
"def live_update!(property)\n property_class = Vebra.models[:property][:class].to_s.camelize.constantize\n\n # ensure we have the full property attributes\n property.get_property if !property.attributes[:status] && property.attributes[:action] != 'deleted'\n\n # find & update or build a new property\n property_model = property_class.find_or_initialize_by_vebra_ref(property.attributes[:vebra_ref])\n\n # make sure property object is not empty\n return false if !property.attributes || !property.attributes[:property_type]\n\n # if the property has been deleted, mark it appropriately and move on\n if property.attributes[:action] == 'deleted'\n return property_model.destroy\n end\n\n # extract accessible attributes for the property\n property_accessibles = property_class.accessible_attributes.map(&:to_sym)\n property_attributes = property.attributes.inject({}) do |result, (key, value)|\n result[key] = value if property_accessibles.include?(key)\n result\n end\n\n # update the property model's attributes\n property_model.no_callbacks = true if property_model.respond_to?(:no_callbacks)\n property_model.update_attributes(property_attributes)\n\n # find & update or build a new address\n if Vebra.models[:address]\n address_class = Vebra.models[:address][:class].to_s.camelize.constantize\n address_model = property_model.send(Vebra.models[:property][:address_method])\n address_model = property_model.send(\"build_#{Vebra.models[:property][:address_method]}\") unless address_model\n\n # extract accessible attributes for the address\n address_accessibles = address_class.accessible_attributes.map(&:to_sym)\n address_attributes = property.attributes[:address].inject({}) do |result, (key, value)|\n result[key] = value if address_accessibles.include?(key)\n result\n end\n\n # update the address model's attributes\n address_model.update_attributes(address_attributes)\n end\n\n # find & update or build new rooms\n if Vebra.models[:room]\n room_class = Vebra.models[:room][:class].to_s.camelize.constantize\n\n # accessible attributes for the rooms\n room_accessibles = room_class.accessible_attributes.map(&:to_sym)\n\n # delete any rooms which are no longer present\n property_rooms = property.attributes[:rooms] || []\n property_model_rooms = property_model.send(Vebra.models[:property][:rooms_method])\n refs_to_delete = property_model_rooms.map(&:vebra_ref) - property_rooms.map { |r| r[:vebra_ref] }\n property_model_rooms.each do |room|\n room.destroy if refs_to_delete.include?(room.vebra_ref)\n end\n\n # find & update or build new rooms\n property_rooms.each do |room|\n room_model = room_class.find_by_property_id_and_vebra_ref(property_model.id, room[:vebra_ref])\n room_model = property_model_rooms.build unless room_model\n\n # extract accessible attributes for the room\n room_attributes = room.inject({}) do |result, (key, value)|\n result[key] = value if room_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n room_model.update_attributes(room_attributes)\n end\n end\n\n # find & update or build new file attachments\n if Vebra.models[:file]\n file_class = Vebra.models[:file][:class].to_s.camelize.constantize\n\n # accessible attributes for the files\n file_accessibles = file_class.accessible_attributes.map(&:to_sym)\n\n # first normalize the collection (currently nested collections)\n property_files = property.attributes[:files].inject([]) do |result, (kind, collection)|\n collection.each do |file|\n file[:type] = kind.to_s.singularize.camelize if file_accessibles.include?(:type)\n file[\"remote_#{Vebra.models[:file][:attachment_method]}_url\".to_sym] = file.delete(:url)\n # if file[:type] is set, it means the attachment file class can be subclassed. In this\n # case we need to ensure that the subclass exists. If not, we ignore this file\n begin\n file[:type].constantize if file_accessibles.include?(:type)\n result << file\n rescue NameError => e\n # ignore - this means the subclass does not exist\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n\n result\n end\n\n # delete any files which are no longer present\n property_model_files = property_model.send(Vebra.models[:property][:files_method])\n refs_to_delete = property_model_files.map(&:vebra_ref) - property_files.map { |f| f[:vebra_ref] }\n property_model_files.each do |file|\n file.destroy if refs_to_delete.include?(file.vebra_ref)\n end\n\n # find & update or build new files\n property_files.each do |file|\n begin\n file_model = property_model_files.find_by_vebra_ref(file[:vebra_ref])\n file_model = property_model_files.build unless file_model\n\n # extract accessible attributes for the file\n file_attributes = file.inject({}) do |result, (key, value)|\n result[key] = value if file_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n file_model.update_attributes(file_attributes)\n rescue CarrierWave::ProcessingError, OpenURI::HTTPError => e\n # just ignore the file\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n end\n\n property_model.no_callbacks = false if property_model.respond_to?(:no_callbacks)\n property_model.save\n return property_model\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def update\n end",
"def update!(**args)\n @mid = args[:mid] if args.key?(:mid)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def modified_properties=(value)\n @modified_properties = value\n end",
"def apply_properties!(properties)\n # Non-commutitivity etc. eventually.\n end",
"def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end",
"def update\n\t\t\n\t\tend",
"def set_props(props)\n @props.merge!(props)\n end",
"def update() end",
"def update!(**args)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def assign_properties\n self.properties ||= {}\n listing_properties.each do |prop|\n self.properties[prop.key] ||= prop.value\n end\n end",
"def change_properties(new_current_floor, new_next_floor, new_movement)\n @current_floor = new_current_floor\n @next_floor = new_next_floor\n @movement = new_movement\n end",
"def update!(**args)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end",
"def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end",
"def update(attributes)\n (@attributes ||= {}).merge! attributes\n\n (self.class.attr_initializables & attributes.keys).each do |name|\n instance_variable_set :\"@#{name}\", attributes[name]\n end\n\n self\n end",
"def update_attributes(attrs)\n super({})\n end",
"def update\n @dirty = true\n end",
"def update\n\n # Run through the mixin updates\n colourable_update\n movable_update\n\n end",
"def set(props)\n props.each do |prop, val|\n self.send(:\"#{ prop }=\", val)\n end\n end",
"def update\n super\n end",
"def update!(**args)\n @property_id = args[:property_id] if args.key?(:property_id)\n @value_status = args[:value_status] if args.key?(:value_status)\n end",
"def update!(**args)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end",
"def movable_update\n\n # Work through the different aspects we update\n movable_location_update\n movable_size_update\n movable_angle_update\n\n end",
"def update(attrs)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value) if respond_to?(\"#{key}=\")\n # attributes[key] = value <- lets make use of virtual attributes too\n end\n end",
"def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'id'}.merge(m2o.merge(m2o){|k, v| v.is_a?(Array) ? v[0] : v})\n self.class.rpc_execute('write', self.id, vals, context)\n reload_from_record!(self.class.find(self.id, :context => context))\n end",
"def properties=(value)\n @properties = value\n end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update ; end",
"def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end",
"def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end",
"def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end",
"def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end",
"def update_with(attributes)\n assign_attributes(attributes)\n end",
"def update\n # don't need to update; hash is shared\n end",
"def update(attributes)\n HashProxy.with(attributes) do |proxy|\n self.class.attribute_names.each do |name|\n send(\"#{name}=\", proxy[name]) if proxy.key?(name)\n end\n end\n save\n end",
"def update!(**args)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @relation = args[:relation] if args.key?(:relation)\n @subject_id = args[:subject_id] if args.key?(:subject_id)\n end",
"def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end",
"def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end",
"def update\n raise NotImplementedError\n end",
"def update_attributes attributes\n @attributes.merge! attributes\n end",
"def update!(**args)\n @async_options = args[:async_options] if args.key?(:async_options)\n @input_mappings = args[:input_mappings] if args.key?(:input_mappings)\n @name_property = args[:name_property] if args.key?(:name_property)\n @validation_options = args[:validation_options] if args.key?(:validation_options)\n end",
"def update\r\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @type = args[:type] if args.key?(:type)\n end",
"def update\n raise NotImplemented\n end",
"def update_obj\n mean, sd = rating.to_glicko_rating\n @obj.rating = mean\n @obj.rating_deviation = sd\n @obj.volatility = volatility\n end",
"def update_values\n end",
"def update_values\n end",
"def update\n raise NotImplementedError\n end",
"def update!(**args)\n @answers_header_signals = args[:answers_header_signals] if args.key?(:answers_header_signals)\n @property_value = args[:property_value] if args.key?(:property_value)\n @response_meaning_application = args[:response_meaning_application] if args.key?(:response_meaning_application)\n end",
"def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @name = args[:name] if args.key?(:name)\n @state = args[:state] if args.key?(:state)\n end",
"def update attributes, collection #:nodoc:\n 0\n end",
"def update_property_groups(roll)\n @property_groups.each { |_, v| v.update_rent(roll) }\n end",
"def update!(**args)\n @source_property = args[:source_property] if args.key?(:source_property)\n end",
"def update_info(update_attr_hash)\n update_attr_hash.each do |k,v| \n\t\t\tself.send(\"#{k}=\",v)\n\t\tend\n end",
"def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end",
"def update\n set_deltatime\n set_last_update_at\n end"
] |
[
"0.701199",
"0.69196975",
"0.69196975",
"0.69196975",
"0.69196975",
"0.69196975",
"0.6739846",
"0.6709455",
"0.6709455",
"0.6698214",
"0.6698214",
"0.6698214",
"0.6698214",
"0.6619038",
"0.65719074",
"0.65380937",
"0.6519628",
"0.63961416",
"0.63910294",
"0.63910294",
"0.633522",
"0.63217974",
"0.62848955",
"0.6272008",
"0.62658215",
"0.62434864",
"0.62196386",
"0.6217854",
"0.6212097",
"0.6205346",
"0.6205346",
"0.6203888",
"0.62035936",
"0.62032425",
"0.6175266",
"0.6175266",
"0.61603904",
"0.61579055",
"0.6147466",
"0.61266834",
"0.6123028",
"0.61209583",
"0.61099416",
"0.61086744",
"0.61016953",
"0.60872084",
"0.6084747",
"0.60634464",
"0.6060025",
"0.6056291",
"0.6052406",
"0.6052406",
"0.6042521",
"0.6032689",
"0.60252035",
"0.6015576",
"0.599316",
"0.5991414",
"0.59785795",
"0.59759766",
"0.5967381",
"0.59643847",
"0.59637874",
"0.59619164",
"0.595378",
"0.595378",
"0.595378",
"0.595378",
"0.595378",
"0.595378",
"0.595378",
"0.595378",
"0.5953092",
"0.5946346",
"0.5946346",
"0.5942476",
"0.5942476",
"0.593757",
"0.5928377",
"0.5926473",
"0.59262335",
"0.5925231",
"0.5925231",
"0.5923493",
"0.59170985",
"0.5916205",
"0.5892186",
"0.5887701",
"0.5885531",
"0.587995",
"0.58796585",
"0.58796585",
"0.5876966",
"0.58603",
"0.5848133",
"0.584427",
"0.5837102",
"0.5830354",
"0.58300084",
"0.5823333",
"0.58222914"
] |
0.0
|
-1
|
Update properties of this object
|
def update!(**args)
@name = args[:name] unless args[:name].nil?
@description = args[:description] unless args[:description].nil?
@initial_node_count = args[:initial_node_count] unless args[:initial_node_count].nil?
@node_config = args[:node_config] unless args[:node_config].nil?
@master_auth = args[:master_auth] unless args[:master_auth].nil?
@logging_service = args[:logging_service] unless args[:logging_service].nil?
@monitoring_service = args[:monitoring_service] unless args[:monitoring_service].nil?
@network = args[:network] unless args[:network].nil?
@cluster_ipv4_cidr = args[:cluster_ipv4_cidr] unless args[:cluster_ipv4_cidr].nil?
@self_link = args[:self_link] unless args[:self_link].nil?
@zone = args[:zone] unless args[:zone].nil?
@endpoint = args[:endpoint] unless args[:endpoint].nil?
@initial_cluster_version = args[:initial_cluster_version] unless args[:initial_cluster_version].nil?
@current_master_version = args[:current_master_version] unless args[:current_master_version].nil?
@current_node_version = args[:current_node_version] unless args[:current_node_version].nil?
@create_time = args[:create_time] unless args[:create_time].nil?
@status = args[:status] unless args[:status].nil?
@status_message = args[:status_message] unless args[:status_message].nil?
@node_ipv4_cidr_size = args[:node_ipv4_cidr_size] unless args[:node_ipv4_cidr_size].nil?
@services_ipv4_cidr = args[:services_ipv4_cidr] unless args[:services_ipv4_cidr].nil?
@instance_group_urls = args[:instance_group_urls] unless args[:instance_group_urls].nil?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def refresh\n self.class.base_properties.each_with_index do |prop, prop_id|\n @properties[prop] = get_property(prop_id)\n end\n refresh_features\n refresh_status\n refresh_config\n self\n end",
"def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end",
"def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update_properties!(branch_id=nil)\n properties = fetch_properties(false, branch_id)\n length = properties.length\n counter = 0\n properties.each do |property|\n counter += 1\n if Vebra.debugging?\n puts \"[Vebra]: #{counter}/#{length}: live updating property with Vebra ref: #{property.attributes[:vebra_ref]}\"\n end\n live_update!(property)\n Vebra.set_last_updated_at(Time.now) if counter == length\n end\n end",
"def update_self obj\n obj.each do |k,v|\n instance_variable_set(\"@#{k}\", v) if v\n end\n end",
"def update_attributes(properties_hash)\n self.class.get_class_properties.each do |property|\n key = property[:name].to_sym\n if properties_hash.has_key? key\n self.setValue(properties_hash[key], forKey:key)\n end\n end\n end",
"def update\n # TODO: implement update\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @states = args[:states] if args.key?(:states)\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end",
"def update!(**args)\n @property = args[:property] if args.key?(:property)\n @total_value_count = args[:total_value_count] if args.key?(:total_value_count)\n @value = args[:value] if args.key?(:value)\n @value_status = args[:value_status] if args.key?(:value_status)\n end",
"def update\n \n end",
"def refresh\n set_attributes\n end",
"def update(attrs)\n @attrs.update(attrs)\n self\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @source = args[:source] if args.key?(:source)\n end",
"def update_resource object, attributes\n object.update attributes\n end",
"def update(attrs)\n @attrs ||= {}\n @attrs.update(attrs)\n self\n end",
"def update\n \n end",
"def update!(**args)\n @property = args[:property] if args.key?(:property)\n @schema = args[:schema] if args.key?(:schema)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def update\n @objects.map(&:update);\n end",
"def update(attributes = {})\n super(attributes)\n retrieve!\n self\n end",
"def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end",
"def update\n raise NotImplementedError\n end",
"def update\n raise NotImplementedError\n end",
"def live_update!(property)\n property_class = Vebra.models[:property][:class].to_s.camelize.constantize\n\n # ensure we have the full property attributes\n property.get_property if !property.attributes[:status] && property.attributes[:action] != 'deleted'\n\n # find & update or build a new property\n property_model = property_class.find_or_initialize_by_vebra_ref(property.attributes[:vebra_ref])\n\n # make sure property object is not empty\n return false if !property.attributes || !property.attributes[:property_type]\n\n # if the property has been deleted, mark it appropriately and move on\n if property.attributes[:action] == 'deleted'\n return property_model.destroy\n end\n\n # extract accessible attributes for the property\n property_accessibles = property_class.accessible_attributes.map(&:to_sym)\n property_attributes = property.attributes.inject({}) do |result, (key, value)|\n result[key] = value if property_accessibles.include?(key)\n result\n end\n\n # update the property model's attributes\n property_model.no_callbacks = true if property_model.respond_to?(:no_callbacks)\n property_model.update_attributes(property_attributes)\n\n # find & update or build a new address\n if Vebra.models[:address]\n address_class = Vebra.models[:address][:class].to_s.camelize.constantize\n address_model = property_model.send(Vebra.models[:property][:address_method])\n address_model = property_model.send(\"build_#{Vebra.models[:property][:address_method]}\") unless address_model\n\n # extract accessible attributes for the address\n address_accessibles = address_class.accessible_attributes.map(&:to_sym)\n address_attributes = property.attributes[:address].inject({}) do |result, (key, value)|\n result[key] = value if address_accessibles.include?(key)\n result\n end\n\n # update the address model's attributes\n address_model.update_attributes(address_attributes)\n end\n\n # find & update or build new rooms\n if Vebra.models[:room]\n room_class = Vebra.models[:room][:class].to_s.camelize.constantize\n\n # accessible attributes for the rooms\n room_accessibles = room_class.accessible_attributes.map(&:to_sym)\n\n # delete any rooms which are no longer present\n property_rooms = property.attributes[:rooms] || []\n property_model_rooms = property_model.send(Vebra.models[:property][:rooms_method])\n refs_to_delete = property_model_rooms.map(&:vebra_ref) - property_rooms.map { |r| r[:vebra_ref] }\n property_model_rooms.each do |room|\n room.destroy if refs_to_delete.include?(room.vebra_ref)\n end\n\n # find & update or build new rooms\n property_rooms.each do |room|\n room_model = room_class.find_by_property_id_and_vebra_ref(property_model.id, room[:vebra_ref])\n room_model = property_model_rooms.build unless room_model\n\n # extract accessible attributes for the room\n room_attributes = room.inject({}) do |result, (key, value)|\n result[key] = value if room_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n room_model.update_attributes(room_attributes)\n end\n end\n\n # find & update or build new file attachments\n if Vebra.models[:file]\n file_class = Vebra.models[:file][:class].to_s.camelize.constantize\n\n # accessible attributes for the files\n file_accessibles = file_class.accessible_attributes.map(&:to_sym)\n\n # first normalize the collection (currently nested collections)\n property_files = property.attributes[:files].inject([]) do |result, (kind, collection)|\n collection.each do |file|\n file[:type] = kind.to_s.singularize.camelize if file_accessibles.include?(:type)\n file[\"remote_#{Vebra.models[:file][:attachment_method]}_url\".to_sym] = file.delete(:url)\n # if file[:type] is set, it means the attachment file class can be subclassed. In this\n # case we need to ensure that the subclass exists. If not, we ignore this file\n begin\n file[:type].constantize if file_accessibles.include?(:type)\n result << file\n rescue NameError => e\n # ignore - this means the subclass does not exist\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n\n result\n end\n\n # delete any files which are no longer present\n property_model_files = property_model.send(Vebra.models[:property][:files_method])\n refs_to_delete = property_model_files.map(&:vebra_ref) - property_files.map { |f| f[:vebra_ref] }\n property_model_files.each do |file|\n file.destroy if refs_to_delete.include?(file.vebra_ref)\n end\n\n # find & update or build new files\n property_files.each do |file|\n begin\n file_model = property_model_files.find_by_vebra_ref(file[:vebra_ref])\n file_model = property_model_files.build unless file_model\n\n # extract accessible attributes for the file\n file_attributes = file.inject({}) do |result, (key, value)|\n result[key] = value if file_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n file_model.update_attributes(file_attributes)\n rescue CarrierWave::ProcessingError, OpenURI::HTTPError => e\n # just ignore the file\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n end\n\n property_model.no_callbacks = false if property_model.respond_to?(:no_callbacks)\n property_model.save\n return property_model\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def update\n end",
"def update!(**args)\n @mid = args[:mid] if args.key?(:mid)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def modified_properties=(value)\n @modified_properties = value\n end",
"def apply_properties!(properties)\n # Non-commutitivity etc. eventually.\n end",
"def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end",
"def update\n\t\t\n\t\tend",
"def set_props(props)\n @props.merge!(props)\n end",
"def update() end",
"def update!(**args)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def assign_properties\n self.properties ||= {}\n listing_properties.each do |prop|\n self.properties[prop.key] ||= prop.value\n end\n end",
"def change_properties(new_current_floor, new_next_floor, new_movement)\n @current_floor = new_current_floor\n @next_floor = new_next_floor\n @movement = new_movement\n end",
"def update!(**args)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end",
"def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end",
"def update(attributes)\n (@attributes ||= {}).merge! attributes\n\n (self.class.attr_initializables & attributes.keys).each do |name|\n instance_variable_set :\"@#{name}\", attributes[name]\n end\n\n self\n end",
"def update_attributes(attrs)\n super({})\n end",
"def update\n @dirty = true\n end",
"def update\n\n # Run through the mixin updates\n colourable_update\n movable_update\n\n end",
"def set(props)\n props.each do |prop, val|\n self.send(:\"#{ prop }=\", val)\n end\n end",
"def update\n super\n end",
"def update!(**args)\n @property_id = args[:property_id] if args.key?(:property_id)\n @value_status = args[:value_status] if args.key?(:value_status)\n end",
"def update!(**args)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end",
"def movable_update\n\n # Work through the different aspects we update\n movable_location_update\n movable_size_update\n movable_angle_update\n\n end",
"def update(attrs)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value) if respond_to?(\"#{key}=\")\n # attributes[key] = value <- lets make use of virtual attributes too\n end\n end",
"def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'id'}.merge(m2o.merge(m2o){|k, v| v.is_a?(Array) ? v[0] : v})\n self.class.rpc_execute('write', self.id, vals, context)\n reload_from_record!(self.class.find(self.id, :context => context))\n end",
"def properties=(value)\n @properties = value\n end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update ; end",
"def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end",
"def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end",
"def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end",
"def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end",
"def update_with(attributes)\n assign_attributes(attributes)\n end",
"def update(attributes)\n HashProxy.with(attributes) do |proxy|\n self.class.attribute_names.each do |name|\n send(\"#{name}=\", proxy[name]) if proxy.key?(name)\n end\n end\n save\n end",
"def update\n # don't need to update; hash is shared\n end",
"def update!(**args)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @relation = args[:relation] if args.key?(:relation)\n @subject_id = args[:subject_id] if args.key?(:subject_id)\n end",
"def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end",
"def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end",
"def update\n raise NotImplementedError\n end",
"def update_attributes attributes\n @attributes.merge! attributes\n end",
"def update!(**args)\n @async_options = args[:async_options] if args.key?(:async_options)\n @input_mappings = args[:input_mappings] if args.key?(:input_mappings)\n @name_property = args[:name_property] if args.key?(:name_property)\n @validation_options = args[:validation_options] if args.key?(:validation_options)\n end",
"def update\r\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @type = args[:type] if args.key?(:type)\n end",
"def update\n raise NotImplemented\n end",
"def update_values\n end",
"def update_values\n end",
"def update_obj\n mean, sd = rating.to_glicko_rating\n @obj.rating = mean\n @obj.rating_deviation = sd\n @obj.volatility = volatility\n end",
"def update\n raise NotImplementedError\n end",
"def update!(**args)\n @answers_header_signals = args[:answers_header_signals] if args.key?(:answers_header_signals)\n @property_value = args[:property_value] if args.key?(:property_value)\n @response_meaning_application = args[:response_meaning_application] if args.key?(:response_meaning_application)\n end",
"def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @name = args[:name] if args.key?(:name)\n @state = args[:state] if args.key?(:state)\n end",
"def update attributes, collection #:nodoc:\n 0\n end",
"def update_property_groups(roll)\n @property_groups.each { |_, v| v.update_rent(roll) }\n end",
"def update_info(update_attr_hash)\n update_attr_hash.each do |k,v| \n\t\t\tself.send(\"#{k}=\",v)\n\t\tend\n end",
"def update!(**args)\n @source_property = args[:source_property] if args.key?(:source_property)\n end",
"def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end",
"def update\n set_deltatime\n set_last_update_at\n end"
] |
[
"0.70132464",
"0.6920457",
"0.6920457",
"0.6920457",
"0.6920457",
"0.6920457",
"0.6739106",
"0.67094105",
"0.67094105",
"0.6698272",
"0.6698272",
"0.6698272",
"0.6698272",
"0.66193163",
"0.6571397",
"0.65391916",
"0.65189683",
"0.63971996",
"0.6391746",
"0.6391746",
"0.6335592",
"0.63222075",
"0.6284795",
"0.6272826",
"0.6266276",
"0.62445426",
"0.6220532",
"0.62182385",
"0.6212645",
"0.62060225",
"0.62060225",
"0.6204405",
"0.62037367",
"0.62033343",
"0.6175208",
"0.6175208",
"0.6160814",
"0.61582965",
"0.61476904",
"0.6127003",
"0.6123051",
"0.6121205",
"0.6110905",
"0.6108608",
"0.6101966",
"0.60876054",
"0.6085846",
"0.6062841",
"0.6061156",
"0.6056585",
"0.6052693",
"0.6052693",
"0.6043685",
"0.6033157",
"0.6025351",
"0.60159266",
"0.5993925",
"0.5990626",
"0.5979035",
"0.5976204",
"0.5968214",
"0.5965481",
"0.59641904",
"0.59613895",
"0.5954287",
"0.5954287",
"0.5954287",
"0.5954287",
"0.5954287",
"0.5954287",
"0.5954287",
"0.5954287",
"0.59536684",
"0.5946672",
"0.5946672",
"0.5941739",
"0.5941739",
"0.5939253",
"0.59279716",
"0.5927805",
"0.59267306",
"0.5925468",
"0.5925468",
"0.5923566",
"0.5918234",
"0.5917259",
"0.5892836",
"0.58884555",
"0.58857834",
"0.58803475",
"0.58803475",
"0.5879918",
"0.58770925",
"0.5861099",
"0.5849016",
"0.58443546",
"0.5837124",
"0.5830856",
"0.5830422",
"0.58239174",
"0.5823106"
] |
0.0
|
-1
|
Update properties of this object
|
def update!(**args)
@machine_type = args[:machine_type] unless args[:machine_type].nil?
@disk_size_gb = args[:disk_size_gb] unless args[:disk_size_gb].nil?
@oauth_scopes = args[:oauth_scopes] unless args[:oauth_scopes].nil?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def refresh\n self.class.base_properties.each_with_index do |prop, prop_id|\n @properties[prop] = get_property(prop_id)\n end\n refresh_features\n refresh_status\n refresh_config\n self\n end",
"def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end",
"def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update_properties!(branch_id=nil)\n properties = fetch_properties(false, branch_id)\n length = properties.length\n counter = 0\n properties.each do |property|\n counter += 1\n if Vebra.debugging?\n puts \"[Vebra]: #{counter}/#{length}: live updating property with Vebra ref: #{property.attributes[:vebra_ref]}\"\n end\n live_update!(property)\n Vebra.set_last_updated_at(Time.now) if counter == length\n end\n end",
"def update_self obj\n obj.each do |k,v|\n instance_variable_set(\"@#{k}\", v) if v\n end\n end",
"def update_attributes(properties_hash)\n self.class.get_class_properties.each do |property|\n key = property[:name].to_sym\n if properties_hash.has_key? key\n self.setValue(properties_hash[key], forKey:key)\n end\n end\n end",
"def update\n # TODO: implement update\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @states = args[:states] if args.key?(:states)\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end",
"def update!(**args)\n @property = args[:property] if args.key?(:property)\n @total_value_count = args[:total_value_count] if args.key?(:total_value_count)\n @value = args[:value] if args.key?(:value)\n @value_status = args[:value_status] if args.key?(:value_status)\n end",
"def update\n \n end",
"def refresh\n set_attributes\n end",
"def update(attrs)\n @attrs.update(attrs)\n self\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @source = args[:source] if args.key?(:source)\n end",
"def update_resource object, attributes\n object.update attributes\n end",
"def update(attrs)\n @attrs ||= {}\n @attrs.update(attrs)\n self\n end",
"def update\n \n end",
"def update!(**args)\n @property = args[:property] if args.key?(:property)\n @schema = args[:schema] if args.key?(:schema)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end",
"def update(attributes = {})\n super(attributes)\n retrieve!\n self\n end",
"def update\n @objects.map(&:update);\n end",
"def update\n raise NotImplementedError\n end",
"def update\n raise NotImplementedError\n end",
"def live_update!(property)\n property_class = Vebra.models[:property][:class].to_s.camelize.constantize\n\n # ensure we have the full property attributes\n property.get_property if !property.attributes[:status] && property.attributes[:action] != 'deleted'\n\n # find & update or build a new property\n property_model = property_class.find_or_initialize_by_vebra_ref(property.attributes[:vebra_ref])\n\n # make sure property object is not empty\n return false if !property.attributes || !property.attributes[:property_type]\n\n # if the property has been deleted, mark it appropriately and move on\n if property.attributes[:action] == 'deleted'\n return property_model.destroy\n end\n\n # extract accessible attributes for the property\n property_accessibles = property_class.accessible_attributes.map(&:to_sym)\n property_attributes = property.attributes.inject({}) do |result, (key, value)|\n result[key] = value if property_accessibles.include?(key)\n result\n end\n\n # update the property model's attributes\n property_model.no_callbacks = true if property_model.respond_to?(:no_callbacks)\n property_model.update_attributes(property_attributes)\n\n # find & update or build a new address\n if Vebra.models[:address]\n address_class = Vebra.models[:address][:class].to_s.camelize.constantize\n address_model = property_model.send(Vebra.models[:property][:address_method])\n address_model = property_model.send(\"build_#{Vebra.models[:property][:address_method]}\") unless address_model\n\n # extract accessible attributes for the address\n address_accessibles = address_class.accessible_attributes.map(&:to_sym)\n address_attributes = property.attributes[:address].inject({}) do |result, (key, value)|\n result[key] = value if address_accessibles.include?(key)\n result\n end\n\n # update the address model's attributes\n address_model.update_attributes(address_attributes)\n end\n\n # find & update or build new rooms\n if Vebra.models[:room]\n room_class = Vebra.models[:room][:class].to_s.camelize.constantize\n\n # accessible attributes for the rooms\n room_accessibles = room_class.accessible_attributes.map(&:to_sym)\n\n # delete any rooms which are no longer present\n property_rooms = property.attributes[:rooms] || []\n property_model_rooms = property_model.send(Vebra.models[:property][:rooms_method])\n refs_to_delete = property_model_rooms.map(&:vebra_ref) - property_rooms.map { |r| r[:vebra_ref] }\n property_model_rooms.each do |room|\n room.destroy if refs_to_delete.include?(room.vebra_ref)\n end\n\n # find & update or build new rooms\n property_rooms.each do |room|\n room_model = room_class.find_by_property_id_and_vebra_ref(property_model.id, room[:vebra_ref])\n room_model = property_model_rooms.build unless room_model\n\n # extract accessible attributes for the room\n room_attributes = room.inject({}) do |result, (key, value)|\n result[key] = value if room_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n room_model.update_attributes(room_attributes)\n end\n end\n\n # find & update or build new file attachments\n if Vebra.models[:file]\n file_class = Vebra.models[:file][:class].to_s.camelize.constantize\n\n # accessible attributes for the files\n file_accessibles = file_class.accessible_attributes.map(&:to_sym)\n\n # first normalize the collection (currently nested collections)\n property_files = property.attributes[:files].inject([]) do |result, (kind, collection)|\n collection.each do |file|\n file[:type] = kind.to_s.singularize.camelize if file_accessibles.include?(:type)\n file[\"remote_#{Vebra.models[:file][:attachment_method]}_url\".to_sym] = file.delete(:url)\n # if file[:type] is set, it means the attachment file class can be subclassed. In this\n # case we need to ensure that the subclass exists. If not, we ignore this file\n begin\n file[:type].constantize if file_accessibles.include?(:type)\n result << file\n rescue NameError => e\n # ignore - this means the subclass does not exist\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n\n result\n end\n\n # delete any files which are no longer present\n property_model_files = property_model.send(Vebra.models[:property][:files_method])\n refs_to_delete = property_model_files.map(&:vebra_ref) - property_files.map { |f| f[:vebra_ref] }\n property_model_files.each do |file|\n file.destroy if refs_to_delete.include?(file.vebra_ref)\n end\n\n # find & update or build new files\n property_files.each do |file|\n begin\n file_model = property_model_files.find_by_vebra_ref(file[:vebra_ref])\n file_model = property_model_files.build unless file_model\n\n # extract accessible attributes for the file\n file_attributes = file.inject({}) do |result, (key, value)|\n result[key] = value if file_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n file_model.update_attributes(file_attributes)\n rescue CarrierWave::ProcessingError, OpenURI::HTTPError => e\n # just ignore the file\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n end\n\n property_model.no_callbacks = false if property_model.respond_to?(:no_callbacks)\n property_model.save\n return property_model\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def update\n end",
"def update!(**args)\n @mid = args[:mid] if args.key?(:mid)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def modified_properties=(value)\n @modified_properties = value\n end",
"def apply_properties!(properties)\n # Non-commutitivity etc. eventually.\n end",
"def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end",
"def update\n\t\t\n\t\tend",
"def set_props(props)\n @props.merge!(props)\n end",
"def update() end",
"def update!(**args)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def assign_properties\n self.properties ||= {}\n listing_properties.each do |prop|\n self.properties[prop.key] ||= prop.value\n end\n end",
"def change_properties(new_current_floor, new_next_floor, new_movement)\n @current_floor = new_current_floor\n @next_floor = new_next_floor\n @movement = new_movement\n end",
"def update!(**args)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end",
"def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end",
"def update(attributes)\n (@attributes ||= {}).merge! attributes\n\n (self.class.attr_initializables & attributes.keys).each do |name|\n instance_variable_set :\"@#{name}\", attributes[name]\n end\n\n self\n end",
"def update_attributes(attrs)\n super({})\n end",
"def update\n @dirty = true\n end",
"def update\n\n # Run through the mixin updates\n colourable_update\n movable_update\n\n end",
"def set(props)\n props.each do |prop, val|\n self.send(:\"#{ prop }=\", val)\n end\n end",
"def update\n super\n end",
"def update!(**args)\n @property_id = args[:property_id] if args.key?(:property_id)\n @value_status = args[:value_status] if args.key?(:value_status)\n end",
"def update!(**args)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end",
"def movable_update\n\n # Work through the different aspects we update\n movable_location_update\n movable_size_update\n movable_angle_update\n\n end",
"def properties=(value)\n @properties = value\n end",
"def update(attrs)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value) if respond_to?(\"#{key}=\")\n # attributes[key] = value <- lets make use of virtual attributes too\n end\n end",
"def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'id'}.merge(m2o.merge(m2o){|k, v| v.is_a?(Array) ? v[0] : v})\n self.class.rpc_execute('write', self.id, vals, context)\n reload_from_record!(self.class.find(self.id, :context => context))\n end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update ; end",
"def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end",
"def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end",
"def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end",
"def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end",
"def update_with(attributes)\n assign_attributes(attributes)\n end",
"def update\n # don't need to update; hash is shared\n end",
"def update(attributes)\n HashProxy.with(attributes) do |proxy|\n self.class.attribute_names.each do |name|\n send(\"#{name}=\", proxy[name]) if proxy.key?(name)\n end\n end\n save\n end",
"def update!(**args)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @relation = args[:relation] if args.key?(:relation)\n @subject_id = args[:subject_id] if args.key?(:subject_id)\n end",
"def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end",
"def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end",
"def update\n raise NotImplementedError\n end",
"def update_attributes attributes\n @attributes.merge! attributes\n end",
"def update!(**args)\n @async_options = args[:async_options] if args.key?(:async_options)\n @input_mappings = args[:input_mappings] if args.key?(:input_mappings)\n @name_property = args[:name_property] if args.key?(:name_property)\n @validation_options = args[:validation_options] if args.key?(:validation_options)\n end",
"def update\r\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @type = args[:type] if args.key?(:type)\n end",
"def update\n raise NotImplemented\n end",
"def update_obj\n mean, sd = rating.to_glicko_rating\n @obj.rating = mean\n @obj.rating_deviation = sd\n @obj.volatility = volatility\n end",
"def update_values\n end",
"def update_values\n end",
"def update\n raise NotImplementedError\n end",
"def update!(**args)\n @answers_header_signals = args[:answers_header_signals] if args.key?(:answers_header_signals)\n @property_value = args[:property_value] if args.key?(:property_value)\n @response_meaning_application = args[:response_meaning_application] if args.key?(:response_meaning_application)\n end",
"def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @name = args[:name] if args.key?(:name)\n @state = args[:state] if args.key?(:state)\n end",
"def update attributes, collection #:nodoc:\n 0\n end",
"def update_property_groups(roll)\n @property_groups.each { |_, v| v.update_rent(roll) }\n end",
"def update!(**args)\n @source_property = args[:source_property] if args.key?(:source_property)\n end",
"def update_info(update_attr_hash)\n update_attr_hash.each do |k,v| \n\t\t\tself.send(\"#{k}=\",v)\n\t\tend\n end",
"def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end",
"def update\n set_deltatime\n set_last_update_at\n end"
] |
[
"0.7012263",
"0.69181895",
"0.69181895",
"0.69181895",
"0.69181895",
"0.69181895",
"0.67403597",
"0.6709326",
"0.6709326",
"0.6696149",
"0.6696149",
"0.6696149",
"0.6696149",
"0.6618882",
"0.6571848",
"0.65386343",
"0.65178275",
"0.6394807",
"0.6389745",
"0.6389745",
"0.63328",
"0.6319025",
"0.6283673",
"0.6269463",
"0.62639254",
"0.62410724",
"0.62170374",
"0.62152076",
"0.6210263",
"0.6204041",
"0.6204041",
"0.62021106",
"0.62017816",
"0.62017",
"0.61730784",
"0.61730784",
"0.6159277",
"0.6156169",
"0.61445665",
"0.6125433",
"0.61241156",
"0.6121413",
"0.6110477",
"0.6105694",
"0.61016303",
"0.60845226",
"0.6084427",
"0.6065455",
"0.6059506",
"0.6054869",
"0.6051708",
"0.6051708",
"0.60413384",
"0.6030853",
"0.6022535",
"0.6015561",
"0.59932375",
"0.59898263",
"0.5976479",
"0.5973787",
"0.59678394",
"0.5963291",
"0.5962048",
"0.5961157",
"0.5950731",
"0.5950731",
"0.5950731",
"0.5950731",
"0.5950731",
"0.5950731",
"0.5950731",
"0.5950731",
"0.59500545",
"0.59443134",
"0.59443134",
"0.59424853",
"0.59424853",
"0.593523",
"0.5926413",
"0.5924831",
"0.592427",
"0.59233046",
"0.59233046",
"0.5921224",
"0.59144294",
"0.59142506",
"0.58887535",
"0.58854496",
"0.5883008",
"0.58792305",
"0.5876954",
"0.5876954",
"0.58744955",
"0.5857968",
"0.5845542",
"0.5841629",
"0.58363605",
"0.5829255",
"0.582919",
"0.5822138",
"0.58208305"
] |
0.0
|
-1
|
Update properties of this object
|
def update!(**args)
@username = args[:username] unless args[:username].nil?
@password = args[:password] unless args[:password].nil?
@cluster_ca_certificate = args[:cluster_ca_certificate] unless args[:cluster_ca_certificate].nil?
@client_certificate = args[:client_certificate] unless args[:client_certificate].nil?
@client_key = args[:client_key] unless args[:client_key].nil?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def refresh\n self.class.base_properties.each_with_index do |prop, prop_id|\n @properties[prop] = get_property(prop_id)\n end\n refresh_features\n refresh_status\n refresh_config\n self\n end",
"def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end",
"def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update_properties!(branch_id=nil)\n properties = fetch_properties(false, branch_id)\n length = properties.length\n counter = 0\n properties.each do |property|\n counter += 1\n if Vebra.debugging?\n puts \"[Vebra]: #{counter}/#{length}: live updating property with Vebra ref: #{property.attributes[:vebra_ref]}\"\n end\n live_update!(property)\n Vebra.set_last_updated_at(Time.now) if counter == length\n end\n end",
"def update_self obj\n obj.each do |k,v|\n instance_variable_set(\"@#{k}\", v) if v\n end\n end",
"def update_attributes(properties_hash)\n self.class.get_class_properties.each do |property|\n key = property[:name].to_sym\n if properties_hash.has_key? key\n self.setValue(properties_hash[key], forKey:key)\n end\n end\n end",
"def update\n # TODO: implement update\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @states = args[:states] if args.key?(:states)\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end",
"def update!(**args)\n @property = args[:property] if args.key?(:property)\n @total_value_count = args[:total_value_count] if args.key?(:total_value_count)\n @value = args[:value] if args.key?(:value)\n @value_status = args[:value_status] if args.key?(:value_status)\n end",
"def update\n \n end",
"def refresh\n set_attributes\n end",
"def update(attrs)\n @attrs.update(attrs)\n self\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @source = args[:source] if args.key?(:source)\n end",
"def update_resource object, attributes\n object.update attributes\n end",
"def update(attrs)\n @attrs ||= {}\n @attrs.update(attrs)\n self\n end",
"def update\n \n end",
"def update!(**args)\n @property = args[:property] if args.key?(:property)\n @schema = args[:schema] if args.key?(:schema)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end",
"def update(attributes = {})\n super(attributes)\n retrieve!\n self\n end",
"def update\n @objects.map(&:update);\n end",
"def update\n raise NotImplementedError\n end",
"def update\n raise NotImplementedError\n end",
"def live_update!(property)\n property_class = Vebra.models[:property][:class].to_s.camelize.constantize\n\n # ensure we have the full property attributes\n property.get_property if !property.attributes[:status] && property.attributes[:action] != 'deleted'\n\n # find & update or build a new property\n property_model = property_class.find_or_initialize_by_vebra_ref(property.attributes[:vebra_ref])\n\n # make sure property object is not empty\n return false if !property.attributes || !property.attributes[:property_type]\n\n # if the property has been deleted, mark it appropriately and move on\n if property.attributes[:action] == 'deleted'\n return property_model.destroy\n end\n\n # extract accessible attributes for the property\n property_accessibles = property_class.accessible_attributes.map(&:to_sym)\n property_attributes = property.attributes.inject({}) do |result, (key, value)|\n result[key] = value if property_accessibles.include?(key)\n result\n end\n\n # update the property model's attributes\n property_model.no_callbacks = true if property_model.respond_to?(:no_callbacks)\n property_model.update_attributes(property_attributes)\n\n # find & update or build a new address\n if Vebra.models[:address]\n address_class = Vebra.models[:address][:class].to_s.camelize.constantize\n address_model = property_model.send(Vebra.models[:property][:address_method])\n address_model = property_model.send(\"build_#{Vebra.models[:property][:address_method]}\") unless address_model\n\n # extract accessible attributes for the address\n address_accessibles = address_class.accessible_attributes.map(&:to_sym)\n address_attributes = property.attributes[:address].inject({}) do |result, (key, value)|\n result[key] = value if address_accessibles.include?(key)\n result\n end\n\n # update the address model's attributes\n address_model.update_attributes(address_attributes)\n end\n\n # find & update or build new rooms\n if Vebra.models[:room]\n room_class = Vebra.models[:room][:class].to_s.camelize.constantize\n\n # accessible attributes for the rooms\n room_accessibles = room_class.accessible_attributes.map(&:to_sym)\n\n # delete any rooms which are no longer present\n property_rooms = property.attributes[:rooms] || []\n property_model_rooms = property_model.send(Vebra.models[:property][:rooms_method])\n refs_to_delete = property_model_rooms.map(&:vebra_ref) - property_rooms.map { |r| r[:vebra_ref] }\n property_model_rooms.each do |room|\n room.destroy if refs_to_delete.include?(room.vebra_ref)\n end\n\n # find & update or build new rooms\n property_rooms.each do |room|\n room_model = room_class.find_by_property_id_and_vebra_ref(property_model.id, room[:vebra_ref])\n room_model = property_model_rooms.build unless room_model\n\n # extract accessible attributes for the room\n room_attributes = room.inject({}) do |result, (key, value)|\n result[key] = value if room_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n room_model.update_attributes(room_attributes)\n end\n end\n\n # find & update or build new file attachments\n if Vebra.models[:file]\n file_class = Vebra.models[:file][:class].to_s.camelize.constantize\n\n # accessible attributes for the files\n file_accessibles = file_class.accessible_attributes.map(&:to_sym)\n\n # first normalize the collection (currently nested collections)\n property_files = property.attributes[:files].inject([]) do |result, (kind, collection)|\n collection.each do |file|\n file[:type] = kind.to_s.singularize.camelize if file_accessibles.include?(:type)\n file[\"remote_#{Vebra.models[:file][:attachment_method]}_url\".to_sym] = file.delete(:url)\n # if file[:type] is set, it means the attachment file class can be subclassed. In this\n # case we need to ensure that the subclass exists. If not, we ignore this file\n begin\n file[:type].constantize if file_accessibles.include?(:type)\n result << file\n rescue NameError => e\n # ignore - this means the subclass does not exist\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n\n result\n end\n\n # delete any files which are no longer present\n property_model_files = property_model.send(Vebra.models[:property][:files_method])\n refs_to_delete = property_model_files.map(&:vebra_ref) - property_files.map { |f| f[:vebra_ref] }\n property_model_files.each do |file|\n file.destroy if refs_to_delete.include?(file.vebra_ref)\n end\n\n # find & update or build new files\n property_files.each do |file|\n begin\n file_model = property_model_files.find_by_vebra_ref(file[:vebra_ref])\n file_model = property_model_files.build unless file_model\n\n # extract accessible attributes for the file\n file_attributes = file.inject({}) do |result, (key, value)|\n result[key] = value if file_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n file_model.update_attributes(file_attributes)\n rescue CarrierWave::ProcessingError, OpenURI::HTTPError => e\n # just ignore the file\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n end\n\n property_model.no_callbacks = false if property_model.respond_to?(:no_callbacks)\n property_model.save\n return property_model\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def update\n end",
"def update!(**args)\n @mid = args[:mid] if args.key?(:mid)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def modified_properties=(value)\n @modified_properties = value\n end",
"def apply_properties!(properties)\n # Non-commutitivity etc. eventually.\n end",
"def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end",
"def update\n\t\t\n\t\tend",
"def set_props(props)\n @props.merge!(props)\n end",
"def update() end",
"def update!(**args)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def assign_properties\n self.properties ||= {}\n listing_properties.each do |prop|\n self.properties[prop.key] ||= prop.value\n end\n end",
"def change_properties(new_current_floor, new_next_floor, new_movement)\n @current_floor = new_current_floor\n @next_floor = new_next_floor\n @movement = new_movement\n end",
"def update!(**args)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end",
"def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end",
"def update(attributes)\n (@attributes ||= {}).merge! attributes\n\n (self.class.attr_initializables & attributes.keys).each do |name|\n instance_variable_set :\"@#{name}\", attributes[name]\n end\n\n self\n end",
"def update_attributes(attrs)\n super({})\n end",
"def update\n @dirty = true\n end",
"def update\n\n # Run through the mixin updates\n colourable_update\n movable_update\n\n end",
"def set(props)\n props.each do |prop, val|\n self.send(:\"#{ prop }=\", val)\n end\n end",
"def update\n super\n end",
"def update!(**args)\n @property_id = args[:property_id] if args.key?(:property_id)\n @value_status = args[:value_status] if args.key?(:value_status)\n end",
"def update!(**args)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end",
"def movable_update\n\n # Work through the different aspects we update\n movable_location_update\n movable_size_update\n movable_angle_update\n\n end",
"def properties=(value)\n @properties = value\n end",
"def update(attrs)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value) if respond_to?(\"#{key}=\")\n # attributes[key] = value <- lets make use of virtual attributes too\n end\n end",
"def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'id'}.merge(m2o.merge(m2o){|k, v| v.is_a?(Array) ? v[0] : v})\n self.class.rpc_execute('write', self.id, vals, context)\n reload_from_record!(self.class.find(self.id, :context => context))\n end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update ; end",
"def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end",
"def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end",
"def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end",
"def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end",
"def update_with(attributes)\n assign_attributes(attributes)\n end",
"def update\n # don't need to update; hash is shared\n end",
"def update(attributes)\n HashProxy.with(attributes) do |proxy|\n self.class.attribute_names.each do |name|\n send(\"#{name}=\", proxy[name]) if proxy.key?(name)\n end\n end\n save\n end",
"def update!(**args)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @relation = args[:relation] if args.key?(:relation)\n @subject_id = args[:subject_id] if args.key?(:subject_id)\n end",
"def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end",
"def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end",
"def update\n raise NotImplementedError\n end",
"def update_attributes attributes\n @attributes.merge! attributes\n end",
"def update!(**args)\n @async_options = args[:async_options] if args.key?(:async_options)\n @input_mappings = args[:input_mappings] if args.key?(:input_mappings)\n @name_property = args[:name_property] if args.key?(:name_property)\n @validation_options = args[:validation_options] if args.key?(:validation_options)\n end",
"def update\r\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @type = args[:type] if args.key?(:type)\n end",
"def update\n raise NotImplemented\n end",
"def update_obj\n mean, sd = rating.to_glicko_rating\n @obj.rating = mean\n @obj.rating_deviation = sd\n @obj.volatility = volatility\n end",
"def update_values\n end",
"def update_values\n end",
"def update\n raise NotImplementedError\n end",
"def update!(**args)\n @answers_header_signals = args[:answers_header_signals] if args.key?(:answers_header_signals)\n @property_value = args[:property_value] if args.key?(:property_value)\n @response_meaning_application = args[:response_meaning_application] if args.key?(:response_meaning_application)\n end",
"def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @name = args[:name] if args.key?(:name)\n @state = args[:state] if args.key?(:state)\n end",
"def update attributes, collection #:nodoc:\n 0\n end",
"def update_property_groups(roll)\n @property_groups.each { |_, v| v.update_rent(roll) }\n end",
"def update!(**args)\n @source_property = args[:source_property] if args.key?(:source_property)\n end",
"def update_info(update_attr_hash)\n update_attr_hash.each do |k,v| \n\t\t\tself.send(\"#{k}=\",v)\n\t\tend\n end",
"def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end",
"def update\n set_deltatime\n set_last_update_at\n end"
] |
[
"0.7012263",
"0.69181895",
"0.69181895",
"0.69181895",
"0.69181895",
"0.69181895",
"0.67403597",
"0.6709326",
"0.6709326",
"0.6696149",
"0.6696149",
"0.6696149",
"0.6696149",
"0.6618882",
"0.6571848",
"0.65386343",
"0.65178275",
"0.6394807",
"0.6389745",
"0.6389745",
"0.63328",
"0.6319025",
"0.6283673",
"0.6269463",
"0.62639254",
"0.62410724",
"0.62170374",
"0.62152076",
"0.6210263",
"0.6204041",
"0.6204041",
"0.62021106",
"0.62017816",
"0.62017",
"0.61730784",
"0.61730784",
"0.6159277",
"0.6156169",
"0.61445665",
"0.6125433",
"0.61241156",
"0.6121413",
"0.6110477",
"0.6105694",
"0.61016303",
"0.60845226",
"0.6084427",
"0.6065455",
"0.6059506",
"0.6054869",
"0.6051708",
"0.6051708",
"0.60413384",
"0.6030853",
"0.6022535",
"0.6015561",
"0.59932375",
"0.59898263",
"0.5976479",
"0.5973787",
"0.59678394",
"0.5963291",
"0.5962048",
"0.5961157",
"0.5950731",
"0.5950731",
"0.5950731",
"0.5950731",
"0.5950731",
"0.5950731",
"0.5950731",
"0.5950731",
"0.59500545",
"0.59443134",
"0.59443134",
"0.59424853",
"0.59424853",
"0.593523",
"0.5926413",
"0.5924831",
"0.592427",
"0.59233046",
"0.59233046",
"0.5921224",
"0.59144294",
"0.59142506",
"0.58887535",
"0.58854496",
"0.5883008",
"0.58792305",
"0.5876954",
"0.5876954",
"0.58744955",
"0.5857968",
"0.5845542",
"0.5841629",
"0.58363605",
"0.5829255",
"0.582919",
"0.5822138",
"0.58208305"
] |
0.0
|
-1
|
Update properties of this object
|
def update!(**args)
@cluster = args[:cluster] unless args[:cluster].nil?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def refresh\n self.class.base_properties.each_with_index do |prop, prop_id|\n @properties[prop] = get_property(prop_id)\n end\n refresh_features\n refresh_status\n refresh_config\n self\n end",
"def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end",
"def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update_properties!(branch_id=nil)\n properties = fetch_properties(false, branch_id)\n length = properties.length\n counter = 0\n properties.each do |property|\n counter += 1\n if Vebra.debugging?\n puts \"[Vebra]: #{counter}/#{length}: live updating property with Vebra ref: #{property.attributes[:vebra_ref]}\"\n end\n live_update!(property)\n Vebra.set_last_updated_at(Time.now) if counter == length\n end\n end",
"def update_self obj\n obj.each do |k,v|\n instance_variable_set(\"@#{k}\", v) if v\n end\n end",
"def update_attributes(properties_hash)\n self.class.get_class_properties.each do |property|\n key = property[:name].to_sym\n if properties_hash.has_key? key\n self.setValue(properties_hash[key], forKey:key)\n end\n end\n end",
"def update\n # TODO: implement update\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @states = args[:states] if args.key?(:states)\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end",
"def update!(**args)\n @property = args[:property] if args.key?(:property)\n @total_value_count = args[:total_value_count] if args.key?(:total_value_count)\n @value = args[:value] if args.key?(:value)\n @value_status = args[:value_status] if args.key?(:value_status)\n end",
"def update\n \n end",
"def refresh\n set_attributes\n end",
"def update(attrs)\n @attrs.update(attrs)\n self\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @source = args[:source] if args.key?(:source)\n end",
"def update_resource object, attributes\n object.update attributes\n end",
"def update(attrs)\n @attrs ||= {}\n @attrs.update(attrs)\n self\n end",
"def update\n \n end",
"def update!(**args)\n @property = args[:property] if args.key?(:property)\n @schema = args[:schema] if args.key?(:schema)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def update(attributes = {})\n super(attributes)\n retrieve!\n self\n end",
"def update\n @objects.map(&:update);\n end",
"def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end",
"def update\n raise NotImplementedError\n end",
"def update\n raise NotImplementedError\n end",
"def live_update!(property)\n property_class = Vebra.models[:property][:class].to_s.camelize.constantize\n\n # ensure we have the full property attributes\n property.get_property if !property.attributes[:status] && property.attributes[:action] != 'deleted'\n\n # find & update or build a new property\n property_model = property_class.find_or_initialize_by_vebra_ref(property.attributes[:vebra_ref])\n\n # make sure property object is not empty\n return false if !property.attributes || !property.attributes[:property_type]\n\n # if the property has been deleted, mark it appropriately and move on\n if property.attributes[:action] == 'deleted'\n return property_model.destroy\n end\n\n # extract accessible attributes for the property\n property_accessibles = property_class.accessible_attributes.map(&:to_sym)\n property_attributes = property.attributes.inject({}) do |result, (key, value)|\n result[key] = value if property_accessibles.include?(key)\n result\n end\n\n # update the property model's attributes\n property_model.no_callbacks = true if property_model.respond_to?(:no_callbacks)\n property_model.update_attributes(property_attributes)\n\n # find & update or build a new address\n if Vebra.models[:address]\n address_class = Vebra.models[:address][:class].to_s.camelize.constantize\n address_model = property_model.send(Vebra.models[:property][:address_method])\n address_model = property_model.send(\"build_#{Vebra.models[:property][:address_method]}\") unless address_model\n\n # extract accessible attributes for the address\n address_accessibles = address_class.accessible_attributes.map(&:to_sym)\n address_attributes = property.attributes[:address].inject({}) do |result, (key, value)|\n result[key] = value if address_accessibles.include?(key)\n result\n end\n\n # update the address model's attributes\n address_model.update_attributes(address_attributes)\n end\n\n # find & update or build new rooms\n if Vebra.models[:room]\n room_class = Vebra.models[:room][:class].to_s.camelize.constantize\n\n # accessible attributes for the rooms\n room_accessibles = room_class.accessible_attributes.map(&:to_sym)\n\n # delete any rooms which are no longer present\n property_rooms = property.attributes[:rooms] || []\n property_model_rooms = property_model.send(Vebra.models[:property][:rooms_method])\n refs_to_delete = property_model_rooms.map(&:vebra_ref) - property_rooms.map { |r| r[:vebra_ref] }\n property_model_rooms.each do |room|\n room.destroy if refs_to_delete.include?(room.vebra_ref)\n end\n\n # find & update or build new rooms\n property_rooms.each do |room|\n room_model = room_class.find_by_property_id_and_vebra_ref(property_model.id, room[:vebra_ref])\n room_model = property_model_rooms.build unless room_model\n\n # extract accessible attributes for the room\n room_attributes = room.inject({}) do |result, (key, value)|\n result[key] = value if room_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n room_model.update_attributes(room_attributes)\n end\n end\n\n # find & update or build new file attachments\n if Vebra.models[:file]\n file_class = Vebra.models[:file][:class].to_s.camelize.constantize\n\n # accessible attributes for the files\n file_accessibles = file_class.accessible_attributes.map(&:to_sym)\n\n # first normalize the collection (currently nested collections)\n property_files = property.attributes[:files].inject([]) do |result, (kind, collection)|\n collection.each do |file|\n file[:type] = kind.to_s.singularize.camelize if file_accessibles.include?(:type)\n file[\"remote_#{Vebra.models[:file][:attachment_method]}_url\".to_sym] = file.delete(:url)\n # if file[:type] is set, it means the attachment file class can be subclassed. In this\n # case we need to ensure that the subclass exists. If not, we ignore this file\n begin\n file[:type].constantize if file_accessibles.include?(:type)\n result << file\n rescue NameError => e\n # ignore - this means the subclass does not exist\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n\n result\n end\n\n # delete any files which are no longer present\n property_model_files = property_model.send(Vebra.models[:property][:files_method])\n refs_to_delete = property_model_files.map(&:vebra_ref) - property_files.map { |f| f[:vebra_ref] }\n property_model_files.each do |file|\n file.destroy if refs_to_delete.include?(file.vebra_ref)\n end\n\n # find & update or build new files\n property_files.each do |file|\n begin\n file_model = property_model_files.find_by_vebra_ref(file[:vebra_ref])\n file_model = property_model_files.build unless file_model\n\n # extract accessible attributes for the file\n file_attributes = file.inject({}) do |result, (key, value)|\n result[key] = value if file_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n file_model.update_attributes(file_attributes)\n rescue CarrierWave::ProcessingError, OpenURI::HTTPError => e\n # just ignore the file\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n end\n\n property_model.no_callbacks = false if property_model.respond_to?(:no_callbacks)\n property_model.save\n return property_model\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def update\n end",
"def update!(**args)\n @mid = args[:mid] if args.key?(:mid)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def modified_properties=(value)\n @modified_properties = value\n end",
"def apply_properties!(properties)\n # Non-commutitivity etc. eventually.\n end",
"def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end",
"def update\n\t\t\n\t\tend",
"def set_props(props)\n @props.merge!(props)\n end",
"def update() end",
"def update!(**args)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def assign_properties\n self.properties ||= {}\n listing_properties.each do |prop|\n self.properties[prop.key] ||= prop.value\n end\n end",
"def change_properties(new_current_floor, new_next_floor, new_movement)\n @current_floor = new_current_floor\n @next_floor = new_next_floor\n @movement = new_movement\n end",
"def update!(**args)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end",
"def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end",
"def update(attributes)\n (@attributes ||= {}).merge! attributes\n\n (self.class.attr_initializables & attributes.keys).each do |name|\n instance_variable_set :\"@#{name}\", attributes[name]\n end\n\n self\n end",
"def update_attributes(attrs)\n super({})\n end",
"def update\n @dirty = true\n end",
"def update\n\n # Run through the mixin updates\n colourable_update\n movable_update\n\n end",
"def set(props)\n props.each do |prop, val|\n self.send(:\"#{ prop }=\", val)\n end\n end",
"def update\n super\n end",
"def update!(**args)\n @property_id = args[:property_id] if args.key?(:property_id)\n @value_status = args[:value_status] if args.key?(:value_status)\n end",
"def update!(**args)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end",
"def movable_update\n\n # Work through the different aspects we update\n movable_location_update\n movable_size_update\n movable_angle_update\n\n end",
"def update(attrs)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value) if respond_to?(\"#{key}=\")\n # attributes[key] = value <- lets make use of virtual attributes too\n end\n end",
"def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'id'}.merge(m2o.merge(m2o){|k, v| v.is_a?(Array) ? v[0] : v})\n self.class.rpc_execute('write', self.id, vals, context)\n reload_from_record!(self.class.find(self.id, :context => context))\n end",
"def properties=(value)\n @properties = value\n end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update ; end",
"def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end",
"def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end",
"def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end",
"def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end",
"def update_with(attributes)\n assign_attributes(attributes)\n end",
"def update\n # don't need to update; hash is shared\n end",
"def update(attributes)\n HashProxy.with(attributes) do |proxy|\n self.class.attribute_names.each do |name|\n send(\"#{name}=\", proxy[name]) if proxy.key?(name)\n end\n end\n save\n end",
"def update!(**args)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @relation = args[:relation] if args.key?(:relation)\n @subject_id = args[:subject_id] if args.key?(:subject_id)\n end",
"def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end",
"def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end",
"def update\n raise NotImplementedError\n end",
"def update_attributes attributes\n @attributes.merge! attributes\n end",
"def update!(**args)\n @async_options = args[:async_options] if args.key?(:async_options)\n @input_mappings = args[:input_mappings] if args.key?(:input_mappings)\n @name_property = args[:name_property] if args.key?(:name_property)\n @validation_options = args[:validation_options] if args.key?(:validation_options)\n end",
"def update\r\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @type = args[:type] if args.key?(:type)\n end",
"def update\n raise NotImplemented\n end",
"def update_obj\n mean, sd = rating.to_glicko_rating\n @obj.rating = mean\n @obj.rating_deviation = sd\n @obj.volatility = volatility\n end",
"def update_values\n end",
"def update_values\n end",
"def update\n raise NotImplementedError\n end",
"def update!(**args)\n @answers_header_signals = args[:answers_header_signals] if args.key?(:answers_header_signals)\n @property_value = args[:property_value] if args.key?(:property_value)\n @response_meaning_application = args[:response_meaning_application] if args.key?(:response_meaning_application)\n end",
"def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @name = args[:name] if args.key?(:name)\n @state = args[:state] if args.key?(:state)\n end",
"def update attributes, collection #:nodoc:\n 0\n end",
"def update_property_groups(roll)\n @property_groups.each { |_, v| v.update_rent(roll) }\n end",
"def update!(**args)\n @source_property = args[:source_property] if args.key?(:source_property)\n end",
"def update_info(update_attr_hash)\n update_attr_hash.each do |k,v| \n\t\t\tself.send(\"#{k}=\",v)\n\t\tend\n end",
"def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end",
"def update\n set_deltatime\n set_last_update_at\n end"
] |
[
"0.701199",
"0.69196975",
"0.69196975",
"0.69196975",
"0.69196975",
"0.69196975",
"0.6739846",
"0.6709455",
"0.6709455",
"0.6698214",
"0.6698214",
"0.6698214",
"0.6698214",
"0.6619038",
"0.65719074",
"0.65380937",
"0.6519628",
"0.63961416",
"0.63910294",
"0.63910294",
"0.633522",
"0.63217974",
"0.62848955",
"0.6272008",
"0.62658215",
"0.62434864",
"0.62196386",
"0.6217854",
"0.6212097",
"0.6205346",
"0.6205346",
"0.6203888",
"0.62035936",
"0.62032425",
"0.6175266",
"0.6175266",
"0.61603904",
"0.61579055",
"0.6147466",
"0.61266834",
"0.6123028",
"0.61209583",
"0.61099416",
"0.61086744",
"0.61016953",
"0.60872084",
"0.6084747",
"0.60634464",
"0.6060025",
"0.6056291",
"0.6052406",
"0.6052406",
"0.6042521",
"0.6032689",
"0.60252035",
"0.6015576",
"0.599316",
"0.5991414",
"0.59785795",
"0.59759766",
"0.5967381",
"0.59643847",
"0.59637874",
"0.59619164",
"0.595378",
"0.595378",
"0.595378",
"0.595378",
"0.595378",
"0.595378",
"0.595378",
"0.595378",
"0.5953092",
"0.5946346",
"0.5946346",
"0.5942476",
"0.5942476",
"0.593757",
"0.5928377",
"0.5926473",
"0.59262335",
"0.5925231",
"0.5925231",
"0.5923493",
"0.59170985",
"0.5916205",
"0.5892186",
"0.5887701",
"0.5885531",
"0.587995",
"0.58796585",
"0.58796585",
"0.5876966",
"0.58603",
"0.5848133",
"0.584427",
"0.5837102",
"0.5830354",
"0.58300084",
"0.5823333",
"0.58222914"
] |
0.0
|
-1
|
Update properties of this object
|
def update!(**args)
@name = args[:name] unless args[:name].nil?
@zone = args[:zone] unless args[:zone].nil?
@operation_type = args[:operation_type] unless args[:operation_type].nil?
@status = args[:status] unless args[:status].nil?
@status_message = args[:status_message] unless args[:status_message].nil?
@self_link = args[:self_link] unless args[:self_link].nil?
@target_link = args[:target_link] unless args[:target_link].nil?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def refresh\n self.class.base_properties.each_with_index do |prop, prop_id|\n @properties[prop] = get_property(prop_id)\n end\n refresh_features\n refresh_status\n refresh_config\n self\n end",
"def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end",
"def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update_properties!(branch_id=nil)\n properties = fetch_properties(false, branch_id)\n length = properties.length\n counter = 0\n properties.each do |property|\n counter += 1\n if Vebra.debugging?\n puts \"[Vebra]: #{counter}/#{length}: live updating property with Vebra ref: #{property.attributes[:vebra_ref]}\"\n end\n live_update!(property)\n Vebra.set_last_updated_at(Time.now) if counter == length\n end\n end",
"def update_self obj\n obj.each do |k,v|\n instance_variable_set(\"@#{k}\", v) if v\n end\n end",
"def update_attributes(properties_hash)\n self.class.get_class_properties.each do |property|\n key = property[:name].to_sym\n if properties_hash.has_key? key\n self.setValue(properties_hash[key], forKey:key)\n end\n end\n end",
"def update\n # TODO: implement update\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @states = args[:states] if args.key?(:states)\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end",
"def update!(**args)\n @property = args[:property] if args.key?(:property)\n @total_value_count = args[:total_value_count] if args.key?(:total_value_count)\n @value = args[:value] if args.key?(:value)\n @value_status = args[:value_status] if args.key?(:value_status)\n end",
"def update\n \n end",
"def refresh\n set_attributes\n end",
"def update(attrs)\n @attrs.update(attrs)\n self\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @source = args[:source] if args.key?(:source)\n end",
"def update_resource object, attributes\n object.update attributes\n end",
"def update(attrs)\n @attrs ||= {}\n @attrs.update(attrs)\n self\n end",
"def update\n \n end",
"def update!(**args)\n @property = args[:property] if args.key?(:property)\n @schema = args[:schema] if args.key?(:schema)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def update\n @objects.map(&:update);\n end",
"def update(attributes = {})\n super(attributes)\n retrieve!\n self\n end",
"def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end",
"def update\n raise NotImplementedError\n end",
"def update\n raise NotImplementedError\n end",
"def live_update!(property)\n property_class = Vebra.models[:property][:class].to_s.camelize.constantize\n\n # ensure we have the full property attributes\n property.get_property if !property.attributes[:status] && property.attributes[:action] != 'deleted'\n\n # find & update or build a new property\n property_model = property_class.find_or_initialize_by_vebra_ref(property.attributes[:vebra_ref])\n\n # make sure property object is not empty\n return false if !property.attributes || !property.attributes[:property_type]\n\n # if the property has been deleted, mark it appropriately and move on\n if property.attributes[:action] == 'deleted'\n return property_model.destroy\n end\n\n # extract accessible attributes for the property\n property_accessibles = property_class.accessible_attributes.map(&:to_sym)\n property_attributes = property.attributes.inject({}) do |result, (key, value)|\n result[key] = value if property_accessibles.include?(key)\n result\n end\n\n # update the property model's attributes\n property_model.no_callbacks = true if property_model.respond_to?(:no_callbacks)\n property_model.update_attributes(property_attributes)\n\n # find & update or build a new address\n if Vebra.models[:address]\n address_class = Vebra.models[:address][:class].to_s.camelize.constantize\n address_model = property_model.send(Vebra.models[:property][:address_method])\n address_model = property_model.send(\"build_#{Vebra.models[:property][:address_method]}\") unless address_model\n\n # extract accessible attributes for the address\n address_accessibles = address_class.accessible_attributes.map(&:to_sym)\n address_attributes = property.attributes[:address].inject({}) do |result, (key, value)|\n result[key] = value if address_accessibles.include?(key)\n result\n end\n\n # update the address model's attributes\n address_model.update_attributes(address_attributes)\n end\n\n # find & update or build new rooms\n if Vebra.models[:room]\n room_class = Vebra.models[:room][:class].to_s.camelize.constantize\n\n # accessible attributes for the rooms\n room_accessibles = room_class.accessible_attributes.map(&:to_sym)\n\n # delete any rooms which are no longer present\n property_rooms = property.attributes[:rooms] || []\n property_model_rooms = property_model.send(Vebra.models[:property][:rooms_method])\n refs_to_delete = property_model_rooms.map(&:vebra_ref) - property_rooms.map { |r| r[:vebra_ref] }\n property_model_rooms.each do |room|\n room.destroy if refs_to_delete.include?(room.vebra_ref)\n end\n\n # find & update or build new rooms\n property_rooms.each do |room|\n room_model = room_class.find_by_property_id_and_vebra_ref(property_model.id, room[:vebra_ref])\n room_model = property_model_rooms.build unless room_model\n\n # extract accessible attributes for the room\n room_attributes = room.inject({}) do |result, (key, value)|\n result[key] = value if room_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n room_model.update_attributes(room_attributes)\n end\n end\n\n # find & update or build new file attachments\n if Vebra.models[:file]\n file_class = Vebra.models[:file][:class].to_s.camelize.constantize\n\n # accessible attributes for the files\n file_accessibles = file_class.accessible_attributes.map(&:to_sym)\n\n # first normalize the collection (currently nested collections)\n property_files = property.attributes[:files].inject([]) do |result, (kind, collection)|\n collection.each do |file|\n file[:type] = kind.to_s.singularize.camelize if file_accessibles.include?(:type)\n file[\"remote_#{Vebra.models[:file][:attachment_method]}_url\".to_sym] = file.delete(:url)\n # if file[:type] is set, it means the attachment file class can be subclassed. In this\n # case we need to ensure that the subclass exists. If not, we ignore this file\n begin\n file[:type].constantize if file_accessibles.include?(:type)\n result << file\n rescue NameError => e\n # ignore - this means the subclass does not exist\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n\n result\n end\n\n # delete any files which are no longer present\n property_model_files = property_model.send(Vebra.models[:property][:files_method])\n refs_to_delete = property_model_files.map(&:vebra_ref) - property_files.map { |f| f[:vebra_ref] }\n property_model_files.each do |file|\n file.destroy if refs_to_delete.include?(file.vebra_ref)\n end\n\n # find & update or build new files\n property_files.each do |file|\n begin\n file_model = property_model_files.find_by_vebra_ref(file[:vebra_ref])\n file_model = property_model_files.build unless file_model\n\n # extract accessible attributes for the file\n file_attributes = file.inject({}) do |result, (key, value)|\n result[key] = value if file_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n file_model.update_attributes(file_attributes)\n rescue CarrierWave::ProcessingError, OpenURI::HTTPError => e\n # just ignore the file\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n end\n\n property_model.no_callbacks = false if property_model.respond_to?(:no_callbacks)\n property_model.save\n return property_model\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def update\n end",
"def update!(**args)\n @mid = args[:mid] if args.key?(:mid)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def modified_properties=(value)\n @modified_properties = value\n end",
"def apply_properties!(properties)\n # Non-commutitivity etc. eventually.\n end",
"def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end",
"def update\n\t\t\n\t\tend",
"def set_props(props)\n @props.merge!(props)\n end",
"def update() end",
"def update!(**args)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def assign_properties\n self.properties ||= {}\n listing_properties.each do |prop|\n self.properties[prop.key] ||= prop.value\n end\n end",
"def change_properties(new_current_floor, new_next_floor, new_movement)\n @current_floor = new_current_floor\n @next_floor = new_next_floor\n @movement = new_movement\n end",
"def update!(**args)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end",
"def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end",
"def update(attributes)\n (@attributes ||= {}).merge! attributes\n\n (self.class.attr_initializables & attributes.keys).each do |name|\n instance_variable_set :\"@#{name}\", attributes[name]\n end\n\n self\n end",
"def update_attributes(attrs)\n super({})\n end",
"def update\n @dirty = true\n end",
"def update\n\n # Run through the mixin updates\n colourable_update\n movable_update\n\n end",
"def set(props)\n props.each do |prop, val|\n self.send(:\"#{ prop }=\", val)\n end\n end",
"def update\n super\n end",
"def update!(**args)\n @property_id = args[:property_id] if args.key?(:property_id)\n @value_status = args[:value_status] if args.key?(:value_status)\n end",
"def update!(**args)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end",
"def movable_update\n\n # Work through the different aspects we update\n movable_location_update\n movable_size_update\n movable_angle_update\n\n end",
"def update(attrs)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value) if respond_to?(\"#{key}=\")\n # attributes[key] = value <- lets make use of virtual attributes too\n end\n end",
"def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'id'}.merge(m2o.merge(m2o){|k, v| v.is_a?(Array) ? v[0] : v})\n self.class.rpc_execute('write', self.id, vals, context)\n reload_from_record!(self.class.find(self.id, :context => context))\n end",
"def properties=(value)\n @properties = value\n end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update ; end",
"def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end",
"def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end",
"def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end",
"def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end",
"def update_with(attributes)\n assign_attributes(attributes)\n end",
"def update(attributes)\n HashProxy.with(attributes) do |proxy|\n self.class.attribute_names.each do |name|\n send(\"#{name}=\", proxy[name]) if proxy.key?(name)\n end\n end\n save\n end",
"def update\n # don't need to update; hash is shared\n end",
"def update!(**args)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @relation = args[:relation] if args.key?(:relation)\n @subject_id = args[:subject_id] if args.key?(:subject_id)\n end",
"def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end",
"def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end",
"def update\n raise NotImplementedError\n end",
"def update_attributes attributes\n @attributes.merge! attributes\n end",
"def update!(**args)\n @async_options = args[:async_options] if args.key?(:async_options)\n @input_mappings = args[:input_mappings] if args.key?(:input_mappings)\n @name_property = args[:name_property] if args.key?(:name_property)\n @validation_options = args[:validation_options] if args.key?(:validation_options)\n end",
"def update\r\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @type = args[:type] if args.key?(:type)\n end",
"def update\n raise NotImplemented\n end",
"def update_values\n end",
"def update_values\n end",
"def update_obj\n mean, sd = rating.to_glicko_rating\n @obj.rating = mean\n @obj.rating_deviation = sd\n @obj.volatility = volatility\n end",
"def update\n raise NotImplementedError\n end",
"def update!(**args)\n @answers_header_signals = args[:answers_header_signals] if args.key?(:answers_header_signals)\n @property_value = args[:property_value] if args.key?(:property_value)\n @response_meaning_application = args[:response_meaning_application] if args.key?(:response_meaning_application)\n end",
"def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @name = args[:name] if args.key?(:name)\n @state = args[:state] if args.key?(:state)\n end",
"def update attributes, collection #:nodoc:\n 0\n end",
"def update_property_groups(roll)\n @property_groups.each { |_, v| v.update_rent(roll) }\n end",
"def update_info(update_attr_hash)\n update_attr_hash.each do |k,v| \n\t\t\tself.send(\"#{k}=\",v)\n\t\tend\n end",
"def update!(**args)\n @source_property = args[:source_property] if args.key?(:source_property)\n end",
"def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end",
"def update\n set_deltatime\n set_last_update_at\n end"
] |
[
"0.70132464",
"0.6920457",
"0.6920457",
"0.6920457",
"0.6920457",
"0.6920457",
"0.6739106",
"0.67094105",
"0.67094105",
"0.6698272",
"0.6698272",
"0.6698272",
"0.6698272",
"0.66193163",
"0.6571397",
"0.65391916",
"0.65189683",
"0.63971996",
"0.6391746",
"0.6391746",
"0.6335592",
"0.63222075",
"0.6284795",
"0.6272826",
"0.6266276",
"0.62445426",
"0.6220532",
"0.62182385",
"0.6212645",
"0.62060225",
"0.62060225",
"0.6204405",
"0.62037367",
"0.62033343",
"0.6175208",
"0.6175208",
"0.6160814",
"0.61582965",
"0.61476904",
"0.6127003",
"0.6123051",
"0.6121205",
"0.6110905",
"0.6108608",
"0.6101966",
"0.60876054",
"0.6085846",
"0.6062841",
"0.6061156",
"0.6056585",
"0.6052693",
"0.6052693",
"0.6043685",
"0.6033157",
"0.6025351",
"0.60159266",
"0.5993925",
"0.5990626",
"0.5979035",
"0.5976204",
"0.5968214",
"0.5965481",
"0.59641904",
"0.59613895",
"0.5954287",
"0.5954287",
"0.5954287",
"0.5954287",
"0.5954287",
"0.5954287",
"0.5954287",
"0.5954287",
"0.59536684",
"0.5946672",
"0.5946672",
"0.5941739",
"0.5941739",
"0.5939253",
"0.59279716",
"0.5927805",
"0.59267306",
"0.5925468",
"0.5925468",
"0.5923566",
"0.5918234",
"0.5917259",
"0.5892836",
"0.58884555",
"0.58857834",
"0.58803475",
"0.58803475",
"0.5879918",
"0.58770925",
"0.5861099",
"0.5849016",
"0.58443546",
"0.5837124",
"0.5830856",
"0.5830422",
"0.58239174",
"0.5823106"
] |
0.0
|
-1
|
Update properties of this object
|
def update!(**args)
@update = args[:update] unless args[:update].nil?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def refresh\n self.class.base_properties.each_with_index do |prop, prop_id|\n @properties[prop] = get_property(prop_id)\n end\n refresh_features\n refresh_status\n refresh_config\n self\n end",
"def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end",
"def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update_properties!(branch_id=nil)\n properties = fetch_properties(false, branch_id)\n length = properties.length\n counter = 0\n properties.each do |property|\n counter += 1\n if Vebra.debugging?\n puts \"[Vebra]: #{counter}/#{length}: live updating property with Vebra ref: #{property.attributes[:vebra_ref]}\"\n end\n live_update!(property)\n Vebra.set_last_updated_at(Time.now) if counter == length\n end\n end",
"def update_self obj\n obj.each do |k,v|\n instance_variable_set(\"@#{k}\", v) if v\n end\n end",
"def update_attributes(properties_hash)\n self.class.get_class_properties.each do |property|\n key = property[:name].to_sym\n if properties_hash.has_key? key\n self.setValue(properties_hash[key], forKey:key)\n end\n end\n end",
"def update\n # TODO: implement update\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @states = args[:states] if args.key?(:states)\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end",
"def update!(**args)\n @property = args[:property] if args.key?(:property)\n @total_value_count = args[:total_value_count] if args.key?(:total_value_count)\n @value = args[:value] if args.key?(:value)\n @value_status = args[:value_status] if args.key?(:value_status)\n end",
"def update\n \n end",
"def refresh\n set_attributes\n end",
"def update(attrs)\n @attrs.update(attrs)\n self\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @source = args[:source] if args.key?(:source)\n end",
"def update_resource object, attributes\n object.update attributes\n end",
"def update(attrs)\n @attrs ||= {}\n @attrs.update(attrs)\n self\n end",
"def update\n \n end",
"def update!(**args)\n @property = args[:property] if args.key?(:property)\n @schema = args[:schema] if args.key?(:schema)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end",
"def update(attributes = {})\n super(attributes)\n retrieve!\n self\n end",
"def update\n @objects.map(&:update);\n end",
"def update\n raise NotImplementedError\n end",
"def update\n raise NotImplementedError\n end",
"def live_update!(property)\n property_class = Vebra.models[:property][:class].to_s.camelize.constantize\n\n # ensure we have the full property attributes\n property.get_property if !property.attributes[:status] && property.attributes[:action] != 'deleted'\n\n # find & update or build a new property\n property_model = property_class.find_or_initialize_by_vebra_ref(property.attributes[:vebra_ref])\n\n # make sure property object is not empty\n return false if !property.attributes || !property.attributes[:property_type]\n\n # if the property has been deleted, mark it appropriately and move on\n if property.attributes[:action] == 'deleted'\n return property_model.destroy\n end\n\n # extract accessible attributes for the property\n property_accessibles = property_class.accessible_attributes.map(&:to_sym)\n property_attributes = property.attributes.inject({}) do |result, (key, value)|\n result[key] = value if property_accessibles.include?(key)\n result\n end\n\n # update the property model's attributes\n property_model.no_callbacks = true if property_model.respond_to?(:no_callbacks)\n property_model.update_attributes(property_attributes)\n\n # find & update or build a new address\n if Vebra.models[:address]\n address_class = Vebra.models[:address][:class].to_s.camelize.constantize\n address_model = property_model.send(Vebra.models[:property][:address_method])\n address_model = property_model.send(\"build_#{Vebra.models[:property][:address_method]}\") unless address_model\n\n # extract accessible attributes for the address\n address_accessibles = address_class.accessible_attributes.map(&:to_sym)\n address_attributes = property.attributes[:address].inject({}) do |result, (key, value)|\n result[key] = value if address_accessibles.include?(key)\n result\n end\n\n # update the address model's attributes\n address_model.update_attributes(address_attributes)\n end\n\n # find & update or build new rooms\n if Vebra.models[:room]\n room_class = Vebra.models[:room][:class].to_s.camelize.constantize\n\n # accessible attributes for the rooms\n room_accessibles = room_class.accessible_attributes.map(&:to_sym)\n\n # delete any rooms which are no longer present\n property_rooms = property.attributes[:rooms] || []\n property_model_rooms = property_model.send(Vebra.models[:property][:rooms_method])\n refs_to_delete = property_model_rooms.map(&:vebra_ref) - property_rooms.map { |r| r[:vebra_ref] }\n property_model_rooms.each do |room|\n room.destroy if refs_to_delete.include?(room.vebra_ref)\n end\n\n # find & update or build new rooms\n property_rooms.each do |room|\n room_model = room_class.find_by_property_id_and_vebra_ref(property_model.id, room[:vebra_ref])\n room_model = property_model_rooms.build unless room_model\n\n # extract accessible attributes for the room\n room_attributes = room.inject({}) do |result, (key, value)|\n result[key] = value if room_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n room_model.update_attributes(room_attributes)\n end\n end\n\n # find & update or build new file attachments\n if Vebra.models[:file]\n file_class = Vebra.models[:file][:class].to_s.camelize.constantize\n\n # accessible attributes for the files\n file_accessibles = file_class.accessible_attributes.map(&:to_sym)\n\n # first normalize the collection (currently nested collections)\n property_files = property.attributes[:files].inject([]) do |result, (kind, collection)|\n collection.each do |file|\n file[:type] = kind.to_s.singularize.camelize if file_accessibles.include?(:type)\n file[\"remote_#{Vebra.models[:file][:attachment_method]}_url\".to_sym] = file.delete(:url)\n # if file[:type] is set, it means the attachment file class can be subclassed. In this\n # case we need to ensure that the subclass exists. If not, we ignore this file\n begin\n file[:type].constantize if file_accessibles.include?(:type)\n result << file\n rescue NameError => e\n # ignore - this means the subclass does not exist\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n\n result\n end\n\n # delete any files which are no longer present\n property_model_files = property_model.send(Vebra.models[:property][:files_method])\n refs_to_delete = property_model_files.map(&:vebra_ref) - property_files.map { |f| f[:vebra_ref] }\n property_model_files.each do |file|\n file.destroy if refs_to_delete.include?(file.vebra_ref)\n end\n\n # find & update or build new files\n property_files.each do |file|\n begin\n file_model = property_model_files.find_by_vebra_ref(file[:vebra_ref])\n file_model = property_model_files.build unless file_model\n\n # extract accessible attributes for the file\n file_attributes = file.inject({}) do |result, (key, value)|\n result[key] = value if file_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n file_model.update_attributes(file_attributes)\n rescue CarrierWave::ProcessingError, OpenURI::HTTPError => e\n # just ignore the file\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n end\n\n property_model.no_callbacks = false if property_model.respond_to?(:no_callbacks)\n property_model.save\n return property_model\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def update\n end",
"def update!(**args)\n @mid = args[:mid] if args.key?(:mid)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def modified_properties=(value)\n @modified_properties = value\n end",
"def apply_properties!(properties)\n # Non-commutitivity etc. eventually.\n end",
"def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end",
"def update\n\t\t\n\t\tend",
"def set_props(props)\n @props.merge!(props)\n end",
"def update() end",
"def update!(**args)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def assign_properties\n self.properties ||= {}\n listing_properties.each do |prop|\n self.properties[prop.key] ||= prop.value\n end\n end",
"def change_properties(new_current_floor, new_next_floor, new_movement)\n @current_floor = new_current_floor\n @next_floor = new_next_floor\n @movement = new_movement\n end",
"def update!(**args)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end",
"def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end",
"def update(attributes)\n (@attributes ||= {}).merge! attributes\n\n (self.class.attr_initializables & attributes.keys).each do |name|\n instance_variable_set :\"@#{name}\", attributes[name]\n end\n\n self\n end",
"def update_attributes(attrs)\n super({})\n end",
"def update\n @dirty = true\n end",
"def update\n\n # Run through the mixin updates\n colourable_update\n movable_update\n\n end",
"def set(props)\n props.each do |prop, val|\n self.send(:\"#{ prop }=\", val)\n end\n end",
"def update\n super\n end",
"def update!(**args)\n @property_id = args[:property_id] if args.key?(:property_id)\n @value_status = args[:value_status] if args.key?(:value_status)\n end",
"def update!(**args)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end",
"def movable_update\n\n # Work through the different aspects we update\n movable_location_update\n movable_size_update\n movable_angle_update\n\n end",
"def properties=(value)\n @properties = value\n end",
"def update(attrs)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value) if respond_to?(\"#{key}=\")\n # attributes[key] = value <- lets make use of virtual attributes too\n end\n end",
"def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'id'}.merge(m2o.merge(m2o){|k, v| v.is_a?(Array) ? v[0] : v})\n self.class.rpc_execute('write', self.id, vals, context)\n reload_from_record!(self.class.find(self.id, :context => context))\n end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update ; end",
"def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end",
"def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end",
"def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end",
"def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end",
"def update_with(attributes)\n assign_attributes(attributes)\n end",
"def update\n # don't need to update; hash is shared\n end",
"def update(attributes)\n HashProxy.with(attributes) do |proxy|\n self.class.attribute_names.each do |name|\n send(\"#{name}=\", proxy[name]) if proxy.key?(name)\n end\n end\n save\n end",
"def update!(**args)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @relation = args[:relation] if args.key?(:relation)\n @subject_id = args[:subject_id] if args.key?(:subject_id)\n end",
"def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end",
"def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end",
"def update\n raise NotImplementedError\n end",
"def update_attributes attributes\n @attributes.merge! attributes\n end",
"def update!(**args)\n @async_options = args[:async_options] if args.key?(:async_options)\n @input_mappings = args[:input_mappings] if args.key?(:input_mappings)\n @name_property = args[:name_property] if args.key?(:name_property)\n @validation_options = args[:validation_options] if args.key?(:validation_options)\n end",
"def update\r\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @type = args[:type] if args.key?(:type)\n end",
"def update\n raise NotImplemented\n end",
"def update_obj\n mean, sd = rating.to_glicko_rating\n @obj.rating = mean\n @obj.rating_deviation = sd\n @obj.volatility = volatility\n end",
"def update_values\n end",
"def update_values\n end",
"def update\n raise NotImplementedError\n end",
"def update!(**args)\n @answers_header_signals = args[:answers_header_signals] if args.key?(:answers_header_signals)\n @property_value = args[:property_value] if args.key?(:property_value)\n @response_meaning_application = args[:response_meaning_application] if args.key?(:response_meaning_application)\n end",
"def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @name = args[:name] if args.key?(:name)\n @state = args[:state] if args.key?(:state)\n end",
"def update attributes, collection #:nodoc:\n 0\n end",
"def update_property_groups(roll)\n @property_groups.each { |_, v| v.update_rent(roll) }\n end",
"def update!(**args)\n @source_property = args[:source_property] if args.key?(:source_property)\n end",
"def update_info(update_attr_hash)\n update_attr_hash.each do |k,v| \n\t\t\tself.send(\"#{k}=\",v)\n\t\tend\n end",
"def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end",
"def update\n set_deltatime\n set_last_update_at\n end"
] |
[
"0.7012263",
"0.69181895",
"0.69181895",
"0.69181895",
"0.69181895",
"0.69181895",
"0.67403597",
"0.6709326",
"0.6709326",
"0.6696149",
"0.6696149",
"0.6696149",
"0.6696149",
"0.6618882",
"0.6571848",
"0.65386343",
"0.65178275",
"0.6394807",
"0.6389745",
"0.6389745",
"0.63328",
"0.6319025",
"0.6283673",
"0.6269463",
"0.62639254",
"0.62410724",
"0.62170374",
"0.62152076",
"0.6210263",
"0.6204041",
"0.6204041",
"0.62021106",
"0.62017816",
"0.62017",
"0.61730784",
"0.61730784",
"0.6159277",
"0.6156169",
"0.61445665",
"0.6125433",
"0.61241156",
"0.6121413",
"0.6110477",
"0.6105694",
"0.61016303",
"0.60845226",
"0.6084427",
"0.6065455",
"0.6059506",
"0.6054869",
"0.6051708",
"0.6051708",
"0.60413384",
"0.6030853",
"0.6022535",
"0.6015561",
"0.59932375",
"0.59898263",
"0.5976479",
"0.5973787",
"0.59678394",
"0.5963291",
"0.5962048",
"0.5961157",
"0.5950731",
"0.5950731",
"0.5950731",
"0.5950731",
"0.5950731",
"0.5950731",
"0.5950731",
"0.5950731",
"0.59500545",
"0.59443134",
"0.59443134",
"0.59424853",
"0.59424853",
"0.593523",
"0.5926413",
"0.5924831",
"0.592427",
"0.59233046",
"0.59233046",
"0.5921224",
"0.59144294",
"0.59142506",
"0.58887535",
"0.58854496",
"0.5883008",
"0.58792305",
"0.5876954",
"0.5876954",
"0.58744955",
"0.5857968",
"0.5845542",
"0.5841629",
"0.58363605",
"0.5829255",
"0.582919",
"0.5822138",
"0.58208305"
] |
0.0
|
-1
|
Update properties of this object
|
def update!(**args)
@desired_node_version = args[:desired_node_version] unless args[:desired_node_version].nil?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def refresh\n self.class.base_properties.each_with_index do |prop, prop_id|\n @properties[prop] = get_property(prop_id)\n end\n refresh_features\n refresh_status\n refresh_config\n self\n end",
"def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end",
"def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update_properties!(branch_id=nil)\n properties = fetch_properties(false, branch_id)\n length = properties.length\n counter = 0\n properties.each do |property|\n counter += 1\n if Vebra.debugging?\n puts \"[Vebra]: #{counter}/#{length}: live updating property with Vebra ref: #{property.attributes[:vebra_ref]}\"\n end\n live_update!(property)\n Vebra.set_last_updated_at(Time.now) if counter == length\n end\n end",
"def update_self obj\n obj.each do |k,v|\n instance_variable_set(\"@#{k}\", v) if v\n end\n end",
"def update_attributes(properties_hash)\n self.class.get_class_properties.each do |property|\n key = property[:name].to_sym\n if properties_hash.has_key? key\n self.setValue(properties_hash[key], forKey:key)\n end\n end\n end",
"def update\n # TODO: implement update\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @states = args[:states] if args.key?(:states)\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end",
"def update!(**args)\n @property = args[:property] if args.key?(:property)\n @total_value_count = args[:total_value_count] if args.key?(:total_value_count)\n @value = args[:value] if args.key?(:value)\n @value_status = args[:value_status] if args.key?(:value_status)\n end",
"def update\n \n end",
"def refresh\n set_attributes\n end",
"def update(attrs)\n @attrs.update(attrs)\n self\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @source = args[:source] if args.key?(:source)\n end",
"def update_resource object, attributes\n object.update attributes\n end",
"def update(attrs)\n @attrs ||= {}\n @attrs.update(attrs)\n self\n end",
"def update\n \n end",
"def update!(**args)\n @property = args[:property] if args.key?(:property)\n @schema = args[:schema] if args.key?(:schema)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end",
"def update(attributes = {})\n super(attributes)\n retrieve!\n self\n end",
"def update\n @objects.map(&:update);\n end",
"def update\n raise NotImplementedError\n end",
"def update\n raise NotImplementedError\n end",
"def live_update!(property)\n property_class = Vebra.models[:property][:class].to_s.camelize.constantize\n\n # ensure we have the full property attributes\n property.get_property if !property.attributes[:status] && property.attributes[:action] != 'deleted'\n\n # find & update or build a new property\n property_model = property_class.find_or_initialize_by_vebra_ref(property.attributes[:vebra_ref])\n\n # make sure property object is not empty\n return false if !property.attributes || !property.attributes[:property_type]\n\n # if the property has been deleted, mark it appropriately and move on\n if property.attributes[:action] == 'deleted'\n return property_model.destroy\n end\n\n # extract accessible attributes for the property\n property_accessibles = property_class.accessible_attributes.map(&:to_sym)\n property_attributes = property.attributes.inject({}) do |result, (key, value)|\n result[key] = value if property_accessibles.include?(key)\n result\n end\n\n # update the property model's attributes\n property_model.no_callbacks = true if property_model.respond_to?(:no_callbacks)\n property_model.update_attributes(property_attributes)\n\n # find & update or build a new address\n if Vebra.models[:address]\n address_class = Vebra.models[:address][:class].to_s.camelize.constantize\n address_model = property_model.send(Vebra.models[:property][:address_method])\n address_model = property_model.send(\"build_#{Vebra.models[:property][:address_method]}\") unless address_model\n\n # extract accessible attributes for the address\n address_accessibles = address_class.accessible_attributes.map(&:to_sym)\n address_attributes = property.attributes[:address].inject({}) do |result, (key, value)|\n result[key] = value if address_accessibles.include?(key)\n result\n end\n\n # update the address model's attributes\n address_model.update_attributes(address_attributes)\n end\n\n # find & update or build new rooms\n if Vebra.models[:room]\n room_class = Vebra.models[:room][:class].to_s.camelize.constantize\n\n # accessible attributes for the rooms\n room_accessibles = room_class.accessible_attributes.map(&:to_sym)\n\n # delete any rooms which are no longer present\n property_rooms = property.attributes[:rooms] || []\n property_model_rooms = property_model.send(Vebra.models[:property][:rooms_method])\n refs_to_delete = property_model_rooms.map(&:vebra_ref) - property_rooms.map { |r| r[:vebra_ref] }\n property_model_rooms.each do |room|\n room.destroy if refs_to_delete.include?(room.vebra_ref)\n end\n\n # find & update or build new rooms\n property_rooms.each do |room|\n room_model = room_class.find_by_property_id_and_vebra_ref(property_model.id, room[:vebra_ref])\n room_model = property_model_rooms.build unless room_model\n\n # extract accessible attributes for the room\n room_attributes = room.inject({}) do |result, (key, value)|\n result[key] = value if room_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n room_model.update_attributes(room_attributes)\n end\n end\n\n # find & update or build new file attachments\n if Vebra.models[:file]\n file_class = Vebra.models[:file][:class].to_s.camelize.constantize\n\n # accessible attributes for the files\n file_accessibles = file_class.accessible_attributes.map(&:to_sym)\n\n # first normalize the collection (currently nested collections)\n property_files = property.attributes[:files].inject([]) do |result, (kind, collection)|\n collection.each do |file|\n file[:type] = kind.to_s.singularize.camelize if file_accessibles.include?(:type)\n file[\"remote_#{Vebra.models[:file][:attachment_method]}_url\".to_sym] = file.delete(:url)\n # if file[:type] is set, it means the attachment file class can be subclassed. In this\n # case we need to ensure that the subclass exists. If not, we ignore this file\n begin\n file[:type].constantize if file_accessibles.include?(:type)\n result << file\n rescue NameError => e\n # ignore - this means the subclass does not exist\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n\n result\n end\n\n # delete any files which are no longer present\n property_model_files = property_model.send(Vebra.models[:property][:files_method])\n refs_to_delete = property_model_files.map(&:vebra_ref) - property_files.map { |f| f[:vebra_ref] }\n property_model_files.each do |file|\n file.destroy if refs_to_delete.include?(file.vebra_ref)\n end\n\n # find & update or build new files\n property_files.each do |file|\n begin\n file_model = property_model_files.find_by_vebra_ref(file[:vebra_ref])\n file_model = property_model_files.build unless file_model\n\n # extract accessible attributes for the file\n file_attributes = file.inject({}) do |result, (key, value)|\n result[key] = value if file_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n file_model.update_attributes(file_attributes)\n rescue CarrierWave::ProcessingError, OpenURI::HTTPError => e\n # just ignore the file\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n end\n\n property_model.no_callbacks = false if property_model.respond_to?(:no_callbacks)\n property_model.save\n return property_model\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def update\n end",
"def update!(**args)\n @mid = args[:mid] if args.key?(:mid)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def modified_properties=(value)\n @modified_properties = value\n end",
"def apply_properties!(properties)\n # Non-commutitivity etc. eventually.\n end",
"def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end",
"def update\n\t\t\n\t\tend",
"def set_props(props)\n @props.merge!(props)\n end",
"def update() end",
"def update!(**args)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def assign_properties\n self.properties ||= {}\n listing_properties.each do |prop|\n self.properties[prop.key] ||= prop.value\n end\n end",
"def change_properties(new_current_floor, new_next_floor, new_movement)\n @current_floor = new_current_floor\n @next_floor = new_next_floor\n @movement = new_movement\n end",
"def update!(**args)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end",
"def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end",
"def update(attributes)\n (@attributes ||= {}).merge! attributes\n\n (self.class.attr_initializables & attributes.keys).each do |name|\n instance_variable_set :\"@#{name}\", attributes[name]\n end\n\n self\n end",
"def update_attributes(attrs)\n super({})\n end",
"def update\n @dirty = true\n end",
"def update\n\n # Run through the mixin updates\n colourable_update\n movable_update\n\n end",
"def set(props)\n props.each do |prop, val|\n self.send(:\"#{ prop }=\", val)\n end\n end",
"def update\n super\n end",
"def update!(**args)\n @property_id = args[:property_id] if args.key?(:property_id)\n @value_status = args[:value_status] if args.key?(:value_status)\n end",
"def update!(**args)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end",
"def movable_update\n\n # Work through the different aspects we update\n movable_location_update\n movable_size_update\n movable_angle_update\n\n end",
"def properties=(value)\n @properties = value\n end",
"def update(attrs)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value) if respond_to?(\"#{key}=\")\n # attributes[key] = value <- lets make use of virtual attributes too\n end\n end",
"def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'id'}.merge(m2o.merge(m2o){|k, v| v.is_a?(Array) ? v[0] : v})\n self.class.rpc_execute('write', self.id, vals, context)\n reload_from_record!(self.class.find(self.id, :context => context))\n end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update ; end",
"def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end",
"def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end",
"def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end",
"def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end",
"def update_with(attributes)\n assign_attributes(attributes)\n end",
"def update\n # don't need to update; hash is shared\n end",
"def update(attributes)\n HashProxy.with(attributes) do |proxy|\n self.class.attribute_names.each do |name|\n send(\"#{name}=\", proxy[name]) if proxy.key?(name)\n end\n end\n save\n end",
"def update!(**args)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @relation = args[:relation] if args.key?(:relation)\n @subject_id = args[:subject_id] if args.key?(:subject_id)\n end",
"def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end",
"def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end",
"def update\n raise NotImplementedError\n end",
"def update_attributes attributes\n @attributes.merge! attributes\n end",
"def update!(**args)\n @async_options = args[:async_options] if args.key?(:async_options)\n @input_mappings = args[:input_mappings] if args.key?(:input_mappings)\n @name_property = args[:name_property] if args.key?(:name_property)\n @validation_options = args[:validation_options] if args.key?(:validation_options)\n end",
"def update\r\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @type = args[:type] if args.key?(:type)\n end",
"def update\n raise NotImplemented\n end",
"def update_obj\n mean, sd = rating.to_glicko_rating\n @obj.rating = mean\n @obj.rating_deviation = sd\n @obj.volatility = volatility\n end",
"def update_values\n end",
"def update_values\n end",
"def update\n raise NotImplementedError\n end",
"def update!(**args)\n @answers_header_signals = args[:answers_header_signals] if args.key?(:answers_header_signals)\n @property_value = args[:property_value] if args.key?(:property_value)\n @response_meaning_application = args[:response_meaning_application] if args.key?(:response_meaning_application)\n end",
"def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @name = args[:name] if args.key?(:name)\n @state = args[:state] if args.key?(:state)\n end",
"def update attributes, collection #:nodoc:\n 0\n end",
"def update_property_groups(roll)\n @property_groups.each { |_, v| v.update_rent(roll) }\n end",
"def update!(**args)\n @source_property = args[:source_property] if args.key?(:source_property)\n end",
"def update_info(update_attr_hash)\n update_attr_hash.each do |k,v| \n\t\t\tself.send(\"#{k}=\",v)\n\t\tend\n end",
"def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end",
"def update\n set_deltatime\n set_last_update_at\n end"
] |
[
"0.7012263",
"0.69181895",
"0.69181895",
"0.69181895",
"0.69181895",
"0.69181895",
"0.67403597",
"0.6709326",
"0.6709326",
"0.6696149",
"0.6696149",
"0.6696149",
"0.6696149",
"0.6618882",
"0.6571848",
"0.65386343",
"0.65178275",
"0.6394807",
"0.6389745",
"0.6389745",
"0.63328",
"0.6319025",
"0.6283673",
"0.6269463",
"0.62639254",
"0.62410724",
"0.62170374",
"0.62152076",
"0.6210263",
"0.6204041",
"0.6204041",
"0.62021106",
"0.62017816",
"0.62017",
"0.61730784",
"0.61730784",
"0.6159277",
"0.6156169",
"0.61445665",
"0.6125433",
"0.61241156",
"0.6121413",
"0.6110477",
"0.6105694",
"0.61016303",
"0.60845226",
"0.6084427",
"0.6065455",
"0.6059506",
"0.6054869",
"0.6051708",
"0.6051708",
"0.60413384",
"0.6030853",
"0.6022535",
"0.6015561",
"0.59932375",
"0.59898263",
"0.5976479",
"0.5973787",
"0.59678394",
"0.5963291",
"0.5962048",
"0.5961157",
"0.5950731",
"0.5950731",
"0.5950731",
"0.5950731",
"0.5950731",
"0.5950731",
"0.5950731",
"0.5950731",
"0.59500545",
"0.59443134",
"0.59443134",
"0.59424853",
"0.59424853",
"0.593523",
"0.5926413",
"0.5924831",
"0.592427",
"0.59233046",
"0.59233046",
"0.5921224",
"0.59144294",
"0.59142506",
"0.58887535",
"0.58854496",
"0.5883008",
"0.58792305",
"0.5876954",
"0.5876954",
"0.58744955",
"0.5857968",
"0.5845542",
"0.5841629",
"0.58363605",
"0.5829255",
"0.582919",
"0.5822138",
"0.58208305"
] |
0.0
|
-1
|
Update properties of this object
|
def update!(**args)
@operations = args[:operations] unless args[:operations].nil?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end",
"def refresh\n self.class.base_properties.each_with_index do |prop, prop_id|\n @properties[prop] = get_property(prop_id)\n end\n refresh_features\n refresh_status\n refresh_config\n self\n end",
"def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end",
"def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update(attrs)\n super(attrs)\n end",
"def update_properties!(branch_id=nil)\n properties = fetch_properties(false, branch_id)\n length = properties.length\n counter = 0\n properties.each do |property|\n counter += 1\n if Vebra.debugging?\n puts \"[Vebra]: #{counter}/#{length}: live updating property with Vebra ref: #{property.attributes[:vebra_ref]}\"\n end\n live_update!(property)\n Vebra.set_last_updated_at(Time.now) if counter == length\n end\n end",
"def update_self obj\n obj.each do |k,v|\n instance_variable_set(\"@#{k}\", v) if v\n end\n end",
"def update_attributes(properties_hash)\n self.class.get_class_properties.each do |property|\n key = property[:name].to_sym\n if properties_hash.has_key? key\n self.setValue(properties_hash[key], forKey:key)\n end\n end\n end",
"def update\n # TODO: implement update\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @states = args[:states] if args.key?(:states)\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end",
"def update!(**args)\n @property = args[:property] if args.key?(:property)\n @total_value_count = args[:total_value_count] if args.key?(:total_value_count)\n @value = args[:value] if args.key?(:value)\n @value_status = args[:value_status] if args.key?(:value_status)\n end",
"def update\n \n end",
"def refresh\n set_attributes\n end",
"def update(attrs)\n @attrs.update(attrs)\n self\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @source = args[:source] if args.key?(:source)\n end",
"def update_resource object, attributes\n object.update attributes\n end",
"def update(attrs)\n @attrs ||= {}\n @attrs.update(attrs)\n self\n end",
"def update\n \n end",
"def update!(**args)\n @property = args[:property] if args.key?(:property)\n @schema = args[:schema] if args.key?(:schema)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def update(attributes = {})\n super(attributes)\n retrieve!\n self\n end",
"def update\n @objects.map(&:update);\n end",
"def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end",
"def update\n raise NotImplementedError\n end",
"def update\n raise NotImplementedError\n end",
"def live_update!(property)\n property_class = Vebra.models[:property][:class].to_s.camelize.constantize\n\n # ensure we have the full property attributes\n property.get_property if !property.attributes[:status] && property.attributes[:action] != 'deleted'\n\n # find & update or build a new property\n property_model = property_class.find_or_initialize_by_vebra_ref(property.attributes[:vebra_ref])\n\n # make sure property object is not empty\n return false if !property.attributes || !property.attributes[:property_type]\n\n # if the property has been deleted, mark it appropriately and move on\n if property.attributes[:action] == 'deleted'\n return property_model.destroy\n end\n\n # extract accessible attributes for the property\n property_accessibles = property_class.accessible_attributes.map(&:to_sym)\n property_attributes = property.attributes.inject({}) do |result, (key, value)|\n result[key] = value if property_accessibles.include?(key)\n result\n end\n\n # update the property model's attributes\n property_model.no_callbacks = true if property_model.respond_to?(:no_callbacks)\n property_model.update_attributes(property_attributes)\n\n # find & update or build a new address\n if Vebra.models[:address]\n address_class = Vebra.models[:address][:class].to_s.camelize.constantize\n address_model = property_model.send(Vebra.models[:property][:address_method])\n address_model = property_model.send(\"build_#{Vebra.models[:property][:address_method]}\") unless address_model\n\n # extract accessible attributes for the address\n address_accessibles = address_class.accessible_attributes.map(&:to_sym)\n address_attributes = property.attributes[:address].inject({}) do |result, (key, value)|\n result[key] = value if address_accessibles.include?(key)\n result\n end\n\n # update the address model's attributes\n address_model.update_attributes(address_attributes)\n end\n\n # find & update or build new rooms\n if Vebra.models[:room]\n room_class = Vebra.models[:room][:class].to_s.camelize.constantize\n\n # accessible attributes for the rooms\n room_accessibles = room_class.accessible_attributes.map(&:to_sym)\n\n # delete any rooms which are no longer present\n property_rooms = property.attributes[:rooms] || []\n property_model_rooms = property_model.send(Vebra.models[:property][:rooms_method])\n refs_to_delete = property_model_rooms.map(&:vebra_ref) - property_rooms.map { |r| r[:vebra_ref] }\n property_model_rooms.each do |room|\n room.destroy if refs_to_delete.include?(room.vebra_ref)\n end\n\n # find & update or build new rooms\n property_rooms.each do |room|\n room_model = room_class.find_by_property_id_and_vebra_ref(property_model.id, room[:vebra_ref])\n room_model = property_model_rooms.build unless room_model\n\n # extract accessible attributes for the room\n room_attributes = room.inject({}) do |result, (key, value)|\n result[key] = value if room_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n room_model.update_attributes(room_attributes)\n end\n end\n\n # find & update or build new file attachments\n if Vebra.models[:file]\n file_class = Vebra.models[:file][:class].to_s.camelize.constantize\n\n # accessible attributes for the files\n file_accessibles = file_class.accessible_attributes.map(&:to_sym)\n\n # first normalize the collection (currently nested collections)\n property_files = property.attributes[:files].inject([]) do |result, (kind, collection)|\n collection.each do |file|\n file[:type] = kind.to_s.singularize.camelize if file_accessibles.include?(:type)\n file[\"remote_#{Vebra.models[:file][:attachment_method]}_url\".to_sym] = file.delete(:url)\n # if file[:type] is set, it means the attachment file class can be subclassed. In this\n # case we need to ensure that the subclass exists. If not, we ignore this file\n begin\n file[:type].constantize if file_accessibles.include?(:type)\n result << file\n rescue NameError => e\n # ignore - this means the subclass does not exist\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n\n result\n end\n\n # delete any files which are no longer present\n property_model_files = property_model.send(Vebra.models[:property][:files_method])\n refs_to_delete = property_model_files.map(&:vebra_ref) - property_files.map { |f| f[:vebra_ref] }\n property_model_files.each do |file|\n file.destroy if refs_to_delete.include?(file.vebra_ref)\n end\n\n # find & update or build new files\n property_files.each do |file|\n begin\n file_model = property_model_files.find_by_vebra_ref(file[:vebra_ref])\n file_model = property_model_files.build unless file_model\n\n # extract accessible attributes for the file\n file_attributes = file.inject({}) do |result, (key, value)|\n result[key] = value if file_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n file_model.update_attributes(file_attributes)\n rescue CarrierWave::ProcessingError, OpenURI::HTTPError => e\n # just ignore the file\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n end\n\n property_model.no_callbacks = false if property_model.respond_to?(:no_callbacks)\n property_model.save\n return property_model\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def update\n end",
"def update!(**args)\n @mid = args[:mid] if args.key?(:mid)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def modified_properties=(value)\n @modified_properties = value\n end",
"def apply_properties!(properties)\n # Non-commutitivity etc. eventually.\n end",
"def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end",
"def update\n\t\t\n\t\tend",
"def set_props(props)\n @props.merge!(props)\n end",
"def update() end",
"def update!(**args)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end",
"def assign_properties\n self.properties ||= {}\n listing_properties.each do |prop|\n self.properties[prop.key] ||= prop.value\n end\n end",
"def change_properties(new_current_floor, new_next_floor, new_movement)\n @current_floor = new_current_floor\n @next_floor = new_next_floor\n @movement = new_movement\n end",
"def update!(**args)\n @property_value = args[:property_value] if args.key?(:property_value)\n end",
"def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end",
"def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end",
"def update(attributes)\n (@attributes ||= {}).merge! attributes\n\n (self.class.attr_initializables & attributes.keys).each do |name|\n instance_variable_set :\"@#{name}\", attributes[name]\n end\n\n self\n end",
"def update_attributes(attrs)\n super({})\n end",
"def update\n @dirty = true\n end",
"def update\n\n # Run through the mixin updates\n colourable_update\n movable_update\n\n end",
"def set(props)\n props.each do |prop, val|\n self.send(:\"#{ prop }=\", val)\n end\n end",
"def update\n super\n end",
"def update!(**args)\n @property_id = args[:property_id] if args.key?(:property_id)\n @value_status = args[:value_status] if args.key?(:value_status)\n end",
"def update!(**args)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end",
"def movable_update\n\n # Work through the different aspects we update\n movable_location_update\n movable_size_update\n movable_angle_update\n\n end",
"def update(attrs)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value) if respond_to?(\"#{key}=\")\n # attributes[key] = value <- lets make use of virtual attributes too\n end\n end",
"def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'id'}.merge(m2o.merge(m2o){|k, v| v.is_a?(Array) ? v[0] : v})\n self.class.rpc_execute('write', self.id, vals, context)\n reload_from_record!(self.class.find(self.id, :context => context))\n end",
"def properties=(value)\n @properties = value\n end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update ; end",
"def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end",
"def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end",
"def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end",
"def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end",
"def update_with(attributes)\n assign_attributes(attributes)\n end",
"def update\n # don't need to update; hash is shared\n end",
"def update(attributes)\n HashProxy.with(attributes) do |proxy|\n self.class.attribute_names.each do |name|\n send(\"#{name}=\", proxy[name]) if proxy.key?(name)\n end\n end\n save\n end",
"def update!(**args)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @relation = args[:relation] if args.key?(:relation)\n @subject_id = args[:subject_id] if args.key?(:subject_id)\n end",
"def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end",
"def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end",
"def update\n raise NotImplementedError\n end",
"def update_attributes attributes\n @attributes.merge! attributes\n end",
"def update!(**args)\n @async_options = args[:async_options] if args.key?(:async_options)\n @input_mappings = args[:input_mappings] if args.key?(:input_mappings)\n @name_property = args[:name_property] if args.key?(:name_property)\n @validation_options = args[:validation_options] if args.key?(:validation_options)\n end",
"def update\r\n end",
"def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @type = args[:type] if args.key?(:type)\n end",
"def update\n raise NotImplemented\n end",
"def update_obj\n mean, sd = rating.to_glicko_rating\n @obj.rating = mean\n @obj.rating_deviation = sd\n @obj.volatility = volatility\n end",
"def update_values\n end",
"def update_values\n end",
"def update\n raise NotImplementedError\n end",
"def update!(**args)\n @answers_header_signals = args[:answers_header_signals] if args.key?(:answers_header_signals)\n @property_value = args[:property_value] if args.key?(:property_value)\n @response_meaning_application = args[:response_meaning_application] if args.key?(:response_meaning_application)\n end",
"def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @name = args[:name] if args.key?(:name)\n @state = args[:state] if args.key?(:state)\n end",
"def update attributes, collection #:nodoc:\n 0\n end",
"def update_property_groups(roll)\n @property_groups.each { |_, v| v.update_rent(roll) }\n end",
"def update!(**args)\n @source_property = args[:source_property] if args.key?(:source_property)\n end",
"def update_info(update_attr_hash)\n update_attr_hash.each do |k,v| \n\t\t\tself.send(\"#{k}=\",v)\n\t\tend\n end",
"def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end",
"def update\n set_deltatime\n set_last_update_at\n end"
] |
[
"0.701199",
"0.69196975",
"0.69196975",
"0.69196975",
"0.69196975",
"0.69196975",
"0.6739846",
"0.6709455",
"0.6709455",
"0.6698214",
"0.6698214",
"0.6698214",
"0.6698214",
"0.6619038",
"0.65719074",
"0.65380937",
"0.6519628",
"0.63961416",
"0.63910294",
"0.63910294",
"0.633522",
"0.63217974",
"0.62848955",
"0.6272008",
"0.62658215",
"0.62434864",
"0.62196386",
"0.6217854",
"0.6212097",
"0.6205346",
"0.6205346",
"0.6203888",
"0.62035936",
"0.62032425",
"0.6175266",
"0.6175266",
"0.61603904",
"0.61579055",
"0.6147466",
"0.61266834",
"0.6123028",
"0.61209583",
"0.61099416",
"0.61086744",
"0.61016953",
"0.60872084",
"0.6084747",
"0.60634464",
"0.6060025",
"0.6056291",
"0.6052406",
"0.6052406",
"0.6042521",
"0.6032689",
"0.60252035",
"0.6015576",
"0.599316",
"0.5991414",
"0.59785795",
"0.59759766",
"0.5967381",
"0.59643847",
"0.59637874",
"0.59619164",
"0.595378",
"0.595378",
"0.595378",
"0.595378",
"0.595378",
"0.595378",
"0.595378",
"0.595378",
"0.5953092",
"0.5946346",
"0.5946346",
"0.5942476",
"0.5942476",
"0.593757",
"0.5928377",
"0.5926473",
"0.59262335",
"0.5925231",
"0.5925231",
"0.5923493",
"0.59170985",
"0.5916205",
"0.5892186",
"0.5887701",
"0.5885531",
"0.587995",
"0.58796585",
"0.58796585",
"0.5876966",
"0.58603",
"0.5848133",
"0.584427",
"0.5837102",
"0.5830354",
"0.58300084",
"0.5823333",
"0.58222914"
] |
0.0
|
-1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.